akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  string S;
  cin >> S;
  int L=S.length();
  int check=0;
  for(int i=1;i<=L-1;i++) if(S[i]!='9') check=1;
  if(check==0) cout << (S[0]-'0')+9*(L-1) << endl;
  else cout << (S[0]-'0')-1+9*(L-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
// using i64 = unsigned long long;
using namespace std;


int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i]) { cout << "No\n"; return 0;}
  }
  for (int i = 0; i < n / 2 / 2; i++) {
    if (s[i] != s[n / 2 - 1 - i]) { cout << "No\n"; return 0;}
  }
  cout << "Yes\n";
}

Measured memory_bytes: 256
<?php

$n = (int) fgets(STDIN);
$t = explode(' ', rtrim(fgets(STDIN)));
$m = (int) fgets(STDIN);
$px = [];
for ($index=0; $index < $m; $index++) {
    $px[$index] = explode(' ', rtrim(fgets(STDIN)));
}

for ($index=0; $index < $m; $index++) {
    $result = 0;
    foreach ($t as $key => $value) {
        if ($px[$index][0] == $key + 1) {
            $result += (int) $px[$index][1];
        } else {
            $result += (int) $value;
        }
    }
    echo $result."\n";
}

Measured memory_bytes: 4728
string = input()
string = string.split()
n = int(string[0])
x = int(string[1])
t = int(string[2])

if(n%x == 0):
    res = int(n/x) * t
    print(res)
else:
    res = (int(n/x) + 1) * t
    print(res)

Measured memory_bytes: 8992
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
                        boolean[] f = new boolean[B];
                        int now=0;
                        while(true){
                                now+=A;
                                now%=B;
                                if(now==C){
                                        System.out.println("YES");
                                        break;
                                }
                                if(f[now]){
                                        System.out.println("NO");
                                        break;
                                }
                                f[now]=true;
                        }
                }
        }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
	int X;

	#ifdef _WIN32
		freopen("input.txt", "r", stdin);
	#endif

	scanf("%d", &X);


#ifdef _WIN32
	printf("input : %d\n", X);
#endif

	int Result = 0;

	Result += 1000 * (X / 500);
	X %= 500;
	Result += 5 * (X / 5);

	printf("%d", Result);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

using T = int;
T op(T a, T b) { return max(a, b); }
T e() { return 0; }

signed main(void) {
  int n, k; cin >> n >> k;
  Vi a(n); rep(i,n) cin >> a[i];
  segtree<T, op, e> seg(300005);
  rrep(i,n) {
    int ma=seg.prod(max(0,a[i]-k),min(300000,a[i]+k)+1);
    int x=seg.prod(a[i],a[i]+1);
    seg.set(a[i],max(ma+1,x));
  }
  pl(seg.all_prod())
  return 0;
}


Measured memory_bytes: 9840
n=int(input(''))
t=[]
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n=n-1
while(1):
    b=n%(26)
    t.append(b)
    n=n-b-1
    if n<=0:
        break
    n=int(n/26)
    
t.reverse()
 
s=''
for a in range(len(t)):
    s=s+l[t[a]]
 
print(s)

Measured memory_bytes: 9208
N, A, B, C = map(int, input().split())
ABC = [A, B, C]

s = [0] * N
for i in range(N):
  s[i] = str(input())
  
d = {"AB":(0, 1, 2), "BC": (2, 1, 0), "AC": (0, 2, 1)}  
dl = ["A", "B", "C"]  

if ABC == [0, 0, 0]:
  print("No")
  quit()

ans = [0] * N  
if A + B + C == 1:
  for n in range(N):
    i, j, k = d[s[n]]
    #print(i, j, k)
    if ABC[i] == 1:
      ABC[i] = 0
      ABC[j] = 1
      ans[n] = dl[j]
    elif ABC[j] == 1:
      ABC[i] = 1
      ABC[j] = 0
      ans[n] = dl[i]
    else:
      print("No")
      quit()
  print("Yes")
  for i in range(N):
    print(ans[i])
    
