akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

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

    int ans = 0;
    for (int i = 0; i < 1000; i++){
        int d1 = i/100;
        int d2 = (i/10)%10;
        int d3 = i%10;
        
        bool f1=false, f2=false;
        rep(i, n){
            if(!f1 && (s[i]-'0')==d1){
                f1=true;
                continue;
            }
            if(!f2 && f1 && (s[i]-'0')==d2){
                f2=true;
                continue;
            }
            if(f2 && (s[i]-'0')==d3){
                ans++;
                // printf("%d\n", i);
                break;
            }
        }
    }
    

    // cout << ans << endl;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int n;
vvi G;
vi f(int s){
    queue<pii>q;
    vi d(n,-inf);
    d[s]=0;
    q.push({s,0});
    while(!q.empty()){
        pii t=q.front();
        q.pop();
        if(t.second<d[t.first])continue;
        rep(i,G[t.first].size()){
            int to=G[t.first][i];
            if(d[to]<t.second+1){
                d[to]=t.second+1;
                q.push({to,t.second+1});
            }
        }
    }
    return d;
}
int main(){
    while(cin>>n,n){
        n+=2;
        vvi in(2);
        int a,b;
        cin>>a>>b;
        in[0]={a,b,0};
        cin>>a>>b;
        in[1]={a,b,0};
        rep(i,n-2){
            int a,b,c;
            cin>>a>>b>>c;
            bool h1=(a-in[0][0])*(a-in[0][0])+(b-in[0][1])*(b-in[0][1])<c*c;
            bool h2=(a-in[1][0])*(a-in[1][0])+(b-in[1][1])*(b-in[1][1])<c*c;

            if(h1^h2)in.pb({a,b,c});
        }
        n=in.size();
        G=vvi(n);
        rep(i,n)rep(j,n)if(in[i][2]<in[j][2]){
            if((in[i][2]-in[j][2])*(in[i][2]-in[j][2])>(in[i][0]-in[j][0])*(in[i][0]-in[j][0])+(in[i][1]-in[j][1])*(in[i][1]-in[j][1])){
                G[i].pb(j);
            }
        }
        int out=0;
        vi d1=f(0);
        vi d2=f(1);
        rep(i,n)rep(j,n){
            if((in[i][2]+in[j][2])*(in[i][2]+in[j][2])<(in[i][0]-in[j][0])*(in[i][0]-in[j][0])+(in[i][1]-in[j][1])*(in[i][1]-in[j][1])){
                cmax(out,d1[i]+d2[j]);
            }
        }

        cout<<out<<endl;
    }
}



Measured memory_bytes: 5716
number = list(map(int, input().split()))

A = number[0]
B = number[1]
C = number[2]
K = number[3]

n = [A,B,C]
result = 0
j = 1
for i in n:
    if K <= i:
        print(result + K*j)
        break
    else:
        result += j*i
        K = K - i 
        j = j - 1

Measured memory_bytes: 9196
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		long n = Long.parseLong(scanner.nextLine());
		long a = 100;
		long x = 0;
		while(a < n) {

			a += a / 100;
			x++;
		}
		System.out.println(x);



	}

}


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

using namespace std;

class UnionFind{
public:
  vector<int> par;

  void init(int n)
  {
    par.clear();
    par.resize(n);
    for (size_t i = 0; i < n; i++) {
      par[i] = i;
    }
  }

  int find(int x)
  {
    if(x == par[x]){
      return x;
    }
    else{
      return par[x] = find(par[x]);
    }
  }

  void unite(int x, int y)
  {
    x = find(x); y = find(y);
    if(x == y){
      return;
    }
    par[x] = y;
  }

  bool same(int x, int y)
  {
    return find(x) == find(y);
  }
};

