akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> k(M,0);
    vector<vector<int>> s(M, vector<int>(10));
    vector<int> p(M,0);
    rep(i, M){
        cin >> k.at(i);
        rep(j, k.at(i)){
            int num;
            cin >> num;
            s.at(i).at(j) = num;
        }
    }
    rep(i, M) cin >> p.at(i);

    //ビット全探索して条件を満たすものを調べる
    int ans = 0;
    for(int bit = 0; bit < (1 << N); bit++){
        bitset<10> bits(bit);
        bool flag = true;
        rep(i, M){//各電球が光るかどうか
            int checkNum = k.at(i);
            int lightedNum = 0;
            rep(j, checkNum){
                if(bits.test(s.at(i).at(j) - 1)) lightedNum++;
            }
            if(lightedNum % 2 != p.at(i)) flag = false;
        }
        if(flag == true) ans++;
    }
    cout << ans << endl;

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int X[110], Y[110], H[110];
	cin >> N;
	rep(i, 0, N)
	{
		cin >> X[i] >> Y[i] >> H[i];
	}

	rep(i, 0, 101)rep(j, 0, 101)
	{
		bool flag = true;
		int h = -1;
		int hmax = 2e9;
		rep(k, 0, N)
		{
			if (H[k] > 0)
			{
				if (h != -1 && h != abs(i - Y[k]) + abs(j - X[k]) + H[k])
				{
					flag = false;
					break;
				}
				else
				{
					h = abs(i - Y[k]) + abs(j - X[k]) + H[k];
				}
			}
			else
			{
				hmax = min(hmax, abs(i - Y[k]) + abs(j - X[k]));
			}
		}

		if (flag&&h <= hmax)
		{
			cout << j << " " << i << " " << h << endl;
		}
	}

	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[3005][3005][5];
