akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        String result = "123".replace(a, "").replace(b, "");
        
        System.out.println(result);

        sc.close();
    }
}


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

h = list(map(int, input().split()))

l = abs(h[1]-h[0])

t = [0, l]

for i in range(n-2):
  a = abs(h[i+2]-h[i])
  A = t[i]+a
  b = abs(h[i+2]-h[i+1])
  B = t[i+1]+b
  if A >= B :
    t.append(B)
  else:
    t.append(A)
    
print(t[n-1])
  
  

Measured memory_bytes: 20480
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
//#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007
//#define N 12
#define sz 1000*1000

 int main(){

  int c[3][3];
   int x=0,y=0;

   for(int i=0;i<3;i++){
      for(int j=0;j<3;j++)
            cin>>c[i][j];
   }

if(c[0][0]-c[0][1]==c[1][0]-c[1][1])
	{
		if(c[1][0]-c[1][1]==c[2][0]-c[2][1])
		{
			x=1;
		}
	}
	if(c[0][1]-c[0][2]==c[1][1]-c[1][2])
	{
		if(c[1][1]-c[1][2]==c[2][1]-c[2][2])
		{
			y=1;
		}
	}

	if(x == 1 && y == 1)
            cout<<"Yes"<<endl;
      else
            cout<<"No"<<endl;

 return 0;
 }


Measured memory_bytes: 3632
// AtCoder Begginer Contest 139 D
// https://atcoder.jp/contests/abc136/tasks/abc139_b

#include<iostream>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull N;
	cin >> N;
	
	ull ans = (N - 1) * N;
	cout << ans / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,y;
    cin>>n>>y;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n-i;j++)
            if(i*10000+j*5000+(n-i-j)*1000==y)
                cout<<i<<' '<<j<<' '<<n-i-j<<'\n',exit(0);
    cout<<"-1 -1 -1\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
S = [A[0]]
for i in range(1, N):
  S.append(S[i-1] + A[i])
x = 0
for i in range(N):
  x += (A[i] * (S[-1] - S[i])) % 1000000007
x = x % 1000000007
print(x)

Measured memory_bytes: 31576
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d, e, f;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> f;
    
    cout << a + b + c + d - min(a, min(b, min(c, d))) + max(e, f) << endl;
}



Measured memory_bytes: 3088
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=int(1e5)+7;
int x,y,h,w,n;
ll ans[20],base=int(1e9)+7,zero,a[MAXN<<4],tot;
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	zero=1ll*(h-2)*(w-2);
	while(n--)
	{
		scanf("%d%d",&x,&y);
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				if(1<=x-i&&x-i<=h-2&&1<=y-j&&y-j<=w-2)
					a[tot++]=base*(x-i)+(y-j);
	}
	sort(a,a+tot);
	for(int i=0,cnt=1;i<tot;i++)
	{
		if(a[i]==a[i+1])
			cnt++;
		else
			ans[cnt]++,cnt=1,zero--;	
	}
	printf("%lld\n",zero);
	for(int i=1;i<10;i++)
		printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> x(n, 0);
    vector<int> v(n);
    rep(i, n) cin >> x[i], v[i] = x[i];

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

    rep(i, n) {
        if (x[i] >= v[n / 2]) cout << v[(n - 1) / 2] << endl;
        else cout << v[n / 2] << endl;
    }

    return 0;
}

Measured memory_bytes: 4608
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int n,tmp=0;
    string ans="No";
    in n;
    int flag=n;
    while(flag>0)
    {
        tmp+=flag%10;
        flag/=10;
    }
    if(n%tmp==0)ans="Yes";
    cout<<ans<<endl;
}


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

int main() 
{
    int n;
    cin >> n;
    vector<tuple<int, int, int>> v;
    for (int i=0; i<n; i++)
    {
        int x,y,h;
        cin >> x >> y >> h;
        v.emplace_back(h, x, y);
    }
    sort(v.begin(), v.end());
    for (int cx=0; cx<=100; cx++)
        for (int cy=0; cy<=100; cy++)
        {
            bool z = true;
            int x0, y0, h0;
            int mini = INT_MAX;
            for (auto it:v)
            {
                x0 = get<1>(it); 
                y0 = get<2>(it);
                h0 = get<0>(it); 
                if (h0 == 0)
                    mini = min(mini, abs(cx-x0) + abs(cy-y0));
                else 
                    break;
            }
            int H = abs(cx-x0) + abs(cy-y0) + h0;
            if (H > mini)
                z = false;
            for (auto it:v)
            {
                int xi = get<1>(it); 
                int yi = get<2>(it); 
                int hi = get<0>(it);
                int H0 = H - abs(cx-xi) - abs(cy-yi);
                if (hi == 0)
                    continue;
                // if (cx == 55 && cy == 80)
                //     cout << H0 << " " << hi;
                if (H0 != hi)
                {
                    z = false;
                    break;
                }
            }
            if (z == true)
            {
                cout << cx << " " << cy << " " << H;
                return 0;
            }
        }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }
    else cout<<"win"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "A"
