akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
        using namespace std;
        using ll = long long;
        using ull = unsigned long long;
        using pii = pair<int, int>;
        using pll = pair<ll, ll>;

        const int MAXN = 1e5 + 5;
        const int MOD = 1e9 + 7;
        const int INF = 0x3f3f3f3f;
        const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
        const double EPS = 1e-9;
        #define NMAX 100005
        #define LAST 1000000000002

        int tab[11] ;
        void base26(ll nombre){
            int base = 26;
            int i=10;
            while(nombre){
                tab[i] = nombre%base;
                if(tab[i]==0){
                    tab[i] = 26;
                    nombre-=26;
                } 
                nombre /= base;
                i--;
            }
            
        }

        int main(){
            ll nombre;
            cin>>nombre;
            base26(nombre);
            for (int i = 0; i < 11; ++i)
            {
                if(tab[i]){
                    cout<<char('a'+tab[i]-1);
                }
            }
           return 0;

        }


Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	
	while(1) {
		
		//input
		cin1(n);
		if (n == 0) break;

		vvi g(n,vi(n,0));
		rep(i,0,n) {
			cin1(m);
			rep(j,0,m) {
				cin1(a);
				g[i][a-1] = 1;
			}
		}

		int k; cin1(k);
		vi K(k,0);
		rep(i,0,k) {
			cin1(K[i]);
		}

		//solve
		int sum = 0;
		int ans = 0;
		rep(i,0,n) {
			bool flag = true;
			rep(j,0,k) {
				if (g[i][K[j]-1] == 0) {
					flag = false;
				}
			}
			if (flag) {
				sum++;
				ans = i + 1;
			}

		}
			if (sum == 1) {
				cout(ans);
			}else {
				cout(-1);
			}

		
	

	}

	return 0;
}

Measured memory_bytes: 3236
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N,D;
    cin >> N >> D;
    int num=0;
    for(int i=1;i<=N;i=i+2*D+1) ++num;
    cout << num;
    }

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

using LL = long long;
double n, m, d;