ll g[3005][3005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll r,c,k; cin>>r>>c>>k;
  rep(i,k){
    ll y,x,v; cin>>y>>x>>v; y--,x--;
    g[y][x]=v;
  }
  
  if(g[0][0]){
    dp[0][0][1]=g[0][0];
  }
  
  rep(i,r){
    rep(j,c){
      for(ll l=0; l<=3; l++){
        if(i>0){
          chmax(dp[i][j][0], dp[i-1][j][l]);
          chmax(dp[i][j][1], dp[i-1][j][l]+g[i][j]);
        }
        if(j>0){
          chmax(dp[i][j][l], dp[i][j-1][l]);
          chmax(dp[i][j][l+1], dp[i][j-1][l]+g[i][j]);
        }
      }
    }
  }
  
  ll ans=0;
  for(ll i=0; i<=3; i++) chmax(ans, dp[r-1][c-1][i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 426156
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
unsigned long long x[100];
int main(void){
    int n;
    cin>>n;
    x[0]=2;
    x[1]=1;
    for(int i=2;i<=n;i++){
        x[i]=x[i-1]+x[i-2];
    }
    cout<<x[n]<<endl;
}


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

int main() {
  int Hs, Ms, Hg, Mg, K;
  cin >> Hs >> Ms >> Hg >> Mg >> K;
  
  int S, G;
  S = 60 * Hs + Ms;
  G = 60 * Hg + Mg;
  
  cout << G - K - S << endl;
  
}

Measured memory_bytes: 3632
#include<cstdio>
using namespace std;
int main(){
    int n,ans=0;
    char a[101],b[101],c[101];
    scanf("%d",&n);
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&b[i]==c[i]&&a[i]==c[i]);
        else if(a[i]==b[i]||b[i]==c[i]||a[i]==c[i]){
            ans++;
        }
        else{
            ans+=2;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <list>
using namespace std;
static const int MAX = 200;

int main(void){
    int n,l,ans=0;
    cin >> n >> l;
    if(0<l){
        for(int i=1; i<n; i++){
            ans += l+i;
        }
        cout << ans;
    }
    else if(l<=0 && 0<=l+n-1){
        for(int i=0; i<n; i++){
            ans += l+i;
        }
        cout << ans;
    }
    else if(l+n-1<0){
        for(int i=0; i<n-1; i++){
            ans += l+i;
        }
        cout << ans;
    }
    return 0;
}

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

xl = []
tt = 10**9
for i in range(n):
    x,l = map(int, input().split())
    xl.append([x+l,x-l])
    tt = min(tt,x-l)

xl.sort()

ans = 0

for i in range(n):
  if tt <= xl[i][1]:
    ans += 1
    tt = xl[i][0]
print(ans)

Measured memory_bytes: 61144
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <math.h>

using namespace std;

int main()
{
    int N,t;
    int sum = 0;
    int result = 0;
    int resultf = 99999999;
    vector<int> X;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>t;
        sum+=t;
        X.push_back(t);
    }
    sum = sum / N;
    for(int j=sum-20;j<sum+20;j++){
        result = 0;
        for(int i=0;i<N;i++){
            result+=pow(X.at(i)-j,2);
        }
        resultf = min(resultf, result);
    }
    
    cout<<resultf;
}


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

using namespace std;

#define db(x) cerr << #x << " = " << x << endl;
#define ll long long

#define A 0
#define B 1
#define C 2

#define INF 0x3f3f3f3f

int n;
vector<int> height;

vector< vector<int> > dp;

vector< vector<int> > vis;

vector< vector<int> > matriz;

int solve(int i, int anterior)
{
    if(vis[i][anterior])
        return dp[i][anterior];

    if(i == n - 1)
    {
        dp[i][anterior] = 0;
        if(anterior != A)
            dp[i][anterior] = max(dp[i][anterior], matriz[i][A]);
        if(anterior != B)
            dp[i][anterior] = max(dp[i][anterior], matriz[i][B]);
        if(anterior != C)
            dp[i][anterior] = max(dp[i][anterior], matriz[i][C]);
        return dp[i][anterior];
    }

    vis[i][anterior] = 1;

    dp[i][anterior]  = 0;
    if(anterior != A)
        dp[i][anterior] = max(dp[i][anterior], solve(i + 1, A) + matriz[i][A]);

    if(anterior != B)
        dp[i][anterior] = max(dp[i][anterior], solve(i + 1, B) + matriz[i][B]);

    if(anterior != C)
        dp[i][anterior] = max(dp[i][anterior], solve(i + 1, C) + matriz[i][C]);

    return dp[i][anterior];
}

int main()
{
    scanf("%d", &n);

    dp  = vector< vector<int> >(n, vector<int>(3));
    vis = vector< vector<int> >(n, vector<int>(3));

    matriz = vector< vector<int> >(n, vector<int>(3));

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            int aux;
            scanf("%d", &aux);
            matriz[i][j] = aux;
        }
    }

    int maxi = solve(0, A);
    maxi = max(maxi, solve(0, B));
    maxi = max(maxi, solve(0, C));

    printf("%d", maxi);
}



Measured memory_bytes: 21376
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

int main(){
    ll a, b; cin >> a >> b; 
    prt(a*b);
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

long long int MOD=1000000007;

long long int gamma[100001];

long long int inv(long long int t){//逆元
	long long int t2[36];
	t2[0]=1;t2[1]=t;
	for(int i=2;i<36;i++){
		t2[i]=(t2[i-1]*t2[i-1])%MOD;
	}
	long long int ans=1;
	long long int s=MOD-2;
	int i=1;
	while(s>0){
		if(s%2==1){ans=(ans*t2[i])%MOD;}
		s=s/2;i++;
	}
  return ans;
}

long long int C(long long int a,long long int b){//combination
  if(a==b or b==0){return 1;}
	long long int ans=gamma[a];
	ans=(ans*inv(gamma[b]))%MOD;
	ans=(ans*inv(gamma[a-b]))%MOD;
	return ans;
}

long long int gcd(long long int a,long long int b){
	while(a!=b){
		if(b>a){swap(a,b);}
		a=a-b;
	}
	return a;
}
int aoki[100000];
int takahasi[100000];

int main(){
	int n,u,v;cin>>n>>u>>v;u--;v--;
	vector<int> tree[100000];
	for(int i=0;i<n-1;i++){
		int a,b;cin>>a>>b;
		tree[a-1].push_back(b-1);
		tree[b-1].push_back(a-1);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<tree[i].size();j++){
			//cout<<tree[i][j];
		}
		//cout<<endl;
	}
	int count=0;
	queue<int> temp;
	int s=0;
	for(int i=0;i<100000;i++){takahasi[i]=-1;aoki[i]=-1;}
	takahasi[u]=0;
	aoki[v]=0;
	temp.push(u);
	int hoge=10;
	while(count<n-1){
		s++;
		int u=temp.size();
		for(int i=0;i<u;i++){
			int g=temp.front();
			temp.pop();
			for(int j=0;j<tree[g].size();j++){
				if(takahasi[tree[g][j]]==-1){
					takahasi[tree[g][j]]=s;
					count++;
					temp.push(tree[g][j]);
					//cout<<g<<"->"<<tree[g][j]<<" ";
				}
				
			}
		}
		//cout<<"W"<<endl;
	}
	int x=temp.size();
	for(int i=0;i<x;i++){
		temp.pop();
	}
	temp.push(v);
	count=0;
	s=0;
while(count<n-1){
		s++;
		int u=temp.size();
		for(int i=0;i<u;i++){
			int g=temp.front();
			temp.pop();
			for(int j=0;j<tree[g].size();j++){
				if(aoki[tree[g][j]]==-1){
					aoki[tree[g][j]]=s;
					count++;
					temp.push(tree[g][j]);
					//cout<<g<<"->"<<tree[g][j]<<" ";
				}
				
			}
		}
		//cout<<"W"<<endl;
	}
	//cout<<endl;
	int ans=0;
	for(int i=0;i<n;i++){
		int t;
		if(takahasi[i]<aoki[i]){
			//if(takahasi[i]==aoki[i] and aoki[i]==1){ans=max(ans,1);}
			//if((aoki[i]-takahasi[i])%2==0){ans=max(ans,aoki[i]-1);}
			//else{ans=max(ans,aoki[i]);}
			ans=max(ans,aoki[i]-1);
		}
		//cout<<i<<":"<<takahasi[i]<<" "<<aoki[i]<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cstdint>
#include <cmath>
using namespace std;

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

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

    int expect[] = { -1, -1, -1 };
    while (m--) {
        int s, c; cin >> s >> c; --s;
        if (expect[s] != -1 && expect[s] != c) {
            cout << -1 << endl;
            return 0;
        }
        expect[s] = c;
    }

    if (n != 1 && expect[0] == 0) {
        cout << -1 << endl;
        return 0;
    }
    if (n != 1 && expect[0] == -1) {
        expect[0] = 1;
    }
    for (auto &e : expect) e = max(e, 0);

    int ans = 0;
    for (int i = n - 1; 0 <= i; --i) {
        ans += expect[i] * pow(10, n - 1 - i);
    }

    cout << ans << endl;
}



Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3, y3, x4, y4;

  int vx = (x2 - x1);
  int vy = (y2 - y1);

  x3 = x2 - vy;
  y3 = y2 + vx;
  x4 = x3 - vx;
  y4 = y3 - vy;

  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main() {
    fastIO;
    int n, rta = 0;
    cin >> n;
    int perm[n];
    for(int i = 0; i < n; i++){
        cin >> perm[i];
    }
    for(int i = 1; i < n-1; i++){
        vector<int> x;
        for(int j = i-1; j <= i+1; j++){
            x.pb(perm[j]);
        }
        sort(x.begin(), x.end());
        if(x[1] == perm[i]) rta++;
    }
    cout << rta << endl;
    return 0;
}



Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

from collections import Counter
def resolve():
    int(input())
    C=Counter(map(int,input().split()))
    C=[(k,v) for k,v in C.items()]
    C.sort(reverse=1)
    ans=0
    for k,v in C:
        if(v>=4):
            ans=k*k
            break

    a=0; b=0
    for i in range(len(C)):
        k,v=C[i]
        if(v>=2):
            a=k
            C[i]=(0,0)
            break

    for i in range(len(C)):
        k,v=C[i]
        if(v>=2):
            b=k
            C[i]=(0,0)
            break

    print(max(ans,a*b))
resolve()

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

int main(){
  int L;
  cin >> L;
  double a = L/3.0;
  printf("%.10f\n", a*a*a);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
/////////////////////////

int const N = 1e5 + 41;

int n, x[N], a, b;
ll ans;

void solve(){
	fi(1, n+1){
		scanf("%d",&x[i]);
	}
	fi(2, n + 1){
		ans += min(b * 1LL, (x[i] - x[i-1]) * 1LL * a);
	}
	printf("%lld\n",ans);
}

void read(){
	scanf("%d %d %d",&n,&a,&b);
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();


	return 0;
}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int K = scan.nextInt();

        if(K <= A) {
            os.println(K);
            return;
        }

        if(K <= A+B) {
            os.println(A);
            return;
        }

        os.println(2*A + B -K);

    }

}

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

int main() {
    string str, p, order;
    int a, b, q;
    cin >> str >> q;
    while (q--) {
        cin >> order;
        if (order == "print") {
            cin >> a >> b;
            for (int i = a; i <= b; ++i) {
                cout << str[i];
            }
            cout << endl;
        }
        if (order == "reverse") {
            cin >> a >> b;
            string str2 = str;
            for (int i = 0; i <= b - a; ++i) {
                str2[a + i] = str[b - i];
            }
            str = str2;
        }
        if (order == "replace") {
            cin >> a >> b >> p;
            for (int i = 0; i <= b - a; ++i) {
                str[a + i] = p[i];
            }
        }
    }
    
    return 0;
}


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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  int ans = 0;
  int a, b, c;
  cin >> a >> b >> c;

  ans = min(a + b, a + c);
  ans = min(ans, b + c);

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pb push_back
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static int f1[1 << 20];
    static int f2[1 << 20];
    static int f[1 << 20];
    static int sz[1 << 20];
    function < int(int) > get = [&](int k)
    {
        return f[k] == k ? k : f[k] = get(f[k]);
    };
    function < int(int) > get1 = [&](int k)
    {
        return f1[k] == k ? k : f1[k] = get1(f1[k]);
    };
    function < int(int) > get2 = [&](int k)
    {
        return f2[k] == k ? k : f2[k] = get2(f2[k]);
    };
    int n,m,k;
    fi>>n>>m>>k;
    for (int i = 1;i <= n;++i)
        f[i] = f1[i] = f2[i] = i;
    while (m --)
    {
        int a,b;
        fi>>a>>b;
        if (get1(a) < get1(b))
            swap(a,b);
        f1[get1(a)] = get1(b);
    }
    while (k --)
    {
        int a,b;
        fi>>a>>b;
        if (get2(a) < get2(b))
            swap(a,b);
        f2[get2(a)] = get2(b);
    }
    static vi s[1 << 20];
    for (int i = 1;i <= n;++i)
        s[get1(i)].pb(i);
    for (int i = 1;i <= n;++i)
    {
        map < int , int > M;
        for (auto it : s[i])
        {
            if (M.count(get2(it)))
                f[get(it)] = get(M[get2(it)]);
            M[get2(it)] = it;
        }
    }
    for (int i = 1;i <= n;++i)
        ++sz[get(i)];
    for (int i = 1;i <= n;++i)
        fo << sz[get(i)] << " \n"[i == n];
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}



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

