akhauriyash/Code-Regression huggingface dataset:
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

ll a[N], fact[N], fInv[N], f[N], f_sum[N];

ll pwr(ll x, ll e);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	fact[0] = 1;
	for (int i = 1; i < N; ++i) {
		fact[i] = (i * fact[i - 1]) % mod;
		fInv[i] = pwr(fact[i], mod - 2);
	}
	for (int i = 0; i < N; ++i) {
		f[i] = (fact[n] * pwr(i + 2, mod - 2)) % mod;
		// f[i] = (f[i] * pwr(n - i - 1, mod - 2)) % mod;
	}
	f_sum[0] = f[0];
	for (int i = 1; i < N; ++i) {
		f_sum[i] = (f_sum[i - 1] + f[i]) % mod;
	}
	// for (int i = 0; i <= 10; ++i) {
	// 	cout << i << ": " << f[i] << endl;
	// }
	// cout << endl;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		int l = i - 1, r = n - i;
		ll temp = (f_sum[l - 1] + f_sum[r - 1] + fact[n]) % mod;
		ans += (a[i] * temp);
		ans %= mod;
	}
	cout << ans << endl;
}

ll pwr(ll x, ll e) {
	ll res = 1;
	while (e) {
		if (e & 1) {
			res = (res * x) % mod;
		}
		x = (x * x) % mod;
		e /= 2;
	}
	return res;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main()
{
    int a,b;
  while(cin>>a>>b)
  {
    if(a%b==0)
        cout<<"0"<<endl;
    else
    {
        int c=a%b;
        if(c==1)
            cout<<c<<endl;
        else
        {
            while(c>1)
            {
                c--;
            }
            cout<<c<<endl;
        }
    }
  }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T,n;
ll a[205],g[65];
char s[205];

void insert(ll x){
	for(int i=60;i>=0;i--){
		if(x&(1ll<<i)){
			if(g[i]){x^=g[i];continue;}
			g[i]=x;break;
		}
	}
}

int check(ll x){
	for(int i=60;i>=0;i--){
		if(x&(1ll<<i)){
			if(g[i]){x^=g[i];continue;}
			return 1;
		}
	}
	return 0;
}

int main(){
	scanf("%d",&T);
	while(T--){
		memset(g,0,sizeof(g));
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		scanf("%s",s+1);
		int flag=1;
		for(int i=n;i>=1;i--){
			if(s[i]=='0') insert(a[i]);
			else if(check(a[i])){flag=0;break;}
		}
		if(flag) puts("0");else puts("1");
	}

	return 0;
}

Measured memory_bytes: 3652
N, M = map(int, input().split())
A = list(map(int, input().split()))

total = sum(A)

noselect = 0
for i in range(N):
    if A[i] < total / (4*M):
        noselect += 1

if N - noselect >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型

int H, W;
vector<string> town;

const int dh[2] = {1, 0};
const int dw[2] = {0, 1};

bool check(int h, int w)
{
    return h >= 0 && h < H && w >= 0 && w < W;
}

int main()
{
    cin >> H >> W;
    town.resize(H);
    rep(i, H)
    {
        cin >> town[i];
    }

    vector<vector<bool>> seen(H, vector<bool>(W, false));
    queue<pair<int, int>> next_visit;
    queue<pair<int, int>> crash_point;
    next_visit.push(make_pair(0, 0));
    seen[0][0] = true;
    int ans = 0;
    if (town[0][0] == '#' && town[1][0] == '.' && town[0][1] == '.')
    {
        ans++;
    }
    // bool lflag = false;

    bool break_flag = false;

    const char moji[2] = {'.', '#'};
    int ima = 1;
    int tugi = 0;
    // rep(i, 2)
    while (!break_flag)
    {
        if (ima == 0)
        {
            ans++;
        }
        while (!next_visit.empty())
        {
            pair<int, int> cur_pos = next_visit.front();
            int h = cur_pos.first;
            int w = cur_pos.second;

            next_visit.pop();

            rep(dir, 2)
            {

                int next_h = h + dh[dir];
                int next_w = w + dw[dir];
                if (!check(next_h, next_w))
                {
                    continue;
                }

                if (seen[next_h][next_w] == true)
                    continue;
                seen[next_h][next_w] = true;

                if (next_h == H - 1 && next_w == W - 1)
                {
                    break_flag = true;
                    if (town[H - 1][W - 1] == moji[1] && ima == 1)
                    {
                        ans++;
                    }
                    cout << ans << endl;
                    return 0;
                }
                if (town[next_h][next_w] == moji[ima])
                {
                    crash_point.push(make_pair(next_h, next_w));
                }
                else
                {
                    next_visit.push(make_pair(next_h, next_w));
                }
            }
        }
        swap(ima, tugi);
        swap(next_visit, crash_point);
    }

    // rep(h, H)
    // {
    //     rep(w, W)
    //     {
    //         cout << seen[h][w];
    //     }
    //     cout << endl;
    // }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
b=[]
c=[0 for x in range(n)]
for i in range(n):
    a.append([int(x) for x in input().split()])
for i in range(m):
    b.append(int(input()))
for i in range(n):
    for y in range(m):
        c[i]+=a[i][y]*b[y]
for x in c:
    print(x)


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

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

  if ((int)n.find("7") == -1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <sstream>
#include <cassert>
#include <functional>
#include <cfloat>
#include <climits>
#include <cstring>
#include <stack>
#include <time.h>
#include <complex>
using namespace std;
int main()
{
    int A,B;
    string S;
    cin>>A>>B>>S;
    for (int i=0;i<A+B+1;i++){
		if(i<A){
			if(!('0'<=S[i]&&S[i]<='9')){
				cout<<"No";
				return 0;
			}
		}
		if(i==A){
			if(S[i]!='-'){
				cout<<"No";
				return 0;
			}
		}
		if(i>A)
			if(!('0'<=S[i]&&S[i]<='9')){
				cout<<"No";
				return 0;
			}
	}
	cout<<"Yes";
}

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

int H, W, N;
pair<int, int> bar[200010];
int g[200010], h[200010];

int f(int x, int y) {
    if (y == 0) {
        return x;
    } else if (y >= 2 * W) {
        return f(x, y % (2 * W));
    } else if (x % 2 != y % 2) {
        if (x == W - 1) return f(x, y - 1);
        else return f(x + min(W - 1 - x, y), y - min(W - 1 - x, y));
    } else {
        if (x == 0) return f(x, y - 1);
        else return f(x - min(x, y), y - min(x, y));
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> H >> W >> N;
    for (int i = 0; i < N; i++) {
        cin >> bar[i].first >> bar[i].second;
        --bar[i].first;
        --bar[i].second;
    }
    sort(bar, bar + N);
    iota(g, g + W, 0);
    for (int i = 0; i < W; i++) {
        h[f(i, H)] = i;
    }
    for (int i = N - 1; i >= 0; i--) {
        int y, x;
        tie(y, x) = bar[i];
        int a = f(x, y);
        int b = f(x + 1, y);
        swap(h[a], h[b]);
    }
    for (int i = 0; i < W; i++) {
        cout << h[i] + 1 << '\n';
    }
}

Measured memory_bytes: 6308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int a = fr.nextInt();
		int b = fr.nextInt();
		int c = fr.nextInt();
		long temp = 0;
		boolean found = false;
		while (temp < 10000) {
			if ((a*temp) % b == c%b) {
				System.out.println("YES");
				found = true;
				break;
			}
			temp++;
		}
		if (!found) {
			System.out.println("NO");
		}
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 25228
N = int(input())
rela = [[0] * N for i in range(N)]
for i in range(N):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        x -= 1
        if y == 1:
            rela[i][x] = 1
        else:
            rela[i][x] = -1  
def kensyou(person):
    for i in range(N):
        for j in range(N):
            if person[i] == 1:
                if rela[i][j] == 1:
                    if person[j] == -1:
                        return 0
                elif rela[i][j] == -1:
                    if person[j] == 1:
                        return 0
    return 1
ans = 0
for i in range(2 ** N):
    person = []
    for j in range(N):
        if ((i >> j) & 1):
            person.append(1)
        else:
            person.append(-1)
    #print(kensyou(person))
    if kensyou(person):
        ans = max(ans, person.count(1))
print(ans)


Measured memory_bytes: 3064
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
// #define mod  11092019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

int main(){
	fastio;
	ll a; read(a);
	cout<<(a)*(1 + a + sqr(a))<<"\n";
	return 0;
}

Measured memory_bytes: 3604
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    string s;
    cin>>s;
    ll n=s.size();
    if(s[s.size()-1]=='1'){cout<<-1<<endl; return 0;}
    s.pop_back();
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[s.size()-1-i]){cout<<-1<<endl; return 0;}
    }
    if(s[0]=='0'){cout<<-1<<endl; return 0;}
    if(n%2==1){
        vector<ll> ret(n/2);
        for(int i=0;i<n/2;i++){
            if(s[i]=='1'){ret[i]=i+1;}
            else{
                ll l=i;
                while(s[i]=='0' && i<n/2){i++;}
                for(ll t=l-1;t<i;t++){
                    ret[t]=i;
                }
                i--;
            }
        }
        for(int i=0;i<n/2;i++){
            cout<<i+1<<" "<<ret[i]+1<<endl;
            cout<<n-i<<" "<<n-ret[i]<<endl;
        }
    }
    else{
        if(s[n/2-1]=='1'){
            cout<<n/2<<" "<<n/2+1<<endl;
            vector<ll> ret(n/2-1);
            for(int i=0;i<n/2-1;i++){
                if(s[i]=='1'){ret[i]=i+1;}
                else{
                    ll l=i;
                    while(s[i]=='0' && i<n/2-1){i++;}
                    for(ll t=l-1;t<i;t++){
                        ret[t]=i;
                    }
                    i--;
                }
            }
            for(int i=0;i<n/2-1;i++){
                cout<<i+1<<" "<<ret[i]+1<<endl;
                cout<<n-i<<" "<<n-ret[i]<<endl;
            }
        }
        else{
            cout<<n<<" "<<n/2<<endl;
            n--;
            vector<ll> ret(n/2);
            for(int i=0;i<n/2;i++){
                if(s[i]=='1'){ret[i]=i+1;}
                else{
                    ll l=i;
                    while(s[i]=='0' && i<n/2){i++;}
                    for(ll t=l-1;t<i;t++){
                        ret[t]=i;
                    }
                    i--;
                }
            }
            for(int i=0;i<n/2;i++){
                cout<<i+1<<" "<<ret[i]+1<<endl;
                cout<<n-i<<" "<<n-ret[i]<<endl;
            }
        }
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 2048
#include <cstdio>  
#include <algorithm>
using namespace std;  
int main() { 	
	int a,b,c;
	int d;
	scanf("%d %d %d", &a, &b, &c);
	if(a>=b && a>=c){
		d=a*10;
		d+=b;
		d+=c;
		printf("%d", d);
	}
	else if(b>=a && b>=c){
		d=b*10;
		d+=a;
		d+=c;
		printf("%d", d);
	}
	else if(c>=a && c>=b){
		d=c*10;
		d+=a;
		d+=b;
		printf("%d", d);
	}
	

	
	
}






Measured memory_bytes: 128
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    long long N, A, B;
    cin >> N >> A >> B;

    long long count = N / (A + B);
    long long amari = N % (A + B);

    long long blue_num = count * A;
    if (amari <= A)
    {
        blue_num += amari;
    }
    else
    {
        blue_num += A;
    }
    

    // 結果出力
    printf("%lld\n", blue_num);
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n<600&&n>=400){
		printf("8");
	}
	if(n<800&&n>=600){
		printf("7");
	}
	if(n<1000&&n>=800){
		printf("6");
	}
	if(n<1200&&n>=1000){
		printf("5");
	}
	if(n<1400&&n>=1200){
		printf("4");
	}
	if(n<1600&&n>=1400){
		printf("3");
	}
	if(n<1800&&n>=1600){
		printf("2");
	}
	if(n<2000&&n>=1800){
		printf("1");
	}
} 


Measured memory_bytes: 3684
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	vll A;
	ll N;
	cin>>N;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	int ans=0;
	for(int i=0;i<N;i++)
		ans+=A[i]-1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
//O(N^3)くらいで最悪のパターンでTLEじゃ...
int main(){

    ll N;
    cin >> N;

    vector<vector<ll > > vec(N, vector<ll >(N - 1, 0));

    //どこまで確認したか
    vector<ll > p(N, 0);  
    //p更新用のキュー  
    queue<ll > p_que;
    //前日試合をした人を格納するキュー 初日は全員該当
    queue<ll > yesterday_que;
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N - 1; j++){
            ll in;
            cin >> in;
            vec[i][j] = in - 1;
        }
        yesterday_que.push(i);
    }

    ll ans = 0;
    
    //最大回数試合をさせて残っている選手がいれば-1する方針
    ll day = 0;
    bool fin_flg = false;
    while(day <= N * (N - 1) / 2){
        //cout << "day" << day + 1 << " size" << yesterday_que.size() << endl;
        ll loop = yesterday_que.size();
        fin_flg = false;

        for(ll j = 0; j < loop; j++){
            
            ll i = yesterday_que.front();
            yesterday_que.pop();

            //cout << i << endl;
            //cout << "1" << endl;
            if(p[i] >= N - 1) continue;
            //cout << "1" << endl;
            if(vec[i][p[i]] == -1){
                //cout << vec[i][p[i]] << endl;
                //p[i]++;
                continue;
            } 
            //cout << "1" << endl;
            //cout << i + 1 << " " << p[i] << endl;
            //cout <<  vec[vec[i][p[i]]][p[vec[i][p[i]]]] << endl;

            if(i == vec[vec[i][p[i]]][p[vec[i][p[i]]]] ){
                //cout << i + 1 << " " << vec[i][p[i]] + 1 << " " << p[i] << endl;
                //cout << "yes" << endl;
                //p[vec[i][p[i]]]++;
                
                //更新準備
                p_que.push(i);
                p_que.push(vec[i][p[i]]);
                //前日試合したリストに追加
                yesterday_que.push(i);
                yesterday_que.push(vec[i][p[i]]);

                //不要なので-1格納
                vec[vec[i][p[i]]][p[vec[i][p[i]]]] = -1;
                vec[i][p[i]] = -1;
                
                //試合したのでフラグ更新
                fin_flg = true;
            }

            ans++;

        }
        
        //各人どこまで試合をしたか更新
        while(!p_que.empty()){
            p[p_que.front()]++;
            p_que.pop();
        }


        //確認
        
        /* 
        for(ll j = 0; j < N; j++){
            for(ll k = 0; k < N - 1; k++){
                cout << vec[j][k] << " ";
            }
            cout << p[j] <<  endl;
        }
        */
        
        //連日試合が開催されていなければ終わり
        if(fin_flg == false){
            break;
        }
        

        day++;
        //cout << "day : " << day << endl;
    }

    //全試合終わっているか?

    for(ll k = 0; k < N; k++){
       if(p[k] != N - 1){
           cout << "-1" << endl;
           return 0;
       }
    }
    cout << day << endl;

}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

