akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;


/** Problem1163 : Cards **/
// 二部マッチング
const int MAX_V = 1010;

class Flow {
public:
	struct edge { int to, cap, rev; };
	vector<edge> G[MAX_V];
	bool used[MAX_V];
	
	void add_edge(int from, int to, int cap) {
		G[from].push_back((edge){to, cap, (int)G[to].size()});
		G[to].push_back((edge){from, 0, (int)G[from].size()-1});
	}
	
	int dfs(int v, int t, int f) {
		if (v==t) return f;
		used[v] = true;
		for (int i=0; i<G[v].size(); i++) {
			edge &e = G[v][i];
			if (!used[e.to] && e.cap>0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d>0) {
					e.cap-=d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int max_flow(int s, int t) {
		int flow = 0;
		for (;;) {
			memset(used, 0, sizeof(used));
			int f = dfs(s, t, INF);
			if (f==0) return flow;
			flow += f;
		}
	}
};

// 最大公約数を求める
int GCD(int a, int b)
{
    int temp;
	
    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;
	
    if( a % b == 0 ) return b;
    return GCD( b, a % b );
}

int main()
{
	int m, n;
	// 0 ~ m-1 : blue
	// m ~ m+n-1 : red
	// m+n : s
	// m+n+1 : g
	
	while (cin>>m>>n, m||n) {
		vector<int> blue, red;
		int s=m+n, t=s+1;
		Flow F;
		
		rep(i, m) {
			int t; cin>>t;
			blue.push_back(t);
		}
		
		rep(i, n) {
			int t; cin>>t;
			red.push_back(t);
		}
		
		rep(i, m) {
			F.add_edge(s, i, 1);
		}
		
		rep(i, n) {
			F.add_edge(m+i, t, 1);
		}
		
		rep(b, m) {
			rep(r, n) {
				if (GCD(blue[b], red[r])>1) {
					F.add_edge(b, m+r, 1);
				}
			}
		}
		
		cout << F.max_flow(s, t) << endl;
	}
}

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

int main(){
	int N; cin >> N;
	int x[N], y[N];
	for(int i=0; i<N; i++) cin >> x[i] >> y[i];
	int ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			int cnt = 0;
			for(int k=0; k<N; k++){
				for(int l=0; l<N; l++){
					if(x[i] - x[j] == x[k] - x[l] && y[i] - y[j] == y[k] - y[l]){
						cnt++;
					}
				}
			}
			if(cnt > ans) ans = cnt;
		}
	}
	cout << N-ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if ( a==b && a!=c )
    puts("Yes");
  else if ( b==c && b!=a )
    puts("Yes");
  else if ( a==c && a!=b )
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;

int main() {
	int N, ans = 0;
	string S;
	cin >> N;
	cin >> S;
	for (int i = 0; i < S.size() - 2; i++) {
		if (S[i] == 'A') {
			if (S[i + 1] == 'B') {
				if (S[i + 2] == 'C') {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
n = n % 10
if n == 0 or n == 1 or n == 6 or n == 8:
    print('pon')
elif n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
else:
    print("bon")


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

int main(void)
{
  int a[10000];
  int b[10000];

  int k=0;
  do{
    k = k + 1;
    cin >> a[k] >> b[k];
  } while(a[k] != 0 || b[k] != 0);

  k=1;
  while(a[k] != 0 || b[k] !=0){
    if(a[k]<b[k])
      cout << a[k] << " " << b[k] << endl;
    else
      cout << b[k] << " " << a[k] << endl;
    k = k + 1;
  }

  return 0;
}

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

int main() {
    long long n;
    cin >> n;

    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if((i % 3 != 0) && (i % 5 != 0)) {
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define N 100000
int main() {
	int n;
	long long int k;
	cin>>n>>k;
	long long int hoge[N]={};
	int a,b;
	for(int i=0;i<n;i++){
		
		cin>>a>>b;
		hoge[a-1]+=b;
	}
	long long count;
 	for(int i=0;i<N;i++){
 		count+=hoge[i];
 		if(count>=k){
 			cout<<i+1<<endl;
 			break;
 		}
 	}
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX_N 10010

using namespace std;

typedef long long ll;
ll N,K[MAX_N];

int main(){

  cin >> N;
  rep(i,N)cin >> K[i];
  sort(K,K+N);
  ll sum = 0;
  rep(i,N){
    if( K[i] > sum+1LL ){
      cout << sum+1LL << endl;
      return 0;
    }
    sum += K[i];
  }
  cout << sum+1LL << endl;
  return 0;
}

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

int main(){
  int time_spent=0;
  int dish_time;
  int max_time_use_dish=10;
  for(int i=0; i<5; i++){
    cin >> dish_time;
    if((dish_time%10!=0) && (dish_time%10<max_time_use_dish)){
      max_time_use_dish = dish_time%10;
    }
    time_spent += ((dish_time-1)/10+1)*10;
  }
  cout << time_spent - (10 - max_time_use_dish) << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    ll ans = ((N-1) * N) / 2;
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter
MOD = 998244353
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0:
    print(0)
    exit()
c = Counter(d)
if c[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(1, len(c)):
    if c[i] == 0:
        print(0)
        exit()
    ans *= c[i - 1]**c[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 19936
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/
ll n, m;
ll a[man];
signed main()
{
    fast;
    cin>>n>>m;
    ll cur=1;
    f(i,1,n+1)
    {
        cin>>a[i];
        a[i]/=2;
        cur = cur / __gcd(cur, a[i]) * a[i];
        if(cur>m) 
        {
            cout<<0<<endl; 
            return 0; 
        }
    }
    f(i,1,n+1)
    {
        if (cur/a[i]%2==0) 
        { 
            cout<<0<<endl;
            return 0; 
        }
    }
    cout<<1+(m-cur)/(2*cur)<<endl;
}   


Measured memory_bytes: 4372
program abc175a
  implicit none
  integer ans,c,i 
  character(len=10) str
  read(*,'(a)') str
  ans=0
  c=0
  do i=1,len(str)
     if(str(i:i)=='R') then
        c=c+1
     else
        c=0
     end if
     ans=max(ans,c)
  end do
  print*,ans
end program abc175a

Measured memory_bytes: 2896
#include<iostream>

using namespace std;

int prime_num[1000001];
int a, d, n;

void prime_data(){
    for(int i=0; i <= 1000000; i++){
        prime_num[i] = 1;
    }
    prime_num[0] = 0;
    prime_num[1] = 0;
    for(int i=2; i<=1000000; i++){
        if(prime_num[i]==1){
            for(int j=0; i*(j+2) <= 1000000; j++){
                prime_num[i*(j+2)] = 0;
            }
        }
    }
}

void found(){
    int count = 0;
    int i = a;
    while(count != n){
        if(prime_num[i] == 1){
            count++;
        }
        if(count == n){
            cout << i << endl;
            break;
        }
        i = i + d;
    }
}


int main(void){
    prime_data();
    while(1){
        cin >> a >> d >> n;
        if(a == 0 && d == 0 && n == 0){
            break;
        }
        found();
    }
    return 0;
}


Measured memory_bytes: 6964
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int n;
  cin>>n;
  ll int lu[87];
  rep(i,0,87) lu[i]=0;
  lu[0]=2;
  lu[1]=1;
  rep(i,2,87) lu[i]=lu[i-1]+lu[i-2];
  
  
  cout<<lu[n];
}

// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int i;
string a, b, c;
int main(){
	cin >> a;
	i = a.size();
	b = a.substr(0, 1);
	c = a.substr(i - 1, 1);
	cout << b << i - 2 << c;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
AB = [map(int, input().split()) for _ in range(M)]

links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

result = [-1] * (N + 1)
q = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))


Measured memory_bytes: 106336
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n);
  ll ans=0;
  rep(i,n){
    cin >> a[i];
    if(i>0){
      if(a[i]+a[i-1]>x){
        ans+=a[i]+a[i-1]-x;
        if(a[i]<a[i]+a[i-1]-x){
          a[i]=0;
          a[i-1]=x;
        }
        else a[i]-=a[i]+a[i-1]-x;
      }
    }
  }
  cout << ans;
}

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

int main(){
    int x,y,t;
    while (1){
        cin >> x >> y;
        if (x == 0 && y == 0)break;
        if (x > y){
        t = x;x = y;y = t;
        }
        cout << x << " " << y << endl;
    }
return 0;
}


Measured memory_bytes: 3004
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = S()

    xxx = [str(i) * 3 for i in range(10)]
    if [i for i in xxx if i in N]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9076
import math
a,b,C = (float(i) for i in input().split())
rad =math.radians(C)
S = a*b*0.5*math.sin(rad)
L = a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(rad))
H = b*math.sin(rad)
print(S)
print(L)
print(H)

Measured memory_bytes: 7784
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s; int start, end;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='A'){
            start = i;
            break;
        }
    }

    for(int i=s.size()-1; i>=0; i--){
        if(s[i]=='Z'){
            end = i;
            break;
        }
    }
    cout<<end-start+1;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int N;
int parent[100001];
int sibling[100001];
int degree[100001];

int calcDepth(int i) {
  if(parent[i] == -1) return 0;
  return calcDepth(parent[i]) + 1;
}

int calcHeight(int i) {
  int j, h;
  h = 0;
  for(j = 0; j < N; ++j) {
    if(parent[j] == i) {
      int tmp = calcHeight(j) + 1;
      if(tmp > h) h = tmp;
    }
  }
  return h;
}

int main() {
  int i,j;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    parent[i] = -1;
    sibling[i] = -1;
    degree[i] = 0;
  }
  for(i = 0; i < N; ++i) {
    int id, left, right;
    scanf("%d %d %d", &id, &left, &right);
    if(left != -1) {
      parent[left] = id;
      sibling[left] = right;
      ++degree[id];
    }
    if(right != -1) {
      parent[right] = id;
      sibling[right] = left;
      ++degree[id];
    }
  }

  for(i = 0; i < N; ++i) {
    int depth = calcDepth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
           i, parent[i], sibling[i], degree[i], depth, calcHeight(i));
    if(depth == 0) {
      printf("root\n");
    } else if(degree[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int& Ai : A) {
    cin >> Ai;
  }
  int Q;
  cin >> Q;
  vector<int> B(Q);
  vector<int> C(Q);
  for (int i = 0; i < Q; ++i) {
    int bi, ci;
    cin >> bi >> ci;
    B[i] = bi;
    C[i] = ci;
  }

  // Value Ai --> the i where Ai is located
  unordered_map<int, vector<int>> locations;
  for (int i = 0; i < N; ++i) {
    locations[A[i]].push_back(i);
  }

  long long sum = 0;
  for (int Ai : A) sum += Ai;

  for (int i = 0; i < Q; ++i) {
    int Bi = B[i];
    int Ci = C[i];

    vector<int> locs = locations[Bi];
    locations[Ci].insert(locations[Ci].end(), locs.begin(), locs.end());

    int nl = locs.size();
    sum += nl * (Ci - Bi);
    locations[Bi].clear();

    for (int ii : locs) {
      A[ii] = Ci;
    }
    cout << sum << endl;
  }

  return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int red = 0, blue = 0;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); ++i){
		if (S[i] == '0') red++;
		else blue++;
	}
	cout << 2*min(red,blue) << '\n';
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
	
}

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

int main(){
	int x1,y1,x2,y2;
  	cin>>x1>>y1>>x2>>y2;
  	cout<<y1-y2+x2<<" "<<y2-x1+x2<<" "<<+x1-y2+y1<<" "<<-x1+y1+x2<<endl;
  	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt=0;
    FOR(i, 0, n){
        cin >> a[i];
        
        int tmp1 = a[i]/2;
        int tmp2 = a[i];
        while(tmp1*2==tmp2){
            cnt++;
            tmp2 = tmp1;
            tmp1 = tmp1 / 2;
        }
    }
    
    cout << cnt << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n=3;
  int a[3];
  for(int i=0; i<n; i++){
      cin >> a[i];
  }
  sort(a,a+n);
  cout << a[0] << " " << a[1] << " " << a[2] <<endl;
}


Measured memory_bytes: 3156
import java.util.*

fun main(args : Array<String>) {
  var (n, m) = readLine()!!.split(' ').map(String::toInt)
  var s = 0
  var e = n + 1
  repeat(m) {
    val (l, r) = readLine()!!.split(' ').map(String::toInt)
    s = Math.max(s, l)
    e = Math.min(e, r)
  }
  println(Math.max(e - s + 1, 0))
}


Measured memory_bytes: 54996
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int n,m,E,last[500],next[250000],to[250000];
int q[500],head,tail;

void add_edge(int u, int v){
    to[E] = v; next[E] = last[u]; last[u] = E++;
}

int l[500],r[500],dl[500],dr[500];
bool visited[500];

bool bfs(){
    memset(dl,-1,sizeof dl);
    memset(dr,-1,sizeof dr);
    head = tail = 0;
    
    bool found = false;
    
    for(int i = 0;i < n;++i){
        if(r[i] == -1){
            q[tail++] = i;
            dl[i] = 0;
        }
    }
    
    while(head < tail){
        int cur = q[head++];
        
        for(int e = last[cur];e != -1;e = next[e]){
            if(to[e] != r[cur] && dr[ to[e] ] == -1){
                dr[ to[e] ] = dl[cur] + 1;
                
                if(l[ to[e] ] == -1) found = true;
                
                if(l[ to[e] ] != -1 && dl[ l[ to[e] ] ] == -1){
                    q[tail++] = l[ to[e] ];
                    dl[ l[ to[e] ] ] = dl[cur] + 2;
                }
            }
        }
    }
    
    return found;
}

bool dfs(int pos){
    if(visited[pos]) return 0;
    visited[pos] = 1;
    
    for(int e = last[pos];e != -1;e = next[e]){
        if(dr[ to[e] ] == dl[pos] + 1 && (l[ to[e] ] == -1 || dfs(l[ to[e] ]))){
            r[pos] = to[e];
            l[ to[e] ] = pos;
            return 1;
        }
    }
    
    return 0;
}

int main(){
    int a[500],b[500];
    
    while(true){
        scanf("%d %d",&n,&m);
        
        if(n == 0) break;
        
        for(int i = 0;i < n;++i) scanf("%d",&a[i]);
        for(int i = 0;i < m;++i) scanf("%d",&b[i]);
        
        memset(last,-1,sizeof last);
        E = 0;
        
        for(int i = 0;i < n;++i)
            for(int j = 0;j < m;++j)
                if(__gcd(a[i],b[j]) > 1)
                    add_edge(i,j);
        
        memset(l,-1,sizeof l);
        memset(r,-1,sizeof r);
        
        int ans = 0;
        bool change = true;
        
        while(bfs()){
            memset(visited,0,sizeof visited);
            
            for(int i = 0;i < n;++i)
                if(r[i] == -1)
                    change |= dfs(i);
        }
        
        for(int i = 0;i < n;++i)
            if(r[i] != -1) ++ans;
        
        printf("%d\n",ans);
    }
    
    return 0;
}

Measured memory_bytes: 1688
#include<string>
#include <iostream>
#include<math.h>

using namespace std;


int main(void) {
    int a,b,c;
    cin >> a >> b;
    string s;
    s = to_string(a) + to_string(b);
    c = stoi(s);
    int d = (int)sqrt((double)c) * (int)sqrt((double)c);
    if( d == c ) cout << "Yes";
    else cout << "No";







    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>

using namespace std;

int main()
{
  int n,c=1;
  string s;
  cin>>n;
  cin>>s;
  
  for(int i=0;i+1<n;i++)
    if(s[i]!=s[i+1])
      c++;
  cout<<c;
  
  
  return 0;
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long

using namespace std;

bool compare(int i,int j)
{
    return i>j;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin>>T;
    int arr[T], v[T];
    for (int j=0;j<T;j++)
    {
        cin>>arr[j];
        v[j] = arr[j];
    }
    sort(v, v+T);
    for (int i=0;i<T;i++)
    {
        if (arr[i]==v[T-1])
            cout<<v[T-2];
        else
            cout<<v[T-1];
        cout<<'\n';
    }



    return 0;

}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);

    vector<int> V;
    
    int N;
    cin >> N;
    for (int i=0; i < N; ++i) {
        int k;
        cin >> k;
        V.push_back(k);
    }

    int ans = 0;
    for (int i=0; i < N; ++i) {
        int k;
        cin >> k;
        if (V[i] > k) ans += V[i]-k;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
	using namespace std;
	using namespace __gnu_pbds;
	typedef long long ll; 
	#define int long long
	typedef unsigned long long lu;
	typedef vector<ll> v;
	typedef vector<vector<ll> > vv;
	typedef vector<string>  vs;
	typedef vector<pair<ll,ll>> vpr;
	typedef long double ld;
	#define f(i,n) for(ll i = 0; i < n; i++)
	#define ff(i,n) for(ll i=1;i<=n;i++)
	#define pb push_back
	#define mp make_pair
	#define endl "\n"
	#define fi first
	#define se second
	#define all(x) x.begin(),x.end()
	#define rall(x) x.rbegin(),x.rend()
	#define amax(x,y) if(y>x) x=y;
	#define amin(x,y) if(y<x)x=y;
	#define bg(x) x.begin()
	#define sz(x) (ll)x.size()
	#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
	#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
	#define mxt(a) *(max_element(a.begin(),a.end()))
	#define mnt(a) *(min_element(a.begin(),a.end())
	#define tc ll t;cin>>t;while(t--)
	typedef pair<ll,ll> pi;
	#define yes cout<<"YES\n";
	#define no cout<<"NO\n";
	#define yesno(f) if(f) yes else no
	const v dx = {1, -1, 0, 0};
	const v dy = {0, 0, 1, -1};
	const ll mod=1e9+7;
	const ld PI = 2 * acos(0.0);
	ll m(ll a){ return (a+mod)%mod;}
	ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
	ll power(ll a,ll b,ll m)
	{
		if(b==0)
			return 1;
		ll d=power(a,b/2,m);
		d=(d*d)%m;
		if(b&1)
			d=(d*a)%m;
		return d;
	}
	// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
	// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
	/*string operations :
	str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
	str.substr (x) : returns a substring str[x],... end of string
	str.find(qtr) : returns the first occurenece of qtr in str */
	int32_t main()
	{
		ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
		string s;cin>>s;
		for(auto it:s)
		{
			if(it=='7')
			{
				cout<<"Yes\n";
				exit(0);
			}
		}
		cout<<"No\n";
		return 0;
	}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
  return true;
}
int zero[100000000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b=0,c=0,d=-1;
  cin>>a;
  for(int i=0;i<a;i++) cin>>zero[i];
  for(int i=0;i<a;i++){
      if(zero[b]==2){
	  d=i+1;
	  break;
      }
      else{
	  b=zero[b]-1;
      }
  }
  cout<<d<<"\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	int N, M; std::cin >> N >> M;
	std::vector<std::vector<int>> s(M);
	for (auto i{ 0 }; i < M; ++i) {
		int k; std::cin >> k;
		for (auto j{ 0 }; j < k; ++j) {
			//予め各電球に対して対応するスイッチの組み合わせを2進数変数に変換しておく。
			int a; std::cin >> a; --a;
			s[i].push_back(a);
		}
	}
	std::vector<int> P(M);
	for (auto& r : P) std::cin >> r;
	
	int ans{ 0 };
	for (int bit{ 0 }; bit < (1 << N); ++bit) {
		bool ok = true;
		for (int i{ 0 }; i < M; ++i) {
			int con{ 0 };
			for (auto& r : s[i])
				//onになっているスイッチの組み合わせと1.で用意した電球に対応するスイッチの組み合わせとでAND演算した結果を取る。
				if (bit & (1 << r))++con;
			if ((con % 2) != P[i])
				ok = false;
		}
		if (ok == true) ++ans;
	}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n, m;
		cin >> n >> m;
		vector <int> num (n, -1);
		for (i = 0; i < m; ++i)
		{
			int pos, aux; cin >> pos >> aux; --pos;
			if (num[pos] >= 0 && num[pos] != aux) num[pos] = -2;
			else if (num[pos] == -1) num[pos] = aux;
		}
		if (n == 1)
		{
			if (num[0] == -2) cout << "-1\n";
			else if (num[0] == -1) cout << "0\n";
			else cout << num[0] << '\n';
		}
		else
		{
			for (i = 0; i < num.size (); ++i)
				if (num[i] == -2) break;
			if (num[0] == 0) i = num.size () - 1;
			if (i < num.size ())
			{
				cout << "-1\n";
				continue;
			}
			if (num[0] == -1) num[0] = 1;
			for (i = 1; i < num.size (); ++i)
				if (num[i] == -1) num[i] = 0;
			trav (a, num) cout << a;
			cout << '\n';
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


int main(){
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];

    string t;
    rep(i,w) t += '.';

    for(int i=0; i<h; ++i){
        if(t == a[i]){
            a.erase(a.begin()+i);
            i = -1;
            --h;
        }
    }
    
    for(int j=0; j<w; ++j){
        bool can = true;
        for(int i=0; i<h; ++i){
            if(a[i][j] != '.') can = false;
        }
        if(can){
            for(int i=0; i<h; ++i) a[i].erase(j,1);
            j = -1;
            --w;
        }
    }
    rep(i,h) cout(a[i]);


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


int main() {
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	ll m = min(a, min(b, min(c, min(d, e))));
	if (n%m == 0)cout << n / m + 4 << endl;
	else cout << n / m + 5 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
h = list(map(int, input().split()))

ans = h[0]
for i in range(1, n):
    if h[i - 1] < h[i]:
        ans += h[i] - h[i - 1]
print(ans)


Measured memory_bytes: 9180
N = gets.to_i
blues = N.times.map { gets.chomp }
M = gets.to_i
reds = M.times.map { gets.chomp }
points = []
blues.uniq.each do |word|
  points << blues.count(word) - reds.count(word)
end
puts points.max < 0 ? 0 : points.max


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

def main():
    N, W = [int(item) for item in input().split()]
    item = np.array([[int(item) for item in input().split()] for _ in range(N)])

    dp = np.zeros((N+1, W+1), dtype='int64')

    for i in range(N):
        dp[i+1] = dp[i]
        w, v = item[i]
        np.maximum(dp[i][:-w] + v, dp[i][w:], out=dp[i+1][w:])
        # print(dp[i+1])
    print(dp[N][W])

if __name__ == "__main__":
    main()

Measured memory_bytes: 91548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int n,y;
    cin >> n >> y;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n-i; j++){
            int k = n-i-j;
            if(10000*i+5000*j+1000*k==y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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

int main(){

	int n, b, f, r, v;
	int A[5][4][11] = {0};

	cin >> n;

	for(int i = 0; i < n; i++ ){
		cin >> b >> f >> r >> v;
		A[b][f][r] = A[b][f][r] + v; 
		//	ここから入居者数の条件 0以下の場合と9以上の場合
		if(A[b][f][r] > 9) A[b][f][r] = 9;
		if(A[b][f][r] < 0) A[b][f][r] = 0;
	}

	for(int i = 1; i <= 4; i++){
		for(int j = 1; j <= 3; j++){
			for(int k = 1; k <=10; k++){
				if(k == 1) cout << " ";
				cout << A[i][j][k] << " \n"[k == 10];
			}
		}
		if(i < 4)cout << "####################" << endl;
	}
	

	return 0;
}


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

#define sz(s) (int)(s.size())
#define eb emplace_back

const int N = 2e5 + 5;
const int sZ = (1 << 19);

#define ll long long

void solve() {
	int n, m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No");
}

int main () {
	cerr << "Ready\n";
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
#define int long long

///My functions
void sread ( string &s ){ cin >> s ; s = '_' + s ; }
void sprint ( string &s ){ cout << s.substr( 1 , s.size() ) ; } 

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n,m,Q,k,a,b,c,sum,ans,MAXans,MINans,sc,pos,acc[mxn],racc[mxn],ar[mxn];
vector<int>v,g[mxn];
bitset<mxn>flag;
bool sol ;
string s;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n ; 

    for( int i = 2 ; i * i <= n ; i++ ){

        if( n % i == 0 ){
            
            sc = 0 ; 
            while( n % i == 0 ){
                sc++ ; 
                n /= i ;
            }

            v.push_back( sc ) ;  

        }

    }

    if( n > 1 ) v.push_back( 1 );

    for( auto i : v ) { 

        int temp = i ;
        for( int j = 1 ; j <= temp ; j++ ){ 
            ans++ ; 
            temp -= j ;
        }

    }

    cout << ans ; 

    return 0;
}
























Measured memory_bytes: 10664
//به نامش
//how we code is who we are :))
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7;

struct pair_hash {
	template <class T1, class T2>
		std::size_t operator () (const std::pair<T1,T2> &p) const {
			auto h1 = std::hash<T1>{}(p.first);
			auto h2 = std::hash<T2>{}(p.second);

			return h1 ^ h2;  
		}
};

ll pw(ll te, ll tee) {
	if (tee == 0)	return 1;
	ll res = pw(te, tee / 2);
	return (tee % 2 ? te * res * res : res * res);
}

ll n;

double ans;
double a;
string s;

void Read_input() {
	cin >> n;
	while (n--) {
		cin >> a >> s;
		if (s == "JPY") {
			ans += a;
			continue;
		}
		a *= 380000;
		ans += a;
	}
	cout << fixed << setprecision(8) << ans;
}

void Solve() {
}


int main() {

	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	//freopen("input.txt", "r", stdin),	freopen("output.txt", "w", stdout);

	Read_input(),	Solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define FOR(i, k, n) for (int(i) = (k); (i) < (n); ++(i))
#define rep(i, n) FOR(i, 0, n)
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef deque<bool> db;
template <class T>
using vv = vector<vector<T>>;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (abs(a - c) <= d)
  {
    cout << "Yes" << endl;
  }
  else if (abs(a - b) <= d && abs(b - c) <= d)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
   int x, y, i, a;

   scanf("%d%d",&x,&y);

   if(x > y){
     while(1){
       a = x % y;
       x = y;
       y = a;
       if(y == 0)break;
     }
     printf("%d\n", x);
   } 

   else if(y > x){
     while(1){
       a = y % x;
       y = x;
       x = a;
       if(x == 0)break;
     }
     printf("%d\n", y);
   }

   else printf("%d\n", x);

   return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int main(void){
    int i,j,H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)
            break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++)
                putchar('#');
            puts("");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 588
inputs = [int(i) for i in input().split()]
K,N = inputs[0],inputs[1]

input_lines = [int(i) for i in input().split()]

max_range = input_lines[0]+(K-input_lines[-1])
for i in range(N):
    if i!=N-1:
        torange = input_lines[i+1]-input_lines[i]
        if torange>max_range:
            max_range = torange
print(K-max_range)


Measured memory_bytes: 26420
n = int(input())

table = [False for i in range(n+1)]
if n >= 4:
    table[4] = True
if n >= 7:
    table[7] = True
for i in range(8,n+1):
    if table[i-4] == True:
        table[i] = True
    if table[i-7] == True:
        table[i] = True
if table[n]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [[1 if i == '#' else 0 for i in STR()] for _ in range(h)]
s = 0
for i in range(h):
    s += sum(a[i])
if s != h + w - 1:
    print('Impossible')
    exit()
y = 0
x = 0
dx = [1, 0]
dy = [0, 1]
while y < h - 1 or x < w - 1:
    flag = [False, False]
    for i in range(2):
        if x + dx[i] < w and y + dy[i] < h and a[y + dy[i]][x + dx[i]] == 1:
            flag[i] = True
    if (flag[0] and flag[1]) or (not flag[0] and not flag[1]):
        print('Impossible')
        exit()
    if flag[0]:
        x += 1
    else:
        y += 1
print('Possible')

Measured memory_bytes: 60140
(a, b, c) = map(int, input().split(' '))
if a*a + b*b == c*c:
    print(a*b//2)
elif b*b + c*c == a*a:
    print(b*c//2)
elif c*c + a*a == b*b:
    print(c*a//2)
    

Measured memory_bytes: 2940
H, W=map(int,input().strip().split(' '))

cost=[]
for i in range(10):
    cost.append(list(map(int,input().strip().split(' '))))

for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
ans=0
for i in range(H):
    a=list(map(int,input().strip().split(' ')))
    for j in a:
        if j!=-1:
            ans+=cost[j][1]
print(ans)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    double d=0;
    cin >> n >> d;
    int cnt=0;
    int x,y;
    double d2=0;
    rep(i,n){
        cin >> x >> y;
        d2=sqrt(pow(abs(x),2)+pow(abs(y),2));
        if(d2<=d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3744
n=int(input())

a = list(map(int,input().strip().split()))

su = a[0]
if n == 2:
  ar = a[1]
else:
  ar = sum(a[1:n])
dif = su-ar
mi = abs(dif)
for i in range(1,n-1):
  dif = dif+2*a[i]
  abs_dif = abs(dif)
  if mi > abs_dif:
    mi = abs_dif
print(mi)

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

const int max_n=1e6+10;
int a[max_n];

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    unordered_map<int, int> m;
    for (int i = 0; i < n; ++i) {
        int x = a[i];
        for (int j = 2; j <= x / j; ++j) {
            if (x % j == 0)
                m[j]++;
            while (x % j == 0) x /= j;
        }
        if (x > 1) m[x]++;
    }
    bool flag = true;
    for (auto item:m) {
        if (item.second > 1) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int g=0;
    for(int i=0;i<n;++i)
        g=gcd(a[i],g);
    if(g==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    return 0;
}


Measured memory_bytes: 10404
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> node;
typedef pair<node, int> P;
int n, m, mp[105][105];
const int inf = 0x3f3f3f3f;
vector<P> vec;
int main()
{	
	while (~scanf("%d%d", &n, &m))
	{
		int ans = 0;
		memset(mp, inf, sizeof(mp));
		for (int i = 0; i < m; i++)
		{
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			mp[a][b] = c;
			mp[b][a] = c;
			vec.push_back(P(node(a, b), c));
		}
		for (int k = 1; k <= n; k++)
		{
			for (int i = 1; i <= n; i++)
			{
				for (int j = 1; j <= n; j++)
				{
					mp[i][j] = min(mp[i][k] + mp[k][j], mp[i][j]);
				}
			}
		}
		for (int i = 0; i < m; i++)
		{
			//debug(mp[(vec[i].first).first][(vec[i].first).second]);
			if (mp[(vec[i].first).first][(vec[i].first).second] < vec[i].second)	ans++;
		}
		printf("%d\n", ans);
	}
}

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

int main(void) {
  char a;
  cin >> a;

  if (isupper(a)) {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
 
  return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
using pii = pair<int,int>;

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

    vector<vector<bool>> out(N, vector<bool>(N, false));
    vector<vector<int>> step(N, vector<int>(N, N));

    for_(y,0,N) for_(x,0,N) {
        step[y][x] = min(step[y][x], x);
        step[y][x] = min(step[y][x], N - 1 - x);
        step[y][x] = min(step[y][x], y);
        step[y][x] = min(step[y][x], N - 1 - y);
    }

    int ans = 0;
    for_(i,0,N*N) {
        int P;
        cin >> P;
        --P;

        int sx = P % N;
        int sy = P / N;

        ans += step[sy][sx];
        out[sy][sx] = true;

        deque<pii> que;
        que.push_back({sx, sy});
        while (!que.empty()) {
            auto [x, y] = que.front(); que.pop_front();
            for_(d,0,4) {
                int nx = x + dx[d], ny = y + dy[d];
                if (nx < 0 or nx >= N or ny < 0 or ny >= N) continue;
                if (step[ny][nx] > step[y][x] + (out[y][x] ? 0 : 1)) {
                    step[ny][nx] = step[y][x] + (out[y][x] ? 0 : 1);
                    if (out[y][x]) que.push_front({nx, ny});
                    else que.push_back({nx, ny});
                }
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;

bool dp[100100];

int main () {
    int A,B;
    cin >> A >> B;

    cout << A*B << endl;

}



Measured memory_bytes: 3624
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map words . tail . lines
printer = unlines . (:[])

solver ps = 
  if 0 < (length $ filter (>=3) $ map length $ filter head $ L.group $ map (\[x,y] -> x==y) ps)
  then "Yes"
  else "No"



Measured memory_bytes: 4028
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int H, W;
    
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << (!((i+j) % 2)? "#" : ".");
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

namespace abc042
{
  public class MainClass
  {
    public static void Main(string[] args)
    {
      long[] input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
      long f_cnt = 0;
      long s_cnt = 0;
      for(int i = 0; i < 3; i++){
        if(input[i] == 5){f_cnt++;}
        if(input[i] == 7){s_cnt++;}
      }
      
      if(f_cnt == 2 && s_cnt == 1){Console.WriteLine("YES");}
      else{Console.WriteLine("NO");}
    }
  }
}

Measured memory_bytes: 11348
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

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

    vector<int> a, b;
    rep(i, M) {
       int ia, ib; cin >> ia >> ib;
       a.push_back(ia);
       b.push_back(ib);
    }

    vector<int> count;
    rep(i, N) count.push_back(0);

    rep(i, N) {
        rep(j, M) {
            if (a[j] == i + 1) count[i]++;
            if (b[j] == i + 1) count[i]++;
        }
    }

    rep(i, N) cout << count[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int larger(int x, int y){
	if(x > y){
		return x;
	}
	else{
		return y;
	}
}

int main(){
	int N;
	cin >> N;
	int trampoline[N];
	for(int i = 0; i < N; i++){
		cin >> trampoline[i];
	}
	int flag = 1;
	int max = 0;
	for(int i = 0; i < N; i++){
		int jumping = 10*i + trampoline[i];
		max = larger(jumping, max);
		if(max < 10*(i+1)){
			flag = 0;
			break;
		}
	}
	max = 0;
	for(int i = 0; i < N; i++){
		int jumping = 10*i + trampoline[N-1-i];
		max = larger(jumping, max);
		if(max < 10*(i+1)){
			flag = 0;
			break;
		}
	}
	if(flag == 1){
		cout << "yes\n";
	}
	else{
		cout << "no\n";
	}
}



Measured memory_bytes: 4272
#include <stdio.h>
int main(void){
    int a, b;
    while(~scanf("%d%d", &a, &b)){
        int x = 0;
        for(int i = a;i < 10e18;i += a){
            if(a % b == 0)break;
            if(i % a == 0 && i % b != 0){
                printf("%d\n", i);
                x = 1;
                break;
            }
        }
        if(x == 0)
            printf("-1\n");
    }
    return 0;
}


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

int main(void)
{
  int H, W;
  cin >> H >> W;
  string S[50];
  
  for (int i=0;i<H;i++){
    cin >> S[i];
  }
  
  bool can = true;
  int dy[4] = {0, 1, 0, -1};
  int dx[4] = {1, 0, -1, 0};
  
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (S[i][j] != '#') continue;
      
      int k;
      for (k=0;k<4;k++){
        int ni = i + dy[k];
        int nj = j + dx[k];
        
        if (ni<0 || ni>=H) continue;
        if (nj<0 || nj>=W) continue;
        if (S[ni][nj] == '#') break;
      }
      if (k == 4){
        can = false;
      }
    }
    if (!can) break;
  }
  
  if (can){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256