int main() {
    int n, k, ans;
    cin >> n >> k;
    n--;
    k--;
    ans = (n + k - 1) / k;
    cout << ans << endl;
}

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

int main(){
	long long  d;
	while( cin >> d, d ){
		int n, m;
		cin >> n;
		cin >> m;
		vector<int> store(n+1), dist(m);
		store[0] = 0;
		for( int i = 1; i < n; i++ ) cin >> store[i];
		store[n] = d;
		for( int i = 0; i < m; i++ ) cin >> dist[i];

		sort( store.begin(), store.end() );

		long long sum = 0;
		for( int i = 0; i < m; i++ ){		// すべての宛先について
			/*** 二分探索 ***/
			int left = 0, right = n;
			while( 1 ){
				int next = (left + right) / 2;
				if( next == left || next == right ) break;
				if( dist[i] < store[next] ) right = next;
				else left = next;
			}
			/****************/
			sum += min(abs(store[left]-dist[i]), abs(store[right]-dist[i]));
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1532
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def dump(*objects):
    print(*objects, file=sys.stderr)


N = int(input())
A = [0] + list(map(int, input().split())) + [0]
dump(N, A)
B = cp.deepcopy(A)
C = cp.deepcopy(A)
for i in range(1, len(A)):
    dump(i)
    B[i] = B[i-1] + abs(A[i]-A[i-1])
for i in range(len(A)-2, -1, -1):
    dump(i)
    C[i] = C[i+1] + abs(A[i]-A[i+1])
dump(A, B, C)
for i in range(1, N+1):
    dump(i, B[i-1] + B[N+1] - B[i+1] + abs(A[i-1]-A[i+1]))
    print(B[i-1] + C[i+1] + abs(A[i-1]-A[i+1]))

exit(0)


Measured memory_bytes: 19652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#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; }
int N,ans=0,tmp=1;
string s[100000+10];

signed main(){
  cin >> N;
  rep(i,N){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    s[i]=S;
    //cout << s[i] << endl;
  }
  sort(s,s+N);
  //rep(i,N) cout << s[i] << endl;
  rep(i,N-1){
    if(s[i]==s[i+1]){
      tmp++;
    }
    else{
      for(int j=tmp-1;j>=1;j--) ans+=j;
      tmp=1;
    }
  }
  //cout << tmp << endl;
  for(int j=tmp-1;j>=1;j--) ans+=j;
  tmp=1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

void inputVector(int n, vector<char>& va) {
	for (int i = 0; i < n; i++) {
		char a;
		cin >> a;
		va.push_back(a);
	}
}
void inputMatrix(int h, int w, vector<vector<char>>& ma) {
	for (int i = 0; i < h; i++) {
		vector<char> va;
		inputVector(w, va);
		ma.push_back(va);
	}
}

void checkRow(int&h, int i, int w, vector<vector<char>>& ma) {
	for (int j = 0; j < w; j++) {
		if (ma.at(i).at(j) == '#') return;
	}
	ma.erase(ma.begin() + i);
	h--;
}

void checkColumn(int h, int& w, int j, vector<vector<char>>& ma) {
	for (int i = 0; i < h; i++) {
		if (ma.at(i).at(j) == '#') return;
	}
	for (int i = 0; i < h; i++) {
		ma.at(i).erase(ma.at(i).begin() + j);
	}
	w--;
}

void outputVector(int n, vector<char> va) {
	for (int i = 0; i < n; i++) {
		cout << va.at(i);
	}
	cout << "\n";
}

void outputMatrix(int h, int w, vector<vector<char>> ma) {
	for (int i = 0; i < h; i++) {
		outputVector(w, ma.at(i));
	}
}

int main(void)
{
	int h, w;
	cin >> h >> w;
	vector<vector<char>> ma;
	inputMatrix(h, w, ma);

	for (int i = h - 1; i >= 0; i--) {
		checkRow(h, i, w, ma);
	}
	for (int j = w - 1; j >= 0; j--) {
		checkColumn(h, w, j, ma);
	}

	outputMatrix(h, w, ma);
	return 0;
}

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


int main() {
    ll n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<n+1;i++){
        cin>>a[i];
        
    }
    set<int>s;
    int clk=1;
    int i=1,cycle=0;
    int p[n+1]={0},flag=0,loc=i;
    while(k>0&&flag!=1){
       loc=i;
         i=a[i];
       if(s.find(loc)==s.end()){
           s.insert(loc);
           p[loc]=clk;
       }
       else {
           flag=1;
           cycle=p[loc]-clk;
           
          
       }
       clk++;
       k--;
       
     
       
       
        
       
    }if(cycle!=0)
    k=k%cycle;
    if(k==0){
        cout<<a[loc];
        return 0;
    }
    int ans=loc;
    for(int j=0;j<k;j++){
        ans=a[ans];
        
    
    }
    cout<<a[ans];
    
    
	// your code goes here
	return 0;
}

Measured memory_bytes: 12592
#include <stdio.h>

int main(void)
{
	int t, n;
	int s, f;
	int i;
	int sum;
	while (1){
		scanf("%d", &t);
		if (t == 0){
			break;
		}
		scanf("%d", &n);
		sum = 0;
		for (i = 0; i < n; i++){
			scanf("%d %d", &s, &f);
			sum += f - s;
		}
		
		if (t <= sum){
			printf("OK\n");
		}
		else {
			printf("%d\n", t - sum);
		}
	}
	return (0);
}

Measured memory_bytes: 612
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int n;
    
    cin >> n;
    

    
    cout << n/3 << endl;
    
    
    
    
    
    
    
    
    

    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class176
    {
        static void Main()
        {
            long N = long.Parse(Console.ReadLine());
            var dic = new Dictionary<int, int>();//数個数
            //素数判定してディクショナリにまとめてみる
            // 2 * 3 _ 3 * 4 => 15?
            for(int i = 2; i <= N; i++)
            {
                int num = i;
                for(int j = 2; j <= Math.Sqrt(i)+1; j++)
                {
                    while (num % j == 0)
                    {
                        num /= j;
                        if (dic.ContainsKey(j)) dic[j]++;
                        else dic[j] = 1;
                    }
                }
                if (num != 1)
                {
                    if (dic.ContainsKey(num)) dic[num]++;
                    else dic[num] = 1;
                }
            }
            long ans = 1;
            foreach(long i in dic.Values)
            {
                ans *= (i + 1);
                ans %= 1000000007;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/
bool isprime(int v) {
    if (v == 1) return false;
    for (int i = 2; 1LL * i*i <= v; i++) if (v%i == 0) return false;
    return true;
}
/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll X;cin>>X;
    ll ans = X;

    while(!isprime(ans)){
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int a=in.nextInt();
			int b=in.nextInt();
			System.out.println(a*b/3.305785);
		}
	}
	
	static public void debug(Object... o)
	{
		System.err.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 17184
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll a[5],n,s=0;
    cin>>n;
    int i,mark,flag=0,m;
    for(i=0;i<5;i++)
        cin>>a[i];
    sort(a,a+5);
    if(n%a[0]!=0)
        s+=n/a[0]+1;
    else s+=n/a[0];
    s+=4;
    cout<<s<<endl;
    return 0;
}


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

main() {

  int i, j, t, y;

  while(1){
    
    cin >> t >> y; 
    if(t == 0 && y == 0){
      break;
    }else {
      for(i = 0; i < t; i++){
	for(j = 0; j < y; j++){
	  if(i % 2 == 0 && j % 2 == 0){
	    printf("#");
	  }else if(i % 2 == 0 && j % 2 != 0){
	    printf(".");
	  }else if(i % 2 != 0 && j % 2 == 0){
	    printf(".");
	  }else if(i % 2 != 0 && j % 2 != 0){
	    printf("#");
	  }
	}
	printf("\n");
      }
      printf("\n");
    }

  }

}

Measured memory_bytes: 1112
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


ll num[100005];
int main() {
	string S;
	cin >> S;
	ll moyoriR = 0, moyoriL = -1;
	rep(i, S.size()) {
		
		if (S[i] == 'R') 
			moyoriR = i;
		else {
			if ( (i - moyoriR) % 2 == 1)
				num[moyoriR + 1] += 1;
			else
				num[moyoriR] += 1;
		}
			
		
	}

	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'L')
			moyoriL = i;
		else {
			if ((moyoriL - i) % 2 == 1)
				num[moyoriL - 1] += 1;
			else
				num[moyoriL] += 1;
		}
			

	}

	rep(i, S.size()) {
		cout << num[i] << " ";

	}

	return 0;
}

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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

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

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

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 500 + 5;

char str[MAXN][MAXN], a[MAXN][MAXN], b[MAXN][MAXN];
bool ok[MAXN][MAXN];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  For(i, 1, n) {
    scanf("%s", str[i] + 1);
  }
  For(i, 1, n) {
    a[i][1] = b[i][m] = '#';
    b[i][1] = a[i][m] = '.';
  }
  For(i, 1, n) {
    FOR(j, 2, m) {
      if (i & 1) {
        a[i][j] = '#';
        b[i][j] = str[i][j] == '#' ? '#' : '.';
      } else {
        b[i][j] = '#';
        a[i][j] = str[i][j] == '#' ? '#' : '.';
      }
    }
  }
  For(i, 1, n) {
    puts(a[i] + 1);
  }
  puts("");
  For(i, 1, n) {
    puts(b[i] + 1);
  }
  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
int main(void){
    long long int a,b,x;
    scanf("%lld %lld %lld",&a,&b,&x);
    long long int r,l,ans;
    r=b/x;
    l=(a)/x;
    ans=r-l;
    if(a%x==0)ans++;
    printf("%lld\n",ans);
    return 0;
    }


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

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

int main() {
    int r, d, x20, ans = 0;
    cin >> r >> d >> x20;
    rep(i, 10) {
        if (i == 0)
            ans += r * x20 - d;
        else
            ans = r * ans - d;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"

int main() {

    std::string S;
    std::cin >> S;
    std::map<char, int> m;
    for (auto& v : S)++m[v];
    bool ans = m.size() == 2 && std::all_of(begin(m), end(m), [](auto p) {return p.second == 2; });
    std::cout << (ans ? "Yes" : "No") << std::endl;
}

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

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;

using namespace std;

template<typename T>
void dump(T *arr, int h, int w){
	rep(i,h){
		rep(j,w) cout << arr[i][j] << "\t";
		cout << "\n";
	}
}

template<typename T>
void dump(T *arr, int a){
	rep(i,a) cout << arr[i] << "\t";
	cout << "\n";
}

const int INF = 1e9;

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

	string s;
	cin >> s;

	int len = s.size();
	int pl=1, pr=1;
	int ps[len] = {};
	repi(i,2,len){
		if(s[i-1] == s[i] && s[i] == 'L'){
			ps[i] = pl;
			pl++;
		}else pl=1;
		if(s[len-i] == s[len-i-1] && s[len-i] == 'R'){
			ps[len-i-1] = pr;
			pr++;
		}else pr=1;
	}
	int times = 1e5;
	int ans[len] = {};
	rep(i,len){
		if(s[i] == 'L'){
			ans[i - ps[i] - (times-ps[i])%2]++;
		}else{
			ans[i + ps[i] + (times-ps[i])%2]++;
		}
	}
	rep(i,len){
		cout << ans[i] << " ";
	}
	cout << "\n";

	return 0;
}


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

typedef long long lli;

lli dp[9][101][1001];

int main(){
  int n,s;

  for(int i=0;i<9;i++) for(int j=0;j<101;j++) for(int k=0;k<1001;k++) dp[i][j][k] = 0;
  for(int i=0;i<=100;i++) dp[0][i][i] = 1;
  
  for(int i=0;i<8;i++){
    for(int j=0;j<100;j++){
      for(int k=0;k<1001;k++){
        if(dp[i][j][k] == 0) continue;
        for(int l=j+1;l<=100;l++){
          if(k + l > 1000) continue;
          dp[i+1][l][k+l] += dp[i][j][k];
        }
      }
    }
  }

  while(cin >> n >> s && (n|s)){
    lli ans = 0;
    for(int i=0;i<=100;i++) ans += dp[n-1][i][s];
    cout << ans << endl;
  }
}

Measured memory_bytes: 8264
var
    n,i,x,y: Integer;
    a: array[1..100] of Integer;

procedure qsort(l,r:Longint;data:PInteger);
var
    i,j,mid,t: Integer;
begin
    if l>=r then
    begin
        exit;
    end;
    i:=l;
    j:=r;
    mid:=data[(l+r) div 2];
    repeat
        while data[i]<mid do
        begin
            inc(i);
        end;
        while data[j]>mid do
        begin
            dec(j);
        end;
        if i<=j then
        begin
            t:=data[i];
            data[i]:=data[j];
            data[j]:=t;
            inc(i);
            dec(j);
        end;
    until i>j;
    qsort(l,j,data);
    qsort(i,r,data);
end;
begin
    readln(n);
    for i := 1 to n do
    begin
        read(a[i]);
    end;
    qsort(0,n-1,@a);
    x:=0;
    y:=0;
    i:=n;
    while i>0 do
    begin
        inc(x,a[i]);
        dec(i,2);
    end;
    i:=n-1;
    while i>0 do
    begin
        inc(y,a[i]);
        dec(i,2);
    end;
    writeln(x-y);
    readln;
    readln;
end.


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


int main(){
    string s;
    cin >> s;
    map<char, int> mp;
    
    string ans = "No";
    if (s[0]==s[1] && s[1]==s[2]) ans = "Yes";
    if (s[1]==s[2] && s[2]==s[3]) ans = "Yes";
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int h1, h2, m1, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int diff = (h2 * 60 + m2) - (h1 * 60 + m1);
  cout << max(0, diff - k) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, n);
  VEC(ll, a, n);
  for (int i = n - 1; i >= 0; i -= 2) {
    cout << a[i] << ' ';
  }
  for (int i = n % 2; i < n; i += 2) {
    cout << a[i] << ' ';
  }
}


Measured memory_bytes: 3712
fun main(args: Array<String>) {
    val K = readLine()!!.toInt()
    val (A, B) = readLine()!!.split(" ").map { it.toInt() }

    var result = false
    for (i in A.. B ) {
        if (i % K == 0)  { result = true }
    }
    
    if(result) {
        println("OK")
    }   else {
        println("NG")

    }
}

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

int main() {
  string s;
  cin >> s;
  
  if (s[0] == s[1] && s[1] == s[2] ||
     s[1] == s[2] && s[2] == s[3])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,s[100000],cnt;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        if(i%2==0)cnt+=s[i];
        else cnt-=s[i];
    }
    cout<<cnt<<" ";
    for(int i=0;i<n-1;i++){
        cnt=(s[i]-cnt/2)*2;
        cout<<cnt<<" ";
    }
    
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
    #define ll  long long int
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define vi vector<int>
    #define br cout <<"\n";
    #define all(x)  (x).begin(),(x).end()
    #define tr(c,i) for(auto i : c)
    #define pii pair< int,int >
    #define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
    #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
    #define er(x) cout << x << " "
    #define err(x,y) cout << x << " "<<y
    const int M = 200005;
    using namespace std;
    clock_t time_p=clock();
    void dem()
    {
        time_p=clock()-time_p;
        cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
    }
    using namespace std ;
    const int N =  50  ;
    const int dx[] = { 1, -1 , 0 , 0  };
    const int dy [] = { 0 ,0 , 1 , -1  };

    int main (){
    int n ,m ;
    cin >> n >>m ;
    vector<int> v ( n ) ;
    for ( int &x : v) cin >> x ;
    priority_queue<int> q ;

    for (auto i : v) q.push( i  ) ;
    while ( m--){
        int  val = q.top();
        q.pop();
        val = val / 2 ;
        q.push(val) ;
    }
    ll sum = 0 ;

 while ( !q.empty() && q.top() != 0 ){
    sum += q.top();
    q.pop();

 }

    cout << sum ;

    return 0 ;

    }




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

template <typename T> using V = vector<T>;
using PII = pair<int, int>;
using TII = tuple<int, int, int>;
using TIII = tuple<int, int, int, int>;
template <typename T> using PQ = priority_queue<T, V<T>, greater<T>>;
template <typename T> void chmin(T &t, const T &val) { t = min(t, val); }

int N, M, H, K;
int S, T;
const int inf = 1e9;

int calc_node_idx(int n, int h) { return n * (H + 1) + h; }

V<int> calc_dist(const V<V<TIII>> &edges, int frees) {
    auto cost = V<int>(N * (H + 1), inf);
    for(int h = 0; h <= H; h++) cost[calc_node_idx(S, h)] = 0;
    
    priority_queue<PII, V<PII>, greater<PII>> pq;
    pq.emplace(0, calc_node_idx(S, 0));
    
    while(pq.size()) {
        int now_cost, now;
        tie(now_cost, now) = pq.top();
        pq.pop();
        if(cost[now] < now_cost) continue;
        int now_idx = now / (H + 1), now_time = now % (H + 1);
        for(const auto &ele : edges[now_idx]) {
            int nxt, c, h, r;
            tie(nxt, c, h, r) = ele;
            int nxt_time = now_time + h;
            if(nxt_time > H) continue;
            int nxt_cost = now_cost + (frees & (1 << r) ? 0 : c);
            int nxt_idx = calc_node_idx(nxt, nxt_time);
            if(cost[nxt_idx] <= nxt_cost) continue;
            cost[nxt_idx] = nxt_cost;
            pq.emplace(nxt_cost, nxt_idx);
        }
    }

    return move(cost);
}

V<int> calc_pass() {
    int P;
    cin >> P;
    auto ret = V<int>(1 << K, inf);
    ret[0] = 0;
    while(P--) {
        int pnum, cost;
        cin >> pnum >> cost;
        int frees = 0;
        while(pnum--) {
            int s;
            cin >> s;
            s--;
            frees |= (1 << s);
        }
        auto cpy = ret;
        for(int ps = 0; ps < (1 << K); ps++) chmin(cpy[ps | frees], cpy[ps] + cost);
        ret = move(cpy);
    }

    for(int s = 0; s < (1 << K); s++) {
        for(int ss = 0; ss < (1 << K); ss++) {
            if((ss | s) == ss) chmin(ret[s], ret[ss]);
        }
    }
    
    return move(ret);
}

bool solve() {
    cin >> N >> M >> H >> K;
    
    if(!(N + M + H + K)) return false;

    V<V<TIII>> edges(N);
    for(int i = 0; i < M; i++) {
        int a, b, c, h, r;
        cin >> a >> b >> c >> h >> r;
        a--;
        b--;
        r--;
        edges[a].emplace_back(b, c, h, r);
        edges[b].emplace_back(a, c, h, r);
    }

    cin >> S >> T;
    S--;
    T--;

    auto free_pass = calc_pass();


    int ans = inf;
    for(int s = 0; s < (1 << K); s++) {
        auto dist = calc_dist(edges, s);
        int minc = inf;
        for(int h = 0; h <= H; h++) chmin(minc, dist[calc_node_idx(T, h)]);
        if(minc == inf) continue;
        chmin(ans, minc + free_pass[s]);
    }
    if(ans == inf) ans = -1;
    cout << ans << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}



Measured memory_bytes: 3264
def gcd(a, b):
    if a%b==0: return b
    return gcd(b, a%b)
K=int(input())
sum=0
for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            if a==b==c: sum+=a
            elif a!=b!=c: sum+=gcd(gcd(a,b),c)*6 
            else: sum+=gcd(gcd(a,b),c)*3
print(sum)

Measured memory_bytes: 9176
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

const i32 mod = 1000000007;

int cmp (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

i32 *fact = NULL;
i32 *iFact = NULL;
void init(const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = inv(fact[n]);
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) iFact[i + 1] * (i + 1) % mod;
  }
}

#define POS(i,j) ((i) * (n + 1) + (j))
/*
i32 calc (i32 x, i32 k, i32 *dp, i32 *a, i32 n) {
  //printf ("call (%" PRIi32 ",%" PRIi32 ")\n", x, k);
  if (k == 0){
    //printf ("x = %" PRIi32 "\n", x);
    return x;
  }
  if (x < a[0]) {
    return (i64) x * fact[k] % mod;
  }
  if (dp[POS(x,k)] >= 0){
    return dp[POS(x,k)];
  }
  i32 local = 0;
  i32 mul = 1;
  i32 i;
  for (i = k; i > 0 && a[i - 1] > x; --i) {
    mul = (i64) mul * i % mod;
  }
  i32 m = i;
  for (i = 0; i < m; ++i) {
    i32 c = calc (x % a[i], i, dp, a, n);
    i32 perm = (i64)fact[m - 1] * iFact[i] % mod;
    local = (local + (i64) c * perm) % mod;
  }
  //printf ("(%" PRIi32 ",%" PRIi32 ") = %" PRIi32 "\n", x, k, local);
  dp[POS(x,k)] = (i64)local * mul % mod;
  return local;
}
*/
i32 calc (i32 x, i32 k, i32 *dp, i32 *a, i32 n) {
  if (k == 0) return x;
  if (dp[POS(x,k)] >= 0) return dp[POS(x, k)];
  if (a[0] > x){
    dp[POS(x,k)] = (i64) k * calc(x, k - 1, dp, a, n) % mod;
  } else {
    dp[POS(x, k)] = ((i64) (k - 1) * calc (x, k - 1, dp, a, n) + calc (x % a[k - 1], k - 1, dp, a, n))%mod;
  } 
  return dp[POS(x, k)];
}

void run (void) {
  i32 n, x;
  scanf ("%" SCNi32 "%" SCNi32, &n, &x);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  qsort (a, n, sizeof (i32), cmp);
  init(n);
  i32 *dp = (i32 *) calloc ((x + 1) * (n + 1), sizeof (i32));
  for (i32 i = 0; i < (x + 1) * (n + 1); ++i) {
    dp[i] = -1;
  }
  i32 ans = calc (x, n, dp, a, n);
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 78720
#include<stdio.h>

int n,a[30],i,s,f;

int main(){
	scanf("%d",&n);
	while(n!=0){
		s=32;f=0;
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		while(s>0){
			s=s-(s-1)%5;
			if(s<0)s=0;
			printf("%d\n",s);
			if(s==0)break;
			s=s-a[f];
			f++;if(f>=n)f=0;
			if(s<0)s=0;
			printf("%d\n",s);
		}
		scanf("%d",&n);
	}
	
	return 0;
}

Measured memory_bytes: 0