akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main(){
	string s, t;
	cin >> s;
	cin >> t;
	int n = s.size();
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j){
			if(s[(i + j) % n] != t[j]) break;
			if(j == n - 1){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    static void solve() {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();

        int[] arr = new int[n];
        for (int i = 0;i<n;i++) {
            arr[i] = scan.nextInt();
        }
//        long prevRes = 1;
//        for(int i=0;i<k;i++) {
//            prevRes*=arr[i];
//        }
        int cutoffInd = 0;
        for(int i = k;i<n;i++) {
            if(arr[i] > arr[cutoffInd]) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            cutoffInd++;
//            long curr = prevRes/arr[cutoffInd]*arr[i];
//            if(curr > prevRes) {
//                System.out.println("Yes");
//            } else {
//                System.out.println("No");
//            }
//            prevRes = curr;
//            cutoffInd++;
        }


//        for (int i = 0; i < n; i++) {
//
//        }

//        int t = scan.nextInt();
//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
//            int[] arr1 = new int[n];
//            for (int j = 0; j < n; j++) {
//                arr1[j] = scan.nextInt();
//            }
////            scase(n, arr1);
//        }


//        long t = scan.nextLong();

//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
////            scase(n);
//        }
    }


    static void solveCase(int t, int x, String s) {

    }

    static void scase(int[] arr1, int[] arr2) {
    }


    public static void main(String[] args) {

        solve();

    }


//
//    class Counter extends HashMap<Integer, Integer> {
//        public int get(int k) {
//            return containsKey(k) ? super.get(k) : 0;
//        }
//
//        public void add(int k, int v) {
//            put(k, get(k) + v);
//        }
//    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }
}

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

using namespace  std;

int n;
string s;

int main () {
	cin >> n;
	cin >> s;
	if(n % 2 == 1) {
		cout << "No";
		return 0;
	}
	for(int i = 0; i < n / 2; i++) {
		if(s[i] == s[i + n / 2]) {
		}
		else {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
# 入力
N = int(input())
b = list(map(int, input().split()))


# 逆順から操作手順を求める
def f(c):
    j = max([j for j, x in enumerate(c, 1) if j == x], default=0)
    return (
        f(c[:(j-1)] + c[j:]) + [j] if j and len(c) >= 2 else
        [j] if j and len(c) == 1 else
        []
    )


res = f(b)

# 出力
ans = '\n'.join(map(str, res)) if len(res) == N else -1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define debug(x) cerr << #x << " : " << x << "\n"
typedef long long ll;
 
// code //


int main() {
	int n;
	cin >> n;
	cout << (n % 2 == 0 ? n : n*2);
}


Measured memory_bytes: 3600
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N, M = l_inpl()
    AB = []
    for _ in range(N):
        AB.append(l_inpl())


    AB.sort(reverse=True)

    q = []
    ans = 0

    for remain_day in range(1, M+1):
        while True:
            if len(AB) > 0 and AB[-1][0] <= remain_day:
                _, b = AB.pop()
                heappush(q, -b)
            else:
                break
        if q:
            ans += -heappop(q)
    print(ans)
if __name__ == "__main__":
    main()


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

void	PF(long P, vector<int> &U, vector<bool> &PR) {
	long PP=sqrt(P)+2;
	long UU=2;
	while (true) {
		if (UU>=PR.size()) break;
		if (PR.at(UU)) {
			while (0==P%UU) {
				U.push_back(UU);
				P /=UU;
			}
		}
		if (2==UU)
			UU=3;
		else
			UU +=2;
	}
	if (1!=P)
		U.push_back(P);
	return;
}

int	main() {
	int N;
	cin >>N;
	vector<int> P;
	vector<bool> PR(35, true);
	for (int i=2; i<35; i++)
		if (PR.at(i))
			for (int j=i+i; j<35; j+=i)
				PR.at(j)=false;
	long S=1;
	if (N>1) {
		for (int i=2; i<=N; i++)
			PF(i, P, PR);
		sort(P.begin(), P.end());
		vector<int> C;
		C.push_back(1);
		for (int i=1; i<P.size(); i++)
			if (P.at(i)==P.at(i-1))
				C.at(C.size()-1)++;
			else
				C.push_back(1);
		for (int i=0; i<C.size(); i++) {
			S *=C.at(i)+1;
			S %=1000000007;
		}
	}
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<double>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void input(BigNum* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atof(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atof(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	const int a = s[0], b = s[1];

	if (a == b) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  int a=N*(N+1)/2;
  if(N%2){
    cout<<N*(N-1)/2-(N-1)/2<<endl;
    for(int i=1;i<=N;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j==N)continue;
        cout<<i<<" "<<j<<endl;
      }
    }
  }
  else{
    cout<<N*(N-1)/2-N/2<<endl;
    for(int i=1;i<=N;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j==N+1)continue;
        cout<<i<<" "<<j<<endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <vector>

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

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

int cntS[26],cntT[26];
int nex[101010][26];
int INF=1e9;

int main(){
  string S,T; cin>>S>>T;
  rep(i,S.length()) cntS[S[i]-'a']++;
  rep(i,T.length()) cntT[T[i]-'a']++;
  rep(i,26){
    if(cntS[i]==0&&cntT[i]>0){
      cout<<-1<<endl;
      return 0;
    }
  }
  rep(i,26) nex[S.length()][i]=INF;
  for(int i=S.length()-1;i>=0;i--){
    rep(j,26){
      if(S[i]-'a'==j){
        nex[i][j]=i;
      }else{
        nex[i][j]=nex[i+1][j];
      }
    }
  }
  int s=0,t=0,inc=0;
  ll ans=0;
  while(t<T.length()){
    int tt=T[t]-'a';
    if(nex[s][tt]<INF){
      if(t==T.length()-1){
        ans=nex[s][tt]+1;
      }
      s=nex[s][tt]+1;
      t++;
    }else{
      inc++;
      s=0;
    }
  }
  ans+=1LL*inc*S.length();
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  if (A == B) {
    printf("%d", C);
  } else if (B == C) {
    printf("%d", A);
  } else {
    printf("%d", B);
  }
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
t = 1

while a != 0 and b != n + 1:
    if t:
        if a + 1 == b:
            a -= 1
        else:
            a += 1
    else:
        if b - 1 == a:
            b += 1
        else:
            b -= 1
    t ^= 1

print('Alice' if t else 'Borys')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 100005
int a[N],b[N],v[N],vv[N];
vector<int> t,ans;
vector<pii> G[N];
bool vis[N];
int n,m;
int dfs(int u)
{
	vis[u]=1;
	int cur=vv[u];
	for(int i=0;i<G[u].size();i++)
	{
		int to=G[u][i].fir;
		if(vis[to]) continue;
		int x=dfs(to);
		if(x) ans.pb(G[u][i].sec);
		cur^=x;
	}
	return cur;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	cin>>n>>m;
	for(int i=0;i<n;i++) a[i]=read(),b[i]=read();
	for(int i=0;i<n;i++) t.pb(a[i]);
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	for(int i=0;i<n;i++)
	{
		a[i]=lower_bound(t.begin(),t.end(),a[i])-t.begin();
		v[a[i]]=b[i];
	}
	v[n]=0;
	int cur=0;
	for(int i=0;i<=n;i++)
	{
		if(cur^v[i])
		{
			vv[i]=1,cur^=1;
		}
	}
	for(int i=1;i<=m;i++)
	{
		int l=read(),r=read();
		l=lower_bound(t.begin(),t.end(),l)-t.begin();
		int p=lower_bound(t.begin(),t.end(),r)-t.begin();
		if(!(p<t.size()&&t[p]==r)) p--;
		r=p+1;
//		printf("%d %d\n",l,r);
		G[l].pb(mp(r,i));
		G[r].pb(mp(l,i));
	}
	for(int i=0;i<=n;i++)
	{
		if(!vis[i])
		{
			if(dfs(i))
			{
				cout<<"-1\n";
				return 0;
			}
		}
	}
	cout<<ans.size()<<endl;
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++) printf("%d ",ans[i]);
	cout<<"\n";
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
#define LINEY "YES\n"
#define Liney "Yes\n"
#define LINEN "NO\n"
#define Linen "No\n"


int main(){
  int N; cin >> N;
  ll worst_r =0;
  ll worst_v = pow(10,9)+1;
  ll a,b;
  REP(i,N){
    cin >> a >>b;
    if(a>worst_r){
      worst_r = a;
      worst_v = b;
    }
  }
  ll r = worst_r + worst_v;
  cout << r << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   //freopen("error.txt", "w", stderr); 
   freopen("output.txt", "w", stdout); 
#endif 
   
 ll T = 1 ;
 //cin>>T;

 for(ll t=0;t<T;t++)
 {
  ll a , b , c , d;
  cin>>a>>b>>c>>d;
  ll x = a*c , y = a*d ,  z = c*b , w = d*b;
  cout<<max(x,(max(y,max(z,w))));

 }
  return 0;
}


Measured memory_bytes: 3648
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

class Node {
   public:
   // long vertex;
   vector<long> to;
   // vector<long> length;
   // int grp;
   long len = 0;
   bool seen = false;
   bool finish = false;
   Node(){;};
};
vector<Node> vGr;

ll dfs(int vertex) {
   if (vGr[vertex].seen) return vGr[vertex].len;
   vGr[vertex].seen = true;
   ll len = 0;
   for (auto el : vGr[vertex].to) {
      chmax(len,dfs(el)+1);
   }
   vGr[vertex].finish = true;
   vGr[vertex].len = len;
   return vGr[vertex].len;
};

int main(void) {
   ll N,M;
   cin>>N>>M;
   vGr.resize(N);
   rep(i,M) {
      ll x,y;
      cin>>x>>y;
      vGr[x-1].to.push_back(y-1);
   }
   rep(i,N) {
      if (!vGr[i].seen) dfs(i);
   }
   ll ans = 0;
   rep(i,N) chmax(ans,(ll)vGr[i].len);
   cout<<ans<<endl;


   return 0;
}

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

int n, ans = 0;
int a[100000];
bool flag[100000];

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

	for (int i = 0; i < n; i++) {
		if (!flag[i]) {
			if (a[a[i]] == i) {
				ans++;
				flag[i] = true;
				flag[a[i]] = true;
			}
		}
	}

	cout << ans << endl;
}

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const int MOD = (int)1e9 + 7;

VVL comb;
void init_comb(int n) {
    comb.resize(n + 1, VL(n + 1, 0));
    FOR(i, 0, n) comb[i][0] = 1;
    FOR(i, 1, n)
    FOR(j, 1, i) {
        comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
        comb[i][j] %= MOD;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    init_comb(n);
    FOR(i, 1, k) {
        ll devide_cnt = comb[k - 1][i - 1];
        ll ans = devide_cnt * comb[n - k + 1][i] % MOD;
        cout << ans << ln;
    }
    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<vector<P>> graph(n);
    for(int i = 0; i < n - 1; ++i){
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        graph[u].emplace_back(v, w);
        graph[v].emplace_back(u, w);
    }
    vector<int> coloring(n, -1);
    coloring[0] = 0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int from = que.front();
        que.pop();
        int c = coloring[from];
        for(auto e : graph[from]){
            int to = e.first, cost = e.second;
            if(coloring[to] != -1)  continue;
            if(cost % 2 == 0)   coloring[to] = c;
            else    coloring[to] = c ^ 1;
            que.push(to);
        }
    }
    for(int x : coloring)   cout << x << '\n';
}

Measured memory_bytes: 6784
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
  int n;
  double x, y, deg, rad;
  
  x = y = deg = rad = 0;
  while (1){
    scanf("%d,%lf", &n, &deg);
    if (n == 0 && deg == 0){
      break;
    }
    x += cos(rad) * n;
    y += sin(rad) * n;
    deg = deg / 180 * M_PI;
    rad += deg;
  }

  printf("%d\n%d\n",(int) y,(int) x);
  return 0;
}

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


void call(int n) {
    int i = 1;
    do {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            do {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;;
                }
                x /= 10;
            } while (x);
        }
    } while (++i <= n);
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    call(n);
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	string t="#"+s;
	vector<int>red(n+1),green(n+1),blue(n+1);
	int sum1=0,sum2=0,sum3=0;
	for(int i=1; i<=n; i++)
	{
		if(t[i]=='R')
		 sum1++;
		if(t[i]=='G')
		 sum2++;
		if(t[i]=='B')
		 sum3++;
		red[i]=sum1;
		green[i]=sum2;
		blue[i]=sum3;
	}
	ll ans=0;
	for(int i=1; i<=n-2; i++)
	{
		for(int j=i+2; j<=n; j++)
		{
			if(t[i]==t[j])
			 continue;
			if(t[i]!='R' && t[j]!='R')
			{
				ans+=red[j]-red[i];
				if((i+j)%2==0)
				{
					if(t[(i+j)/2]=='R')
					 ans--;
				}
			}
			else if(t[i]!='G' && t[j]!='G')
			{
				ans+=green[j]-green[i];
				if((i+j)%2==0)
				{
					if(t[(i+j)/2]=='G')
					 ans--;
				}
			}
			else if(t[i]!='B' && t[j]!='B')
			{
				ans+=blue[j]-blue[i];
				if((i+j)%2==0)
				{
					if(t[(i+j)/2]=='B')
					 ans--;
				}
			}
			
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(){
        int a,h,m,s,b;
        scanf("%d" ,&a);
        h = a/3600;
        b = a%3600;
        m = b/60;
        s = b%60;



        printf("%d:%d:%d\n",h,m,s);
        return 0;
}

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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

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

inline bool inside(int y, int x, int H, int W)
{
  return (y >= 0 && x >= 0 && y < H && x < W);
}

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

string K;
int D, N;
ll dp[100005][105][2]; // dp[i][j][k]:=先頭からi桁目まで確定していて、各桁の数字のmod Dの総和がjで、今見ている範囲においてK以下か

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>K>>D;
  int N=K.length();
  
  dp[0][0][0]=1;
  
  rep(dgt, N) rep(d, D) rep(isless, 2){
    int c=K[dgt]-'0';
    rep(nxt, 10){
      if(!isless && nxt>c) continue;
      
      ll m=(d+nxt)%D; // 次の桁でのmod Dの総和
      if(nxt<c) dp[dgt+1][m][1]+=dp[dgt][d][isless];
      else if(nxt==c) dp[dgt+1][m][isless]+=dp[dgt][d][isless];
      else if(nxt>c) dp[dgt+1][m][isless]+=dp[dgt][d][isless];
      
      dp[dgt+1][m][isless]%=MOD;
    }
  }
  
  ll ans=(dp[N][0][0]+dp[N][0][1]-1+MOD)%MOD;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int ma = x;
	int mi = y;
	for (int i = 0; i < n; i++) {
		int s;
		cin >> s;
		ma = max(ma, s);
	}
	for (int i = 0; i < m; i++) {
		int s;
		cin >> s;
		mi = min(mi, s);
	}
	if (ma < mi) { cout << "No War"; }
	else { cout << "War"; }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;

namespace CPLib
{
    class Atria
    {
        static void Main(string[] args)
        {
            long n = long.Parse(ReadLine());
            long[,] dp = new long[n+2,3];
            long[,] a = new long[n+2, 3];
            for (int i = 0; i < n; i++)
            {
                int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (int j = 0; j < 3; j++)
                {
                    a[i, j] = s[j];
                }
            }
            for (long i = 0; i <= n; i++)
            {
                for (long j = 0; j < 3; j++)
                {
                    for (long k = 0; k < 3; k++)
                    {
                        if (j == k) continue;
                        ChMax(ref dp[i+1, k], dp[i, j] + a[i, k]);
                    }
                }
            }
            long res = 0;
            for (long i = 0; i < 3; i++)
            {
                ChMax(ref res, dp[n, i]);
            }
            WriteLine(res);
        }
        static bool ChMax(ref long a, long b)
        {
            if (a < b)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


Measured memory_bytes: 21812
n = int(input())
dist = []
max1 = -pow(10, 11)
min1 = pow(10, 11)
max2 = -pow(10, 11)
min2 = pow(10, 11) 
for i in range(n):
    x, y = (int(x) for x in input().split())
    if max1 < x + y:
        max1 = x + y
    if min1 > x + y:
        min1 = x + y
    if max2 < x - y:
        max2 = x - y
    if min2 > x - y:
        min2 = x - y
print(max(max1-min1, max2-min2))



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

int main() {
    int k, t; cin >> k >> t;
    vector<int> a(t, 0);
    for(int i = 0; i < t; ++i) 
        cin >> a[i];

    sort(a.rbegin(), a.rend());

    int others = k - a[0];

    cout << max(0, a[0] - 1 - others) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int a[4]; // NWSE
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='N') a[0]=1;
        if(s[i]=='W') a[1]=1;
        if(s[i]=='S') a[2]=1;
        if(s[i]=='E') a[3]=1;
    }
    if((a[0]^a[2])||(a[1]^a[3])) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
#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>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char A[2050];
char B[2050];

int L[2050];
int R[2050];

int mx1[2050];
int mx2[2050];
int getans(char* A, char* B) {
	int N = strlen(A), i, j;
	for (i = 0; i < N; i++) if (B[i] == '1') break;
	if (i >= N) {
		for (i = 0; i < N; i++) if (A[i] == '1') return INF;
		return 0;
	}

	for (i = 0; i < N; i++) {
		for (j = i;; j--) if (B[(j + N) % N] == '1') break;
		L[i] = j;
		for (j = i;; j++) if (B[j%N] == '1') break;
		R[i] = j;
	}

	int rv = INF;
	for (i = 0; i < N; i++) {
		vector <pii> Vu;
		int x = i;
		for (j = 0; j < N; j++) {
			if (A[j] == B[(j - i + N) % N]) continue;
			x++;

			int s = -i + j, e = j;
			if (L[e] >= s) continue;

			Vu.emplace_back(R[e] - e, (s+N)%N - L[(s+N)%N]);
		}
		sort(all(Vu));

		mx1[0] = 0;
		for (j = 0; j < Vu.size(); j++) mx1[j + 1] = max(mx1[j], Vu[j].first);
		mx2[Vu.size()] = 0;
		for (j = (int)Vu.size() - 1; j >= 0; j--) mx2[j] = max(mx2[j + 1], Vu[j].second);

		for (j = 0; j <= Vu.size(); j++) rv = min(rv, x + 2 * (mx1[j] + mx2[j]));
	}
	return rv;
}
int main() {
	scanf("%s %s", A, B);
	
	int N = strlen(A);
	int ans = getans(A, B);
	reverse(A, A + N);
	reverse(B, B + N);
	ans = min(ans, getans(A, B));
	if (ans == INF) ans = -1;
	return !printf("%d\n", ans);
}

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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int dp[3005][3005];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int k = t.size();
	s += '*';
	t += '&';
	rep(i, n + 1)rep(j, k + 1) {
		maxs(dp[i + 1][j], dp[i][j]);
		maxs(dp[i][j + 1], dp[i][j]);
		if (s[i] == t[j]) maxs(dp[i + 1][j + 1], dp[i][j] + 1);
	}
	string ans = "";
	int i = n, j = k;
	while (i >= 1 and j >= 1) {
		int x = dp[i][j];
		if (i && dp[i - 1][j] == x) {
			i--;
		}
		else if (j && dp[i][j - 1] == x) {
			j--;
		}
		else {
			i--; j--;
			ans += s[i];
		}
	}
	reverse(all(ans));
	cout << ans << endl;
	return 0;
}


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

#define rep(i, u) for (int i = 0; i < u; i++)

int main() {
  int a;
  rep(i, 10000) {
    cin >> a;
    if (a == 0) break;
    cout << "Case " << i + 1 << ": " << a << endl;
  }
  return 0;
}



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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int A,B,C; cin>>A>>B>>C;
	cout << (!(C<A)&&!(C>B) ? "Yes" : "No") << endl;
	return 0;
}


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

if x<=6:
    print("1")
    exit()
elif x<=11:
    print("2")
    exit()
else:
    ans=((x//11)*2)
    if x%11==0:
        print(ans)  
    elif x%11<=6:
        print(ans+1)
    else:
        print(ans+2)

Measured memory_bytes: 3060
A, B = map(int, input().split())

ans = ["Alice", "Bob", "Draw"]

if A == 1:
  A = 14
if B == 1:
  B = 14
  
if A > B:
  print(ans[0])
elif A == B:
  print(ans[2])
else:
  print(ans[1])


Measured memory_bytes: 8984
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Lesson5D　goto 文は、C/C++言語などで使うことのできる文で、実行されると無条件に指定されたラベルに処理が飛びます。例えば goto CHECK_NUM; という文が実行されると、プログラムの中で CHECK_NUM: と書かれた行に処理が移ります。この機能を使って、繰り返し処理なども実現することができます。

一方、goto 文は自由度が高すぎ、プログラムの可読性に影響するため、可能な限り使わないことが推奨されています。

次のC++言語のプログラムと同じ動作をするプログラムを作成してください。ただし、goto 文は使わないで実装してみましょう。
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}




 * @author 前島佑介
 * @version 2014/12/1
 */
class Main {

	/**
	 * プログラムのエントリポイント
	 * @param args
	 */
	public static void main(String[] args) {

		int intNum = 0;

		//入力値を１つ受け取る
		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			String strLine = insBR.readLine();

			//入力値　Stringをint型にキャスト
			intNum = Integer.parseInt(strLine);

		}catch(IOException e) {

			System.out.println(e);
		}catch(NumberFormatException e) {

			System.out.println("数値で入力して下さい");
		}

		//3倍数と一桁目が3を表示する
		//問題と同じcallを使う
		call(intNum);


	}

	/**
	 * 3倍数と一桁目が3を表示する
	 * @param intNum
	 */
	static void call(int n){

		String cout = "";

		for(int i = 3; i <= n; i++) {
			int x =i;

			if ( x % 3 == 0 ){
				cout = cout + " " + String.valueOf(i);

				continue;
			}

			do {
				if ( x % 10 == 3 ){
					cout = cout + " " + String.valueOf(i);

					break;
				}
				x/=10;
			}while(x != 0);

		}

		System.out.println(cout);
	}
}

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

int main() {
  
  /////箱の宣言/////
  
  int c[3][3]; //3x3の行列
  bool point=0; //判定用
  
  
  /////入力部/////
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j];
    }
  }
  
  for(int i=0;i<2;i++){
    int data_norm=c[i][0]-c[i+1][0];
    int data=0;
    for(int j=0;j<3;j++){
      data=c[i][j]-c[i+1][j];
      if(data_norm!=data)point=1;
    }
  }
  
  for(int i=0;i<2;i++){
    int data_norm=c[0][i]-c[0][i+1];
    int data=0;
    for(int j=0;j<3;j++){
      data=c[j][i]-c[j][i+1];
      if(data_norm!=data)point=1;
    }
  }
  if(point) cout<<"No"<<endl;
  
  else cout<<"Yes"<<endl;
}
  


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

L=input().rstrip().split(" ")
s=str.upper(L[0][0])+str.upper(L[1][0])+str.upper(L[2][0])
print(s)


Measured memory_bytes: 3316
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (b <= (a + 1) / 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
x,ans,q = [[] for i in range(n+1)],[-1]*(n+1),[]
for i in range(n-1):
    u,v,w = (int(i) for i in input().split())
    x[u].append((v,w%2))
    x[v].append((u,w%2))
for i,j in x[1]: q.append((i,1,j))
ans[1] = 0
while q:
    i,p,d = q.pop()
    ans[i] = abs(d-ans[p])
    for j,k in x[i]:
        if ans[j]==-1: q.append((j,i,k))
for i in ans[1:]: print(i)

Measured memory_bytes: 36424
def abc084_c():
  n = int(input())
  train = [tuple(map(int, input().split())) for _ in range(n-1)]

  def arrive_time(st):
    time = 0
    for i in range(st, n-1):
      c, s, f = train[i]
      # 現在時刻(または最初の出発時刻)を、出発間隔で切り上げ除算して、出発タイミングを決める
      departure = f * ((max(time, s) + f - 1) // f)
      # 出発時刻＋所要時間
      time = departure + c
      #print('st {} departure {} -> st {} arrived {}'.format(i, departure, i+1, time))
    return time

  for i in range(n):
    ans = arrive_time(i)
    print(ans)

abc084_c()

Measured memory_bytes: 3188
#include <iostream>
#include <stdlib.h>

void merge(int n, int* s, int left, int mid, int right, int* count)
{
    int start = left;
    int size = right - left;
    int startM = mid;
    int* mergeArray = (int*)malloc(size * sizeof(int));
    int i = 0;
    while (size > i) {
	if (mid == right || (left != startM && s[left] < s[mid])) {
	    mergeArray[i] = s[left];
	    left++;
	} else {
	    mergeArray[i] = s[mid];
	    mid++;
	}
	*count = *count + 1;
	i++;
    }
    for (int i = 0; i < size; i++) {
	s[start + i] = mergeArray[i];
    }
}
void mergeSort(int n, int* s, int left, int right, int* count)
{
    if (left + 1 < right) {
	int mid = (right + left) / 2;
	mergeSort(n, s, left, mid, count);
	mergeSort(n, s, mid, right, count);
	merge(n, s, left, mid, right, count);
    }
}
int main()
{
    int n = 0;
    int count = 0;
    std::cin >> n;
    int* s = (int*)malloc(n * sizeof(int));
    for (int i = 0; i < n; i++) {
	std::cin >> s[i];
    }
    mergeSort(n, s, 0, n, &count);
    for (int i = 0; i < n; i++) {
	std::cout << s[i];
	if (i + 1 < n) {
	    std::cout << " ";
	}
    }
    std::cout << std::endl;
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 50072
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N,W;
  cin>>N>>W;
  std::vector<int> w(N),v(N);
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];
  int a,b,c,d;
  a=b=c=d=0;
  for(int i=0;i<N;i++){
    if(w[i]==w[0])a++;
    if(w[i]==w[0]+1)b++;
    if(w[i]==w[0]+2)c++;
    if(w[i]==w[0]+3)d++;
  }
  std::vector<int> aa(a+1),bb(b+1),cc(c+1),dd(d+1);
  int ax,bx,cx,dx;
  ax=bx=cx=dx=0;
  for(int i=0;i<N;i++){
    if(w[i]==w[0]){aa[ax]=v[i];ax++;}
    if(w[i]==w[0]+1){bb[bx]=v[i];bx++;}
    if(w[i]==w[0]+2){cc[cx]=v[i];cx++;}
    if(w[i]==w[0]+3){dd[dx]=v[i];dx++;}
  }
  aa[a]=bb[b]=cc[c]=dd[d]=1000000000;
  sort(aa.rbegin(),aa.rend());
  sort(bb.rbegin(),bb.rend());
  sort(cc.rbegin(),cc.rend());
  sort(dd.rbegin(),dd.rend());
  aa[0]=bb[0]=cc[0]=dd[0]=0;
  for(int i=1;i<a+1;i++)aa[i]+=aa[i-1];
  for(int i=1;i<b+1;i++)bb[i]+=bb[i-1];
  for(int i=1;i<c+1;i++)cc[i]+=cc[i-1];
  for(int i=1;i<d+1;i++)dd[i]+=dd[i-1];
  int ans=0;
  for(int i=0;i<a+1;i++){
    for(int j=0;j<b+1;j++){
      for(int k=0;k<c+1;k++){
        for(int l=0;l<d+1;l++){
          if(w[0]*(i+j+k+l)+j+2*k+3*l<=W)ans=max(ans,aa[i]+bb[j]+cc[k]+dd[l]);
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int N,C;
    cin >> N >> C;
    vector< vector<int> > Dtable(C, vector<int> (C));
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            cin >> Dtable[i][j];//iからjに色を塗り替えた時の違和感
        }
    }
    vector< vector<int> > now(N, vector<int> (N));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cin >> now[i][j];
            now[i][j]--;
        }
    }

    vector< vector<int> > sums(3, vector<int> (C));//sums[i][j]は3で割った余りがiの群をすべてjにする時の総コスト
    for(int i=0; i<3; i++){
        for(int j=0; j<C; j++){
            sums[i][j]=0;
        }
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if((i+j)%3==0){
                for(int c0=0; c0<C; c0++){
                    sums[0][c0]+=Dtable[now[i][j]][c0];
                }
            }else if((i+j)%3==1){
                for(int c0=0; c0<C; c0++){
                    sums[1][c0]+=Dtable[now[i][j]][c0];
                }
            }else{
                for(int c0=0; c0<C; c0++){
                    sums[2][c0]+=Dtable[now[i][j]][c0];
                }
            }
        }
    }
    int ans=1000000000;
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            if(i==j) continue;
            for(int k=0; k<C; k++){
                if(i==k || j==k) continue;
                ans = min(ans, sums[0][i]+sums[1][j]+sums[2][k]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

const int NMAX=200010; // we can calculate nCk until n is equal to NMAX
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

mint f(int s, int t, int x, int y) {
  return Comb(x - s + y - t, y - t);
}

int main()
{
  int h,w,a,b;cin >> h >> w >> a >> b;
  Make_Fact();
  Make_InvFact();
  
  mint res;
  rep1(i,h-a) {
    res += f(1, 1, i, b) * f(i, b+1, h, w);
  }

  cout << res.x << "\n";

  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(){

  int x,y,irekae,amari;

  scanf("%d%d",&x,&y);

  if(x<=y){
    irekae = x;
    x = y;
    y = irekae;
  }

  amari = x % y;
  while(amari!=0){
    /*ユークリッドの互除法*/
    x = y;
    y = amari;
    amari = x % y;
  }

  printf("%d\n",y);

  return 0;
}



Measured memory_bytes: 2112
package main

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

func main() {
	n := getInt()

	as := make([]int, n)
	for i := range as {
		as[i] = getInt()
	}
	sort.Ints(as)

	candidate := make([]int, 0, n/2)
	for i := 0; i < n-1; i++ {
		if as[i] == as[i+1] {
			candidate = append(candidate, as[i])
			i++
		}
	}

	if len(candidate) < 2 {
		fmt.Println(0)
	} else {
		fmt.Println(candidate[len(candidate)-1] * candidate[len(candidate)-2])
	}
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 3456
#include <iostream>
#include <stdio.h>
#include <queue>
#include <string.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int maxm=20005;
const int maxn=10005;
struct EdgeNode
{
    int to;
    int w;
    int d;
    int next;
};
EdgeNode edges[maxn*maxn];//?里要注意
int n,m;
int head[maxn],edge;
bool vis[maxn];
queue<int>que;
long long dis[maxn],cost[maxn];
void add(int u,int v,int d,int c)
{
    edges[edge].w=c;
    edges[edge].d=d;
    edges[edge].to=v;
    edges[edge].next=head[u];
    head[u]=edge++;
}
void init()
{
    memset(head,-1,sizeof(head));
    edge=0;
}
int spfa(int n)
{
    int u,sum2=0;
    dis[0]=0;
    cost[0]=0;
    for(int i=1; i<=n; i++)
    {
        dis[i]=INF;
        cost[i]=INF;
    }
    memset(vis,0,sizeof(vis));
    while(!que.empty())
        que.pop();
    que.push(1);
    //sum2++;
    vis[1]=true;
    dis[1]=0;
    cost[1]=0;
    while(!que.empty())
    {
        u=que.front();
        que.pop();
        vis[u]=false;

        for(int i=head[u]; i!=-1; i=edges[i].next)
        {
            int v=edges[i].to;
            int w=edges[i].w;
            int d=edges[i].d;
            if(dis[v]>dis[u]+d)//不能在?里直接用等号，用了之后第三??例?不去
            {
                dis[v]=dis[u]+d;
                cost[v]=w;
                if(!vis[v])
                {
                    vis[v]=true;
                    que.push(v);
                }

            }
            else if(dis[v]==dis[u]+d)
            {
                if(cost[v]>w)
                    cost[v]=w;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cost[0]+=cost[i];
        return cost[0];

}
int main()
{
    int u0,v0,d0,c0;
    while(cin>>n>>m)
    {
        init();
        if(n==0&&m==0)
            break;
        int sum=0;
        for(int i=1; i<=m; i++)
        {
            cin>>u0>>v0>>d0>>c0;
            add(u0,v0,d0,c0);
            add(v0,u0,d0,c0);
        }
        sum=spfa(n);
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3920
#include<iostream>
using namespace std;
int main(){
    int a,b,c,i;
    cin>>a>>b>>c;
    i=3;
    if(a==b&&b==c)
        i=1;
    else if(a==b||b==c||a==c)
        i=i-1;
    cout<<i;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args)throws Exception {

	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String line = br.readLine();
	    //文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除きます。
	    line = line.trim();
	    //半角スペースを区切り文字として扱う
	    String[] readLineArray = line.split("[\\s+]");
	    //変数に配列を代入
	    int count = 0;
	    int a = Integer.parseInt(readLineArray[0]);
	    int b = Integer.parseInt(readLineArray[1]);
	    int c = Integer.parseInt(readLineArray[2]);
	    for (int i = a;i<=b;i++){
	    	if(c%i ==0){
	    		count++;
	    	}
	    }
	    System.out.println(count);
	}

}

Measured memory_bytes: 17092
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	x := 0
	for _, v := range s {
		if v == 'o' {
			x++
		}
	}
	fmt.Println(700 + 100*x)
}


Measured memory_bytes: 640
#include <iostream>

int main(int argc, const char * argv[]) {
    int l;
    l=0;
    std::string a,b;
    std::cin>>a>>b;
    l=a.length();
    if(a== b.substr(0,l)){
        std::cout<<"Yes"<<std::endl;
    }else
        std::cout<<"No"<<std::endl;
    return 0;
}


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

int main()
{
	int n, ball;
	queue<pair<int, int> > qu;

	cin >> n;

	for (int i=0; i<n; i++){
		bool flag = false;
		int rem;

		cin >> ball;
		qu.push(make_pair(ball, 0));

		for (int j=0; j<9; j++){
			cin >> ball;

			while (!qu.empty() && ball != qu.front().first && ball != qu.front().second)
			{
				if(qu.front().first < ball){
					qu.push(make_pair(ball, qu.front().second));
					//cout << ball << ',' << qu.front().second << ' ';	//debug
				}
				else if(qu.front().second < ball){
					qu.push(make_pair(qu.front().first, ball));
					//cout << qu.front().first << ',' << ball;	//debug
				}

				//cout << endl; //debug
				
				qu.pop();
				//if(qu.empty())	break;
			}

			if(qu.empty()){
				rem = j+1;
				break;
			}
			if(j==8 && !qu.empty()){
				rem = 9;
				flag = true;
			}
		}

		for(; rem < 9; rem++)	cin >> ball;

		if(flag)	cout << "YES" << endl;
		else		cout << "NO" << endl;
		
		while (!qu.empty()) qu.pop();
	}

	return 0;
}

Measured memory_bytes: 1192
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      if(A<=B){
        System.out.println(A);
      }else{
        System.out.println(A-1);
      }
    }
}

Measured memory_bytes: 35888
S = input()

ans = len(S)+1
# 010...
cnt = 0
for i in range(len(S)):
    if i%2 == 0:
        color = '0'
    else:
        color = '1'
    if S[i] != color:
        cnt += 1
if cnt < ans:
    ans = cnt

# 101...
cnt = 0
for i in range(len(S)):
    if i%2 == 0:
        color = '1'
    else:
        color = '0'
    if S[i] != color:
        cnt += 1
if cnt < ans:
    ans = cnt

print(ans)



Measured memory_bytes: 3188
#include<cstdio>
using namespace std;
long long m,n,maxx;
long long gcd(long long a,long long b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	scanf("%lld%lld",&n,&m);
	if(m %n==0){
		printf("%lld",m /n);
		return 0;
	}
	for(long long i=1;i<=m;i++){
		if(m%i==0&&n*i<=m){
			maxx=i;
		}
		if(n*i>m)break;
	}
	printf("%lld",maxx);
	return 0;
}

Measured memory_bytes: 128