else:
  for n in range(N):
    i, j, k = d[s[n]]
    #print(i, j, k)
    if ABC[i] == 0:
      if ABC[j] == 0:
        print("No")
        quit()
      else:
        ABC[i] += 1
        ABC[j] -= 1
        ans[n] = dl[i]
    elif ABC[j] == 0:
      ABC[i] -= 1
      ABC[j] += 1
      ans[n] = dl[j]
    else:
      if n < N - 1:
        if (ABC[i] == 1) or (ABC[j] == 1):
          if s[n] != s[n + 1]:
            n1, n2, n3 = d[s[n + 1]]
            if (i == n1) or (i == n2):
              ABC[i] += 1
              ABC[j] -= 1
              ans[n] = dl[i]
            else:
              ABC[i] -= 1
              ABC[j] += 1
              ans[n] = dl[j]
              
          else:
            ABC[i] -= 1
            ABC[j] += 1
            ans[n] = dl[j]
        else:
          ABC[i] -= 1
          ABC[j] += 1
          ans[n] = dl[j]
      else:
        ABC[i] -= 1
        ABC[j] += 1
        ans[n] = dl[j]
        
  print("Yes")
  for i in range(N):
    print(ans[i])
            
            
      
    
    
    
      
      

Measured memory_bytes: 17000
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
// ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;
ll cas=0;

void solve()
{
    cin>>n>>m;
    ans=0;
    F(i,n){
        cin>>x>>y;
        ll su=(x*x)+(y*y);
        if(su<=(m*m))ans++;
    }
    prn(ans);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    
    ll t = 1;
    // cin >> t;
    cas=1;
    // stress();
    while (t--){
        solve();
        cas++;
    }
    return 0;
}

Measured memory_bytes: 3680
n, k = map(int, input().split())
H = [0] * n
for i in range(n):
  H[i] = int(input())
H.sort()

min_dif = 10**9 + 1
for shift in range(n - k + 1):
  dif = H[shift + k - 1] - H[shift]
  min_dif = min(min_dif, dif)
print(min_dif)

Measured memory_bytes: 45144
import sys
stdin = sys.stdin

 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()

food = [1] * (m + 1)

for i in range(n):
    a = na()
    for f in range(1, len(food)):
        if f not in a[1:]:
            food[f] = 0

print(sum(food[1:]))


Measured memory_bytes: 3064
#include <vector>
#include <iostream>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    vector<vector<int>> route(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        route[a].push_back(b);
    }

    for (int k: route[1]) {
        for (int k_to: route[k]) {
            if (k_to == N) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
};


Measured memory_bytes: 8576
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

int n,a[55];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int pos=1;
	for(int i=1;i<=n;i++)
		if(abs(a[i])>abs(a[pos])) 
			pos=i;
	printf("%d\n",2*n);	
	if(a[pos]>=0)
	{
		printf("%d %d\n",pos,n);
		printf("%d %d\n",pos,n);
		for(int i=1;i<n;i++)
		{
			printf("%d %d\n",n,i);
			printf("%d %d\n",n,n);
		}
	}
	else
	{
		printf("%d %d\n",pos,1);
		printf("%d %d\n",pos,1);
		for(int i=n;i>1;i--)
		{
			printf("%d %d\n",1,i);
			printf("%d %d\n",1,1);
		}
	}
}


Measured memory_bytes: 256
M, D = map(int,input().split())

ans = 0
for m in range(1, M+1):
    for d in range(22, D+1):
        d1 = d % 10
        d10 = d // 10
        if m == d1 * d10 and d1 >= 2 and d10 >= 2:
            ans += 1
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll T;
	cin >> T;
	FOR(t,0,T){
		string s;
		set<string> se;
		cin >> s;
		ll ss = s.size();
		FOR(i,1,ss){
			string a,b;
			a = s.substr(0,i);
			b = s.substr(i,ss-i);
			se.insert(a+b);
			se.insert(b+a);
			REV(a);
			se.insert(a+b);
			se.insert(b+a);
			REV(a);REV(b);
			se.insert(a+b);
			se.insert(b+a);
			REV(a);
			se.insert(a+b);
			se.insert(b+a);			
		}
		cout << se.size() << endl;
	}
	

}