map<int, int> fr;

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n){
		int t;
		scanf("%d", &t);
		++fr[t];
	}
	int m;
	scanf("%d", &m);
	f(i, 0, m){
		int t;
		scanf("%d", &t);
		if (--fr[t] == -1) { printf("NO\n"); return 0; }
	}
	printf("YES\n");
}

Measured memory_bytes: 9600
#include <iostream> 
    #include <algorithm> 
    #include <cstring> 
    #include <cstdio>
    #include <vector> 
    #include <queue> 
    #include <cstdlib> 
    #include <iomanip>
    #include <cmath>
    #include <cassert>
    #include <ctime> 
    #include <map> 
    #include <set> 
    using namespace std; 
    #define lowbit(x) (x&(-x)) 
    #define max(x,y) (x>y?x:y) 
    #define min(x,y) (x<y?x:y) 
    #define MAX 100000000000000000 
    #define MOD 1000000007
    #define pi acos(-1.0) 
    #define ei exp(1) 
    #define PI 3.141592653589793238462
    #define ios() ios::sync_with_stdio(false)
    #define INF 1044266558
    #define mem(a) (memset(a,0,sizeof(a)))
    typedef long long ll;
    ll n,front,last;
    ll gcd(ll x,ll y)
    {
        return y==0?x:gcd(y,x%y);
    }
    ll lcm(ll x,ll y)
    {
        return x/gcd(x,y)*y;
    }
    int main()
    {
        while(scanf("%lld",&n)!=EOF)
        {
            scanf("%lld",&front);
            for(int i=1;i<n;i++)
            {
                scanf("%lld",&last);
                front=lcm(front,last);
            }
            printf("%lld\n",front);
        }
        return 0;
    }

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> H >> W >> L >> R;
	cout << (H - L)*(W - R) << endl;
	return 0;
}

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