signed main() {
  // freopen("in", "r", stdin);
  while(cin >> n >> m >> d) {
    if (d == 0) printf("%.15f\n", (m-1)*(n-d)/n/n);
    else printf("%.15f\n", (m-1)*2*(n-d)/n/n);
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void)
{
	int a[4][4];
	int b[4][4];
	int c[4];
	int d[4];
	int i,j;
	int k,tamp=1;
	for(i=1;i<=3;i++)
	for(j=1;j<=3;j++)
	{
		scanf("%d",&a[i][j]);
	}
	for(i=0;i<=100;i++)
	{
		c[1]=i;
		d[1]=a[1][1]-c[1];
		if(d[1]<0)
		{
			tamp=0;
			break;
		}
		c[2]=a[2][1]-d[1];
		d[2]=a[2][2]-c[2];
		c[3]=a[3][2]-d[2];
		d[3]=a[3][3]-c[3];
		for(j=1;j<=3;j++)
		for(k=1;k<=3;k++)
		{
			b[j][k]=c[j]+d[k];
			if(b[j][k]!=a[j][k])
			{
				tamp=0;
				break;
			}
		}
		if(j==4)
		break;
	}
	if(tamp==1)
	printf("Yes\n");
	else
	printf("No\n");
}

Measured memory_bytes: 128
/*
I_Love_Trueno 
Author- darklight13
Smoke_Weed_Everyday
*/
#define _CRT_SECURE_NO_DEPRECATE
#define V__0_0__V
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double   ld;
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define view(x)     cout << (#x) << " is " << (x) << endl
#define view2(x,y)     cout << (#x) <<" "<<(#y)<< " are " << (x) <<" "<<(y)<< endl
#define  pb push_back
#define  F  first
#define  S  second
#define  mp make_pair
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
#define all(v) (v).begin(),(v).end()
#define sz(a) (ll)((a).size())
#define sq(x) ((x)*(x))
#define pii pair<ll,ll>
#define endl '\n'
#define pow (ll)pow

int32_t main()
{
  // FRE
    SYNC
    int n;cin>>n;
    ll h[n+1];
    for(int i=1;i<=n;i++)    cin>>h[i];
    ll dp[n+1];
    dp[1]=0;dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  for(int i=N;i>=1;i--){
    double x=sqrt(i);
    if(x==(int)x){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int cnt = 0;

void insertionsort(vector<int> &vec,int gap){
  for(int i=gap;i < vec.size();i++){
    int v = vec.at(i);
    int j = i - gap;
    while(j >= 0 && vec.at(j) > v){
      vec.at(j+gap) = vec.at(j);
      j-=gap;
      cnt++;
    }
    vec.at(j+gap) = v;
  }
}

void shellsort(vector<int> &vec){
  int m = (int)log2((double)vec.size())+1;
  vector<int> G(m);
  int l = vec.size();
  for(int i=0;i < m;i++){
    G.at(i) = l;
    l /= 2;
  }
  for(int i=0;i < m;i++){
    insertionsort(vec,G.at(i));
  }
  cout << m << endl;
  for(int i=0;i < G.size();i++){
    cout << G.at(i);
    if(i != G.size()-1) cout << " ";
    else cout << endl;
  }
  cout << cnt << endl;
  for(int i=0;i < vec.size();i++){
    cout << vec.at(i) << endl;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i=0;i < A.size();i++){
    cin >> A.at(i);
  }
  shellsort(A);

  return 0;
}


Measured memory_bytes: 6664
#include <stdio.h>

int main(void) {

	int a, b, c;
	int count5 = 0;
	int count7 = 0;

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

	if(a == 5) {
		count5++;
	}
	else if(a == 7) {
		count7++;
	}

	if(b == 5) {
		count5++;
	}
	else if(b == 7) {
		count7++;
	}

	if(c == 5) {
		count5++;
	}
	else if(c == 7) {
		count7++;
	}

	if(count5 == 2 && count7 == 1) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int C = sc.nextInt();
    int D[][] = new int[C+1][C+1];
    int count0[] = new int[C+1];
    int count1[] = new int[C+1];
    int count2[] = new int[C+1];
    for (int i=1; i<=C; i++) {
      for (int j=1; j<=C; j++) {
        D[i][j] = sc.nextInt();
      }
    }
    for (int i=1; i<=N; i++) {
      for (int j=1; j<=N; j++) {
        int tmp = sc.nextInt();
        if ((i+j)%3 == 0) {
          count0[tmp]++;
        } else if ((i+j)%3 == 1) {
          count1[tmp]++;
        } else {
          count2[tmp]++;
        }
      }
    }
    long ans = Long.MAX_VALUE;
    for (int a=1; a<=C; a++) {
      for (int b=1; b<=C; b++) {
        if (b==a) {
          continue;
        }
        for (int c=1; c<=C; c++) {
          if (c==a || c==b) {
            continue;
          }
          long tmpAns = 0;
          for (int i=1; i<=C; i++) {
            tmpAns += count0[i]*D[i][a];
            tmpAns += count1[i]*D[i][b];
            tmpAns += count2[i]*D[i][c];
          }
          ans = Math.min(tmpAns, ans);
        }
      }
    }
    System.out.println(ans);
  }

  private static final long MOD = 998244353;
  private static long FACT[];
  private static long IFACT[];

  // Pre-calculate factorial and its mod_inverse for calculate nCr in O(1)
  private static void create_fact(int N) {
    FACT = new long[N+1];
    IFACT = new long[N+1];
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i=1; i<=N; i++) {
      FACT[i] = FACT[i-1] * i % MOD;
      IFACT[i] = mod_inverse(FACT[i]);
    }
  }

  // Return nCr
  private static long comb(int n, int r) {
    if (n < 0 || r < 0 || n < r) {
      return 0;
    }
    if (r > n/2) {
      r = n - r;
    }
    return FACT[n]*IFACT[n-r]%MOD*IFACT[r]%MOD;
  }

  // Fast mod inverse
  private static long mod_inverse(long a) {
    long b = MOD;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + MOD : p;
  }
}


Measured memory_bytes: 74760
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

int main(){
        ll n,a,b;
        cin>>a>>b>>n;
        ll answer= b/n-(a-1)/n;
        cout<<answer<<endl;
}


Measured memory_bytes: 81148
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int n, l[22], r[22][33], p[22]; string s[22];
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> s[i] >> l[i];
			for (int j = 0; j < l[i]; j++) {
				cin >> r[i][j];
			}
		}
		fill(p, p + n, 0);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l[i]; j++) {
				int cnt = 0;
				for (int k = 0; k < n; k++) {
					if (find(r[k], r[k] + l[k], r[i][j]) != (r[k] + l[k])) cnt++;
				}
				p[i] += n - cnt + 1;
			}
		}
		int res = *min_element(p, p + n), x = 0;
		string ret = "~";
		for (int i = 0; i < n; i++) {
			if (p[i] == res && ret > s[i]) ret = s[i], x = p[i];
		}
		cout << x << ' ' << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  Int ans=a[1];
  for(Int i=1;i<n;i++){
    if(min(a[0]-a[i],a[i])>min(a[0]-ans,ans)) ans=a[i];
  }
  cout<<a[0]<<" "<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string s, t;
    int N;
    cin >> s;
    N = s.size();
    t = s[0];
    int sum = 0;
    rep(i, 0, 1<<(N-1)) {
        int a;
        sum = s[0] - '0';
        t = s[0];
        rep(j, 0, N - 1) {
            a = s[j+1] - '0';
            if(i & (1<<j)) {
                sum += a;
                t = t + '+' + s[j+1];
            } else {
                sum -= a;
                t = t + '-' + s[j+1];
            }
        }

        if(sum == 7) {
            cout << t << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int n = Read.Int();
        int[] a = new int[n];
        for(int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }
        int lightning=0;
        for (int i = 0; i < n; i++)
        {
            lightning = a[lightning] - 1;
            if (lightning == 1) { Console.WriteLine(i+1);break; }
            if (i == n - 1) { Console.WriteLine(-1); }
        }
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 15328
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mod 1000000007LL;
#define mkp make_pair
#define pb push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
double pi=3.1415926535;
double eps=0.000001;
 
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
 
 
int32_t main(){
/////////////////////////////////////////////////////////////////////
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(10);
	int n, w,sum=0;
	cin>>n>>w;
	vii wt(n), val(n);
	rep(i,0,n){
		cin>>wt[i];
		cin>>val[i];
		sum+=val[i];
	}
	vector < vii > dp(n+1, vector <int> (sum+1, INT_MAX));
	dp[0][0]=0;
	rep(i,0,n){
		rep(ii,0,sum+1){
			dp[i+1][ii]=min(dp[i][ii], dp[i+1][ii]);
			if(ii-val[i]>=0){
				dp[i+1][ii]=min(dp[i+1][ii], dp[i][ii-val[i]]+wt[i]);
			}
		}
	}
//	rep(i,0,n+1){
//		rep(ii,0,sum+1) if(dp[i][ii]!=INT_MAX) cout<<dp[i][ii]<<"\t"; else cout<<"INF\t";
//		cout<<endl;
//	}
	int ans=INT_MIN;
	rep(i, 0, sum+1){
		if(dp[n][i]<=w) ans=max(ans, i);
	}
	cout<<ans<<endl;
	return 0;
	}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  N %= 500;
  if( N == 0 | N <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L;
ll A[300005] = {};
ll B[101][100005] = {};
ll C[300005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	int kaisuu;
	int dan;
	int score;
	char situ[52][2][2];
	

	bool operator<(const ST& another) const
	{
		return dan < another.dan;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

string SS[3];


int main() {

	cin >> a>>b>>c;
	f = false;


	for (int i = 1; i < 1000; i++) {
		if ((a * i) % b == c) {
			f = true;
		}
	}

	if (f == false) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}


	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
bool t[10000] = {false};
int main()
{
	int n, c, i, j, d;
	t[0] = true;
	for (i = 2; i * i <= 10000; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j <= 10000; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n, n)
	{
		for (i = n; i >= 5; i--)
		{
			if ((!t[i-1]) && (!t[i-3]))
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 876
/*	* In the name of GOD
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	string s, t;
	cin >> s >> t;
	bool f = true;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != t[i])
			f = false;
	}
	cout << (f ? "Yes" : "No");
}


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


int main()
{
  int i;
  int x;
  for(i=1;i<=5;i++)
  {
    cin>>x;
    if(x==0)
    {
      cout<<i<<"\n";
      break;
    }
  }
  return(0);
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(void){
    // Your code her
    int N;
    
    cin >> N;
    
    if(N % 1000 > 0){
        cout << 1000 - (N % 1000) << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3636
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn solve(n: &str, k: usize) -> usize {
    if k == 0 {
        return 1;
    }
    if n.len() < k {
        return 0;
    }

    let top: usize = n[0..1].parse().unwrap();
    if top == 0 {
        solve(&n[1..], k)
    } else {
        let mut s = String::new();
        for _ in 0..(n.len() - 1) {
            s.push_str("9");
        }
        let mut ans = 0;
        //000000~099999
        ans += solve(&s, k);
        //100000~299999
        ans += (top - 1) * solve(&s, k - 1);
        //300000~314159
        ans += solve(&n[1..], k - 1);
        ans
    }
}

fn main() {
    let n: String = read().unwrap();
    let k: usize = read().unwrap();
    println!("{}", solve(&n, k));
}


Measured memory_bytes: 4352
#include <iostream>
#include <queue>
#include <vector>

#define MAX_N 100000
#define MAX_M 100000

using namespace std;

struct Edge
{
    int to, idx;
};
vector<Edge> G[MAX_N];

struct Direction
{
    int from, to;

    bool is_defined() { return from >= 0 and to >= 0; }
};
Direction directions[MAX_M];

int num_edges[MAX_N];

void add_edge( int u, int v, int eidx )
{
    G[u].push_back( {v, eidx} );
    G[v].push_back( {u, eidx} );
    num_edges[u]++;
    num_edges[v]++;
}

bool visited[MAX_N];

void dfs( int root, int par )
{
    int eidx;

    for ( auto e : G[root] )
    {
        if ( e.to == par )
        {
            eidx = e.idx;
            continue;
        }
        if ( visited[e.to] ) continue;

        visited[e.to] = true;

        dfs( e.to, root );
    }

    int out = 0;
    for ( auto e : G[root] ) out += directions[e.idx].from == root;

    int remains = num_edges[root];
    if ( ( out + remains ) % 2 == 1 )
    {
        directions[eidx].from = par;
        directions[eidx].to = root;

        num_edges[root]--;
        num_edges[par]--;
        remains--;
    }

    for ( auto e : G[root] )
    {
        if ( remains == 0 ) break;

        Direction &d = directions[e.idx];
        if ( d.is_defined() ) continue;

        d.from = root;
        d.to = e.to;

        num_edges[root]--;
        num_edges[e.to]--;

        remains--;
    }
}

void init( int N, int M )
{
    for ( int i = 0; i < N; i++ ) num_edges[i] = 0;
    for ( int i = 0; i < M; i++ ) directions[i] = {-1, -1};
}

int main( int argc, char **argv )
{
    int N, M;
    cin >> N >> M;

    init( N, M );

    for ( int i = 0; i < M; i++ )
    {
        int A, B;
        cin >> A >> B;

        add_edge( A - 1, B - 1, i );
    }

    if ( M % 2 == 1 ) { cout << -1 << endl; }
    else
    {
        dfs( 0, -1 );

        for ( int i = 0; i < M; i++ )
        {
            if ( !directions[i].is_defined() )
            {
                cout << -1 << endl;
                return 0;
            }
        }

        for ( int i = 0; i < M; i++ )
        {
            cout << ( directions[i].from + 1 );
            cout << " ";
            cout << ( directions[i].to + 1 );
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 16000
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();
		int temp = 0;
		int one = N / 10;
		if (one == 0) {
			System.out.println(N % 10);
			return;
		}
		temp += 9;
		int three = N / 1000;
		if (three == 0) {
			if (N > 99) {
				System.out.println(temp + N - 99);
				return;
			} else {
				System.out.println(temp);
				return;
			}
		}
		temp += 999 - 99;
		if (N > 9999 && N < 100000) {
			System.out.println(temp + N - 9999);
		} else if (N > 9999) {
			System.out.println(temp + N - 9999 - 1);
		} else {
			System.out.println(temp);
			return;
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<map>
#include<vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> di(N);
	for (int n = 0; n < N; n++) {
		cin >> di[n];
	}
	map<int, int> mp;
	for (int n = 0; n < N; n++) {
		int di_n = di[n];
		mp[di_n] = 1;
	}
	int num = mp.size();
	cout << num << endl;
	return 0;


}



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

const int N = 100005;

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

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		f[i] = 1e9 + 123;
	}
	f[1] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= min(n, i + k); ++j) {
			f[j] = min(f[j], f[i] + abs(a[i] - a[j]));
		}
	}
	printf("%d\n", f[n]);
} 

Measured memory_bytes: 1024
# import numpy as np
import itertools

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# print(P)
	# 一度計算したサイクル情報をキャッシュしておくための配列
	# cycleIDs = np.full( N, -1, np.int64 )
	cycleIDs = [ -1 for _ in range(N)]
	cycleInfs = []
	cycleID = 0
	procCnt = 0

	for n in range(N):
		v = n

		if cycleIDs[v] != -1:
			continue
		else:
			currentCycleCosts = []
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleCosts.append( C[v] )
				cycleIDs[v] = cycleID

				v = P[v]
				if cycleIDs[v] != -1:
					# サイクル終了
					# ループを含めない最大の処理回数
					procCnt = K % len( currentCycleCosts )
					# それで足りてるのかわからないが、Last2周分は、ループ合計がプラスでも必ずしもループするとは限らない
					# その部分は、ちゃんと計算する
					# -------------------------------------------------
					# 4 101
					# 2 3 4 1
					# 50 -49 -50 50
					# 上記のようなパターンの場合、
					# 最大25回ループ + 1回処理可能だが、その場合、25 + 50 = 75
					# 24回ループ + 2回処理でやめると、124になる
					# 無条件でループする回数は、ループ可能な最大の回数-1らしい
					# -------------------------------------------------
					# 割り切れて、尚且つサイクル合計がマイナスのパターンで、最低１個は処理するのにもここで対応
					if len( currentCycleCosts ) + procCnt <= K:
						procCnt += len( currentCycleCosts )

					cycleInfs.append( ( procCnt, len(currentCycleCosts), currentCycleCosts * 3 ) )
					cycleID += 1
					break



	# scores = []
	# procCnt = 0
	ans = -10 ** 9
	for procCnt, currentCycleSize, currentCycleCosts in cycleInfs:

		# サイクル内でループしてスコアを稼ぐ場合の考慮
		loopScore = 0
		if sum(currentCycleCosts) > 0:
			cycleLoopCnt =  ( K - procCnt ) // currentCycleSize
			loopScore = cycleLoopCnt * sum(currentCycleCosts[:currentCycleSize])
			# print("loopScore",loopScore,procCnt)

		# このサイクルに属する全頂点分をまとめて計算する
		for i in range(currentCycleSize):
			# print(np.roll( currentCycleCosts, i ).cumsum()[:procCnt])
			ans = max( ans, max( list( itertools.accumulate( currentCycleCosts[i:i+procCnt] ) ) ) + loopScore )


	print(ans)
	# print(max(scores))


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

using namespace std;

int N;

long long int K, Q;
int A[100005];

long long int C[100005];

int main(void) {

	cin >> N >> K >> Q;

	for (int i = 1; i <= Q; i++) {
		cin >> A[i];
	}

	for (int i = 1; i <= N; i++) {
		C[i] = K;
	}

	for (int i = 1; i <= Q; i++) {
		C[A[i]]++;
	}

	for (int i = 1; i <= N; i++) {
		C[i] -= Q;
	}

	for (int i = 1; i <= N; i++) {
		if (C[i] > 0) { cout << "Yes" << endl; }
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400007;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n;
int arr[MAX/4];
int dpT[MAX/4];
int dp(int pos)
{
	if(pos>n-1)
		return INF;
	if(pos==n-1)
		return 0;
	if(dpT[pos]!=-1)
		return dpT[pos];
	return dpT[pos]=min(dp(pos+1)+abs(arr[pos]-arr[pos+1]),dp(pos+2)+abs(arr[pos]-arr[pos+2]));
}



int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	FILL(dpT,-1);
	cin >> n;
	FOR(i,0,n)
		cin >> arr[i];
	cout<<dp(0);




	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  
  for(int i = 0; i < N; i++) {
    int Xi;
    cin >> Xi;
   	
    if(Xi < K - Xi) {
      sum += (Xi * 2);
    }
    else {
      sum += (K - Xi) * 2;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3580
x = int(input())
if x == 1 or x == 2:
    print(2)
else:
    isPrime = True
    while True:
        for i in range(2, x):
            if x % i == 0:
                x += 1
                isPrime = False
                break
        if isPrime:
            print(x)
            break
        else:
            isPrime = True


Measured memory_bytes: 38512
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    unordered_set<ll> a, b;
    REP(i, n) {
        ll _a; cin >> _a;
        if (a.find(_a) != a.end()) {
            cout << 0 << '\n'; return 0;
        }
        a.insert(_a);
    }
    REP(i, m) {
        ll _b; cin >> _b;
        if (b.find(_b) != b.end()) {
            cout << 0 << '\n'; return 0;
        }
        b.insert(_b);
    }
    ll ans = 1;
    ll ac=0, bc=0;
    for (ll i = n*m; i>0; i--) {
        if (a.find(i) != a.end() && b.find(i) != b.end()) {
            ac++, bc++;
        } else if (a.find(i) == a.end() && b.find(i) != b.end()) {
            ans *= bc;  // 今まで考えたBと同じ行にしか置けない
            ans %= MOD; ac++;
        } else if (a.find(i) != a.end() && b.find(i) == b.end()) {
            ans *= ac;  // 今まで考えたAと同じ行にしか置けない
            ans %= MOD; bc++;
        } else {
            ans *= (ac*bc - (n*m-i));
            ans %= MOD;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    vector<ll> diff(m-1,0);
    for(int i = 0; i < m; i++){
        cin >> x[i];
    }
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    sort(all(x));
    for(int i = 0; i < m-1; i++){
        diff[i] = x[i+1] - x[i];
    }
    sort(all(diff));
    ll ans = 0;
    for(int i = 0; i < m-n; i++){
        ans += diff[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,k=gsmi
putsend 1 if k==1

def pow(base,b)
  ans=1
  while b>0 do
    d = b/10
    m = b%10
    ans*=(base**m)
    ans%=MOD
    base = (base**10)%MOD
    b=d
  end
  ans
end

cnt=pow(k,n)%MOD
k.downto 2 do |i|
  c=pow(k/i,n)
  i.step(k,i) do |j|
    next if i==j
    c-=h[j]
  end
  h[i]=c
  cnt+=c*i
  cnt%=MOD
  #puts h.to_a.to_s
  #puts cnt
end
cnt-=sum h.values

puts cnt%MOD

Measured memory_bytes: 19184
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	NM := sc.nextInts()
	// N := NM[0]
	M := NM[1]
	mAc := make(map[string]int)
	mWa := make(map[string]int)
	for i := 0; i < M; i++ {
		prob := sc.nexts()
		nth := prob[0]
		result := prob[1]
		if result == "AC" {
			mAc[nth] = 1
		} else {
			if mAc[nth] == 0 {
				mWa[nth]++
			}
		}
	}
	var sumAc int
	var sunWa int

	for _, v := range mAc {
		sumAc += v
	}

	for i, v := range mWa {
		if mAc[i] == 1 {
			sunWa += v
		}
	}

	fmt.Println(sumAc, sunWa)
}

/* template functions */
var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}

func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}

func (s *scanner) resetCur() {
	s.cur = 0
}

func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}

func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}

func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur], 64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i], 64)
	}
	s.resetCur()
	return res
}