int main()
{
  int N; cin >> N;
  UnionFind uf; uf.init(N);
  int Q; cin >> Q;
  for (size_t q = 0; q < Q; q++) {
    int com, x, y; cin >> com >> x >> y;
    if(com == 0){
      uf.unite(x, y);
    }
    else{
      if(uf.same(x, y)){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
  }


  return 0;
}

Measured memory_bytes: 3156
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(long long a, long long b){
	int xa=-a,xb=-b+1;
	if (xa<0) xa=0;
	if (xb<0) xb=0;
	if (a<=0 && b>=0) {
		puts("Zero");
	} else if ((xa-xb)%2!=0) {
		puts("Negative");
	} else {
		puts("Positive");
	}
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long b;
	long long a;
	scanf("%lld",&a);
	scanf("%lld",&b);
	solve(a, b);
	return 0;
}



Measured memory_bytes: 256
from itertools import permutations

def calc_distance(p1, p2):
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**0.5

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

perm = permutations(range(N), N)
d_list = []
for p in perm:
    d = 0
    for i in range(N - 1):
        d += calc_distance(P[p[i]], P[p[i+1]])
    d_list.append(d)
print(sum(d_list) / len(d_list))

Measured memory_bytes: 42476
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void){
    int N, K;
    cin >> N >> K;
    double prob = 0;
    for(int i=1; i<=N; i++) {
        double ai = 1;
        for(int j=i; j<K; j=j*2) {
            ai /= 2;
        }
        prob += ai;
    }
    cout << fixed << setprecision(10) << prob / N << endl;
    return 0;    
}


Measured memory_bytes: 256
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times {|i|yield(i)}                    end
def repl(st,en,n=1);       n*= -1 if st>en;st.step(en,n){|i|yield(i)} end

N,x = gi
a = gi
ans = 0
rep N-1 do |i|
	if a[i]+a[i+1] > x
		s = a[i]+a[i+1]-x
		ans += s
		if a[i+1]< s
			a[i]-= s-a[i+1]
			a[i+1]= 0
		else
			a[i+1] -= s
		end
	end
end

puts ans

Measured memory_bytes: 9148
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int a = in();
  string s ; cin >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int N,W; cin>>N>>W;
  vector<ll> w(N),v(N); rep(i,N)cin>>w.at(i)>>v.at(i);
  //Wが大きい場合のdp
  ll MAX_V = 100100;
  vector<vector<ll>> dp(N+1,vector<ll> (MAX_V+1,INF));//dp[i][v]is 0toi-1の品物を使ってvの価値を生み出すのに必要な重さの最小値

  rep(i,N+1)dp.at(i).at(0)=0;

  rep1(i,N){
    rep1(j,MAX_V){
      //i番目の品物を使う場合
      if(j-v.at(i-1)<0)dp.at(i).at(j)=min(dp.at(i-1).at(j),dp.at(i).at(j));
      else dp.at(i).at(j)=min(dp.at(i-1).at(j),dp.at(i-1).at(j-v.at(i-1))+w.at(i-1));
    }
  }

  ll res = 0;
  rep(i,MAX_V)if(dp.at(N).at(i)<=W)res = max(res,i);
  cout<<res<<endl;
}


Measured memory_bytes: 80256
#include <cstdio>
#include <algorithm>

using std::min;

const int MOD=1000000007;

const int MAXN=200011, MAXM=200011;

inline int sum(const int &a, const int &b){
	return (a+b>=MOD)?(a+b-MOD):(a+b);
}

inline int mul(const int &a, const int &b){
	return (int)((1LL*a*b)%(long long)(MOD));
}

inline void add(int &f, const int &v){
	f+=v;if(f>=MOD)	f-=MOD;
}

int N, M;
int A[MAXM];
char input[MAXM];
int F[MAXN];

inline bool AllZero(){
	int Cnt=0;
	for(int i=1;i<=M;++i)	Cnt+=!A[i];
	return Cnt==M;
}