Measured memory_bytes: 3224
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int main(){
	int n; cin>>n;
	ll d=0;
	rep(i,n){
		int p; char c; int m;
		cin>>p>>c>>m;
		if(c=='(')d+=m;
		else d-=m;
		cout<<(d==0?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 856
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string W[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  REP(i,7){
    if (s==W[i]){
      cout << 7-i << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//解答写し 
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long kazu_r = count(begin(s), end(s), 'R');
  long long kazu_g = count(begin(s), end(s), 'G');
  long long kazu_b = count(begin(s), end(s), 'B');
  long long kotae = kazu_r * kazu_g * kazu_b;
  for (int j = 1; j < n; ++j) {
    for (int i = 0; i < j; ++i) {
      int k = 2 * j - i;
      if (k < n) {
        kotae -= s[i] != s[j] and s[j] != s[k] and s[k] != s[i];
      }
    }
  }
  cout << kotae << '\n';
}

Measured memory_bytes: 3572
def f(l):
    r = sum(l)**2
    for x in l:
        r -= x**2
    r = r//2
    r += sum(l)+1
    return r

N, = map(int, input().split())
G = [set() for _ in range(N+1)]
G2 = [set() for _ in range(N+1)]
sz = [1 for _ in range(N+1)]
X = [-1] + list(map(int, input().split()))
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a].add(b)
    G[b].add(a)

stack = [1]
vs = set([1])
vs_dfs = []
while stack:
    v = stack.pop()
    vs_dfs.append(v)
    for u in G[v]:
        if u in vs:
            continue
        vs.add(u)
        G2[v].add(u)
        stack += [u]
for x in vs_dfs[::-1]:
    for u in G2[x]:
        sz[x] += sz[u]

stack = [1]
path = []
R = [0] * (N+1)
kh = [[N] for _ in range(N+1)]
while stack:
    v = stack.pop()
    if v > 0:
        if path:
            parent = path[-1]
            kh[X[parent]].append(sz[v])
        path.append(v)
        tmp = []
        for u in G2[v]:
            tmp.append(sz[u])
            stack += [-v, u]
        tmp.append(kh[X[v]][-1]-1-sum(tmp))
        kh[X[v]][-1] -= sz[v]
        R[X[v]] += f(tmp)
    else:
        c = path.pop()
        kh[X[-v]].pop()
for i in range(1, N+1):
    print(R[i])



Measured memory_bytes: 255216
n,y = map(int,input().split())

for i in range(n+1):
  for j in range(n+1):
    k = n-i-j
    if y==(10000*i+5000*j+1000*k) and k>=0:
      print(i,j,k)
      exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();

    if (((a + k) - 1) >= ((b - k) + 1)) {
      for (int i = a; i <= b; i++) {
        System.out.println(i);
      }
    } else {
      for (int i = a; i <= ((a + k) - 1); i++) {
        System.out.println(i);
      }
      for (int i = (b - k) + 1; i <= b; i++) {
        System.out.println(i);
      }
    }

  }
}

Measured memory_bytes: 36228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main{ // 

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int h = cin.nextInt();
		int w = cin.nextInt();
		int n = cin.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = cin.nextInt();

		long start = now();

		int[][] ans = solve(h, w, n, a);
		String ansstr = Arrays.stream(ans)
				.map(row -> Arrays.stream(row).mapToObj(Objects::toString).collect(Collectors.joining(" ")))
				.collect(Collectors.joining(System.lineSeparator()));
		cout.println(ansstr);

		trace("elapsed", now() - start);
	}

	private static int[][] solve(int h, int w, int n, int[] a) {
		int[][] ans = new int[h][w];
		int[] b = Arrays.copyOf(a, n);
		int c = 0;
		for (int y = 0; y < h; y++) {
			int s, d;
			if (y % 2 == 0) {
				s = 0;
				d = 1;
			} else {
				s = w - 1;
				d = -1;
			}
			for (int i = 0, x = s; i < w; i++, x += d) {
				ans[y][x] = c + 1;
				b[c] -= 1;
				if (b[c] == 0)
					c += 1;
			}
		}
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 31060
import java.nio.file.FileSystemLoopException;
import java.text.DecimalFormat;
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        if (N == 1) {
            System.out.println("Hello World");
        }
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());
        System.out.println(A + B);
    }

}