int f(int x){
	return x*x;
}

int main(){
	int d,s;
	
	while(cin>>d){
		s=0;
		for(int i=0;i<600/d;i++){
			s+=d*f(d*i);
		}	
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include <iomanip>

using namespace std;



int main() {

	int64_t N, K;
	cin >> N >> K;

	vector<int64_t> H(N);
	for (int64_t i = 0; i < N; i++) {
		cin >> H[i];

	}

	sort(H.begin(), H.end());
	int64_t attack = 0;
	for (int64_t i = 0; i < N - K; i++) {
		attack += H[i];
	}

	cout << attack;
	return 0;
}

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

using namespace std;

int main()
{
  int a, b; cin >> a >> b;
  if(a+b == 3)
    cout << 3 << endl;
  else if(a+b == 4)
    cout << 2 << endl;
  else if(a+b == 5)
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

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

vector<i64> strongly_connected_components(const vector<vector<i64>>& g) {
  i64 n = g.size();
  vector<vector<i64>> rg(n);
  for(int i = 0;i < n;i++) {
    for(auto j: g[i]) {
      rg[j].push_back(i);
    }
  }

  vector<bool> vis(n,false);
  vector<i64> vs;
  vector<i64> res(n,-1);
  function<void(int)> dfs = [&](int v) {
    vis[v] = true;
    for(auto& t : g[v]) {
      if(!vis[t]) dfs(t);
    }
    vs.push_back(v);
  };

  function<void(int,int)> rdfs = [&](int v,int k) {
    vis[v] = true;
    res[v] = k;
    for(auto to : rg[v]) {
      if(!vis[to]) rdfs(to,k);
    }
  };

  for(int i = 0;i < n;i++) {
    if(!vis[i]) dfs(i);
  }

  vis.assign(n,false);
  int k = 0;
  for(int i = n - 1;i >= 0;i--) {
    if(!vis[vs[i]]) rdfs(vs[i] , k++);
  }
  return res;
}

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<vector<i64>> G(N);
  rep(i,0,M) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
  }
  auto res = strongly_connected_components(G);

  rep(i,0,N) {
    vector<i64> vec;
    rep(j,0,N) {
      if(res[i] == res[j]) vec.push_back(j);
    }
    rep(j,0,vec.size()) {
      cout << vec[j] + 1 << " \n"[j + 1 == vec.size()];
    }
  }
}



Measured memory_bytes: 5692
<>=~/ (.*) /,$
$`{$1}=$$1{$`}=$' for 2..<>;@s=<>=~$"*$';map{$d[$_]or$d[$_]=$d[$u]+$$u{$_},push@s,$_}keys%{$u=$_}for@s;//,print$d[$`]+$d[$'],$/for<>