int main(){
	
	scanf("%d%d", &N, &M);
	scanf("%s", input);
	for(int i=1;i<=M;++i)	A[i]=input[i-1]!=input[0];
	
	if(AllZero()){
		int F[2][2], T[2][2];
		F[0][0]=F[1][1]=1;
		F[0][1]=F[1][0]=0;
		for(int i=2;i<=N;++i){
			for(int s=0;s<2;++s)
				for(int n=0;n<2;++n)
					T[s][n]=0;
			for(int s=0;s<2;++s)
				for(int n=0;n<2;++n)
					for(int c=0;c<2;++c)
						if(n+c<2)	add(T[s][c], F[s][n]);
			for(int s=0;s<2;++s)
				for(int n=0;n<2;++n)
					F[s][n]=T[s][n];
		}
		int Ans=0;
		for(int s=0;s<2;++s)
			for(int n=0;n<2;++n)
				if(s+n<2)	add(Ans, F[s][n]);
		printf("%d\n", Ans);
	}
	else{
		int Lim=N;
		for(int i=1, c=0, p=0;i<=M;++i){
			if(A[i]){
				if(c&1)	Lim=min(Lim, c+1);
				else if(!p)	Lim=min(Lim, c+2);
				c=0;p=i;
			}
			else	++c;
		}
		F[0]=F[2]=1;
		for(int i=4;i<=N;i+=2){
			F[i]=sum(F[i-2], F[i-2]);
			if(i>=Lim+2){
				add(F[i], MOD-F[i-(Lim+2)]);
			}
		}
		int Ans=0;
		for(int i=2;i<=Lim;i+=2){
			add(Ans, mul(F[N-i], i));
		}
		printf("%d\n", Ans);
	}
	
	return 0;
}

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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
 
    if (a == b+c || b == c+a || c == a+b) {
        cout << "Yes" << endl;
    } else {
        cout << "No"  << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,a,b,c,i,max=0,min=1e9,d[100010],s=0;
  int f[100010]={};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(i=0;i<n;i++){      
    min=MIN(min,d[i]);
    max=MAX(max,d[i]-min);
  }
  //printf("%d\n",max);
  min=1e9;
  for(i=0;i<n;i++){
    min=MIN(min,d[i]);//printf("%d %d\n",min,d[i]);
    if(d[i]-min==max)f[i]=1;
  }
  //for(i=0;i<n;i++)printf("%d %d\n",d[i],f[i]);
  a=-1;
  c=b=0;
  //printf("%d\n",max);
  for(i=n-1;i>-1;i--){//printf("%d %d %d\n",a,b,c);
    if(f[i]){
      if(a==d[i])c++;
      else{
	s+=MIN(c,b);
	c=1;
	b=0;
	a=d[i];
      }
    }
    else if(a-d[i]==max)b++;
  }
  printf("%d\n",s+MIN(b,c));
  return 0;
}
    
  


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int M1, M2, D1, D2;
    scanf("%d", &M1);
    scanf("%d", &D1);    
    scanf("%d", &M2);    
    scanf("%d", &D2);

    if (M1 == M2)
    {
        printf("0");
    }else{
        printf("1");
    }
    return 0;

}

Measured memory_bytes: 128
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll fl=0, n,i,j, x, y;
	//pair< ll, ll> pr[mx];
	vector< pair< ll, ll> > pr;
	cin>>n;
	for(i=0; i< n;i ++)
	{
	    cin>>x>>y;
	    pr.pb({y,x});
	}
	
	sort(pr.begin(), pr.end());
	ll kk=0;
	for(i=0; i< n; i++){
	    
	    kk+= pr[i].second;
	    if(kk> pr[i].first)
	    {
	        fl= 1;
	        break;
	    }
	    
	}
	if(fl)
	cout<<"No";
	else
	cout<<"Yes\n";
    return 0;
}

























Measured memory_bytes: 6128
def hug_counter(kaibun):
    global REQUIRED_HUG_COUNT
    if len(kaibun) < 1:
        return
    if kaibun[0] != kaibun[-1]:
        REQUIRED_HUG_COUNT += 1
    kaibun = kaibun[1:-1]
    hug_counter(kaibun)
        
REQUIRED_HUG_COUNT = 0
S = input()
hug_counter(S)
print(REQUIRED_HUG_COUNT)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    vector<int> v(3);
    REP(i,3) cin >> v[i];
    sort(ALL(v));
    int ans = v[0] == v[1] ? v[2] : v[0];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  int count = 0;
  int ans = 2*n;
  for(int i = n;i > 0;i--){
    if(s.substr(n-i,i) == t.substr(0,i)){
      ans = 2*n-i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a,b,c,d;
    scanf("%d %d",&a,&b);
    if(a>b){
    c=a-1;
    d=a+c;
    printf("%d\n",d);
    }
    else if(a<b){
    c=b-1;
    d=b+c;
    printf("%d\n",d);
    }
    else{
    d=a+b;
    printf("%d\n",d);
    }
    return 0;
}



Measured memory_bytes: 128
import sys
input = sys.stdin.readline
def main():
    S = input().strip()
    before = "R"
    nowL = 0
    nowR = 0
    keyL = -1
    keyR = -1
    ans = [0] * len(S)
    for i, s in enumerate(S):
        if s == before:
            if s == "R":
                nowR += 1
            else:
                nowL += 1
        else:
            if s == "L":
                keyR = i-1
                keyL = i
                ans[keyR] += (nowR+1) // 2
                ans[keyL] += nowR // 2
                before = "L"
                nowL = 1
            else:
                ans[keyR] += nowL // 2
                ans[keyL] += (nowL+1) // 2
                nowR = 1
                before = "R"
    ans[keyR] += nowL // 2
    ans[keyL] += (nowL+1) // 2
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i=0; i< n; i++)
using namespace std;