func digits(x int) int {
	return len(strconv.Itoa(x))
}

func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}


Measured memory_bytes: 9344
// by https://atcoder.jp/contests/abc070/tasks/abc070_c
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func gcd(m, n uint64) uint64 {
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(m)
	b := new(big.Int).SetUint64(n)
	return z.GCD(x, y, a, b).Uint64()
}

func main() {
	var clockNum int
	// 最初の値が時計の数
	clockNum, _ = strconv.Atoi(nextLine())

	clockPeriods := []int{}
	for i := 0; i < clockNum; i++ {
		var tmp, _ = strconv.Atoi(nextLine())
		clockPeriods = append(clockPeriods, tmp)
	}
	// fmt.Println(clockPeriods)

	for i := 0; i < clockNum; i++ {
		// fmt.Println(clockPeriods[i])
	}

	// fmt.Println("clocks:")
	// fmt.Println(clockNum)

	// fmt.Println("periods:")
	// for _, pos := range clockPeriods {
	// 	// fmt.Println(pos)
	// 	// fmt.Print()
	// }

	if clockNum == 1 {
		fmt.Println(clockPeriods[0])
	} else {
		// fmt.Println(uint64(clockPeriods[0]))
		// fmt.Println(uint64(clockPeriods[1]))
		maxgcd := gcd(uint64(clockPeriods[0]), uint64(clockPeriods[1]))
		// fmt.Println(maxgcd)
		a := uint64(clockPeriods[0]) / maxgcd * uint64(clockPeriods[1])
		// fmt.Println(product)
		// fmt.Println(a)

		for i := 0; i < clockNum-2; i++ {
			maxgcd := gcd(a, uint64(clockPeriods[i+2]))
			// fmt.Println(maxgcd)
			a = a / maxgcd * uint64(clockPeriods[i+2])
			// fmt.Println(product)
			// a = product / maxgcd
			// fmt.Print(i + 2)
			// fmt.Print("回目の最小公倍数は")
		}
		fmt.Println(a)
	}

}

Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#include <utility>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