Measured memory_bytes: 125824
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()
	M := map[int]int{}
	o := 0
	for i := 0; i < N; i++ {
		a := sc.i()
		o += a
		M[a]++
	}
	Q := sc.i()
	for i := 0; i < Q; i++ {
		b := sc.i()
		c := sc.i()
		o += (c - b) * M[b]
		M[c] += M[b]
		delete(M, b)
		fmt.Println(o)
	}

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int l = s.length();
    int ans = 999;
    for (int i = 0; i < l - 2; i++) {
        if (ans > abs(753 - stoi(s.substr(i, 3)))) {
            ans = abs(753 - stoi(s.substr(i, 3)));
        }
    }   
    cout << ans;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split( )))
tmp = 0
ans = 0
for i in range(n):
    if p[i]==i+1:
        tmp+=1
    else:
        if tmp:
            ans += (tmp+1)//2
        tmp = 0

ans += (tmp+1)//2
print(ans)

Measured memory_bytes: 52908
long a[3][1<<18],b,c,x,y,N[1<<18],M[1<<18],i,j;main(n){scanf("%d",&n);for(i=0;i<3;++i)for(j=0;j<n;++j){scanf("%d",&a[i][j]);--a[i][j];}for(i=0;i<n;++i){if(a[0][i]/3!=a[1][i]/3||a[1][i]/3!=a[2][i]/3||a[2][i]/3!=a[0][i]/3||a[1][i]%3!=1||(a[1][i]/3-i)%2){puts("No");return 0;}x=a[1][i]/3+1;while(x){if(i&1)c-=M[x];else b-=N[x];x-=x&-x;}if(i&1)c+=i/2;else b+=i/2;y=a[2][i]/3+1;while(y<1<<18){if(i&1)++M[y];else++N[y];y+=y&-y;}if(a[0][i]%3){if(i&1)++b;else++c;}}puts(b&1|c&1?"No":"Yes");}

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