int main() {
	int n; cin >> n;
	vector<vector<int>> v(n, vector<int>(n, -1));
	rep(i, n) {
		int k;
		cin >> k;
		for (int j = 0; j < k;j++) {
			int x, y;
			cin >> x >> y;
			x--;
			v[i][x] = y;
		}
	}

	//for (int q = 0; q < n; q++) {
	//	for (int w = 0; w < n; w++) {
	//		cout << v[q][w] << " ";
	//	}
	//	cout << endl;
	//}
	int m = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		int cnt = 0;
		bool f = true;
		for (int j = 0; j < n; j++) {
			if (bit & 1 << j) {
				for (int q = 0; q < n; q++) {
					if (v[j][q] == 1) {
						if (!(bit & 1 << q)){
							f = false;
							break;
						}
					}
					if (v[j][q] == 0) {
						if ((bit & 1 << q)) {
							f = false;
							break;
						}
				    }
				}
				if (f) cnt++;
			}
			if (!f) break;
		}
		if (!f) continue;
		if (cnt > m) m = cnt;
	}
	cout << m << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

vector<pair<int, int> > g[100000];

pair<int, int> dfs(int v, int par = -1) {
  pair<int, int> ret = {0, v};
  for (auto &x : g[v]) {
    int w, cost;
    tie(w, cost) = x;
    if (w == par)
      continue;
    auto r = dfs(w, v);
    ret = max(ret,  {cost+r.first, r.second});
  }
  return ret;
}

int solve() {
  auto v = dfs(0);
  auto w = dfs(v.second);
  return w.first;
}

int main() {
  int n;
  scanf(" %d", &n);
  REP (i, n-1) {
    int x, y, d;
    scanf(" %d %d %d", &x, &y, &d);
    g[x].push_back({y, d});
    g[y].push_back({x, d});
  }
  int ret = solve();
  printf("%d\n", ret);
  
  return 0;
}

Measured memory_bytes: 14860
/*
 * Author       : YangDavid
 * Created Time : 2019年07月12日 星期五 10时28分09秒
 */

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

ll n, x;
ll solve(ll L, ll R) {
    if(L % R == 0) return 2LL * (L - R);
    return 2LL * L - R - (L % R) + solve(R, L % R);
}
int main() {
    cin >> n >> x;
    cout << x + solve(n, n - x) << endl;
    return 0;
}


Measured memory_bytes: 636
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
const int maxn=1e5+10;
using namespace std;
typedef long long ll;
ll n,a[maxn],tree[maxn*2],pre[maxn*2],l,r;
void add(int x,ll v)
{
	for(int i=x;i<=2*maxn;i+=i&-i)
    tree[i]+=v;
}
ll ask(int x)
{
    ll ans=0;
    for(int i=x;i>0;i-=i&-i)
    ans+=tree[i];
    return ans;
}
bool check(int mid)//最后的中位数应该是从右数第n*(n+1)/4个,即顺序对恰为n*(n+1)/4即答案 大于说明mid找小了 小于说明mid找大了 
{
	memset(tree,0,sizeof(tree));
	pre[0]=0;
	ll ans=0;
	for(int i=1;i<=n;++i)
	pre[i]=pre[i-1]+(a[i]>=mid?1:-1);
	//任意大于0的区间均可 即若pre[1]>0 应加上1即pre[0] 故从0开始 
	for(int i=0;i<=n;++i)
	{
		ans+=ask(pre[i]+maxn);//求[1,pre[i]+maxn]的值即比当前值小的已插入值 顺序对 
		//考虑到pre[i]最小可为-n,故移位maxn使之不为负 
		add(pre[i]+maxn,1ll);
	}
	return ans>=n*(n+1)/4;//前缀和顺序对的个数 即比mid要大的中位数个数 
	//如果大于 说明大于mid的中位数超过n*(n+1)/4个 mid一定不是中位数 
	//mid在前一半里 只有n*(n+1)/2为奇数且ans取等才可能是中位数
	//如果小于 则mid在后一半里,比n*(n+1)/2+1要大 
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
	 scanf("%d",&a[i]);
	 r=max(r,a[i]);
    }
    while(l<=r)//二分最后的中位数 
    {
    	int mid=(l+r)>>1; 
    	if(check(mid))l=mid+1;//mid可能符合条件 但mid一旦符合条件 l即保持mid+1不变 答案只可能是l-1即r
		else r=mid-1; 
    }
    printf("%d\n",r);
	return 0;
} 

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){

	char X,Y;
	cin>>X>>Y;
	
	if(X>Y){
		cout<<'>'<<endl;
	}
	else if(X<Y){
		cout<<'<'<<endl;
	}
	else{
		cout<<'='<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int k2 = k * 2;
        int[][] a = new int[k2 + 1][k2 + 1];
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt() % k2;
            int y = scanner.nextInt() % k2;
            if (scanner.next().equals("W")) {
                y = (y + k) % k2;
            }
            a[x + 1][y + 1]++;
        }

        for (int x = 1; x <= k2; x++) {
            for (int y = 1; y <= k2; y++) {
                a[x][y] += a[x - 1][y] + a[x][y - 1] - a[x - 1][y - 1];
            }
        }

        int ans = Integer.MIN_VALUE;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                int s1 = a[i][j] + a[0][0] - a[0][j] - a[i][0] +
                         a[k2][j] + a[i + k][0] - a[i + k][j] - a[k2][0] +
                         a[i + k][j + k] + a[i][j] - a[i][j + k] - a[i + k][j] +
                         a[i][k2] + a[0][j + k] - a[0][k2] - a[i][j + k] +
                         a[k2][k2] + a[i + k][j + k] - a[i + k][k2] - a[k2][j + k];
                int s2 = a[i][j + k] + a[0][j] - a[0][j + k] - a[i][j] +
                         a[i + k][j] + a[i][0] - a[i][j] - a[i + k][0] +
                         a[i + k][k2] + a[i][j + k] - a[i][k2] - a[i + k][j + k] +
                         a[k2][j + k] + a[i + k][j] - a[i + k][j + k] - a[k2][j];
                ans = Math.max(ans, Math.max(s1, s2));
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
	int a, b, c; cin >> a >> b >> c;
	int x = a + b; int y = b + c; int z = a + c;
	int n[3] = { x,y,z };
	int min = x;
	for (int i = 0; i < 3; i++)if (min > n[i]) { min = n[i]; }
	cout << min;
}