string s;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>s;
    if(s[1]!=s[2]){
        puts("No");
        return 0;
    }
    if(s[0]==s[1]||s[3]==s[1]){
        puts("Yes");
        return 0;
    }
    puts("No");
}

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

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

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

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,a,b; cin>>n>>a>>b;
  if((b-a-1)%2) cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
  
}

Measured memory_bytes: 3644
N = int(input())
A = list(map(int,input().split()))

ans = 2 ** 30

def GCD(a,b):
    c = a%b
    if c  == 0:
        return b
    return (GCD(b,c))

tmp = A[0]
for a in A[1:]:
    tmp = GCD(a,tmp)
    
print(tmp)




    



Measured memory_bytes: 14224
X = int(input())
flag = 0
A = 0
B = 0
for i in range(0,100000):
  if flag== 1:
    break
  for j in range(i,100000):
    
    x = i**5 + j**5
    #print(x)
    if x == X:
      A = i
      B = -j
      flag = 1
      break
    elif x > X:
      break
for i in range(1,100000):
  if flag == 1:
    break
  for j in range(0,i):
    x = i**5 - j**5
    if x == X:
      A = i
      B = j
      flag = 1
      break
    elif x < X:
      break
  
      
print("{} {}".format(A,B))

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  int L[N]={};
  rep(i,N) cin >> L[i];
  static int ans=0;
  sort(L,L+N);
  for(int i=N-1;i>=0;i--){

    for(int j=i-1;j>=0;j--){
      for(int k=j-1;k>=0;k--){
        if(L[j]+L[k]>L[i]) ans++;
        else break;
      }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int l,r,d;
        cin>>l>>r>>d;
        int count=0;
        for(int i=l;i<=r;i++)
        {
                if(i%d==0)
                {
                        count+=1;
                }
        }
        cout<<count;
}

Measured memory_bytes: 3616
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if X == 500 * a + 100 * b + 50 * c:
                count = count + 1
print(count)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

using P = pair<int, int>;
const int INF = 1001001001;

// 0: 左 1: 上 2: 下 3: 右
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};

int main(){
    int h, w; // h: 高さ w: 幅
    cin >> h >> w;
    vector<string> s(h);
    int ans = 0;

    rep(i, h) cin >> s[i];
    rep(si, h)rep(sj, w) {
        if (s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) { // s[i][j]の値をxにupdateする。成功したらqueueに突っ込む。
            if(dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i, j)); // q.emplace(i, j)
        };
        update(si, sj, 0);
        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();

            rep(dir, 4) {
                int ni = i + di[dir], nj = j + dj[dir];
                if ((ni < 0) || (ni >= h) || (nj < 0) || (nj >= w)) continue;
                if (s[ni][nj] == '#') continue;
                update(ni, nj, dist[i][j] + 1);
            }
        }
        rep(i,h)rep(j, w) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 100 + 3, inf = 1e9 + 10;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll n, a, b;
	cin >> n >> a >> b;
	//cout<<a%b<<'\n';
	if (n <= a and n <= b) {
		cout << min(a, n) << '\n';
	}
	else {
		ll s = a + b;
		ll mul = n / s;
		if (mul == 0)cout << a << '\n';
		else cout << (mul * a * 1LL) + min(n % s, a) << '\n';
	}
	return 0;
}

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

int main()
{
  int n,q,c=0;
  vector<int> s,t;
  
  //input
  cin>>n; s.resize(n);
  for(int i=0; i<n; i++) cin>>s[i];
  cin>>q; t.resize(q);
  for(int i=0; i<q; i++) cin>>t[i];
  
  //process
  for(int j=0;j<q;j++) for(int i=0; i<n; i++) if(t[j]==s[i]){ c++; break; }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 22;
const int mod = 1000000007;

int n;
int a[N][N];
ll dp[N][(1<<N)];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> a[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int mask = 1; mask < (1ll<<n); mask++){
            int br = __builtin_popcount(mask);
            if(br != i){
                continue;
            }
            for(int j = 0; j < n; j++){
                if(mask&(1ll<<j) && a[i][j+1]){
                    dp[i][mask] += dp[i-1][mask^(1ll<<j)];
                    dp[i][mask] %= mod;
                }
            }
        }
    }
    cout << dp[n][(1ll<<n)-1] << endl;
}