Measured memory_bytes: 22740
#include<iostream>
#include<queue>
#include<string>
using namespace std;
string S; queue<string> Q;
int main() {
    cin >> S; Q.push(S); bool flag = false;
    if (S == "ABC") { flag = true; cout << "Yes" << endl; return 0; }
    while (!Q.empty()) {
        string T = Q.front(); Q.pop();
        for (int i = 0; i < 3; i++) {
            string U = ""; int D = T.size(); bool OK = false;
            for (int j = 0; j < D; j++) {
                if (j < D - 2 && T.substr(j, 3) == "ABC") { U += (char)('A' + i); j += 2; }
                else { U += T[j]; if (T[j] == (char)('A' + i)) { OK = true; break; } }
            }
            if (OK == true)continue;
            if (U == "ABC") { flag = true; break; }
            if (T != U) Q.push(U);
        }
        if (flag == true) { cout << "Yes" << endl; break; }
    }
    if (flag == false)cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3212
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    if (n == 1) {
        cout << 1 << "\n";
        return 0;
    }

    int ans = 1;
    int state = 1; // 0:up, 1:any, 2:down
    for (int i = 1; i < n; i++) {
        if (a[i] > a[i-1]) {
            if (state == 2) {
                ans++;
                state = 1;
            } else {
                state = 0;
            }
        } else if (a[i] < a[i-1]) {
            if (state == 0) {
                ans++;
                state = 1;
            } else {
                state = 2;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<String> list = new ArrayList<>();
        for (int i = 0; i < n; i++) list.add(sc.next());

        Map<String, Long> map = list.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        long max = map.entrySet().stream().map(Map.Entry::getValue).max(Comparator.naturalOrder()).get();

        List<String> results = map.entrySet().stream()
                .filter(m -> m.getValue() == max)
                .map(Map.Entry::getKey)
                .sorted(Comparator.naturalOrder())
                .collect(Collectors.toList());

        results.forEach(System.out::println);
    }
}

Measured memory_bytes: 90188
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int arr[105];
int main()
{
    fast
    int x,n,a,y,z;
    cin >> x >> n;
    if(n==0)
        cout << x << endl;
    else
    {
        for(int i=1; i<=n; i++)
        {
            cin >> a;
            arr[a] = 1;
        }

        for(int i=x; i<=101; i++)
        {
            if(arr[i]==0)
            {
                y = i;
                break;
            }
        }

        for(int i=x; i>=0; i--)
        {
            if(arr[i]==0)
            {
                z = i;
                break;
            }
        }

        if(y-x<x-z)
            cout << y << endl;
        else
            cout << z << endl;

    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1; i<=n-1; i++) {
    for(int j =1; i*j<= n-1; j++) {
      int ab = i*j;
      if(n-ab <=0) continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){    
    scanf("%lf %lf %lf %lf",&ax,&ay,&bx,&by);
    scanf("%lf %lf %lf %lf",&cx,&cy,&dx,&dy);
    P AB=P(bx-ax,by-ay);
    P CD=P(dx-cx,dy-cy);
    P k=AB*conj(CD);
    if(imag(k)==0)printf("2\n");
    else if(real(k)==0)printf("1\n");
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a;
	cin>>a;
	double ans=0,b;
	for(int i=1;i<=a;i++)
	{
		cin>>b;
		ans+=1*1.0/b;
	}
	ans=1*1.0/ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int k;
  cin >> k;

  ll ans = 0;
  rep(i,1,k+1) rep(j,1,k+1) rep(l,1,k+1) ans += __gcd(i,__gcd(j,l));
  cout << ans << '\n';
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int ans[N];

int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }

   int vals = 0;
   for (int i = n-1; i >= 0; --i)
   {
      if(i == n-1){
         ans[i] = 0;
      }
      else{
         if(a[i] >= a[i+1]){
            ans[i] = 1 + ans[i+1];
         }
         else{
            ans[i] = 0;
         }
      }
      smax(vals, ans[i]);
   }

   cout<<vals;

   return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	double x[11];
	string u;
	double total=0;

	cin>>n;

	rep(i,n){
		cin>>x[i]>>u;
		if(u=="JPY")total+=x[i];
		else total+=380000*x[i];
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  string s;
  cin >> s;
  ll ans = 0;
  int cnt = 0;
  REP(i,(int)s.size()){
    if(s[i]=='B'){
      cnt++;
    }else if(s[i]=='W'){
      ans += cnt;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;
#define ll long long
 

int main() {
    ll n,m;
    cin>>n>>m;
    ll res=0;
    if(n%2)
    {   
        if(m%2)
        res=((n/2)+1)*((m/2)+1)+(n/2)*(m/2);
        else
        res=((n/2)+1)*((m/2))+(n/2)*(m/2);
    }
    else
    {
        if(m%2)
        res=((n/2))*((m/2)+1)+(n/2)*(m/2);
        else
        res=((n/2))*((m/2))+(n/2)*(m/2);
    }
    if(n==1 or m==1)
    cout<<1;
    else
    cout<<res;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
d=deque(['3','5','7'])
def dfs(d,n,lst):
  while len(list(d))>0:
    for i in range(len(list(d))):
      s=d.popleft()
      for j in ['3','5','7']:
        if int(s+j)<=n:
          lst.append(s+j)
          d.append(s+j)
  return lst
lst=dfs(d,n,[])
num=0
for i in lst:
  if len(set(list(i)))==3:
    num+=1
print(num)  

Measured memory_bytes: 47708
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


ll gcd(ll x,ll y){
  return y==0? x:gcd(y,x%y);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  int flg=0;
  repeat(i,S.length()){
    flg |= 1<<(S[i]-'a');
  }
  string ans="None";
  repeat(i,26){
    if(!((flg>>i)&1)){
      ans = 'a'+i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    int a[105], n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 == 0 || a[i] % 5 == 0)
                continue;
            else
            {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    //cin.close();
    //cout.close();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 10;
int n,x,ans[maxn];
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &x);
		ans[x] = i;
	}
	for (int i = 1; i <= n; i++)
	{
		printf("%d%c", ans[i],i==n?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>


using namespace std;

int p, q, r;

int mOr(int x, int y) {
  if (x == 2 || y == 2) {
    return 2;
  }
  if (x == 0 && y == 0) {
    return 0;
  }
  return 1;
}

int mAnd(int x, int y) {
  if (x == 0 || y == 0) {
    return 0;
  }
  if (x == 2 && y == 2) {
    return 2;
  }
  return 1;
}

int mNot(int x) {
  if (x == 0) {
    return 2;
  }else if (x == 1) {
    return 1;
  }else {
    return 0;
  }
}

int solve(string str) {
  int ret = 0;
  if (str == "R") {
    return r;
  }
  if (str == "P") {
    return p;
  }
  if (str == "Q") {
    return q;
  }
  if (str == "2") {
    return 2;
  }
  if (str == "1") {
    return 1;
  }
  if (str == "0") {
    return 0;
  }

  if (str[0] == '(') {
    int cnt = 0;
    string lstr = "", rstr = "";
    for (int i = 1; i < str.size(); i++) {
      if (cnt == 0) {
	if (str[i] == '+') {
	  int x = solve(lstr);
	  for (int j = i+1; j < str.size()-1; j++) {
	    rstr += str[j];
	  }
	  int y = solve(rstr);
	  return mOr(x, y);
	}
	if (str[i] == '*') {
	  int x = solve(lstr);
	  for (int j = i+1; j < str.size()-1; j++) {
	    rstr += str[j];
	  }
	  int y = solve(rstr);
	  return mAnd(x, y);
	}
	if (str[i] == '(') {
	  lstr += str[i];
	  cnt++;
	}else {
	  lstr += str[i];
	}
      }else if (str[i] == '(') {
	lstr += str[i];
	cnt++;
      }else if (str[i] == ')') {
	lstr += str[i];
	cnt--;
      }else {
	lstr += str[i];
      }
    }
  }

  if (str[0] == '-') {
    ret = mNot(solve(str.substr(1)));
  }

  return ret;
}

int main() {
  while (true) {
    string str;
    cin >> str;
    if (str == ".") break;

    int ans = 0;
    for (int i = 0; i <= 2; i++) {
      for (int j = 0; j <= 2; j++) {
	for (int k = 0; k <= 2; k++) {
	  p = i;
	  q = j;
	  r = k;
	  if (solve(str) == 2) {
	    ans++;
	  }
	}
      }
    }

    std::cout << ans << std::endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    ll ans = 0;
    ll sum = 0;
    for(int i=0;i<n;i++){
        if(a[i] == 0){
            ans += (sum / 2);
            sum = 0;
        }
        sum += a[i];
    }
    ans += (sum / 2);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
#define LL long long
const int MAXN = 500+50;
const int MAXM = 8*15+50;
const int MOD = 1e9+7;
const double PI = acos(-1);
inline char getc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
    int x=0,f=1; char ch=getc();
    while(!isdigit(ch)){ if(ch=='-') f=-1; ch=getc(); }
    while(isdigit(ch)) x=x*10+ch-48,ch=getc();
    return x*f;
}
signed main(){
#ifndef ONLINE_JUDGE
    //freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
#endif // ONLINE_JUDGE
    int n=read(); bool ok=true;
    for(int i=1;i<=n;i++){
        int x=read();
        if(x%2==0){
            if(x%3==0 || x%5==0) continue;
            ok=false;
        }
    }
    puts(ok ? "APPROVED":"DENIED");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long N;
    scanf("%ld", &N);
    for(long n = 1; n <=3500; n++){
        for(long h = 1; h <= 3500; h++){
            if(4 * n * h - N * n - N * h <= 0){
                continue;
            }
            if((N * n * h) % (4 * n * h - N * n - N * h)  == 0){
                long w = (N * n * h) / (4 * n * h - N * n - N * h);
                printf("%ld %ld %ld", n, h, w);
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n, k;
	cin >> n >> k;
	if ((n + 1) / 2 >= k) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 764
N = int(input())
h = list(map(int, input().split()))
dp = [10**10 for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
    
print(dp[-1])

Measured memory_bytes: 13924
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
    }

    Arrays.sort(a);
    
    if (N % 2 == 0) {
      long count = 0;
      for (int i = 0; i < N / 2 - 1; i++) {
        count -= 2 * a[i];
      }
      count -= a[N / 2 - 1];
      count += a[N / 2];
      for (int i = N / 2 + 1; i < N; i++) {
        count += 2 * a[i];
      }
      System.out.println(count);
    } else {
      long c1 = 0;
      for (int i = 0; i < N / 2 - 1; i++) {
        c1 -= 2 * a[i];
      }
      c1 -= a[N / 2 - 1];
      c1 -= a[N / 2];
      for (int i = N / 2 + 1; i < N; i++) {
        c1 += 2 * a[i];
      }
      long c2 = 0;
      for (int i = 0; i < N / 2; i++) {
        c2 -= 2 * a[i];
      }
      c2 += a[N / 2];
      c2 += a[N / 2 + 1];
      for (int i = N / 2 + 2; i < N; i++) {
        c2 += 2 * a[i];
      }
      System.out.println(Math.max(c1, c2));
    }
  }
}


Measured memory_bytes: 58000
#include <iostream>
#include<cstring>
using namespace std;

int main() {
	// your code goes here
	int a,b,i,f=1;
	cin>>a>>b;
	string s;
	cin>>s;
	if(s.size()==a+b+1)
	{
	    if(s[a]=='-')
	    {
	        for(i=0;i<s.size();i++)
	        {
	            if(i!=a&&s[i]=='-')
	            {
	                f=0;
	            break;
	            }
	        }
	        if(f==1)
	    cout<<"Yes"<<endl;
	    else
	    cout<<"No"<<endl;
	    }
	    else
	    cout<<"No"<<endl;
	}
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
# E
N = int(input())
P_list = list(map(int, input().split()))
X_list = list(map(int, input().split()))

# graph
child_list = [[] for _ in range(N+1)]
for i in range(2, N+1):
    child_list[P_list[i-2]].append(i)

# from root
# minimize local total weight

color1 = [0]+X_list
color2 = [0]*(N+1)

# solve knapsack
def solve_knapsack(L, M):
    min_acc = sum([min(color1[j], color2[j]) for j in L])
    if min_acc > M:
        return -1
    else:
        add_can = M - min_acc
        add_set = set([0])
        for j in L:
            add_j = max(color1[j], color2[j]) - min(color1[j], color2[j])
            add_set_ = set(add_set)
            for s in add_set:
                if s + add_j <= add_can:
                    add_set_.add(s + add_j)
            add_set = add_set_
        
        total = sum([color1[j]+color2[j] for j in L])
        return total - max(add_set) - min_acc

res = "POSSIBLE"

for i in range(N, 0, -1):
    if len(child_list[i]) == 0:
        pass
    elif len(child_list[i]) == 1:
        j = child_list[i][0]
        if min(color1[j], color2[j]) > X_list[i-1]:
            res = "IMPOSSIBLE"
            break
        elif max(color1[j], color2[j]) > X_list[i-1]:
            color2[i] = max(color1[j], color2[j])
        else:
            color2[i] = min(color1[j], color2[j])
    else:
        c2 = solve_knapsack(child_list[i], X_list[i-1])
        if c2 < 0:
            res = "IMPOSSIBLE"
            break
        else:
            color2[i] = c2
    
print(res)

Measured memory_bytes: 3440
<?php
    fscanf(STDIN, "%d", $n);
    $cards = explode(" ", trim(fgets(STDIN)));
    $total = array_sum($cards);
    $sunu = 0;
    for ($i = 0; $i < $n-1; $i++) {
        $sunu += $cards[$i];
        $diff[] = abs($sunu - ($total - $sunu));
    }
    echo min($diff) . "\n";
?>


Measured memory_bytes: 67140
//Optimise
#include <bits/stdc++.h>
using namespace std;

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

ll solve(vector<pair<int, int>> &v, int p, int q)
{
	// db(p,q);
	if (p == 0 && q == 0)
		return 1e18;
	int n = v.size();
	vector<bool> vis(n);
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		if (vis[i])
			continue;
		cnt++;
		pair<int, int> curr = v[i];
		if (binary_search(v.begin(), v.end(), make_pair(v[i].f + p, v[i].s + q)))
		{
			auto it = lower_bound(v.begin(), v.end(), make_pair(curr.f + p, curr.s + q));
			while (it != v.end())
			{
				if (it->f != (curr.f + p))
					break;
				if (it->s != (curr.s + q))
					break;
				int j = it - v.begin();
				db(curr.f, curr.s, curr.f + p, curr.s + q, i, j);
				if (vis[j])
					break;
				vis[j] = true;
				curr = v[j];
				it = lower_bound(v.begin(), v.end(), make_pair(curr.f + p, curr.s + q));
			}
		}
		vis[i] = true;
	}
	db(cnt, p, q) 
	return cnt;
}

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int>> V(n);
	for (auto &x : V)
		cin >> x.f >> x.s;
	sort(V.begin(), V.end());
	ll answer = n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
		{
			if (i == j)
				continue;
			ll temp = solve(V, V[j].f - V[i].f, V[j].s - V[i].s);
			answer = min(answer, temp);
		}
	cout << answer << '\n';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
import sys 
import numpy as np

readline = sys.stdin.buffer.readline

H, W, K = map(int, readline().split())
# 2次元配列に格納する
C_ij = []
for h in range(H):
    C_ij.append(input()) # bufferだとbがつくのでこちらに

ans = 0
# bit全探索[2重ループver]
for h_bit in range(2**H):
    for w_bit in range(2**W):
        black = 0
        for h in range(H):
            for w in range(W):
                if not((h_bit >> h) & 1) and not((w_bit >> w) & 1) and \
                C_ij[h][w] == '#':
                    black += 1
        if black == K:
            ans += 1

# 配列形式C_ij[H][0][W]
print(ans)

Measured memory_bytes: 27232
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int max1 = -2147483647;
int max2 = -2137384637;
int a[2000010];
int main(){
	int i, j, k;
	cin >> n;
	for(i = 1; i <= n; ++i){
		scanf("%d",&a[i]);
		if(a[i] > max1){
			max1 = a[i];
			continue;
		}
		if(a[i] > max2){
			max2 = a[i];
			continue;
		}
	}
	for(i = 1; i <= n; ++i){
		if(a[i] != max1)printf("%d\n",max1);
		else if(max2 == -2137384637) printf("%d\n",max1);
		else printf("%d\n",max2);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int x;
    cin >> x;
    int count = x / 100;
    if(x >= count * 100 && x <= count * 105)
    {
        cout << "1\n";
    }
    else
    {
        cout << "0\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int dy[4] = {1, 0, -1, 0};
const int dx[4] = {0, 1, 0, -1};
int n;
int x[20010], y[20010];
string dir[20010];
map<int, map<int, int>> mp;
int checked[20010];
int used[20010];

bool dfs(int curr, int p) {
  checked[curr] = 1;
  used[curr] = p;
  bool res = true;
  for (int i = 0; i < 4; i++) {
    int ny = y[curr] + dy[i];
    int nx = x[curr] + dx[i];
    int next = mp[ny][nx];
    if (!next || next == curr) continue;
    if (y[next] == ny && x[next] == nx) {
      res *= !used[next] ? dfs(next, p) : used[next] == p;
    } else {
      res *= !used[next] ? dfs(next, -p) : used[next] == -p;
    }
  }
  for (int i = 0; i < 4; i++) {
    int ny = y[curr] + dy[i] + (dir[curr] == "y");
    int nx = x[curr] + dx[i] + (dir[curr] == "x");
    int next = mp[ny][nx];
    if (!next || next == curr) continue;
    if (y[next] == ny && x[next] == nx) {
      res *= !used[next] ? dfs(next, -p) : used[next] == -p;
    } else {
      res *= !used[next] ? dfs(next, p) : used[next] == p;
    }
  }
  used[curr] = 0;
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n) {
    mp.clear();
    fill_n((int*)checked, 20010, 0);
    for (int i = 1; i <= n; i++) {
      cin >> x[i] >> y[i] >> dir[i];
      mp[y[i]][x[i]] = i;
      mp[y[i] + (dir[i] == "y")][x[i] + (dir[i] == "x")] = i;
    }
    string ans = "Yes";
    for (int i = 1; i <= n; i++) {
      if (checked[i]) continue;
      fill_n((int*)used, 20010, 0);
      if (dfs(i, 1)) continue;
      fill_n((int*)used, 20010, 0);
      if (dfs(i, -1)) continue;
      ans = "No";
    }
    cout << ans << endl;
  }  

  return 0;
}


Measured memory_bytes: 21136
while n = gets
  break if n.to_i.zero?

  s = gets.chomp.split.map(&:to_i)
  m = s.inject(:+) / s.size.to_f
  variance = s.inject(0.0) {|total, v| total + (v - m)**2 } / s.size.to_f
  puts Math.sqrt(variance)
end

Measured memory_bytes: 8840
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
   int n,k,ans=0;
   cin>>n>>k;
   int a[n+2];
   for(int i=0;i<n;i++)
    {
    cin>>a[i];
    }
    sort(a,a+n,cmp);
    for(int i=0;i<k;i++)   
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    vector<vector<bool>> del(h, vector<bool>(w));
    rep(i, h) {
        bool ok = true;
        rep(j, w) {
            if (a[i][j]=='#') ok = false;
        }
        if (ok) {
            rep(j, w) del[i][j] = true;
        }
    }
    rep(j, w) {
        bool ok = true;
        rep(i, h) {
            if (a[i][j]=='#') ok = false;
        }
        if (ok) {
            rep(i, h) del[i][j] = true;
        }
    }
    rep(i, h) {
        bool ok = false;
        rep(j, w) {
            if (del[i][j]) continue;
            cout << a[i][j];
            ok = true;
        }
        if (ok) cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,m;
	string a,b,x;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a+=x;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>x;
		b+=x;
	}
	if(a<b) cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3196
n, p = map(int, input().split())
ans = 1

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    
s = factorization(p)

for valu, num in s:
    if num >= n:
        tmp = num//n
        ans *= valu**tmp
print(ans)

Measured memory_bytes: 9364
#include<bits/stdc++.h>
using namespace std;
string s,t;
int i,j,a;
int main()
{
	cin>>s>>t;a=s.size();
	for(i=0;i<a;i++)
	{
		for(j=0;j<a;j++)
		{
			if(s[j]!=t[j])break;
		}
		if(j==a){cout<<"Yes";return 0;}
		else
		{
			s[a]=s[0];
			for(int k=1;k<=a;k++)
			s[k-1]=s[k];
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256