Measured memory_bytes: 256
N = int( input() )
A = list( map( int, input().split()))
L = [ 0 ] * ( 10 ** 5 )

for a in A:
  L[ a - 1 ] += 1
SumA = sum( A )

Q = int( input() )
for _ in range( Q ):
  b, c = map( int, input().split() )
  SumA += ( c - b ) * L[ b - 1 ]
  L[ c - 1 ] += L[ b - 1 ] 
  L[ b - 1 ] = 0
  print( SumA )

Measured memory_bytes: 20868
#include <iostream>
#include <cmath>
#include <iomanip>

#define PI 3.141592653589793

int main(void) {
    int H, M;
    double A, B;
    double H_angle, M_angle;
    double angle = 0;
    double d;
    
    std::cin >> A >> B >> H >> M;
    
    // H_angle = 360.0 * H / 12.0 + 30.0 * M / 60.0;
    // M_angle = 360.0 * M / 60.0;
    
    H_angle = PI * H / 6.0 + PI * M / 360.0;
    M_angle = PI * M / 30.0;
    
    angle = H_angle-M_angle;
    d = std::sqrt(A*A+B*B-2.0*A*B*std::cos(angle));
    
    // std::cout << H_angle << " : " << M_angle << std::endl;
    std::cout << std::setprecision(12) << d << std::endl;
    
    return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int ans1 = 0;
  int ans2 = 0;
  for(int i = 0; i < S.size(); i++) {
    if(i % 2 == 0) {
      if(S[i] != '0') {
        ans1++;
      }
      else {
        ans2++;
      }
    }
    else {
      if(S[i] != '1') {
        ans1++;
      }
      else {
        ans2++;
      }
    }
  }
  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int A = 0, B = 0, C = 0;
	int tmp = 0;

	cin >> A;
	cin >> B;
	cin >> C;

	for (int i = 100; i >= 1; i--) {
		tmp = A * i;

		if ((tmp % B) == C) {
			cout << "YES" << endl;
			return 0;
		}

	}
	cout << "NO" << endl;
	return 0;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a,x,b) (a<=x && x<=b)
#define WS std::cout<<" ";
#define NL std::cout<<"\n"
#define OUT(dist) std::cout<<(dist);
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;



