akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)

MOD=10**9+7

N,K=map(int,input().split())
g=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

MAX=10**6
fc=[1]*MAX
inv=[1]*MAX
ifc=[1]*MAX

for i in range(2,MAX):
    fc[i]=i*fc[i-1]%MOD
    inv[i]=MOD-(MOD//i)*inv[MOD%i]%MOD
    ifc[i]=inv[i]*ifc[i-1]%MOD

def comb(n,k):
    if n<0 or k<0 or n-k<0:
        return 0
    return fc[n]*ifc[n-k]%MOD*ifc[k]%MOD

def dfs(cur,par):
    ret=1
    ch=len(g[cur])
    if par!=-1:
        ch-=1
    
    if par==-1:
        ret=comb(K-1,ch)*fc[ch]%MOD
    else:
        ret=comb(K-2,ch)*fc[ch]%MOD
        
        
    for dst in g[cur]:
        if dst==par:
            continue
        ret=ret*dfs(dst,cur)%MOD
    return ret

ans=K*dfs(0,-1)%MOD
print(ans)


Measured memory_bytes: 211032
/**
 *   
 *   Date: 18 August 2019
 *   Time: 17:31:37
**/
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a;
	string s;
	cin>>a;
	cin>>s;
	if(a>=3200)
		cout<<s;
	else
		cout<<"red";

return 0;
}

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

int main() {
  int n, k, i, li, ans;
  vector<int> bow;
  
  cin >> n >> k;
  for (i=0; i<n; i++) 
  {
    cin >> li;
    bow.push_back(li);
  }
  
  sort(bow.begin(), bow.end(), greater<int>());
  ans = accumulate(bow.begin(), bow.begin()+k, 0);
  
  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 rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int H,W;
cin >> H >> W;
vvi a(H,vi(W));
rep(h,H) rep(w,W) cin >> a[h][w];

vvi ans;
rep(h,H) {
    rep(w,W-1) {
        if(a[h][w] % 2 == 1) {
            ans.push_back({h+1,w+1,h+1,w+2});
            a[h][w+1]++;
        }
    }
}
rep(h,H-1) {
    if(a[h][W-1] % 2 == 1) {
        ans.push_back({h+1,W,h+2,W});
        a[h+1][W-1]++;
    }
}
int N = SZ(ans);
cout << N << endl;
rep(i,N) {
    rep(j,4) {
        if(j < 3) cout << ans[i][j] << ' ';
        else cout << ans[i][j];
    }
    cout << endl;
}
return 0;
}

Measured memory_bytes: 10032
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int X=stdIn.nextInt();
		int Y=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		int a[]=new int[A];
		int b[]=new int[B];
		int c[]=new int[C];
		int x=0,y=0,z=0;
		long ans=0;
		for(int i=0;i<A;i++){
			a[i]=stdIn.nextInt();
		}
		for(int i=0;i<B;i++){
			b[i]=stdIn.nextInt();
		}
		for(int i=0;i<C;i++){
			c[i]=stdIn.nextInt();
		}
		A--;B--;C--;
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		for(int i=0;i<X+Y;i++){
			if(x>=X)
				a[A]=0;
			if(y>=Y)
				b[B]=0;
			if(a[A]>=b[B]&&a[A]>=c[C]){
				ans+=a[A];x++;A--;
				if(A<0){
					A=0;
					a[A]=0;
				}
			}
			else
				if(b[B]>a[A]&&b[B]>=c[C]){
					ans+=b[B];y++;B--;
					if(B<0){
						B=0;
						b[B]=0;
					}
				}
				else
					if(c[C]>a[A]&&c[C]>b[B]){
						ans+=c[C];z++;C--;
						if(C<0){
							C=0;
							c[C]=0;
						}
					}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 95964
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	cout << (N + 1) / 2 << "\n";

	return 0;
}



Measured memory_bytes: 3616
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050
ll dp[N];
main(){
    vec color(N,-1),next(N,-1);
    ll n=in();
    rep(i,n){
        int c=in();
        if(color[c]!=-1)next[color[c]]=i;
        color[c]=i;
    }
    dp[0]=1ll;
    rep(i,n-1){
        dp[i+1]+=dp[i];
        dp[i+1]%=MOD;
        if(next[i]!=-1&&next[i]!=i+1){
            dp[next[i]]+=dp[i];
            dp[next[i]]%=MOD;
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 10112
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int x,y,z;
  cin>>x>>y;
  if(x<y)swap(x,y);
  while(1){
    z=x%y;
    if(z==0)break;
    x=y,y=z;
  }cout<<y<<endl;
  return 0;
}

Measured memory_bytes: 3124
//https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_2_C
//p072.cpp

#include<iostream>
using namespace std;

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j].value < A[j - 1].value) {
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

//バブルソートと選択ソートの結果を比較
bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit)return false;
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}

	for (int i = 0; i < N; i++) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	}else {
		cout << "Not stable" << endl;
	}
	return 0;
}