const int A = 1000005;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(A);
    
    for (int i = 0; i < n; i++ ) {
        cin >> a[i];
        c[a[i]]++;
    }
    int pairwise = true;
    for (int i = 2; i < A; i++) {
        int cnt = 0;
        for (int j = i; j < A; j += i) {
            cnt += c[j];
        }
        if (cnt > 1) {
            pairwise = false;
        }
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    } else {
        int g = 0;
        for (int i = 0; i < n; i++) {
            g = gcd(g, a[i]);
            if (g == 1) {
                cout << "setwise coprime" << "\n";
                return 0;
            }
        }
    }
    cout << "not coprime" << "\n";
    return 0;
}

Measured memory_bytes: 11040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
	cin >> a >> b;
  int c = a + b;
  if ( ( a + b ) / 2 * 2 == c ) {
    cout << c / 2 << endl;
  }
    else cout << c / 2 + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define Author std::ios_base::sync_with_stdio(0);
#define ABHISHEK_SHARMA cout.tie(0);
#define IIIT_ALLAHABAD cin.tie(0);

int main(){
    //Booster
    Author
        ABHISHEK_SHARMA
        IIIT_ALLAHABAD
    //Driver Code here
    ll n, i, t, k, count=0;
    string s;
    cin>>s;
    for(i=0; i<s.length(); i++){
        if(s[i]=='1'){
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

main(){
  int n, m;
  int data[1000];
  while(cin >> n >> m){
    if(n==0 && m==0) break;
    for(int i=0;i<n;i++){
      cin >> data[i];
    }
    bool first=true;
    int ans=-1;
    int pos=0;
    for(int i=0;i<m;i++){
      int x;
      cin >> x;
      if(!first) continue;
      if(x+pos>=n-1 && first){
	first=false;
	ans=i+1;
      }
      pos+=x;
      pos+=data[pos];
      if(pos<0) pos=0;
      if(pos>=n-1 && first){
	first=false;
	ans=i+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 55;
int n;
int a[N];
int mi, mx, idx1, idx2;
ii ans[N * 2];
int k;

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] > 0) {
            if (a[i] > mx) {
                mx = a[i];
                idx1 = i;
            }
        } else if (a[i] < 0) {
            if (mi > a[i]) {
                mi = a[i];
                idx2 = i;
            }
        }
    }
    if (mx != 0 && mi != 0) {
        if (mx >= -mi) {
            // +mx
            for (int i = 1; i <= n; ++i) {
                a[i] += mx;
                ans[k++] = {idx1, i};
            }
        } else {
            // +mi
            for (int i = 1; i <= n; ++i) {
                a[i] += mi;
                ans[k++] = {idx2, i};
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (a[i] > 0) {
            for (int j = 2; j <= n; ++j) {
                if (a[j] < a[j - 1]) {
                    ans[k++] = {j - 1, j};
                    a[j] += a[j - 1];
                }
            }
            break;
        } else if (a[i] < 0) {
            for (int j = n; j > 1; --j) {
                if (a[j - 1] > a[j]) {
                    ans[k++] = {j, j - 1};
                    a[j - 1] += a[j];
                }
            }
            break;
        }
    }


    cout << k << endl;
    for (int i = 0; i < k; ++i) {
        cout << ans[i].first << ' ' << ans[i].second << endl;
    }

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

vector<pair<int, ll>> node[100001];
ll dist[100001];

void init(){
    rep(i, 100001) dist[i] = 0;
}

void dfs(int p, int s, ll acc){
    dist[s] = acc;
    rep(i, node[s].size()){
        int to = node[s][i].first;
        ll cost = node[s][i].second;
        if(to == p) continue;
        dfs(s, to, acc+cost);
    }
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    int N; cin >> N;
    rep(i, N-1){
        int a, b; ll c; cin >> a >> b >> c;
        node[a].push_back(make_pair(b, c));
        node[b].push_back(make_pair(a, c));
    }
    int Q, K; cin >> Q >> K;
    dfs(-1, K, 0);

    vector<ll> ans;
    rep(i, Q){
        int x, y; cin >> x >> y;
        ans.push_back(dist[x]+dist[y]);
    }
    rep(i, Q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 16760
#include <iostream>
using namespace std;
using ll = long long;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define fromto(i,a,b) for(int i=(a);i<=(b);++i)

const int INF = 1e9;

string N; int n;
int memo[101][3][2];
int dfs(int keta, int rest, bool lower) {
  // あとrest個数字を選べて、残りketa桁決めれるときの場合の数
  if (memo[keta][rest][lower] != INF)
    return memo[keta][rest][lower];
  if (keta == n)
    return rest > 0 ? 0 : 1;

  if (lower) {
    if (rest == 0)
      return memo[keta][rest][lower] = dfs(keta+1, rest, lower);
    return memo[keta][rest][lower] = 9 * dfs(keta+1, rest-1, lower) + dfs(keta+1, rest, lower);
  }

  // まだ未確定
  int D = N[keta] - '0';
  int ans = dfs(keta+1, rest, (D > 0));

  if (rest >= 1)
    fromto(i, 1, D)
      ans += dfs(keta+1, rest-1, (i < D));
  return memo[keta][rest][lower] = ans;
}

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

  n = N.size();

  rep(i, n+1) rep(j, 3) {
    memo[i][j][0] = memo[i][j][1] = INF;
  }
  // まず、Nより桁数が小さい場合をカウントしたい。
  ll ans = 0;
  rep(i, 1, n) {
    if (i < K) continue;
    ll tmp = 1;
    rep(j, K) tmp *= 9;
    if (K == 2) tmp *= (i-1);
    if (K == 3) tmp *= (i-1) * (i-2) / 2;
    ans += tmp;
  }
  ans += ((N[0]-'0')-1) * dfs(1, K-1, true);
  ans += dfs(1, K-1, false);

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


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

using namespace std;

int main()
{
    int n;
    int h[10010] = {};
    int ans = 0;
    bool flg = true;

    cin >> n;

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

    ans++;

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (h[j] > h[i]) {
                flg = 0;
            }
        }
        if (flg && h[i-1] <= h[i]) {
            ans++;
        }
        flg = true;
    }

    cout << ans << endl;
}


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

//#define int long long

using namespace std;

int a[100001];

int main () {
	string s;
	cin >> s;
	bool n = 0, w = 0, S = 0, e = 0;
	for (int i = 0;i < s.size ();i ++) {
		if (s[i] == 'N') n = 1;
		if (s[i] == 'W') w = 1;
		if (s[i] == 'E') e = 1;
		if (s[i] == 'S') S = 1;
	}
	if (e == w && S == n) cout << "Yes";
	else cout << "No";
    return 0;
}

Measured memory_bytes: 256
N = input()
suma = 0
for i in N:
    suma += int(i)
if N[0] == '1':
    c = False
    for i in range(9):
        if str(i) in N[1:]:
            c = True
    if c:
        print(9*(len(N)-1))
    else:
        print(9*(len(N)-1)+1)
else:
    c = False
    for i in range(9):
        if str(i) in N[1:]:
            c = True
    if c:
        print(9*(len(N)-1) + (int(N[0])-1))
    else:
        print(9*(len(N)-1) + int(N[0]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define endl '\n'
using namespace std;
const int N=3000;
ll a[N];
ll b[N];
int32_t main(){
    ll n,x;
    cin >> n >> x;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        b[i]=a[i];
    }
    ll ans=(ll)1e18+100;
    for (int i=0;i<=n;i++){
        ll cnt=i*x;
        for (int j=1;j<=n;j++){
            cnt+=b[j];
        }
        ans=min(ans,cnt);
        for (int j=1;j<=n;j++){
            ll z=j-i-1;
            z+=n;
            z%=n;
            if (z==0) z=n;
            b[j]=min(b[j],a[z]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	map<int, int> mp;
	bool ok[N]{};
	int a;
	string b;
	int numAC{}, numWA{}, tmp[N]{};
	rep(i,M){
		cin >> a >> b;
		--a;
		if(ok[a]) continue;
		if(b == "AC"){
			numWA += tmp[a];
			ok[a] = true;
			numAC++;
		}
		else{
			tmp[a]++;
		}
	}
	cout << numAC << ' ' << numWA << endl;
}

Measured memory_bytes: 1152
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007
now_colors = [-1, -1, -1]  # 赤色, 青色, 緑色
ans = 1
for i in range(N):
    candidate_count = 0
    flag = [False]*3
    for j in range(3):
        if A[i]-1 == now_colors[j]:
            candidate_count += 1
            flag[j] = True
    for k in range(3):
        if flag[k]:
            now_colors[k] += 1
            break
    ans *= candidate_count % mod
print(ans % mod)


Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int n;
   cin>>n;
   int a[n];
   unordered_map<int,int> m;
   for(int i=0;i<n;i++){
    cin>>a[i];
   }
   int allgcd=a[0];
   for(int i=1;i<n;i++){
    allgcd=__gcd(a[i],allgcd);
   }
   const int N=1000001;
   vector<char> is_prime(N+1, true);
   is_prime[0] = is_prime[1] = false;
   for (int i = 2; i <= N; i++) {
    if (is_prime[i] && (long long)i * i <= N) {
        for (int j = i * i; j <= N; j += i)
            is_prime[j] = false;
    }
   }
   vector<int> c;
   for(int i=0;i<=N/2;i++){
       if(is_prime[i]){
           c.emplace_back(i);
       }
   }
  int g=1;
   for(int i=0;i<n;i++){
       int l=a[i];
       if(is_prime[l]){
           m[l]++;
           if(m[l]>1){
           	 g=0;
           	 i=n;
           }
       }else{
      for(int j=0;j<(int)c.size();j++){
          if(is_prime[l]){
              m[l]++;
              if(m[l]>1){
              	g=0;
              	i=n;
              }
              break;
          }
        if(l%c[j]==0){
          m[c[j]]++;
          if(m[c[j]]>1){
          	g=0;
          	i=n;
          	break;
          }
          while(l%c[j]==0){
               l=l/c[j];
          }
        }
        if(l<c[j]){
            break;
        }
      }
       }
   }
   
   if(g){
    cout<<"pairwise coprime"<<"\n";
    return 0;
   }
   if(allgcd==1){
      cout<<"setwise coprime"<<"\n";
      return 0;
   }
   cout<<"not coprime"<<"\n";
   return 0;


   
}


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



#define all(c) (c).begin(),(c).end()
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define mod 1000000007

int main(){
  int n;
  cin >> n;
  if(n ==1) cout << "Hello World" << endl;
  else{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

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

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

  string s;
  cin >> s;
  vector<string> t = {"dream", "dreamer", "erase", "eraser"};
  int l = s.size();
  while (!s.empty()) {
    bool flag = false;
    for (string &x : t) {
      if (s.size() < x.size()) continue;
      if (s.substr(s.size()-x.size(), x.size()) == x) {
        s.erase(s.size()-x.size(), x.size());
        flag = true;
      }
    }
    if (!flag) {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define M 1111111
int sosu[M];

int main(){
	
	while(1){
		int a;
		cin>>a;
		if(a==0)break;
		
		int b[1111]={0};
		
		rep(i,a){
			int c;
			cin>>c;
			b[c]++;
		}
		
		int ans = 0;
		int st = -1;
		int en = 0;
		rep(i,1111){
			if(b[i]!=0){
				if(st==-1)st=i;
				en = i;
				ans += i*b[i];
			}
		}
		
		ans -= st+en;
		printf("%d\n",ans/(a-2));
	}
}

Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int sum=0;
            for(int i=0;i<n/4;i++) {
                sum+=sc.nextInt();
            }
            System.out.println(sum);
        }
    }
}


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

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

    int N, K;
    cin >> N >> K;
    int ans = 0;
    rep(i, N){
        int x;
        cin >> x;
        ans += min(x, K-x)*2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    cin >> n;
    int a[n];
    int x = 0;
    rep(i,n) {
        cin >> a[i];
        x ^= a[i];
    }
    rep(i,n) {
        cout << (int)(x ^ a[i]);
        if (i < n-1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4412
#include <iostream>
#include<cstdio>
#include<string>
#include<stdio.h>
using namespace std;

int main() {

	string str;
	getline(cin, str);
	for (int i = 0; i<str.size(); i++) {
		if (str[i] >= 'a'&&str[i] <= 'z') str[i] += 'A' - 'a';
		else if (str[i] >= 'A'&&str[i] <= 'Z') str[i] += 'a' - 'A';
	}
	cout << str << endl;

	return 0;
}




Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <string>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main()
{
	int debt = 100000, n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		debt *= 1.05;
		debt += (debt % 1000) ? 1000 : 0;
		debt -= debt % 1000;
	}
	cout << debt << endl;
	return 0;
}

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

int main() {
  int N,ans=1;
  cin >> N;
  vector<string>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<N-1; i++){
    if(vec[i] != vec[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9580
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H * W - (((h * W) + (w * H)) - (h * w))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string s;
    std::cin >> s;

    if (s[0] == s[2]) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256