int main(){
    INIT;
    int r; cin >> r;
    cout << 3*r*r;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
const int MOD = 1000000007;
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> f(n + 1, 1);
	for (int i = 2; i <= n; i++) {
		int keep = i;
		for (int j = 2; j <= i; j++) {
			int count = 0;
			while (keep % j == 0) {
				keep /= j;
				count++;
			}
			f[j] += count;
		}
	}
	ll ans = 1;
	for (int i = 2; i <= n; i++)
		ans = ans * f[i] % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    vector<int> ans(0);
    while(n != 1){
        ans.push_back(abs(n % (-2)));
        if(n % (-2) == 0) n = n / (-2);
        else n = (n + (-2 + 1)) / (-2);
    }
    ans.push_back(1);
    for(int i = ans.size() - 1; i >= 0; i--){
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

using namespace std;

int main(){
	long double a;
	scanf("%Lf",&a);
	double q=a/3,w=a/3,e=a/3;
	printf("%.12lf\n",q*w*e);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  cin >> a >>b;
  int A =a.size();
  int B =b.size();
  int ans =0;
  if(A>B){
    ans =1;
  }
  else if(A<B){
    ans =3;
  }
  else{
    for(int i = 0;i<A;i++){
      if(a.at(i) >b.at(i)){
        ans=1;
        break;
      }
      else if(a.at(i)<b.at(i)){
        ans =3;
        break;
      }
    }
  }
  if(ans ==1){
    cout << "GREATER";
  }
  else if(ans ==3){
    cout << "LESS";
  }
  else{
    cout << "EQUAL";
  }
}


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

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

ll lcm(ll a, ll b){
	return (a/gcd(a, b))*b;
}

ll n,m;

vector <ll> a[200003];

ll vis[200003];
ll cnt;

ll dfs(ll s)
{
	vis[s] = 1;
	cnt++;

	ll len = a[s].size();
	for(ll i = 0 ; i < len;i++)
	{
		if(vis[a[s][i]] == 0)
			dfs(a[s][i]);
	}

	return 0;
}



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

	ll i;
	cin >> n >> m;

	map <pair<ll,ll>,ll> ma;

	ll mas = 1;
	for(i=0;i<m;i++)
	{
		ll x,y;
		cin >> x >> y;

		pair <ll,ll> z,z1;

		z = mp(x,y);
		z1 = mp(y,x);


		if(ma.find(z) == ma.end() && ma.find(z1) == ma.end())
		{
			ma.insert(mp(z,1));
			a[x].pb(y);
			a[y].pb(x);
		}
	}

	memset(vis,0,sizeof(vis));
	for(i=0;i<n;i++)
	{
		cnt = 0;

		if(vis[i] == 0)
		{
			dfs(i);
		}

		mas = max(mas,cnt);
	}

	cout << mas << endl;
}

Measured memory_bytes: 37992
#include <cstdio>
#include <cstring>
#include <iostream>
#define MN 4010
#define mod 998244353

int f[MN][MN];
int r[MN], b[MN];
char s[MN];

int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1); 
	for(int i = 1; i <= n; i++)
	{
		int x = s[i] - '0';
		r[i] = r[i - 1]; b[i] = b[i - 1];
		if(x == 0) r[i] += 2;
		if(x == 1) r[i]++, b[i]++;
		if(x == 2) b[i] += 2;
	}
	for(int i = n + 1; i <= 2 * n; i++) r[i] = r[i - 1], b[i] = b[i - 1];
	f[0][0] = 1;
	for(int i = 1; i <= 2 * n; i++)
	{
		for(int j = 0; j <= i; j++)
		{
			int k = i - j;
			if(j > r[i] || k > b[i]) continue;
			if(j) f[i][j] = (f[i][j] + f[i - 1][j - 1]) % mod;
			if(k) f[i][j] = (f[i][j] + f[i - 1][j]) % mod;
		}
	}
	printf("%d\n", f[2 * n][r[n]]);
}

Measured memory_bytes: 60544
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1),dp(n+1,mod);
    REP(i,1,n) {
        cin>>h[i];
    }
    dp[n] = 0;
    REPN(i,n-1,1) {
        REP(j,1,min(k,n-i)) {
            dp[i] = min(dp[i],abs(h[i+j]-h[i])+dp[i+j]);
        }
    }
    cout<<dp[1];
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 1024
#include <stdio.h>

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

	return yuclid(b, a % b);
}

int gcd(int a, int b, int c) {
	return yuclid(yuclid(a, b), c);
}

int main() {
	int input;
	int i, j, k;
	long long int sum = 0;

	scanf("%d", &input);

	for(i = 1; i <= input; i++) {
		for(j = 1; j <= input; j++) {
			for(k = 1; k <= input; k++) {
				sum += gcd(k, j, i);
			}
		}
	}

	printf("%lld\n", sum);
	return 0;
}