Measured memory_bytes: 3108
def gcd(a, b)
  a, b = b, a if a > b
  while b % a != 0
    d = a
    a = b % a
    b = d
  end
  a
end

def lcm(a, b)
  a * b / gcd(a, b)
end

n = gets.chomp.to_i
ts = n.times.map do
  gets.chomp.to_i
end

c = ts.inject do |a, b|
  lcm(a, b)
end

p c

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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<bool> AC(N, false);
  vector<int> WA(N, 0);

  int p;
  string s;
  for (int i = 0; i < M; i++) {
    cin >> p >> s;
    if (AC[p - 1]) {
      continue;
    }
    if (s == "AC") {
      AC[p - 1] = true;
    } else {
      WA[p - 1]++;
    }
  }

  int ac = 0, wa = 0;
  for (int i = 0; i < N; i++) {
    if (AC[i]) {
      ac++;
      wa += WA[i];
    }
  }

  cout << ac << " " << wa << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long n,k;
long long l[20],r[20];
long long d[200010];
long long mod=998244353;
long long lowbit(long long x)
{
    return x&-x;
}
void update(long long x,long long v)
{
    while(x<=n)
    {
        d[x]=(d[x]+v)%mod;
        x+=lowbit(x);
    }
}
long long query(long long x)
{
    long long res=0;
    while(x)
    {
        res=(res+d[x])%mod;
        x-=lowbit(x);
    }
    return res;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(long long i=1;i<=k;i++)
	{
		scanf("%lld%lld",&l[i],&r[i]);
	}
	update(1,1);
	for(long long i=2;i<=n;i++)
	{
		long long x=0;
		for(long long j=1;j<=k;j++)
		{
			x+=(query(max(i-l[j],0ll))%mod-query(max(i-r[j]-1,0ll))%mod)%mod;
			x=(x%mod+mod)%mod;
		}
		update(i,x);
	}
	printf("%lld",(((query(n)%mod-query(n-1)%mod)%mod)+mod)%mod);
	return 0;
}

Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
//#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main() {
	int n;
	while (cin >> n && n) {
		vi d(2 * n + 1, -1);
		d[0] = 0;
		rep(i, 0, n) {
			int in;
			cin >> in;
			d[in] = 1;
		}
		int taro = n, hana = n;
		int now = 0;
		for (int i = 0;; i++) {
			if (taro == 0 || hana == 0) break;
			if (i % 2 == 0) {
				if (now == 2 * n) {
					now = 0;
					continue;
				}
				rep(j, now + 1, 2 * n + 1) {
					if (d[j] == 1) {
						d[j] = 0;
						taro--;
						now = j;
						//o("t:" << j);
						break;
					}
					if (j == 2 * n) {
						now = 0;
					}
				}
			}
			else {
				if (now == 2 * n) {
					now = 0;
					continue;
				}
				rep(j, now + 1, 2 * n + 1) {
					if (d[j] == -1) {
						d[j] = 0;
						hana--;
						now = j;
						//o("h:" << j);
						break;
					}
					if (j == 2 * n) {
						now = 0;
					}
				}
			}
		}
		cout << hana << endl;
		cout << taro << endl;
	}
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
  public static void main(String[] args) {
    long INF = (long)Math.pow(10, 15);
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[M];
    int[] b = new int[M];
    long[] c = new long[M];
    for(int i = 0; i < M; i++) {
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
      c[i] = (-1) * sc.nextLong();
    }
    long[] dist = new long[N];
    for(int i = 0; i < N; i++) {
      dist[i] = INF;
    }
    dist[0] = 0;
    for(int i = 0; i < N - 1; i++) {
      boolean update = false;
      for(int j = 0; j < M; j++) {
        if(dist[a[j]] != INF && dist[b[j]] > dist[a[j]] + c[j]) {
          dist[b[j]] = dist[a[j]] + c[j];
          update = true;
        } 
      }
      if(!update) break;
    }
    long ans = dist[N - 1];

    for(int i = 0; i < N; i++) {
      dist[i] = INF;
    }
    dist[0] = 0;
    boolean[] negative = new boolean[N];
    for(int i = 0; i < N; i++) {
      boolean update = false;
      for(int j = 0; j < M; j++) {
        if(dist[a[j]] != INF && dist[b[j]] > dist[a[j]] + c[j]) {
          dist[b[j]] = dist[a[j]] + c[j];
          update = true;
          if(i == N - 1) negative[b[j]] = true;
          if(negative[a[j]]) negative[b[j]] = true;
        } 
      }
      if(!update) break;
    }
    if(negative[N - 1]) {
      System.out.println("inf");
    } else {
      System.out.println((-1) * ans);
    }    
  }
}