typedef long long ll;

int main(void) {
  int n, now = 0;
  scanf("%d", &n);
  ll dis[n];
  rep(i, n) dis[i] = 10e13;
  dis[0] = 0;
  char f[n];
  rep(i, n) f[i] = 0;
  f[0] = 1;
  vector< pair<int, int> > vec[n];
  rep(i, n) {
    int u, k;
    scanf("%d%d", &u, &k);
    rep(j, k) {
      int c, v;
      scanf("%d%d", &v, &c);
      pair<int, int> p = make_pair(v, c);
      vec[u].push_back(p);
    }
  }
  /*rep(i, n) {
    vector< pair<int, int> >::iterator it;
    for(it = vec[i].begin(); it != vec[i].end(); ++it) printf("%d:%d ", (*it).first, (*it).second);
    printf("\n");
  }*/
  rep(i, n - 1) {
    int j = now;
    vector< pair<int, int> >::iterator it;
    for(it = vec[j].begin(); it != vec[j].end(); ++it) {
      if(dis[(*it).first] > dis[j] + (*it).second) dis[(*it).first] = dis[j] + (*it).second;
    }
    ll min = 10e13, minn;
    rep(k, n) if(!f[k] && min > dis[k]) min = dis[k], minn = k;
    f[minn] = 1;
    now = minn;
    /*rep(j, n) printf("%d ", dis[j]);
    printf("\n");*/
  }
  rep(i, n) printf("%d %lld\n", i, dis[i]);
  return 0;
}