Measured memory_bytes: 1728
#include<iostream>
#include<set>
using namespace std;
int n;
main()
{
	while(cin>>n,n)
	{
		set<int>M;
		for(int i=1;i<n;i++)M.insert(i*i%n);
		int cnt[5555]={};
		for(int a:M)
		{
			for(int b:M)
			{
				if(a==b)continue;
				int d=a-b;
				if(d<0)d+=n;
				if(d>n/2)d=n-d;
				cnt[d]++;
			}
		}
		for(int i=1;i<=n/2;i++)cout<<cnt[i]<<endl;
	}
}



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

int main(){
    int n;
    cin >> n;
    n = n%10;
    if(n==3)    cout << "bon" << endl;
    else if(n==0||n==1||n==6||n==8) cout << "pon" << endl;
    else    cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll n; cin >> n;
    ll ans = 0;

    if(n%1000!=0) ans = 1000 - n%1000;


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
using System;
using System.Linq;
public class Hello
{
    
    public static int[] dx = {1,0};
    public static int[] dy = {0,1};
    public static int max = 0;
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[,] board = new int[2, N];
        
        for(int i = 0; i < 2; i++)
        {
            int[] line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            for(int j = 0; j < N; j++)
            {
                board[i, j] = line[j];
            }
            
        }
        
        dfs(board, 0, 0, ref N, board[0, 0]);
        Console.WriteLine(max);
    }
    
    public static void dfs(int[,] board, int x, int y, ref int N, int sum)
    {
        
        if(y == 1 && x == N - 1)
        {
            max = Math.Max(sum, max);
            //Console.WriteLine("max = " + max);
            return;
        }
       
        for(int j = 0; j < 2; j++)
        {
            int next_y = y + dy[j];
            int next_x = x + dx[j];
            if(next_y >= 2 || next_x >= N )
            {
                continue;
            }
            else
            {
                //sumに次の移動先の値を加える
                sum += board[next_y, next_x];
                //Console.WriteLine("sum = " + sum);
                dfs(board, next_x, next_y, ref N, sum);
                sum -= board[next_y, next_x];
            }
            
        }
        
        return;
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cstring>
using namespace std;
main(){
  char str[10005][40];
  char cp[100];
  int max=0;
  int mpos=0;
  int saihin=1;
  int spos=0;
  int i=0;
  int ruiseki=1;
  while(cin>>str[i]){
    i++;
  }
  for(int j=0;j<i-1;j++){
    for(int k=i-1;k>j;k--){
      if(strcmp(str[k],str[k-1])<0){
	strcpy(cp,str[k]);
	strcpy(str[k],str[k-1]);
	strcpy(str[k-1],cp);
      }
    }
  }
  for(int j=1;j<i;j++){
    if(strlen(str[j])>max){
      max=strlen(str[j]);
      mpos=j;
    }
    if(strcmp(str[j],str[j-1])==0){
      ruiseki++;
    }
    else{
      ruiseki=1;
    }
    if(ruiseki>saihin){
      saihin=ruiseki;
      spos=j;
    }
  }
  cout<<str[spos]<<" "<<str[mpos]<<endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<< X <<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};

const int INF=100000000;
int mode=1;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=10000;i++){
		if((a*i)%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))
List = [0]*N
for i in range(M):
    A,B = map(int,input().split())
    if(H[A-1] > H[B-1]):
        List[B-1] = 1
    elif(H[A-1] < H[B-1]):
        List[A-1] = 1
    else:
        List[A-1] = 1
        List[B-1] = 1
print(str(List.count(0)))

Measured memory_bytes: 19952
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin>>x;
	int a=x/500;
	long long ans=a*1000;
	x-=a*500;
	a=x/5;
	ans+=a*5;
	cout<<ans<<endl;
	return 0;
}

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> broken(n+1);
    rep(i,m) {
        int a;
        cin >> a;
        broken[a] = 1;
    }
    vector<int> dp(n+2);
    const int mod = 1000000007;
    dp[n] = 1;
    for(int i=n-1;i >= 0;i--){
        if(broken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1]+dp[i+2]) % mod;
    }
    cout << dp[0] << endl;
}


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