Measured memory_bytes: 321792
#include<stdio.h>
int main(){
  int a,b,c=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a<=b&&b<=c)printf("%d %d %d\n",a,b,c);
  else   if(a<=b&&b>=c)printf("%d %d %d\n",a,c,b);
  else   if(b<=a&&a<=c)printf("%d %d %d\n",b,a,c);
  else   if(b<=c&&c<=a)printf("%d %d %d\n",b,c,a);
  else   if(c<=b&&b<=a)printf("%d %d %d\n",c,b,a);
  else   printf("%d %d %d\n",c,a,b);

    return 0;
  }

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    string a,b;
    cin>>a>>b;
    int x,y;
    cin>>x>>y;
    string s;
    cin>>s;
    if(s==a)
    {
        x--;
    }
    if(s==b)
    {
        y--;
    }
    cout<<x<< " "<<y;

    return 0;
}


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

using namespace std;

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

int main() {
  
  int N, C;
  while(cin >> N >> C && N && C) {
    int panel[N]; memset(panel, 0, sizeof panel);
    rep(i, N) rep(j, 16) {
      int x; cin >> x;
      if(x) { panel[i] += 1<<j; }
    }
    
    int jubi[C]; memset(jubi, 0, sizeof jubi);
    rep(i, C) rep(j, 16) {
      int x; cin >> x;
      if(x) { jubi[i] += 1<<j; }
    }
    
    int dp[2][1<<16];
    memset(dp, -1, sizeof dp);
    dp[0][0] = 0;
    
    int const mask = (1<<16)-1;
    rep(i, N) rep(S, 1<<16) {
      if(dp[i&1][S] == -1) continue;
      dp[(i+1)&1][panel[i]|S] = max(dp[(i+1)&1][panel[i]|S], dp[i&1][S]);
      rep(j, C) {
        int nS = (panel[i]|S)&(mask-jubi[j]);
        int score = __builtin_popcount(panel[i]|S) - __builtin_popcount(nS);
        dp[(i+1)&1][nS] = max(dp[(i+1)&1][nS], dp[i&1][S] + score);
      }
    }
    cout << *max_element(dp[N&1], dp[N&1]+(1<<16)) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
long long n,v[401],dp[401][401];

long long ans(int l , int r){
    if(l == r){
        return 0;
    }
    if(dp[l][r] != -1){
        return dp[l][r];
    }
    long long sum = 0,ret=1000000000000000000;
    for(int i = l ; i <= r ; i += 1){
        sum += v[i];
    }
    for(int i = l ; i < r ; i += 1){
        ret = min(ret,sum+ans(l,i)+ans(i+1,r));
    }
    return dp[l][r] = ret;
}

int main(){
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i = 0 ; i < n ; i += 1){
        cin >> v[i];
    }
    cout << ans(0,n-1) << endl;
}

Measured memory_bytes: 1536
#include<iostream>

#define endl '\n'

using namespace std;

const int MAXN=103,MAXS=1e5+3;
long long dp[MAXS],weight[MAXN];
int cost[MAXN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,w;
    cin>>n>>w;
    int sum=0;
    for(int i=1;i<=n;++i){
        cin>>weight[i]>>cost[i];
        sum+=cost[i];
    }
    for(int i=1;i<MAXS;++i){
        dp[i]=1e10;
    }
    for(int i=1;i<=n;++i){
        for(int i2=sum;i2>=cost[i];--i2){
            dp[i2]=min(dp[i2],dp[i2-cost[i]]+weight[i]);
        }
    }
    int res=0;
    for(int i=sum;i>=0;--i){
        if(dp[i]<=w){
            res=i;
            break;
        }
    }
    cout<<res<<endl;
return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 201
using namespace std;
int n,m;
int a[MAXN][MAXN],layer[MAXN];
char s[MAXN][MAXN];
queue <int> q;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        char in[MAXN];
        scanf("%s",in);
        for(int j=1;j<=n;j++)
        {
            a[i][j]=in[j-1]-'0';
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        memset(layer,0,sizeof(layer));
        layer[i]=1;
        q.push(i);
        int tmp=1;
        while(!q.empty())
        {
            int u=q.front();q.pop();
            tmp=max(tmp,layer[u]);
            for(int v=1;v<=n;v++)
            {
                if(a[u][v])
                {
                    if(layer[v])
                    {
                        if((layer[u]&1)==(layer[v]&1))
                        {
                            cout<<-1<<endl;
                            return 0;
                        }
                    }
                    else
                    {
                        layer[v]=layer[u]+1;
                        q.push(v);
                    }
                }
            }
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
N, A, B =map(int, input().split())
R = N // 10000
S = N // 1000
T = N // 100
U = N // 10
V = N % 10
total = 0
for r in range(R +1):
  for s in range(10): 
    for t in range(10):
      for u in range(10):
        for v in range(10):
          if A <= r+s+t+u+v and r+s+t+u+v <= B and 10000*r+1000*s+100*t+10*u+v <=N:
            total = total + 10000*r+1000*s+100*t+10*u+v
print(total)

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

int main(void){
  ll n,x;
  vector< ll > a;
  ll res = 0;
  cin >> n >> x;
  ll aa;
  cin >> aa;
  a.push_back(aa);
  for(int i = 1;i < n;++i){
    cin >> aa;
    a.push_back(aa);
    if(a[i] + a[i-1] > x){
      ll eat = 
	min((a[i] + a[i-1]) - x,a[i]);
      a[i] -= eat;
      res += eat;
      if(a[i] + a[i-1] > x){
	ll eat =
	  min((a[i] + a[i-1]) - x,a[i-1]);
	a[i-1] -= eat;
	res += eat;
      }	
    }
  }
  cout << res << endl;;
  return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  int k;
  vector<vector<int>> s(M);
  for(int i=0; i<M; i++){
    cin >> k;
    for(int j=0; j<k; j++){
      int a; cin >> a; --a;
      s[i].push_back(a);
    }  
  }
  
  vector<int> p(M);
  for(int i=0; i<M; i++) cin >> p[i];
  
  int ans=0;
  for (int bit = 0; bit < (1<<N); ++bit){
  	int flag=1;
    
    for(int i=0; i<M; i++){
      int count = 0;
      for (auto v : s[i]) {
          if(bit &(1<<v)) count++;
      }
      if(count%2!=p[i]) flag=0; 
    }
    if(flag==1) ++ans;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// 約数のvectorを返す
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) {
                ret.push_back(n / i);
            }
        }
    }

    return ret;
}

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

    ll n;
    cin >> n;

    vector <ll> div = divisor(n);

    ll ans = 0;

    for (ll i : div) {
        ll m = n / i - 1;
        if (m && n % m == i) {
            ans += m;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
char s;
bool c,f;
int main()
{
    c=0,f=0;
    while(cin>>s)
    {
        if(s=='C')
            c=1;
        if(s=='F')
            if(c)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	cin>>n;

	vc s(n);

	bool flag=false;

	rep(i, n){
		cin>>s[i];
		if(s[i]=='Y') flag=true;
	}
	if(flag){
		cout<<"Four"<<endl;
	}else{
		cout<<"Three"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		 Scanner sc=new Scanner(System.in);
		 int i=sc.nextInt();
		 int j=sc.nextInt();
		 int arr[]=new int[j];
		 List<Integer> li1=new ArrayList<Integer>();
		 if(j==0)
		 {
			 System.out.println(i);
			 return;
		 }
		 for(int k=0;k<j;k++)
		 {
			 arr[k]=sc.nextInt();
			 li1.add(arr[k]);
		 }
		 if(!li1.contains(i))
		 {
			 System.out.println(i);
			 return;
		 }
		
		 for(int k=0;k<=j;k++)
		 {
			if((li1.contains(i+k))&&(li1.contains(i-k)))
			 { 
				 continue;
			 }
           
			 if(!li1.contains(i-k))
			 {
				 System.out.println(i-k);
                 break;
				 
			 }
			 if(!li1.contains(i+k))
			 {
				 System.out.println(i+k);
                 break;
				 
			 }	 
		 }
		 
		 
	}
 
}

Measured memory_bytes: 35836
#include<stdio.h>

int num1,first[2000];
  
int solve(int a,int b){
  int result;
  if(b==0){
    return 1;
  }
  if(a>=num1){
    return 0;
  }
  result=solve(a+1,b) || solve(a+1,b-first[a]);
  return result;
}



int main(){
 int i,num2,second[2000];
   scanf("%d",&num1);
  for(i=0;i<num1;i++){
    scanf("%d",&first[i]);
  }
  scanf("%d",&num2);
  for(i=0;i<num2;i++){
    scanf("%d",&second[i]);
  }

  for(i=0;i<num2;i++){
    if(solve(0,second[i])){
	printf("yes\n");
      }else{
	printf("no\n");
      }
  }
  return 0;
}







Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);

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

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool used[210];

int main() {
	int x, y;
	std::cin >> x >> y;
	if (x == 0 || y == 0) {
		if (x == 0) {
			if (y < 0) {
				std::cout << abs(y) + 1 << std::endl;
			}
			else {
				std::cout << y << std::endl;
			}
		}
		else if (y == 0) {
			if (x <= 0) {
				std::cout << abs(x) << std::endl;
			}
			else {
				std::cout << abs(x) + 1 << std::endl;
			}
		}
	}
	else if (x > 0 && y > 0) {
		if (x <= y) {
			std::cout << y - x << std::endl;
		}
		else {
			std::cout << 2 + x - y << std::endl;
		}
	}
	else if (x < 0 && y < 0) {
		if (x <= y) {
			std::cout << y - x << std::endl;
		}
		else {
			std::cout << 2 + x - y << std::endl;
		}
	}
	else if (x < 0 && y > 0) {
		if (abs(x) == y) {
			std::cout << 1 << std::endl;
		}
		else if (abs(x) > y) {
			std::cout << min(y - x, 1 + abs(x) - y) << std::endl;
		}
		else {
			std::cout << min(y - x, 1 + y - abs(x)) << std::endl;
		}
	}
	else if (x > 0 && y < 0) {
		y = abs(y);
		if (x == y) {
			std::cout << 1 << std::endl;
		}
		else if (x > y) {
			std::cout << 1 + x - y << std::endl;
		}
		else {
			std::cout << 1 + y - x << std::endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N; cin >> N;
  vector<int> a(N-1),b(N-1);
  rep(i,N-1) cin >> a[i] >> b[i];
  
  vector<vector<pair<int, int>>> G(N);
  rep(i,N-1) G[a[i]-1].push_back(make_pair(b[i]-1, i));

  vector<int> color(N,-1);
  color[N-1] = 1e9;
  queue<pair<int, int>> que;
  que.push(make_pair(0,N-1));
  
  int K = 0; 
  while(!que.empty()) {
    int v = que.front().first; 
    int c = que.front().second;
    que.pop();
    int n = G[v].size();
    rep(i,n) {
      que.push(make_pair(G[v][i].first,G[v][i].second));
      if (color[c] == i+1) {
        color[G[v][i].second] = n+1;
        K = max(K, n+1);
      } else {
        color[G[v][i].second] = i+1;
        K = max(K, i+1);
      }
    }
  }

  cout << K << endl;
  rep(i,N-1) cout << color[i] << endl;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=3e5+51,MOD=1e9+7;
struct Edge{
	ll to,prev;
};
Edge ed[MAXN<<1];
ll n,from,to,tot,res;
ll last[MAXN],f[MAXN],sz[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
inline void addEdge(ll from,ll to)
{
	ed[++tot].prev=last[from];
	ed[tot].to=to;
	last[from]=tot;
}
inline ll qpow(ll base,ll exponent)
{
	ll res=1;
	while(exponent)
	{
		if(exponent&1)
		{
			res=(li)res*base%MOD;
		}
		base=(li)base*base%MOD,exponent>>=1;
	}
	return res;
}
inline void dfs(ll node,ll fa)
{
	sz[node]=1;
	for(register int i=last[node];i;i=ed[i].prev)
	{
		if(ed[i].to!=fa)
		{
			dfs(ed[i].to,node),sz[node]+=sz[ed[i].to];
		}
	}
}
inline void dfs2(ll node,ll fa)
{
	if(node!=1)
	{
		f[node]=(li)f[fa]*(n-sz[node])%MOD*qpow(sz[node],MOD-2)%MOD;
	}
	for(register int i=last[node];i;i=ed[i].prev)
	{
		if(ed[i].to!=fa)
		{
			dfs2(ed[i].to,node);
		}
	}
}
int main()
{
	n=read();
	for(register int i=0;i<n-1;i++)
	{
		from=read(),to=read();
		addEdge(from,to),addEdge(to,from);
	}
	dfs(1,0),f[1]=res=1;
	for(register int i=1;i<=n;i++)
	{
		f[1]=(li)f[1]*sz[i]%MOD,res=(li)res*i%MOD;
	}
	dfs2(1,0);
	for(register int i=1;i<=n;i++)
	{
		printf("%d\n",(li)res*qpow(f[i],MOD-2)%MOD);
	}
}

Measured memory_bytes: 9856
import collections
n = int(input())
s = [input() for _ in range(n)]
# s.append('')
m = int(input())
t = [input() for _ in range(m)]
# t.append('')
sc = collections.Counter(s)
tc = collections.Counter(t)
# print(sc, tc)
ans = 0
for string, times in sc.items():
    if string in tc.keys():
        ans = max(ans, times - tc[string])
    else:
        ans = max(ans, times)
        
        
print(ans)


Measured memory_bytes: 9432
#include<stdio.h>
int main(){
  int a,b,c,x,ans = 0;
  scanf("%d %d %d %d",&a,&b,&c,&x);
  for(int i = 0;i <= a;i++){
    for(int j = 0;j <= b;j++){
      for(int k = 0;k <= c;k++){
        if(i * 500 + j * 100 + k * 50 == x){
          ans++;
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int seisuudesuka(double b){
    if(b==(int)b)return 1;
    else return 0;
}

int main(){
    int n,d;
    scanf("%d %d ",&n,&d);
    int data[n][d];
    int *buf;
    for(int i = 0; i < n; i++){
        buf = inputArray(d);
        for(int j=0;j<d;j++){
            data[i][j] = buf[j];
        }
        free(buf);
    }
    double dis;
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            dis = 0;
            for(int k=0;k<d;k++){
                dis += (data[i][k]-data[j][k])*(data[i][k]-data[j][k]);
            }
            dis = sqrt(dis);
            if(seisuudesuka(dis))ans++;
        }
    }
    printf("%d",ans);

    return 0;
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int n,x[200001],i,b;
	long long c=0;
	scanf("%d",&n);
	x[0]=0;
	for(i=1;i<=n;i++){
		scanf("%d",&x[i]);
		if(x[i-1]>=x[i]) {
			b=x[i-1]-x[i];
			x[i]=x[i-1];
			c+=b;
		}
	}
	printf("%lld\n",c);
	return 0;
}


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

int main() {

  string S ,T;
  cin >> S >> T ;

  int count = 0;

  for(int i=0 ; i<S.size();i++){

    if(S.at(i) != T.at(i)){
      count ++;
    }

  }

  cout << count << endl;

}

Measured memory_bytes: 3912
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
int count1[101];
int main()
{
	int a;
	
	int max1 = 0;
	memset(count1, 0, sizeof(count1));
	while (cin>>a)
	{
		count1[a]++;
		if (count1[a] > max1)
		{
			max1 = count1[a];
		}
	
	}
	for (int i = 0; i < 101; i++)
	{
		if (max1 == count1[i])
		{
			cout << i << endl;
		}
	}
    return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  double xa,ya,xb,yb,xc,yc,xd,yd;
  while(cin >> xa >> ya >> xb >> yb
	>> xc >> yc >> xd >> yd) {
    double dx1 = xb - xa, dy1 = yb - ya;
    double dx2 = xd - xc, dy2 = yd - yc;
    if(abs(dx1 * dx2 + dy1 * dy2) < 1e-10)
      cout <<"YES"<<endl;
    else
      cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
#define Maxn 200005
#define mod 1000000007
using namespace std;
LL n,a[Maxn],x[Maxn],v[Maxn],p[Maxn];
LL x1[Maxn],v1[Maxn],L[Maxn],R[Maxn];
LL f[Maxn];
inline LL lowbit(LL x){return x&(-x);}
inline void Add(LL x,LL y)
{
	while(x<=200003)a[x]+=y,x+=lowbit(x);
	return;
}
inline LL Sum(LL x)
{
	LL sum=0;
	while(x>0)sum+=a[x],x-=lowbit(x);
	return sum;
}
int main(void)
{
	LL i,sum=0;
	scanf("%lld",&n);
	for(i=1;i<=n;++i)scanf("%lld%lld",&x[i],&v[i]);
	memcpy(x1,x,sizeof(x));
	memcpy(v1,v,sizeof(v));
	sort(x1+1,x1+n+1);
	sort(v1+1,v1+n+1);
	for(i=1;i<=n;++i)
	{
		LL px=lower_bound(x1+1,x1+n+1,x[i])-(x1);
		LL pv=lower_bound(v1+1,v1+n+1,v[i])-(v1);
		p[px]=pv;
	}
	R[1]=p[1]+1;
	for(i=2;i<=n;++i)R[i]=max(R[i-1],p[i]+1);
	L[n]=p[n];
	for(i=n-1;i>=1;--i)L[i]=min(L[i+1],p[i]);
	f[1]=1;Add(1,1);
	for(i=1;i<=n;++i)
	{
		LL sum=Sum(R[i])-Sum(L[i]-1);
		sum=(sum+mod)%mod;
		f[R[i]]=(f[R[i]]+sum)%mod;
		Add(R[i],sum);
	}
	printf("%lld\n",f[n+1]);
	return 0;
}


Measured memory_bytes: 14336
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		//入力
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		//処理
		int n = s.length();
		int[] ans = new int[n];
		for(int i = 0; i < n; i++) ans[i] = 0;
		int last = 0;
		for(int i = 0; i < n; i++){
			if(s.charAt(i) == 'R'){
				last++;
			}else{
				ans[i] += last/2;
				ans[i-1] += (last+1)/2;
				last = 0;
			}
		}
		last = 0;
		for(int i = n-1; i >= 0; i--){
			if(s.charAt(i) == 'L'){
				last++;
			}else{
				ans[i] += last/2;
				ans[i+1] += (last+1)/2;
				last = 0;
			}
		}
		
		//出力
		PrintWriter out = new PrintWriter(System.out);
		for(int i = 0; i < n; i++){
			out.print(ans[i]);
			if(i != n-1) out.print(" ");
			else out.println();
		}
		out.flush();
	}
}

Measured memory_bytes: 32200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using ll = long 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; }

int main() {
	
	
	
	int n; cin >> n;
	
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	//sort(a.begin(),a.end());
	
	
	//vector<int> cost(n,10000000);
	
	ll cost[100010];
	rep(i,100010) cost[i]=10000000000000;
	
	
	cost[0]=0;
	
	
	/*
	for(int i=2;i<n;i++){
		
		cost[i]=min(cost[i],abs(a[i]-a[i-1])+cost[i-1]);
		cost[i]=min(cost[i],abs(a[i]-a[i-2])+cost[i-2]);
	}
	*/
	for (int i=1;i<n;i++) {
        chmin(cost[i], cost[i - 1] + abs(a[i] - a[i - 1]));
        if (i > 1) chmin(cost[i], cost[i - 2] + abs(a[i] - a[i - 2]));
    }



	cout << cost[n-1] << '\n';
	return 0;

}

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

#define ll long long
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    set<string> S;
    multiset<string> s;
    rep(i,N)
    {
        string tmp;
        cin >> tmp;
        S.insert(tmp);
        s.insert(tmp);
    }
    ll max_num = 0;
    for(set<string>::iterator itr = S.begin(); itr != S.end(); ++itr)
    {
        if( s.count( *itr ) > max_num ) max_num = s.count( *itr );
    }

    vector<string> ans;

    for(set<string>::iterator itr = S.begin(); itr != S.end(); ++itr)
    {
        if( s.count( *itr ) == max_num ) ans.push_back(*itr);
    }

    sort(all(ans));
    rep(i,ans.size()) cout << ans[i] << endl;

    



}


Measured memory_bytes: 33268
s = raw_input()

def check(s):
	if len(s) == 0:
		return True
	x = s[0]
	for z in s:
		if z != x:
			return False
	return True

in_s = s
answer = len(s)

for x in in_s:
	s = in_s
	cur_ = 0
	for it_ in range(len(in_s) + 2):
		if check(s):
			cur_ = it_
			break
		new_s = ""
		for i in range(len(s) - 1):
			if s[i] == x or s[i + 1] == x:
				new_s = new_s + x
			else:
				new_s = new_s + s[i]
		s = new_s
	answer = min(answer, cur_)
print answer




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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
  string S;
  cin >> S;
  FOR(i, 0, S.size()) { cout << "x"; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
//	-*- mode: C++ -*-
//	Ring
//
//		Write a program which finds a pattern p in a ring shaped text s.
//
//
//
//
//	Input
//		In the first line, the text s is given.
//		In the second line, the pattern p is given.
//
//	Output
//		If p is in s, print Yes in a line, otherwise No.
//
//	Constraints
//		1≤ length of p≤ length of s≤100
//		s and p consists of lower-case letters
//	Sample Input 1
//		vanceknowledgetoad
//		advance
//	Sample Output 1
//		Yes
//
//	Sample Input 2
//		vanceknowledgetoad
//		advanced
//	Sample Output 2
//		No

#include <iostream>
#include <string>

int	main(int	argc,
		 char*	argv[])
{
	std::string	s	{};
	std::string	p	{};

	std::cin >> s;
	std::cin >> p;

	if(s.find(p) != std::string::npos){
		std::cout << "Yes" << '\n';
		return 0;
	}

	for(unsigned int i = 1; i < p.length(); i++){
		std::string	subptop	= p.substr(0, i);
		std::string subpbot	= p.substr(i, p.length() - i);

		if((s.find(subpbot) == 0) &&
		   (s.rfind(subptop) == (s.length() - i))){
			std::cout << "Yes" << '\n';
			return 0;
		}
	}

	std::cout << "No" << '\n';

    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

LL n, a[100055], d[100055], tot, sum, times;
 
int main () {
	
	scanf("%lld", &n);
	
	tot = (n + 1) * n / 2;
	
	FOE(i, 1, n) scanf("%lld", a + i);
	FOE(i, 1, n) sum += a[i];
	
	if (sum % tot != 0)
		return 0 * printf("NO\n");
	else
		times = sum / tot;
	
	a[0] = a[n];
	
	FOE(i, 1, n) d[i] = a[i] - a[i - 1] - times;
	
	FOE(i, 1, n) {
		if (d[i] > 0)
			return 0 * printf("NO\n");
		else {
			d[i] = -d[i];
			if (d[i] % n != 0)
				return 0 * printf("NO\n");
			else {
				times -= d[i] / n;
			}
		}
	}
	
	printf("%s\n", (times == 0) ? "YES" : "NO");
	
	return 0;
	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define db(...) " [" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "] "
using ii=long long;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(all(v));
    vector<vector<int>> d(n);
    for (int i = n - 1; i >= 0; --i) {
        if (i+ 1 != n) d[i] = d[i + 1];
        d[i].push_back(v[i]);
        sort(all(d[i]));
    }
    int r = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            int a = v[i];
            int b = v[j];
            r += distance(
                lower_bound(all(d[j + 1]), max(a - b, b - a) + 1),
                lower_bound(all(d[j + 1]), a + b)
            );
        }
    }
    cout << r << "\n";
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int x = 0;
    rep(i,n){
        if (a[i] == x+1){
            x++;
        }
    }
    cout << (x == 0 ? -1 : n - x) << endl;
    return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	var l int
	for i := 0; i < k; i++ {
		if a+i > b {
			break
		}
		fmt.Println(a + i)
		l = a + i
	}
	for i := 1; i <= k; i++ {
		if b-k+i <= l {
			continue
		}
		fmt.Println(b - k + i)
	}
}


Measured memory_bytes: 512
n,m=map(int,raw_input().split())
l=[]
for i in range(n):
    l.append(list(map(int,raw_input().split())))

l.sort(key=lambda x: x[0])

counter=0
i=0
ans=0
while counter < m:
    counter+=l[i][1]
    i+=1

for k in range(i):
    ans+=l[k][0]*l[k][1]


if counter>m:
    ans-=l[k][0]*(counter-m)
print ans



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main() {
    string N; cin >> N;
    string str = "No";
    for(int i = 0; i < 3; ++i) {
        if(N[i] == '7') {
            str = "Yes";
        }
    }

    cout << str << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int M = scanner.nextInt();

        int[] aArray = new int[A];
        int[] bArray = new int[B];
        int[][] mArray = new int[M][3];

        int minA = Integer.MAX_VALUE;
        int minB = Integer.MAX_VALUE;
        for (int i = 0; i < A; i++) {
            aArray[i] = scanner.nextInt();
            minA = Math.min(aArray[i], minA);
        }
        for (int i = 0; i < B; i++) {
            bArray[i] = scanner.nextInt();
            minB = Math.min(bArray[i], minB);
        }

        int ans = minA + minB;
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < 3; j++) {
                mArray[i][j] = scanner.nextInt();
            }
        }

        scanner.close();

        for (int[] item : mArray) {
            ans = Math.min(aArray[item[0] - 1] + bArray[item[1] - 1] - item[2], ans);
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 162904
N, M, Q = map(int, input().split())

query = [list(map(int, input().split())) for _ in range(Q)]

l = []
def dfs(lis, y):
  if len(lis) == N:
    l.append(lis)
    return
  else:
    for i in range(y, M+1):
      z = list(lis)
      z.append(i)
      dfs(z, i)
    return
      
dfs([], 1)

ans = 0
for A in l:
  tmp = 0
  for a, b, c, d in query:
    if A[b-1] - A[a-1] == c:
      tmp += d
  ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 28640
n = int(input())
# n = 703

alphabets = [chr(97 + i) for i in range(26)]

x = []

m = n
while True:
    b = m % 26
    if b == 0:
        b = 26
        a = m // 26 - 1
    else:
        a = m // 26

    x.append(alphabets[b - 1])

    if a < 1:
        break

    m = a

print(''.join(reversed(x)))


Measured memory_bytes: 9188
package main

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

type scanner struct {
	sc *bufio.Scanner
}

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

func (sc *scanner) nextInt() int {
	i, err := strconv.Atoi(sc.next())
	if err != nil {
		panic(err)
	}
	return i
}

func newScanner(r io.Reader, split bufio.SplitFunc) *scanner {
	sc := bufio.NewScanner(r)
	sc.Split(split)
	return &scanner{
		sc: sc,
	}
}

var wsc = newScanner(os.Stdin, bufio.ScanWords)
var lsc = newScanner(os.Stdin, bufio.ScanLines)

func next() string {
	return wsc.next()
}

func nextInt() int {
	return wsc.nextInt()
}

func nextLine() string {
	return lsc.next()
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func main() {
	want := strings.Split("CODEFESTIVAL2016", "")
	got := strings.Split(next(), "")
	ans := 0
	for i := 0; i < len(want); i++ {
		if want[i] != got[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640