Measured memory_bytes: 7232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll r,d,x;
cin >> r>>d>>x;
rep(i,10){
    cout << x*r-d << endl;
    x=x*r-d ;
}


return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(n: int, p: "List[int]"):

    count = 0
    for i in range(1,n - 1):
        if p[i] != max(p[i - 1], p[i], p[i + 1]) and p[i] != min(p[i - 1], p[i], p[i + 1]):
            count += 1
    print(count)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>                                                              

int chk(int);

int main(void){
   int x,y,xg,yg;
   scanf("%d%d",&x,&y);

   xg = chk(x); yg = chk(y);
   if(xg==yg){
      printf("Yes\n");
   } else {
      printf("No\n");
   }

   return 0;
}

int chk(int n){
   int g;
   if(n==2) return 2;
   if (n<8){
      if(n%2==1){ g=0;
      } else { g=1;}
   } else {
      if(n%2==0){g=0;
      } else { g=1;}
   }

   return g; 
}   

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

using namespace std;
typedef long long ll;

int a[100001];
ll dp[100001];

int main(void) {
    int i, n;
    cin >> n;
    for(i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    dp[0] = a[0];
    for(i=1; i<n; i++) dp[i] = dp[i-1] + a[i];

    for(i=n-2; i>=0; i--) {
        if(2*dp[i] < a[i+1]) return !printf("%d\n", n-i-1);
    }

    return !printf("%d\n", n);
}

Measured memory_bytes: 1408
/*
Nahid Hossain
Jahangirnagar University
Roll:54
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 1000005

ll a[ma],b[ma];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,x,k;
    while(cin>>n)
    {
        n*=3;
        ll m=n/3;
       for(i=1;i<=n;i++)cin>>a[i];
       sort(a+1,a+n+1);
       ll s=0;
       for(i=n-1;i>=1;i-=2)
       {
           if(m==0)break;
           s+=a[i];
           m--;
       }
       cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 4352
S = int(input())
H = list(map(int, input().split()))

max=0
tmp=0

for i in range(len(H)-1):
    if(H[i]>=H[i+1]):
        tmp+=1
    else:
        if(max<tmp):
            max=tmp
        tmp=0
if(max<tmp):
    max=tmp

print(max)



Measured memory_bytes: 14252
import math
x, k, d = map(int, input().split())
if k * d <= abs(x):
    print(abs(x) - k * d)
    exit()
if x < 0:
    x = abs(x)
move = math.ceil(x/d)
x = x - d * move
k -= move
if k % 2 == 0:
    print(abs(x))
else:
    x = x + d
    print(abs(x))



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

int main(){
    string a;
    cin >> a;
    string b;
    cin >> b;
    reverse(b.begin(),b.end());
    if(a == b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
N,Y=map(int,input().split())
ansx=-1
ansy=-1
ansz=-1
for x in range(N+1):
    for y in range(N+1-x):
        z= N-x-y
        total = 10000*x + 5000*y + 1000*z
        if total== Y:
            ansx=x
            ansy=y
            ansz=z
            break
print("{} {} {}".format(ansx, ansy, ansz))




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

using namespace std;

int main() {
   int h,w;
   cin >> h >> w;

   rep(i,w+2)
   cout << '#' ; 
   cout << endl;

   rep(i,h){
      string s;
      cin >> s;
      cout << '#' << s << '#' << endl;
   }

   rep(i,w+2)
   cout << '#' ; 
   cout << endl;
}

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

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int cnt=0;
    while(n!=1){
      if(n%2==0)n/=2;
      else n=3*n+1;
      cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
a[];main(c,l,r,p,f){for(;scanf(f="%d\n",&r)*r;printf(f,c)){for(c=++r;c;)l=scanf(f,--c+a);for(;l<r&&!++c|a[p=l+r>>1]-*a;)a[p]<*a?r=p:(l=p+1);}}

Measured memory_bytes: 0
package main

import (
	"container/heap"
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	pq := make(PriorityQueue, n)
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		pq[i] = &Item{value: a, index: i}
	}
	heap.Init(&pq)

	for i := 0; i < m; i++ {
		item := heap.Pop(&pq).(*Item)
		item.value /= 2
		heap.Push(&pq, item)
	}

	ans := 0
	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		ans += item.value
	}
	fmt.Println(ans)
}

// Item .
type Item struct {
	value int // The value of the item; arbitrary.
	index int // The index of the item in the heap.
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].value > pq[j].value
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// Push .
func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

// Pop .
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}


Measured memory_bytes: 4736