akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int main() {
    std::string str;
    
    std::cin >> str;
    if(*str.begin() == *str.rbegin()) {
        std::cout << *str.begin() << std::endl;
    }else {
        std::cout << 'o' << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3148
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int A[] = new int[Q];
    for(int i=0;i<Q;i++){
      A[i] = sc.nextInt();
    }
    int P[] = new int[N];//参加者の点数列（正解数）
    //正解数が規定正解数に達していない人間はアウト
    //規定正解数→Q-K+1
    int border = Q-K+1;
    
    for(int i=0;i<Q;i++){
      P[A[i]-1]=P[A[i]-1]+1;
    }

    for(int i=0;i<N;i++){
      if(P[i]<border){
        System.out.println("No");
      }else{
        System.out.println("Yes");
      }
    }
    
    
    
    
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
}

Measured memory_bytes: 70136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int ans = 0;
    for (int i = 0; i <= N - 1; i++){
        for (int j = 0; j <= N - i; j++){
            int sub_ans = 0;
            priority_queue<int> q;
            rep(k,i){
                sub_ans += vec[k];
                q.push(vec[k] * -1);
            }
            rep(l,j){
                sub_ans += vec[N - 1 - l];
                q.push(vec[N - 1 - l] * -1);
            }
            if (i + j > K){
                continue;
            }
            else{
                int lim = K - i - j;
                rep(m,lim){
                    if (q.size() == 0){
                        break;
                    }
                    if (q.top() >= 0){
                        sub_ans += q.top();
                        q.pop();
                    }
                }
            }
            ans = max(ans,sub_ans);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    np.set_printoptions(threshold=20)
    N = int(input())
    l = list(map(int, input().rstrip().split()))
    for i, v in enumerate(l):
        l[i] = v - (i + 1)
    l.sort()
    now = 0
    for v in l:
        now += abs(v - (l[0] - 1))
    right_count = N
    left_count = 0
    ans = now
    before = l[0] - 1
    for v in l:
        now -= right_count * (v - before)
        now += left_count * (v - before)
        right_count -= 1
        left_count += 1
        ans = min(now, ans)
        before = v
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49544
#include <iostream>
#include <vector>
using namespace std;
#define MAX 100005
int n, m;
bool visited[MAX];
vector<int> graph[MAX];

void DFS(int u) {
	visited[u] = true;
	for (int i = 0;i < graph[u].size();i++) {
		int v = graph[u][i];
		if (!visited[v])
			DFS(v);
	}
}

int main()
{
	int testcase, u, v, num;

		cin >> n;
		cin >> m;
		for (int i = 0;i < m;i++) {
			cin >> u >> v;
			graph[u].push_back(v);
			graph[v].push_back(u);
		}

		for (int u = 0;u <= n;u++)
			visited[u] = false;

		num = 0;
		for (int u = 1;u <= n;u++) {
			if (!visited[u]) {
				num++;
				DFS(u);
			}
		}
  cout << num - 1;
}


Measured memory_bytes: 9640
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 500005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}

int n, m, f1[maxn], f2[maxn], x, ans;
char ch[maxn], s[maxn];
int main(){
	int i, j, k;
	scanf("%s", ch + 1);
	n = strlen(ch + 1);
	for(i = 2, j = 0;i <= n;i++){
		while(j && ch[j + 1] != ch[i]) j = f1[j];
		if(ch[j + 1] == ch[i]) j++;
		f1[i] = j;
	}
	for(i = 1;i <= n;i++) s[i] = ch[n - i + 1];
	for(i = 2, j = 0;i <= n;i++){
		while(j && s[j + 1] != s[i]) j = f2[j];
		if(s[j + 1] == s[i]) j++;
		f2[i] = j;
	}
	if(n % (n - f1[n]) != 0 || f1[n] == 0) {printf("1\n1");return 0;} 
	if(n - f1[n] == 1) {printf("%d\n1", n);return 0;}
	for(i = 1;i < n;i++){
		k = n - i;
		if((i % (i - f1[i]) != 0 || f1[i] == 0) && (k % (k - f2[k]) != 0 || f2[k] == 0)) ans++;
	}
	printf("2\n%d",ans);
	return 0;
}


Measured memory_bytes: 8676
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
a,b,c = map(int,input().split())
if a < b:
	if a < c:
		if b < c:
			print(a, b, c)
		else:
			print(a, c, b)
	else:
		print(c, a, b)
else:
	if b < c:
		if a < c:
			print(b, a, c)
		else:
			print(b, c, a)
	else:
		print(c, b, a)

Measured memory_bytes: 7572
cuts = []
for i in range(2000):
  cuts+= [[int(i*0.08), int(i*0.10)]]
  
A, B = map(int,input().split())

for i in range(1,2000):
  if [A, B] == cuts[i]:
    print(i)
    break
else:
  print(-1)

Measured memory_bytes: 3188
def main():
    n = int(input())

    nums = []
    for i in range(n):
        nums.append(int(input()))

    rj = max(nums[1:])
    r  = rj - nums[0]

    for i in range(1, n-1):
        ri = nums[i]

        if ri == rj:
            rj = max(nums[i+1:])

        r = max(r, rj-ri)

    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 16984
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <utility>

#include <cstdio>
 
using namespace std;

#define REP(var, count) for(int var=0; var<count; var++)

int parent[100010];
bool marked[100010];

// sky58
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};

int main(void) {
	while(true) {
		int N, Q;
		scanf("%d", &N);
		scanf("%d", &Q);
		
		if ( N==0 ) { break; }
		
		marked[1] = true;
		REP(i, N-1) {
			scanf("%d", &parent[i+2]);
			marked[i+2] = false;
		}
		
		long long ret = 0;
		REP(i, Q) {
			char met[256];
			int id;
			scanf("%s", met);
			scanf("%d", &id);
			
			if ( met[0] == 'Q' ) {
				int node = id;
				while ( !marked[node] ) {
					node = parent[node];
				}
				
				ret += node;
			} else {
				marked[id] = true;
			}
		}
		
		cout << ret << endl;
	}

}

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

int main() {
  int N;
  cin >> N;
  
  vector<long long> a(3*N); 
  for(int i=0;i<3*N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end(),greater<int>());
  
  long long a_sum = 0;
  for(int i=0;i<N;i++){
    a_sum += a.at(2*i+1);
  }
  
  cout << a_sum << "\n";
}

Measured memory_bytes: 2560
// --------------
// Tejas Pandey  |
// 18 - 08 - 19  |
// ABC #138      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		double ans = 0;
		for(int i = 0;i < n;i++){
			int a;
			cin >> a;
			ans += 1.0/a;
		}
		ans = 1.0/ans;
		cout << fixed << setprecision(5) << ans << "\n";
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
    {
        cout << (a - 1) << " " << b << endl;
    }
    else
    {
        cout << a << " " << (b - 1) << endl;
    }
    return 0;
}

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