int main(){
  int d;
  cin >>d;
  if(d == 25) cout << " Christmas" << endl;
  if(d == 24) cout << " Christmas Eve" << endl;
  if(d == 23) cout << " Christmas Eve Eve" << endl;
  if(d == 22) cout << " Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
// ABC068B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	int ans = 1;
	while (1) {
		if (ans * 2 > N) {
			break;
		}
		ans *= 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int ansMax[100001];
vector<int> v[100001];

int dfs(int x, int dist){
	if (ansMax[x]!=-1) return ansMax[x]; 
	//ansMax[x] = max(ansMax[x], dist);
	int maxLength = 0;
	int flag = 0;
	for(auto node: v[x]){
		flag = 1;
		//ansMax[node] = max(ansMax[node], dist+1);
		maxLength = max(maxLength, dfs(node, dist+1)); 
	}
	if (flag==0) return 0;
	return ansMax[x] = maxLength+1;
}


int main(){
	int n, m, x, y;
	cin >> n >> m;
	//vector<int> v[n+1];
	int in[n+1];
	mst0(in);
	memset(ansMax,-1,sizeof(ansMax));
	FOR0(i,m){
		cin>> x >> y;
		v[x].pb(y);
		in[y]++;
	}
	FOR1(i,n){
		if (in[i]==0) dfs(i,0);
	}
	int ans =  0;
	FOR1(i,n) {
		//cout << ansMax[i] << " ";
		ans = max(ans,ansMax[i]);
	}
	cout << ans;

}


Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, A = 0, C = 1, G = 2;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int dp[4][4][4] = {};
  dp[3][3][3] = 1;
  for (int it = 0; it < n; it++) {
    int nxt[4][4][4] = {};
    for (int cur = 0; cur < 4; cur++) {
      for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
          for (int k = 0; k < 4; k++) {
            if (cur == C && i == G && j == A) continue;
            if (cur == C && i == A && j == G) continue;
            if (cur == G && i == C && j == A) continue;
            if (cur == C && i == G && k == A) continue;
            if (cur == C && j == G && k == A) continue;
            (nxt[cur][i][j] += dp[i][j][k]) %= mod;
          }
        }
      }
    }
    swap(dp, nxt);
  }
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        (ans += dp[i][j][k]) %= mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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


def solve(N: int, D: int, X: "List[List[int]]"):
    count = 0
    for i in range(N):
        for j in range(i + 1,N):
            sum = 0
            for k in range(D):
                sum += (X[i][k] - X[j][k]) ** 2
            f = float(math.sqrt(sum))
            if f.is_integer():
                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
    D = int(next(tokens))  # type: int
    X = [ [ int(next(tokens)) for _ in range(D) ] for _ in range(N) ]  # type: "List[List[int]]"
    solve(N, D, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def merge(a, b):
    if a[0] > b[0]:
        if a[1] > b[0]:
            return a
        return a[0], b[0]
    if b[1] > a[0]:
        return b
    return b[0], a[0]


n = input()
a = map(int, raw_input().split())

dp = [(a[i], 0) for i in range(1 << n)]
for j in range(n):
    for mask in range(1, len(dp)):
        if mask & (1 << j):
            dp[mask] = merge(dp[mask], dp[mask ^ (1 << j)])

best = a[0]
for i in range(1, len(dp)):
    best = max(best, sum(dp[i]))
    print(best)


Measured memory_bytes: 76292
def solve():
  from collections import deque
  from sys import stdin
  
  f_i = stdin
  N = int(f_i.readline())
  
  e_color = {}
  edge = []
  adj = [[] for i in range(N)]
  for i in range(N - 1):
    a, b = map(int, f_i.readline().split())
    a -= 1
    b -= 1
    e = frozenset((a, b))
    e_color[e] = None
    edge.append(e)
    adj[a].append(b)
    adj[b].append(a)
  
  color_to_parent = [0] * N # color of edge between a vertex and its parent
  q = deque([0])
  notVisited = [True] * N
  notVisited[0] = False
  
  # BFS
  while q:
    v = q.popleft()
    color = 1
    for child in adj[v]:
      if notVisited[child]:
        if color == color_to_parent[v]:
          color += 1
        color_to_parent[child] = color
        e_color[frozenset((v, child))] = color
        color += 1
        notVisited[child] = False
        q.append(child)
  
  print(len(max(adj, key=len)))
  g = (e_color[e] for e in edge)
  print('\n'.join(map(str, g)))

solve()

Measured memory_bytes: 59132
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;


ll a[200005];
ll tmplist[100005];


int main(){
	int n;
	cin >> n;
	ll anstmp = 0;

	rep(i,n) {cin >> a[i]; anstmp^=a[i];}

	rep(i,n){cout << (anstmp^a[i]) << ' ';}
	prints();






    return 0;
}




Measured memory_bytes: 5000