Measured memory_bytes: 30568
n = int(input())
n0 = n
digits = len(str(n))
s = 0

for ii in range(digits)[::-1]:
  s += int(n/10**ii)
  n -= int(n/10**ii) * 10**ii
  
if n0 % s == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <stdio.h>
int a[500001],n;

int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2+1;}

void maxHeapify(int a[],int i){
  int l,r,max=0,t;
  l=left(i);
  r=right(i);
  if(l<=n && a[l]>a[i])max=l;
  else max=i;
  if(r<=n && a[r]>a[max])max=r;

  if(max!=i){
    t=a[i];
    a[i]=a[max];
    a[max]=t;
    maxHeapify(a,max);
  }
}
void buildMaxHeap(int a[]){
  int i;
  for(i=n/2;i>=1;i--)maxHeapify(a,i);
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&a[i]);
  buildMaxHeap(a);
  for(i=1;i<=n;i++){
    printf(" %d",a[i]);
   }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;


const int MOD = 1000000007;


long long factorial(long long x) {
    long long ans = 1;
    while (x >= 1) {
        ans *= x;
        ans %= MOD;
        x--;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main() {
    // inputs
    int X, Y;
    cin >> X >> Y;

    long long A = 2 * Y - X;
    long long B = 2 * X - Y;

    if (A % 3 != 0 || B % 3 != 0 || A < 0 || B < 0) {
        cout << 0 << endl;
        return 0;
    }

    A /= 3;
    B /= 3;

    long long numerator = factorial(A+B);
    long long denominator = factorial(A) * factorial(B) % MOD;


    // cout
    cout << numerator * modinv(denominator, MOD) % MOD << endl;
    return 0;
}

// :!g++ -std=c++11 % && ./a.out



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

using namespace std;

long long n, q, a[100005], cnt[100005], ans;

int main() {
    cin >> n;
    for (long long i = 1; i <= n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        ans += a[i];
    }
    cin >> q;
    while (q--)
    {
        long long b, c;
        cin >> b >> c;
        ans += cnt[b] * (c - b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5156
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	class a implements Comparable{
		int i;
		a(int p){
			i = p;
		}
		public int compareTo(Object arg0) {
			return ((a)arg0).i - this.i;
		}
	}
	void run(){
		a[] d = new a[5];
		for(int i= 0 ; i < 5 ; i++){
			d[i] = new a(sc.nextInt());
		}
		Arrays.sort(d);
		for(int i= 0 ; i < 5 ; i++){
			System.out.print(d[i].i);
			if(i < 4){
				System.out.print(" ");
			}
		}
		System.out.println();
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

Measured memory_bytes: 11000
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

class Ruiwa():
    def __init__(self, a):
        self.H = h = len(a)
        self.W = w = len(a[0])
        self.R = r = a
        for i in range(h):
            for j in range(1,w):
                r[i][j] += r[i][j-1]

        for i in range(1,h):
            for j in range(w):
                r[i][j] += r[i-1][j]

    def search(self, x1, y1, x2, y2):
        if x1 > x2 or y1 > y2:
            return 0

        r = self.R
        rr = r[y2][x2]
        if x1 > 0 and y1 > 0:
            return rr - r[y1-1][x2] - r[y2][x1-1] + r[y1-1][x1-1]
        if x1 > 0:
            rr -= r[y2][x1-1]
        if y1 > 0:
            rr -= r[y1-1][x2]

        return rr


def main():
    n,m,q = LI()
    a = [[1 if c == '1' else 0 for c in S()] for _ in range(n)]
    b = [[0] * m for _ in range(n)]
    c = [[0] * m for _ in range(n)]
    for i in range(n):
        for j in range(m):
            if a[i][j] == 0:
                continue
            if i > 0 and a[i-1][j]:
                b[i][j] += 1
            if j > 0 and a[i][j-1]:
                c[i][j] += 1
    A = Ruiwa(a)
    B = Ruiwa(b)
    C = Ruiwa(c)
    rr = []
    for i in range(q):
        y1,x1,y2,x2 = LI_()
        r = A.search(x1,y1,x2,y2) - B.search(x1,y1+1,x2,y2) - C.search(x1+1,y1,x2,y2)
        rr.append(r)

    return '\n'.join(map(str,rr))


print(main())


Measured memory_bytes: 177700
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[3 * n];
        for (int i = 0 ; i < 3 * n ; i++) {
            a[i] = sc.nextLong();
        }

        Arrays.sort(a);

        long ans = 0;
        for (int i = 0 ; i < 2 * n ; i++) {
            if (i % 2 == 0) {
                ans += a[i + n];
            }
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 99388
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 998244353;
ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
//ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}

int main()
{
    FAST_IO;
    int n, h, w;
    cin>>n>>h>>w;
    if(n<h || n<w) return cout<<0<<nl,0;
    int ans = (n-h+1)*(n-w+1);
    cout<<ans<<nl;

    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int X;

  cin >> X;

  bool ans = false;

  if(X >= 2000){
    ans = true;
  }else
  {
    int d100 = X / 100;
    if(X <= d100 * 100 + 5 * d100){
      ans = true;
    }else{
      ans = false;
    }
  }
  
  if(ans){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }




  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


int main() {
	ll n, c, d[510][510], cc[510][510], ans = INF2;
	ll mcos[3][35];
	cin >> n >> c;
	for (int i = 1;i <= c;i++) {
		for (int j = 1;j <= c;j++)cin >> d[i][j];
	}
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n;j++)cin >> cc[i][j];
	}
	for (int i = 0;i < 3;i++) {
		for(int j=1;j<=c;j++)
			mcos[i][j] = INF2;
	}
	for (int i = 1;i <= c;i++) {
		ll m1 = 0, m2 = 0, m3 = 0;
		for (int j = 1;j <= n;j++) {
			for (int k = 1;k <= n;k++) {
				if ((j + k) % 3 == 0)m1 += d[cc[j][k]][i];
				else if ((j + k) % 3 == 1)m2 += d[cc[j][k]][i];
				else if ((j + k) % 3 == 2)m3 += d[cc[j][k]][i];
			}
		}
		mcos[0][i] = m1;
		mcos[1][i] = m2;
		mcos[2][i] = m3;
	}

	for (int i = 1;i <= c;i++) {
		for (int j = 1;j <= c;j++) {
			if (i == j)continue;
			for (int k = 1;k <= c;k++) {
				if (k == j || i == k)continue;
				ans = min(ans, mcos[0][i] + mcos[1][j] + mcos[2][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define sz(s) (ll)s.size()
#define print(d) cout << fixed << setprecision(15) << d
#define pii pair<ll,ll>
#define ppii pair<ll,pii>
#define ff first
#define ss second
const ll MOD = 1000000007;
const ll MAXN = 1e6 + 5;
const ll inf = 2e18;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update> ord_set;
#define debug(x) cerr << #x << " = " << x << endl


ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 

vector<ll>bombs;
vector<ll>quan;
vector<ll>prefix;
ll sum(ll l,ll r)
{
    if(l==inf&&r==inf)return 0;
    if(r==inf)r=sz(prefix);
    if(l==0)return prefix[r-1];
    return prefix[r-1] - prefix[l-1];
}


int main()
{
  fast
  ll n,d,a;
  cin >> n >> d >> a;
  ll points[n];
  ll health[n];
  pii p[n];
  fr(i,0,n)
  {
    cin >> points[i] >> health[i];
    p[i]=make_pair(points[i],health[i]);
  }
  sort(p,p+n);
  fr(i,0,n)
  {
    points[i]=p[i].first;
    health[i]=p[i].second;
  }
  fr(i,0,n)
  {
    if(i==0)
    {
        bombs.push_back(points[i]+d);
        quan.push_back(health[i]/a+(health[i]%a!=0));
        prefix.push_back(quan[0]);
    }
    else
    {
       ll l,r;
       auto it = lower_bound(bombs.begin(),bombs.end(),points[i]-d);
       auto it1 = upper_bound(bombs.begin(),bombs.end(),points[i]+d);
       if(it==bombs.end())
       {
        l=inf;
       }
       else
        l= it - bombs.begin();
       if(it1==bombs.end())
       {
        r=inf;
       }
       else
        r= it1 - bombs.begin();
       ll val=sum(l,r);
       health[i]-=(val*a);
       if(health[i]<0)health[i]=0;
       bombs.push_back(points[i]+d);
       quan.push_back(health[i]/a+(health[i]%a!=0));
       prefix.push_back(prefix[i-1]+quan[i]);
    }
  }
  cout << prefix[n-1];
  return 0;
}










Measured memory_bytes: 11476
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	ll N;
	cin >> N;

	vector<int> A(N);
	REP(i, N) cin >> A[i];
	sort(ALL(A));
	
	vector<int> B(N);
	REP(i, N) cin >> B[i];
	sort(ALL(B));
	
	vector<int> C(N);
	REP(i, N) cin >> C[i];
	sort(ALL(C));

	vector<int> sum(N + 1, 0);
	REP(i, N) {
		int idx = upper_bound(ALL(B), A[i]) - B.begin();
		sum[idx]++;
	}
	
	ll nowCnt = 0;
	ll ans = 0;
	REP(i, N) {
		ll idx = upper_bound(ALL(C), B[i]) - C.begin();
		nowCnt += sum[i];
		ans += (N - idx) * nowCnt;
	}

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


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

int main(){
  int n, m, X, Y, xmax, ymin, x, y;
  cin >> n >> m >> X >> Y;
  
  cin >> xmax;
  for(int i = 1; i < n; i++){
    cin >> x;
    if(x > xmax){
      xmax = x;
    }
  }
  
  cin >> ymin;
  for(int i = 0; i < m; i++){
    cin >> y;
    if(y < ymin){
      ymin =  y;
    }
  }
  
  if(min(Y, ymin) - max(X, xmax) > 0){
    cout << "No War";
  }
  else{
    cout << "War";
  }
}

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}
using P = pair<int,int>;
int k;
vector<ll> disvec(100000, 0);
vector<vector<P>> g(100000);

void dfs(int node, int par, ll dis){
	disvec[node] = dis;
	for(auto [n, d]: g[node]){
		if(n != par){
			dfs(n, node, dis + d);
		}
	}
}


void Main(){
	int n; cin >> n;
	
	Rep(n-1){
		int a,b,c; cin >> a >> b >> c;
		a--; b--;
		g[a].push_back(P(b,c));
		g[b].push_back(P(a,c));
	}
	int q; cin >> q >> k;
	k--;
	dfs(k, -1, 0);
	Rep(q){
		int x,y; cin >> x >> y;
		x--; y--;
		cout << disvec[x] + disvec[y] << endl;
	}
}


Measured memory_bytes: 14180
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long x = s.nextLong();
        long temp = x/500;
        long flag = x - 500*temp;
        long temp1 = flag/5;
        System.out.println(temp*1000 + temp1*5);
        }
    }



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

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

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N;
char A[555][555], in[555][555];
int ok[555], ex[555], exx[555];

int solve(){
  int i, j, k, fg;
  int res = MD, tmp;

  rep(i,N) ok[i] = ex[i] = 0;

  rep(i,N){
    k = 0;
    rep(j,N) if(A[j][i]=='#') k++;
    if(k==N) ok[i] = 1;
  }

  fg = 0;
  rep(i,N){
    k = 0;
    rep(j,N) if(A[i][j]=='#') k++;
    if(k==N) fg++;
  }

  if(fg){
    res = 0;
    rep(i,N) if(!ok[i]) res++;
    return res;
  }

  rep(i,N) rep(j,N) if(A[i][j]=='#') exx[i] = 1, ex[j] = 1;
  rep(i,N) rep(j,N) if(A[i][j]=='#') ex[j] = 1;
  rep(j,N) if(exx[j] || ex[j]){
    tmp = 0;
    if(ex[j]==0) tmp++;
    rep(k,N){
      if(A[j][k]!='#'){
        tmp += 2;
      } else if(ok[k]==0){
        tmp++;
      }
    }
    res = min(res, tmp);
  }

  return res;
}

int main(){
  int i, j, k, fg;
  int res, tmp;

  reader(&N);
  rep(i,N) reader(A[i]);

  res = solve();
  if(res == MD){ writerLn(-1); return 0; }

  writerLn(res);

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

const int N=3e5+5;
const int M=1e5+5;
int n,m,bit[M];

void upd(int x,int val){
	for(;x<M;x=x|(x+1))
		bit[x]+=val;
}

int get(int x){
	int cnt=0;
	for(;x>=0;x=(x&(x+1))-1)
		cnt+=bit[x];
	return cnt;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	vector<tuple<int,int,int>> seg;
	for(int i=0;i<n;++i){
		int l,r;
		cin>>l>>r;
		seg.emplace_back(r-l+1,l,r);
	}
	sort(seg.begin(),seg.end());
	reverse(seg.begin(),seg.end());
	for(int i=1;i<=m;++i){
		while(!seg.empty()&&get<0>(seg.back())<i){
			int len,l,r;
			tie(len,l,r)=seg.back();
			seg.pop_back();
			upd(l,1);
			upd(r+1,-1);
		}
		int res=int(seg.size());
		for(int j=0;j<=m;j+=i)
			res+=get(j);
		cout<<res<<'\n';
	}
}



Measured memory_bytes: 9468
X = int(input())

C = [0 for _ in range(X + 1)]
C[0] = 1
cost = [100, 101, 102, 103, 104, 105]

for x in range(X):
    for c in cost:
        if x + c > X:
            continue
        C[x + c] += C[x]

print(1 if C[X] != 0 else 0)


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

int main() {
  int N;
  cin>>N;
  vector<int> p(N+1);
  for(int i=1;i<=N;i++){
    cin>>p.at(i);
  }
  vector<int> q(N+1);
  vector<int> r={};
  for(int i=N;i>0;i--){
    int Z=0;
    for(int j=1;j<=N/i;j++){
      Z+=q.at(j*i);
    }
    if(Z%2!=p.at(i)){
      q.at(i)=1;
      r.push_back(i);
    }
  }
  cout<<r.size()<<endl;
  for(int i=0;i<r.size();i++){
    cout<<r.at(i);
    if(i<r.size()-1){
      cout<<" ";
    }
  }
  cout<<endl;
    
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int sum=0,fushu=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-') fushu=-fushu;
		c=getchar();
	}
	while(isdigit(c)){
		sum=sum*10+(c^48);
		c=getchar();
	}
	return sum*fushu;
}
void write(int x){//只能输出非负整数！！！比赛的时候看清楚！！！ 
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
inline void writeln(int x){
	write(x);
	putchar('\n');
}
int const maxn=1e5+5;
int n,cnt,H[maxn],dist[maxn];
struct Edge{
	int next,to,length;
}E[maxn<<1];
inline void add(int a,int b,int c){
	E[++cnt]=(Edge){H[a],b,c};
	H[a]=cnt;
}
void dfs(int x,int fa){
	for(int i=H[x];i;i=E[i].next){
		int y=E[i].to;
		if(y==fa) continue;
		dist[y]=dist[x]+E[i].length;
		dfs(y,x);
	}
}
signed main(){
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read(),z=read();
		add(x,y,z),add(y,x,z);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
	  writeln((dist[i]&1));
	return 0;
}

Measured memory_bytes: 8192
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll n;
	msetll a;

	REP(i, n)
	{
		inll a_;
		a.insert(a_);
	}

	ll al = 0, bo = 0;

	ITRREPR(it, a)
	{
		al += *it;
		if (++it != a.rend())
			bo += *it;
		else
			break;
	}

	return OUT(al - bo);
}


Measured memory_bytes: 256
#include"iostream"
#include"vector"
#include"math.h"
#include"iomanip"
#include"stdio.h"
using namespace std;

typedef struct
{
  double x,y;
}dVector;

int main()
{
  vector<dVector> point;
  dVector buf;
  dVector p1,p2,p3;
  double len;
  int n=2;
  buf.x=0;
  buf.y=0;
  point.push_back(buf);
  buf.x=100;
  point.push_back(buf);
  cin >> n;
  for(int j=0;j<n;j++)
    {
      for(int i=0;i<point.size()-1;)
        {
          p1.x=(2*point[i].x+point[i+1].x)/3;
          p1.y=(2*point[i].y+point[i+1].y)/3;
          p3.x=(point[i].x+2*point[i+1].x)/3;
          p3.y=(point[i].y+2*point[i+1].y)/3;
          if(p1.y==p3.y)
            {
              if(p1.x<p3.x)
                {
                  len=p3.x-p1.x;
                  p2.x=(p1.x+p3.x)/2;
                  p2.y=p1.y+sqrtl(len*len*3/4);
                }
              else
                {
                  len=p1.x-p3.x;
                  p2.x=(p1.x+p3.x)/2;
                  p2.y=p1.y-sqrtl(len*len*3/4);
                }
            }
          else
            {
              len=hypotl(p3.x-p1.x,p3.y-p1.y);
              if(p1.y<p3.y)
                {
                  if(p1.x<p3.x)
                    {
                      p2.x=p3.x-len;
                      p2.y=p3.y;
                    }
                  else
                    {
                      p2.x=p1.x-len;
                      p2.y=p1.y;
                    }
                }
              else
                {
                  if(p1.x<p3.x)
                    {
                      p2.x=p1.x+len;
                      p2.y=p1.y;
                    }
                  else
                    {
                      p2.x=p3.x+len;
                      p2.y=p3.y;
                    }
                }
            }
          point.insert(point.begin()+i+1,p3);
          point.insert(point.begin()+i+1,p2);
          point.insert(point.begin()+i+1,p1);
          i+=4;
        }
    }
  for(int i=0;i<point.size();i++)
    {
      printf("%f %f\n",point[i].x,point[i].y);
      //cout<<setprecision(10)<<point[i].x<<" "<<point[i].y<<endl;
    }
}


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

namespace _1_9_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string ca = "";
            string card = "";
            string c = "";
            int s = 0;
            while ((ca = Console.ReadLine()) != "-")
            {
                card = ca + ca;
                c = Console.ReadLine();
                s = int.Parse(c);
                for (int i = 0;i < s; i++)
                {
                    string str = Console.ReadLine();
                    int a = int.Parse(str);
                    card = card.Substring(a,ca.Length) + card.Substring(a, ca.Length);
                }
                Console.WriteLine("{0}",card.Substring(0,ca.Length));
            }
        }
    }
}



Measured memory_bytes: 15996
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	string S;cin>>S;
    
	// 解法
	bool ans = true;
	// printf("%s\n", S.c_str());
	if (S[0]==S[1] & S[1]==S[2]) ans = false;

	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


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

int main() {
	// your code goes here
    int n,k,i,j;
    cin>>n>>k;
    int arr[100005];
    for(i=1;i<=n;i++)
    cin>>arr[i];
    
    int dp[100005];
    for(i=1;i<=100005;i++)
    dp[i]=1e9;
    dp[1]=0;
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        if(i-j>0)
        {
            /*cout<<i<<" "<<j<<endl;
            cout<<dp[i]<<" "<<dp[j]<<endl;
            cout<<arr[i]<<" "<<arr[j]<<endl;*/
            dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
        }
    
        //cout<<"finally value of i "<<i<<" "<<dp[i]<<endl;
    }
    
    /*for(i=1;i<=n;i++)
    cout<<dp[i]<<" ";*/
    cout<<dp[n]<<endl;
        
	return 0;
}





Measured memory_bytes: 1024
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int n=as.nextInt();
		int i=1;
		String str;
		
		while(true){
			int x=i;
			if(x % 3 == 0){
				str=" "+String.valueOf(i);
				System.out.print(str);
			
			}
			
			else if(x % 10 == 3){
				str=" "+String.valueOf(i);
				System.out.print(str);
			}
			
			else{
				while(true){
					x=x/10;
					if(x == 0){
						break;
					}
				
				
					if(x % 10 == 3){
						str=" "+String.valueOf(i);
						System.out.print(str);
						break;
					}
					
					
				
				}
				
			}
				 
			
			if(i++ >= n){
				System.out.println();
				break;
			}
			
		}
		
		
		
		
		
			

	}

}

Measured memory_bytes: 28736
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	long toKey(int a, int b) {
		if (a < b) {
			return ((long) b) << 32 | (long) a;
		} else {
			return ((long) a) << 32 | (long) b;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<Integer>[] g = new Set[N];
		for (int i = 0; i < N; ++i) {
			g[i] = new HashSet<>();
		}
		int[] rep = new int[N];
		for (int i = 0; i < N; ++i) {
			rep[i] = i;
		}
		ArrayDeque<Long> pend = new ArrayDeque<>();
		for (int i = 0; i < 2 * (N - 1); ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			--a;
			--b;
			if (g[a].contains(b)) {
				pend.add(toKey(a, b));
			}
			g[a].add(b);
			g[b].add(a);
		}
		DJSet ds = new DJSet(N);
		while (!pend.isEmpty()) {
			long key = pend.poll();
			int a = (int) (key >> 32);
			int b = (int) (key);
			a = rep[ds.root(a)];
			b = rep[ds.root(b)];
			if (ds.equiv(a, b))
				continue;
			ds.setUnion(a, b);
			if (g[a].size() < g[b].size()) {
				int tmp = a;
				a = b;
				b = tmp;
			}
			g[a].remove(b);
			g[b].remove(a);
			for (int v : g[b]) {
				g[v].remove(b);
				g[v].add(a);
				if (g[a].contains(v)) {
					pend.add(toKey(v, a));
				}
				g[a].add(v);
			}
			g[b].clear();
			rep[ds.root(b)] = a;
		}
		if (ds.size(0) == N) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	class DJSet {
		int n;
		int[] upper;

		public DJSet(int n) {
			this.n = n;
			upper = new int[n];
			Arrays.fill(upper, -1);
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		int root(int x) {
			return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
		}

		void setUnion(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (size(x) < size(y)) {
				int tmp = x;
				x = y;
				y = tmp;
			}
			upper[x] += upper[y];
			upper[y] = x;
		}

		int size(int x) {
			return -upper[root(x)];
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 199288
#include<stdio.h>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=200100,P=998244353;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar( ));
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,m,A,B;
ll ans;
char a[N],b[N];
int main(){
	ll i,j,ia,ib;
	n=read();m=read();
	scanf("%s",a+1);
	scanf("%s",b+1);
	ans=1ll*n/__gcd(n,m)*m;
	A=ans/n;B=ans/m;
	i=j=1;ia=ib=1;
	while(i<=ans&&j<=ans){
		if(i==j)
			if(a[ia]!=b[ib])goto fuck;
		if(i<=j)ia++,i+=A;
		else ib++,j+=B;
	}write(ans);puts("");
	return 0;fuck:puts("-1");
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int n, bunkai[101][101], jisu[1010], ans;
vector<int> sosubox;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 2; i <= 100; i++){
        bool sosu = true;
        for (int j = 2; j < i; j++){
            if (i % j == 0) sosu = false;
        }
        if (sosu) sosubox.push_back(i);
    }
    for (int i = 1; i <= 100; i++){
        for (int j = 0; j < sosubox.size(); j++){
            int a = i;
            while(a % sosubox[j] == 0){
                bunkai[i][sosubox[j]]++;
                a /= sosubox[j];
            }
        }
    }
    for (int i = 1; i < 100; i++){
        for (int j = 1; j < 100; j++){
            bunkai[i + 1][j] += bunkai[i][j];
        }
    }
    for (int i = 1; i < 100; i++){
        jisu[bunkai[n][i]]++;
    }
    for (int i = 100; i > 0; i--){
        jisu[i - 1] += jisu[i];
    }
    ans += jisu[4] * (jisu[4] - 1) / 2 * max(jisu[2] - 2, 0);
    ans += jisu[14] * max(jisu[4] - 1, 0);
    ans += jisu[24] * max(jisu[2] - 1, 0);
    ans += jisu[74];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define reps(i, s, e) for (ll i = s; i < e; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, s, e) for (ll i = e-1; i >= s; --i)
#define rrep(i, n) rreps(i, 0, n)

// const ll LL_INF = 1LL<<60;

template <class T> inline void chmin(T& a, T b) {if (a > b) {a = b;}}
template <class T> inline void chmax(T& a, T b) {if (a < b) {a = b;}}

using namespace std;

ll inline decode(string& str) {
    istringstream ss(str);
    ll res;
    ss >> res;
    return res;
}

int main() {
    stack<ll> st;

    string str;
    getline(cin, str);
    istringstream ss(str);

    while(true) {
        string str;
        ss >> str;
        if (str[0] >= '0' && str[0] <= '9') st.push(decode(str));
        else {
            ll left = st.top();
            st.pop();
            ll right = st.top();
            st.pop();
            if (str[0] == '+') st.push(left + right);
            else if(str[0] == '-') st.push(- left + right);
            else st.push(left * right);
        }
        if (ss.eof()) break;
    }
    cout << st.top() << endl;    
}


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

int main(){
  string  S;
  int count=0;
  int ans;
  int i;
  
  cin>>S;
  for(i=0;i<3;i++){
    if(S[i]=='o')count++;
  }
  ans=700+100*count;
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
struct L {
  int a, b, c;
  L(int a=0, int b=0, int c=0): a(a), b(b), c(c) {}
};
 
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
int main() {
  int n, m;
  cin >> n >> m;
  map<int,int> mpX, mpY;
  mpX[0] = 0;
  mpY[0] = 0;
 
  vector<L> lh, lv;
  rep(i,n) {
    int a, b, c;
    cin >> a >> b >> c;
    mpX[a] = 0;
    mpX[b] = 0;
    mpY[c] = 0;
    lh.emplace_back(a,b,c);
  }
  rep(i,m) {
    int a, b, c;
    cin >> c >> a >> b;
    mpY[a] = 0;
    mpY[b] = 0;
    mpX[c] = 0;
    lv.emplace_back(a,b,c);
  }
 
  vector<int> xs, ys;
  for (auto& p : mpX) {
    p.second = xs.size();
    xs.push_back(p.first);
  }
  for (auto& p : mpY) {
    p.second = ys.size();
    ys.push_back(p.first);
  }
 
  int h = xs.size()*2;
  int w = ys.size()*2;
 
  vector<vector<int>> d(h, vector<int>(w));
  rep(i,n) {
    int a = mpX[lh[i].a]*2;
    int b = mpX[lh[i].b]*2;
    int c = mpY[lh[i].c]*2;
    for (int x = a; x <= b; ++x) d[x][c] = -1;
  }
  rep(i,m) {
    int a = mpY[lv[i].a]*2;
    int b = mpY[lv[i].b]*2;
    int c = mpX[lv[i].c]*2;
    for (int y = a; y <= b; ++y) d[c][y] = -1;
  }
 
  queue<P> q;
  int sx = mpX[0]*2, sy = mpY[0]*2;
  d[sx][sy] = 1;
  q.emplace(sx,sy);
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    rep(v,4) {
      int nx = x+dx[v], ny = y+dy[v];
      if (nx < 0 || nx >= h) continue;
      if (ny < 0 || ny >= w) continue;
      if (d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx,ny);
    }
  }
 
  ll ans = 0;
  rep(x,h)rep(y,w) {
    if (d[x][y] != 1) continue;
    if (x == 0 || x == h-1 || y == 0 || y == w-1) {
      cout << "INF" << endl;
      return 0;
    }
    if (x%2 == 0 || y%2 == 0) continue;
    ll ex = xs[x/2+1]-xs[x/2];
    ll ey = ys[y/2+1]-ys[y/2];
    ans += ex*ey;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 144448