int main()
{
    int n,a[300000]={0},i,j,max=-1,c=0;
    for(i=0;i<5;i++)
        cin>>a[i];
        cin>>n;
    for(i=0;i<5;i++)
        for(j=i+1;j<5;j++)
    {
        c=a[j]-a[i];
        if(c>max)
            max=c;
    }
    if(max>n)
        cout<<":("<<endl;
    else
        cout<<"Yay!"<<endl;

    return 0;
}


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

using namespace std;

/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)  //a~(b - 1)?????§
#define print(i) cout << i << endl //?°??????????Python?????????
#define all(i) (i).begin(),(i).end() //??¨??????(sort??¨???)
#define mp make_pair //mp(OO, OO)??¨???:::pint??¨???

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/

int main(void)
{
  int n;
  int dp[35] = {1, 1, 2};

  FOR(i, 3, 31){
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
  }

  while (cin >> n){
    if (n == 0) break;
    cout << dp[n] / 10 / 365 + 1 << endl;
  }

  return 0;
}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PI 3.14159265358979323846264338327950

#define ll  long long int
#define MAXX 1000005

int n , x;
int a[MAXX];
bool used[MAXX];
int p[MAXX];

int main()
{
    FAST;
    cin >> n;
    n ++;
    n --;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        used[a[i]] = true;
        p[a[i]]++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
            p[a[i]]--;
            if(!p[a[i]])
                used[a[i]] = false;
            bool flag = true;
        for(int j = 1; j * j <= a[i]; j++){
            if(a[i] % j == 0){
                if(used[j]){
                    flag = false;
                    break;
                }
                int k = a[i] / j;
                if(used[k]){
                    flag = false;
                    break;
                }
            }
        }
        if(flag)
            ans++;
        p[a[i]]++;
        used[a[i]] = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9248
s = list(input())
a = s[:(len(s)-1)//2]
b = s[(len(s)+2)//2:]

flag = True
for i in range(len(s)//2):
  if s[i] != s[len(s)-i-1]:
    flag = False
    break
  
flagA = True
for i in range((len(a)//2)):
  if a[i] != a[len(a)-i-1]:
    flagA = False
    break
    
flagB = True
for i in range(len(b)//2+1):
  if b[i] != b[len(b)-i-1]:
    flagB = False
    break
    
if flag and flagA and flagB:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(final String[] args) {
    final Scanner sc = new Scanner(System.in);
    String s = sc.next();
    sc.close();

    int cnt = s.length();
    String x = "";
    for (int i = 0; i < cnt; ++i){
      x += "x";
    }

      System.out.println(x);
  }
}

Measured memory_bytes: 22100
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	int now;
	cin >> now;
	int ans = 1;
	rep(i, n - 1) {
		int x;
		cin >> x;
		if (now > x) {
			ans++;
			now = x;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
#include<queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    int sum=0;
    REP(i,N.size()){
        if(N[i]=='2')sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#02:08
#BFS
n,m,k = map(int,input().split())
peer = [[] for _ in range(n)]
num = [1 for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
root = [i for i in range(n)]
cnt = [0 for _ in range(n)]
for i in range(n):
  if seen[i] == 1:
    continue
  seen[i] = 1
  now = [i]
  tmp = 1
  while now:
    last = now
    now = []
    for x in last:
      for y in peer[x]:
        if seen[y] == 0:
          seen[y] = 1
          now.append(y)
          root[y] = i
          tmp += 1
  cnt[i] = tmp
#print(root)
#print(cnt)
for i in range(n):
  cnt[i] = cnt[root[i]]
#print(cnt)
for i in range(n):
  cnt[i] -= num[i]
#print(cnt)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    cnt[a] -= 1
    cnt[b] -= 1
print(' '.join(map(str,cnt)))

Measured memory_bytes: 35416
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int n, m, a[50], b[50];
bool graph[50][50], visited[50];

void dfs(int v){
  visited[v]=true;
  for(int v2=0; v2<n; v2++){
    if(graph[v][v2]==false){
      continue;
    }
    if(visited[v2]==true){
      continue;
    }
    dfs(v2);
  }
}

int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }

  int ans=0;

  for(int i=0; i<m; i++){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    for(int j=0; j<n; j++){
      visited[j]=false;
    }
    dfs(0);
    bool bridge=false;
    for(int j=0; j<n; j++){
      if(!visited[j]){
        bridge=true;
      }
    }
    if(bridge){
      ans++;
    }

    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }

  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl
#abc083_b.pl
#Wed Jan 10 20:26:19 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;

my @temps = split(" ",$temp);

my $n = $temps[0];
my $a = $temps[1];
my $b = $temps[2];

my $num = 1;

my $answer = 0;

while ($num <= $n){
	my @digit = split("",$num);
	my $total = 0;
	foreach (@digit){
		$total = $total + $_;
	}
	if ($total >= $a && $total <=$b){
		$answer = $answer + $num;
	}
	$num++;
}

print $answer,"\n";

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	bool b = 1;
	cin >> a;
	for(int i = 0; i < a.size(); i++)
		{
			if(a[i] == 'C' && b)
				{
					b = !b;
				}
			if(a[i] == 'F' && !b)
				{
					cout << "Yes" << endl;
					return 0;
				}
		}
	cout << "No" << endl;
}

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

const int MAX = 1e6 + 5;
const int MOD = 998244353;

inline int add(int x, int y) {
	x += y;
	if (x >= MOD)
		return x - MOD;
	if (x < 0)
		return x + MOD;
	return x;	
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

int choose(int x) {
	return mul(mul(x, x - 1), (MOD + 1) / 2);
}

int N;
int cnt[MAX];
int sum[MAX];
int p[MAX], rad[MAX], num[MAX];
vector <int> divs[MAX];

void load() {
	scanf("%d", &N);
	while (N--) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
}

int calc(int g) {
	int res = 0;
	vector <int> todo;
	for (int i = g; i < MAX; i += g) {
		if (!cnt[i])
			continue;
		int curr = i / g;
		int tot = mul(curr, cnt[i]);
		for (auto it : divs[rad[curr]]) {
			todo.push_back(it);
			res = add(res, num[it] ? -mul(sum[it], tot) : mul(sum[it], tot));
			sum[it] = add(sum[it], tot);
		}
	}
	for (auto it : todo)
		sum[it] = 0;
	return mul(res, g);
}

int solve() {
	for (int i = 2; i < MAX; i++)
		if (!p[i])
			for (int j = i; j < MAX; j += i)
				if (!p[j])
					p[j] = i;
	
	rad[1] = 1;
	for (int i = 2; i < MAX; i++) {
		int tmp = p[i], curr = i;
		while (!(curr % tmp))
			curr /= tmp;
		rad[i] = tmp * rad[curr];
		num[i] = num[curr] ^ 1;
	}
	
	for (int i = 1; i < MAX; i++)
		if (rad[i] == i) 
			for (int j = i; j < MAX; j += i)
				if (rad[j] == j)
					divs[j].push_back(i);
	
	int sol = 0;
	for (int i = 1; i < MAX; i++) {
		sol = add(sol, calc(i));
		sol = add(sol, mul(choose(cnt[i]), i));
	}
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 91440
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, A, B, C; cin >> N >> A >> B >> C;
  int d[3];
  d[0] = A, d[1] = B, d[2] = C;
  vector<P> que(N);
  rep(i, N){
    string s; cin >> s;
    if (s == "AB") {que[i].first = 0, que[i].second = 1;}
    else if(s == "AC") {que[i].first = 0, que[i].second = 2;}
    else if(s == "BC") {que[i].first = 1, que[i].second = 2;}
  }
  string ans;
  auto add = [&](int a, int b){
    d[a]++;
    d[b]--;
    ans += 'A' + a;
  };
  que.emplace_back(0, 1);
  rep(i, N){
    int a = que[i].first;
    int b = que[i].second;
    if (!d[a] && !d[b]) {
      cout << "No" << endl;
      return 0;
    }
    if (!d[a]) {
      add(a, b);
    } else if (!d[b]){
      add(b, a);
    } else{
      int na = que[i + 1].first;
      int nb = que[i + 1].second;
      if (a == na || a == nb){
        add(a, b);
      } else{
        add(b, a);
      }
    }
  }
  cout << "Yes" << endl;
  rep(i, N) cout << ans[i] << endl;
}


Measured memory_bytes: 6432
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	int cnt2, cnt4;
	cnt2 = cnt4 = 0;
	for(int i=0; i<N; i++)
	{
		int a;
		cin >> a;

		if(a%4 == 0)
			cnt4++;
		else if(a%2 == 0)
			cnt2++;
	}

	string ret = "No";
	if(cnt4 >= N/2)
		ret = "Yes";
	else if(cnt2 >= N-cnt4*2)
		ret = "Yes";

	cout << ret << endl;

	return 0;
}


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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

int main() {
	int n, k; cin >> n >> k;
	if(k == 1) {
		cout << 0 << endl;
	} else {
		n -= k;
		cout << n << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define db(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x) double(x * acos(-1) / 180.0)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int v[N];
map<ll, int> mp;
ll f(ll x){return x * (x + 1) / 2;}
bool isPrime(ll x){
    if(x < 2)return 0;
    if(x == 2)return 1;
    if(x % 2 == 0)return 0;
    for(ll i = 3; i * i <= x; i += 2)
        if(x % i == 0)
            return 0;
    return 1;
}
void fact(ll x){
    if(x % 2LL == 0){    
        while(x % 2LL == 0){
            mp[2]++;
            x /= 2;
        }
    }

    for(ll i = 3; i * i <= x; i += 2){
        if(x % i == 0){    
            while(x % i == 0){
                mp[i]++;
                x /= i;
            }
        }
            
    }
    if(x > 1)
        mp[x]++;
}  
ll POW(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b & 1)
            ans *= a;
        b >>= 1;
        a *= a;
    }
    return ans;
}
int main(){
    //FL;
    fin;

    
    ll n;
    cin >> n;
    ll ans = 0;
    if(isPrime(n))
        ans = 1;
    else if(n == 1)
        ans = 0;
    else{
        fact(n);
        fori(i, mp){
            //cout << i->F << " " << i->S << endl;
            int a = 1, b = 100, mid;
            while(b - a > 1){
                mid = (a + b) >> 1;
                if(f(mid) <= (i->S))
                    a = mid;
                else
                    b = mid;
            }
            ans += a;
        }
    }
    cout << ans << '\n';
    time;
    return 0;
}       


Measured memory_bytes: 3808
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long odd = 0;
  long multiple4 = 0;
  for (long i = 0; i < n; i++) {
    if (a[i]%2 != 0) {
      odd++;
    }
    if (a[i]%4 == 0) {
      multiple4++;
    }
  }
  if (multiple4 >= odd || multiple4*2+1 == n) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;

int board[1234][1234];
//#=-1 .=0

int main(void)
{
	int n, m, d;
	scanf("%d %d %d", &n, &m, &d);
	memset(board, 0xff, sizeof(board));
	for (int i = 0; i < n; ++i)
	{
		char str[123];
		scanf("%s", str);
		for (int j = 0; j < m; ++j)
		{
			board[i][j] = (str[j] == '#') ? -1 : 0;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			bool flag = true;
			for (int dd = 0; dd < d; ++dd)
			{
				if (board[i][j + dd] == -1)
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				++ans;
			}
			flag = true;
			for (int dd = 0; dd < d; ++dd)
			{
				if (board[i + dd][j] == -1)
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				++ans;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  long k;
  cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.erase(k) << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    long long int n,a,b; cin >> n >> a >> b;
    if(a > b) swap(a,b);
    if(abs(a-b) % 2 ==0){
        cout << (max(a,b) - min(a,b)) / 2 << endl;
        return 0;
    }
    cout << min((n-b+n-a+1)/2, (a-1+b-1+1)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

int main(){
	string ST;
	cin >> ST;
	int i;
	for (i = 0; i < ST.size(); ++i){
		if (ST[i] == '?')putchar('D'); else putchar(ST[i]);
	}
	return 0;
}

Measured memory_bytes: 3724
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
mic = 0
for i in range(n):
    if a[i]<0: 
        mic += 1
        a[i] *= -1
if mic%2:
    a.sort()
    print(sum(a[1:])-a[0])
else:
    print(sum(a))
    

Measured memory_bytes: 85976
l, r = map(int, input().split())
 
v = []
if l*r < 2019:
    print(l*r)
else:
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            v.append(i*j%2019)
            if v[-1] == 0:
                break
        else:
            continue
        break
 
    print(min(v))

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

int check(int card[3][10],int sum)
{
  int flag=0;
  /**
  cout<<"sum:"<<sum<<endl;
  for(int i=0;i<3;i++)
    for(int j=1;j<10;j++)
      {
	if(card[i][j]>0)
	  cout<<i<<" "<<j<<" "<<card[i][j]<<endl;
      }
  **/

  if(sum==0)
    return 1;
  
  for(int i=0;i<3;i++)
    for(int j=1;j<10;j++)
      {
	if(card[i][j]>0)
	  {
	    int tmpcard[3][10];
	    for(int i=0;i<3;i++)
	      memcpy(tmpcard[i],card[i],sizeof(card[i]));
	    if(card[i][j]>2)
	      {
		//		cout<<"del 3card:"<<i<<","<<j<<endl;
		tmpcard[i][j]-=3;
		if(check(tmpcard,sum-3)==1)
		  return 1;
	      }
	    for(int i=0;i<3;i++)
	      memcpy(tmpcard[i],card[i],sizeof(card[i]));
	    if(j<9 && card[i][j]>0 &&card[i][j+1]>0 &&card[i][j+2]>0 )
	      {
		//		cout<<"del renzoku-card:"<<i<<","<<j<<endl;
		tmpcard[i][j]--;
		tmpcard[i][j+1]--;
		tmpcard[i][j+2]--;
		if(check(tmpcard,sum-3)==1)
		  return 1;
	      }
	    return 0;
	  }	
      }

  return flag;
}

int main()
{
  int n;
  cin>>n;
  for(;n--;)
    {
      int tmpnum[9];
      char tmpmark;
      int card[3][10];
      for(int i=0;i<3;i++)
	memset(card[i],0,sizeof(card[i]));

      for(int i=0;i<9;i++)
	cin>>tmpnum[i];

      for(int i=0;i<9;i++)
	{
	  cin>>tmpmark;
	  if(tmpmark=='R')
	    card[0][tmpnum[i]]++;
	  else if(tmpmark=='G')
	    card[1][tmpnum[i]]++;
	  else
	    card[2][tmpnum[i]]++;
	}
      cout<<check(card,9)<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
string a;
cin>>a;
for (int i = 0; i < 3; i++)
{
    cout<<a.at(i);
}
cout<<endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
using INT64 = long long;

int main(void)
{
    IOS
    int n,m;
    cin >> n>>m;
    vector<int> p(m);
    vector<bitset<10>> d;
    for(int i = 0; i < m; i++){
        bitset<10> bs(0);
        int k;
        cin >> k;
        for (int j = 0; j < k;j++) {
            int s;
            cin >> s;
            bs.set(s-1);
        }
        //cerr << bs << endl;
        d.push_back(bs);
    }
    for(int i = 0; i < m;i++) cin >> p[i];

    unsigned int sw = 1 << (n);

    int ans=0;
    for(unsigned int i = 0; i < sw;i++){
        bitset<10> ssw(i);
        cerr << ssw << endl;
        bool flag = true;
        for (int j = 0; j < m; j++) {
            bitset<10> sk = d[j];
            //cerr << sk << endl;
            sk &= ssw;
            int count = sk.count();
            //cerr << count << endl;
            if (count % 2 != p[j]) {
                flag = false;
                break;
            }
            if (!flag) break;
        }
        if (flag) ans++;
    }

    cout << ans << endl; 
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000009ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
char s[1252525];
const int B = 10009;
int bpow[1252525];
int hsh[1252525];
int rhsh[1252525];

int subhash(int l, int r){
  // printf("[%d,%d): ",l,r);
  // FOR(i,l,r)putchar(s[i]); puts("");
  ll ret = hsh[r];
  ret += MOD - (ll)hsh[l] * bpow[r-l] % MOD;
  return ret % MOD;
}
int subrevhash(int l, int r){
  swap(l,r); l=n-l; r=n-r;
  ll ret = rhsh[r];
  ret += MOD - (ll)rhsh[l] * bpow[r-l] % MOD;
  return ret % MOD;
}

int main(){
  // n = 10;
  while(true){
    // REP(i,n)s[i] = 'a' + (rand()%26);
    scanf("%d",&n);
    scanf("%s",s);
    
    int ans = n;

    bpow[0] = 1;REP(i,n)bpow[i+1]=(ll)bpow[i]*B%MOD;
    hsh[0] = 0; REP(i,n)hsh[i+1]=((ll)hsh[i]*B+s[i])%MOD;
    rhsh[0] = 0;REP(i,n)rhsh[i+1]=((ll)rhsh[i]*B+s[n-1-i])%MOD;
    // exh
    FOR(len,2,n){
      if(2*len-2 < n){
        int unitlen = 2*len-2;
        int restlen = n - unitlen;
        if(subhash(0,restlen) != subhash(n-restlen,n))continue;
        if(restlen>0){
          bool ok = true;
          REP(_,10){
            int x = rand() % restlen;
            if(s[0+x] != s[n-restlen+x])ok=false;
          }
          if(!ok)continue;
        }
      }
      int r = min(2*len-1, n);
      int sublen = r - len;
      if(subhash(len-1-sublen,len-1) != subrevhash(len,r))continue;
      if(sublen>0){
        bool ok = true;
        REP(_,10){
          int x = rand() % sublen;
          if(s[len-1-sublen+x] != s[r-1-x])ok=false;
        }
        if(!ok)continue;
      }
      ans = len; break;
    }
    printf("%d\n",ans);

    // // check ans
    // int naiveans = n;
    // FOR(len,2,n){
    //   bool ok = true;
    //   REP(i,n){
    //     char x = s[i];
    //     int id = len-1-abs((i%(2*len-2))-len+1);
    //     char y = s[id];
    //     if(x!=y){
    //       ok = false; break;
    //     }
    //   }
    //   if(ok){
    //     naiveans = len; break;
    //   }
    // }
    // if(true || ans != naiveans){
    //   DEBUG("ERROR");
    //   puts(s);
    //   DEBUG(ans);
    //   DEBUG(naiveans);
    //   return 0;
    // }
    break;
  }
  return 0;
}



Measured memory_bytes: 15888
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

string mymax(string s, string t){
  if (s[s.size()-1] == '-')
    return t;
  if (t[t.size()-1] == '-')
    return s;

  if (s.size() > t.size())
    return s;

  if (s.size() < t.size())
    return t;

  if (s.size() == 0)
    return "";
  

  if (s[0] > t[0])
    return s;
  if (s[0] < t[0])
    return t;

  return s[0] + mymax(s.substr(1), t.substr(1));
}

int main(void){
  ll n, m;
  cin >> n >> m;

  ll match[10] = {0, 2, 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6}; 


  vector<ll> a(10, 0);
  for (int i = 0; i < m; i++){
    ll b;
    cin >> b;
    a[b] = 1;
  }

  vector<vector<string>> dp(n + 10, vector<string>(10, "-"));


  for (int i = 0; i < 10; i++){
    dp[0][i] = "";
  }
  
  for (int i = 0; i < n; i++){
    for (int j = 1; j < 10; j++){
      for (int k = 1; k < 10; k++){
        if (a[j])
          dp[i + match[j]][j] = mymax(dp[i + match[j]][j], (string){(char)('0' + j)} + dp[i][k]);
      }
    }
  }

  string res = "";
  for (int i = 1; i < 10; i++){
    res = mymax(res, dp[n][i]);
  }
  
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 225792
#include<iostream>
#include<algorithm>
#include <cstdlib>
using namespace std;

int gcd(int a, int b){
    if (b == 0) return a;
    else gcd(b, a % b);
}

int main(){
    int N, X;
    cin >> N >> X;
    int x[1000000];
    int difx[1000000];
    for (int i = 0; i < N; i++){
        cin >> x[i];
    }
    for (int i = 0; i < N; i++){
        difx[i] = abs(x[i] - X);
    }
    int s = difx[0];
    for (int i = 1; i < N; i++){
        s = gcd(s, difx[i]);
    }
    cout << s << endl;


    return 0;

}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    if(m<=2*n)
    {
        cout<<m/2<<endl;
        return 0;
    }
    else
    {
        ll s=m-2*n;
        ll tot=n+s/4;
        cout<<tot<<endl;

    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int f[10][10];

int main()
{
	int x,y,s;
	int sx[]={-1,0,1,0},sy[]={0,1,0,-1},
			mx[]={-1,-1,-1,0,0,1,1,1},my[]={-1,0,1,-1,1,-1,0,1},
			lx[]={-2,-1,-1,-1,0,0,0,0,1,1,1,2},ly[]={0,-1,0,1,-2,-1,1,2,-1,0,1,0};

	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF)
	{
		f[y][x]++;
		if(s==1)
		{
			for (int i = 0; i < 4; ++i)
			{
				int nx=x+sx[i],ny=y+sy[i];
				if(0<=nx&&nx<10&&0<=ny&&ny<10)
				{
					f[ny][nx]++;
				}
			}
		}
		else if(s==2)
		{
			for (int i = 0; i < 8; ++i)
			{
				int nx=x+mx[i],ny=y+my[i];
				if(0<=nx&&nx<10&&0<=ny&&ny<10)
				{
					f[ny][nx]++;
				}
			}
		}
		else
		{
			for (int i = 0; i < 12; ++i)
			{
				int nx=x+lx[i],ny=y+ly[i];
				if(0<=nx&&nx<10&&0<=ny&&ny<10)
				{
					f[ny][nx]++;
				}
			}
		}
	}
	int ans=0,zero=0;
	for (int i = 0; i < 10; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			ans=max(ans,f[i][j]);
			if(f[i][j]==0) zero++;
		}
	}
	cout<<zero<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
string mp[101];
int n,m,ans,vis[101][101];
void dfs(int x,int y,char c){
	mp[x][y]=1;
	for(int i=0;i<4;i++){
		int fx=x+dx[i];
		int fy=y+dy[i];
		if(fx>=0 && fx<n && fy>=0 && fy<m && !vis[fx][fy] && mp[fx][fy]==c){
			vis[fx][fy]=1;
			dfs(fx,fy,c);
		}
	}
}
int main(){
	while(cin>>n>>m){
		if(n==0 && m==0)	return 0;
		for(int i=0;i<n;i++)
			cin>>mp[i];
		memset(vis,0,sizeof(vis));
		ans=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(!vis[i][j]){
					ans++;
					dfs(i,j,mp[i][j]);
				}			
			}
		}
		cout<<ans<<endl;
	}
	return 0;
 }


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, m, f, a[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&m);
	for(int i = 1; i <= n; i++)
		scanf("%d", a + i);
	for(int i = 1; i < n; i++)
		if(a[i] + a[i + 1] >= m){
			printf("Possible\n");
			for(int j = 1; j < i; j++)
				printf("%d\n", j);
			for(int j = n - 1; j > i; j--)
				printf("%d\n", j);
			printf("%d\n", i);
			return 0;
		}
	printf("Impossible\n");
	return 0;
}

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

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

  int result = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      result = max(result, abs(a[i] - a[j]));
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

X = int(input())

a=0
if X==2 or X==3:
  a=1
while a<1:
  for i in range(2,int(np.sqrt(X))+1):
    a=1
    if X%i==0:#素数でない
      a=0
      break
    else:#素数かも
      pass
  if a==0:
    X+=1
print(X)

Measured memory_bytes: 12392
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

bool has[101];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    while (k--) {
        int m;
        cin >> m;
        while (m--) {
            int x;
            cin >> x;
            has[x] = true;
        }
    }
    int ans = n;
    FOR(i, 1, n + 1) ans -= has[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <math.h>

int main ()
{
  int a;
  int b;

  scanf("%d", &a);
  scanf("%d", &b);

  if (a < b) {
    printf("a < b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 2564
using System;
using System.Collections.Generic;
using System.Linq;
namespace ITP1_6_A
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }
            return list_temp;
        }


        public static void Main (string[] args)
        {
            List<string[]> list_result = new List<string[]>();
            list_result = getinputdata ();


            //int n= int.Parse(list_result[0][0]);
            string[] a=list_result[1];

            Array.Reverse(a);
            Console.WriteLine(String.Join(" ",a));


        }
    }
}

Measured memory_bytes: 9044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n = Integer.parseInt(br.readLine());

		String[] numStrAry =  br.readLine().split(" ");
		int[] numIntAry = new int[n];

		for(int i = 0 ; i < n ; i++) numIntAry[i] = Integer.parseInt(numStrAry[i]);

		insertSort(n,numIntAry);
	}

	public static void insertSort(int n, int[] numIntAry){

		StringBuilder sb = new StringBuilder();
		for(int i = 0 ; i < n ; i++){
			sb.append(numIntAry[i]);
			sb.append(" ");
		}
		sb.deleteCharAt(sb.length() - 1);
		sb.append("\n");

		for(int i = 1 ; i < n ; i++){
			int j  = i - 1;
			int val = numIntAry[i];

			while(j >= 0 && val < numIntAry[j]){
				numIntAry[j+1] = numIntAry[j];
				j--;
			}
			numIntAry[j+1] = val;

			for(int x = 0 ; x < n ; x++){
				sb.append(numIntAry[x]);
				sb.append(" ");
			}
			sb.deleteCharAt(sb.length() - 1);
			sb.append("\n");
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}

}

Measured memory_bytes: 25896
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,c,k;
    cin>>n>>c>>k;
    vector<int> t(n);
    for(int i=0;i<n;i++)cin>>t[i];
    sort(All(t));
    t.push_back(inf);
    if(c==1){
    	cout<<n<<endl;
    	return 0;
    }	
    int res=0;
    int tmp=0;
    int now=t[0];
    for(int i=0;i<n+1;i++){
        if(t[i]<=now+k){
            tmp++;
            if(tmp==c){
                res++;
                tmp=0;
                now=t[i+1];
            }
        }
        else{
            res++;
            tmp=1;
            now=t[i];
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200011];
int B[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    REP (i, N) B[i] = A[i];
    sort(B, B+N);
    REP (i, N) {
	int ans;
	if (A[i] < B[N/2]) ans = B[N/2];
	else ans = B[N/2-1];
	printf("%d\n", ans);
    }


}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
     ll t,d,x,y,res=0,c=0;

    cin >>t >> d;
    while(t--)
    { res=0;
       cin >> x >> y;
        res = ceil(sqrt(pow(x,2)+pow(y,2)));
        if(res<=d)
        {
            c++;
        }
    }

    cout << c<<endl;
    return 0;
}


Measured memory_bytes: 3732
A,B,C,D=list(map(int,input().split(" ")))
t=0 # 現在のターン

while True:
    if t%2==0: # 高橋君のターン
        C-=B # 高橋君の攻撃
    elif t%2==1: # 青木君のターン
        A-=D # 青木君の攻撃
    
    if A<=0 or C<=0: # 戦闘終了
        break

    t+=1 # 次のターンへ

if C<=0: # 高橋君の勝ち
    print("Yes")
else: # 高橋君の負け
    print("No")

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,m,x,A[12][12],C[12];
    cin>>n>>m>>x;
    rep(i,n){
        cin>>C[i];
        rep(j,m) cin>>A[i][j];
    }
    ll inf=1e9,ans=inf;
    rep(i,1<<n){
        vec B(m,0);
        ll a=0;
        rep(j,n) if((i>>j)&1){
            a+=C[j];
            rep(k,m) B[k]+=A[j][k];
        }
        int z=1;
        rep(j,m) if(B[j]<x) z=0;
        if(z) ans=min(a,ans);
    }
    if(ans==inf) cout<<-1;
    else cout<<ans;
}

Measured memory_bytes: 3512