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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    
    int a = 0;
    for(int i=0;i<3;i++){
      if(s.charAt(i) =='A')
        a += 1;
    }
    if(a == 0|| a==3)
      System.out.println("No");
    else
      System.out.println("Yes");
  }
}

Measured memory_bytes: 21588
//D 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
deque<char>s;
int main(){
	string S;
	cin >> S;
	for(int i = 0;i < S.size();i++)s.push_back(S[i]);
	int q;
	cin >> q;
	bool d = 0;
	while(q--){
		int opt;
		cin >> opt;
		if(opt == 1)d ^= 1;
		else{
			int qwq;char x;
			cin >> qwq >> x;
			if(d){
				if(qwq == 1)s.push_back(x);
				else s.push_front(x);
			}
			else{
				if(qwq == 1)s.push_front(x);
				else s.push_back(x);
			}
		}
	}
	if(d)reverse(s.begin(),s.end());
	for(char x:s)cout << x;
	return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p;
  int tmp;
  for(int i = 0;i<n;i++){
    cin >> tmp;
    p.push_back(tmp);
  }
  sort(p.begin(), p.end());//昇順
  int c= 0;
  
  for(int i = 0;i<k;i++){
    c+= p[i];
  }
  
  cout<< c;
  
}

Measured memory_bytes: 3544
def main(N,Y):
    # type: (int, int) -> None
    Y = Y // 1000
    lb = (2*(Y-N)-1) // 9 + 1
    ub = min ((Y-N) // 4, Y // 5)
    ans = [ (x,y,z) for w in range(lb,ub+1) for x in [Y-N-4*w] for y in [w - 2*x] for z in [N - x - y] ]
    assert(all(map(lambda a: a[0]>=0 and a[1]>=0 and a[2]>=0, ans)))
    if ans == []:
        print("-1 -1 -1")
    else:
        x,y,z = ans[0]
        print("{0} {1} {2}".format(x,y,z))
    return

if __name__ == '__main__':
    N, Y, *_ = map(int, input().split())
    main(N,Y)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int t = 0;

        if(a>b){
             t=a;    a=b;    b=t;
        }
        if(b>c){
             t=b;    b=c;    c=t;
        }
        if(a>b){
             t=a;    a=b;    b=t;
        }
        System.out.println(a+" "+b+" "+c);
        sc.close();
    }
}


Measured memory_bytes: 26136
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N;
    cin >> N;
    lint a[N];
    rep(i,N) cin >> a[i];
    sort(a,a+N);
    rep(i,N) a[i]-=N-1;
    lint ans=0;
    while(true){
        rep(i,N){
            lint plus=max(0LL,(a[i]+N-1)/N);
            ans+=plus;
            a[i]-=plus*N;
            rep(j,N) if(j!=i) a[j]+=plus;
        }
        bool check=true;
        rep(i,N) if(a[i]>0) check=false;
        if(check) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = putStrLn . solve . head . tail . lines =<< getContents

count c d [] = (c, d)
count c d ('(':s) = count (c + 1) d s
count c d (')':s) 
    | c > 0 = count (c - 1) d s
    | otherwise = count c (d + 1) s

solve s = answer where
    (op, cl) = count 0 0 s
    answer = replicate cl '(' ++ s ++ replicate op ')'


Measured memory_bytes: 508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		sc.close();
		if(N < 2 || N % 2 == 1){
			System.out.println(fnika(N));
		}else{
			System.out.println(fnijou(N));
		}
	}

	private static long fnika(long n) {// n<2のとき
		return 0;
	}

	private static long fnijou(long n) {// n>=2のとき
		n /= 2;
		long baisu = 0;
		while(n!=0){
			baisu += n / 5;
			n /= 5;
		}
		return baisu;
	}
}


Measured memory_bytes: 21972
#dpテーブルのみでの解法(とびとび)
n,w=map(int,input().split())
a=[]
dp=[]
for i in range(n):
   a.append(list(map(int,input().split())))
for k in range(n+1):
  dp.append([])
  for l in range(w+1):
      dp[k].append(0)
for i in range(n):
   for j in range(w+1):
       dp[i+1][j]=max(dp[i+1][j],dp[i][j])
       if j+a[i][0]<=w:
           dp[i+1][j+a[i][0]]=max(dp[i+1][j+a[i][0]],dp[i][j]+a[i][1])
print(dp[n][w])

Measured memory_bytes: 143436
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,f;
   long double xy;
    long long cnt = 0;
    cin>>n>>f;
    while(n--){
        double x,y;
        cin>>x>>y;
        xy = sqrt(x*x+y*y);
       // cout<<xy<<" - "<<f<<endl;
        if(xy<=f) cnt++;

    }
    cout<<cnt;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  bool ok = false;
  int ans10, ans5, ans1;
  for (int i = 0; i <= min(N, Y/10000); i++) {
    int y10 = Y - i * 10000;
    int n10 = N - i;
    for (int j = 0; j <= min(n10, y10/5000); j++) {
      int y5 = y10 - j * 5000;
      int n5 = n10 - j;
      if (n5 * 1000 == y5) {
        ok = true;
        ans10 = i, ans5 = j, ans1 = n5;
      }
    }
  }
  
  if (ok) {
    cout << ans10 << " " << ans5 << " " << ans1 << endl;
  } else {
    cout << -1 << " " << -1 << " " << -1;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}
ll ans=-1000000000;



int main()
{
 string s;
 cin>>s;
 ll n;
 cin>>n;
 ll cnt=0;
 rep(i,n){
  ll a;
  cin>>a;
  if(a==1)cnt++;
  if(a==2){
      ll b;
      string c;
      cin>>b>>c;
      if(cnt%2==1){
          if(b==1)b=2;
          else b=1;
      }
      if(b==1)s.insert(0,c);
      if(b==2)s+=c;
  }
 }
 if(cnt%2==1)reverse(s.begin(),s.end());
cout<<s<<endl;
}



Measured memory_bytes: 3924
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
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; }

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

  rep(i,0,s.size()){
    int x=s[i]-'A';
    x=(x+n)%26;
    putchar('A'+x);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+10,Mod=1e9+7;
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> a(n);
    for(int& x : a) {
        scanf("%d", &x);
    }
    vector<bool> dp(k + 1);
    for(int stones = 0; stones <= k; ++stones) {
        for(int x : a) {
            if(stones >= x && !dp[stones-x]) {
                dp[stones] = true;
            }
        }
    }

    puts(dp[k] ? "First" : "Second");
}


Measured memory_bytes: 256
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <iostream>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;
int main() {
    string s;
    cin >> s;
    if (s == "ABC"){
        cout << "ARC";
    }
    else {
        cout << "ABC";
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int a[100][100], b[100];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << a[k - 1] << "\n";
    return 0;
}

Measured memory_bytes: 892
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
  int N;
  cin>>N;
  vector<int> p(1000000,0);
  int s=0;
  for(int i=0;i<N;i++){
    int k;
    cin>>k;
    p[k]++;
    s+=k;
  }
  int Q;
  cin>>Q;
  while(Q--){
    int a,b;
    cin>>a>>b;
    s=s-p[a]*a+p[a]*b;
    p[b]+=p[a];
    p[a]=0;
    cout<<s<<'\n';
  }
}
signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

Measured memory_bytes: 11156
#include <stdio.h>

int main(void)
{

  int A=0,B=0,C=0;
  
  scanf("%d %d %d",&A,&B,&C);

  if(A==B&&A!=C)
  {
    printf("Yes\n");
  }

  else
  {
    if(A==C&&B!=C)
    {
      printf("Yes\n");
    }
    else
    {
      if(B==C&&B!=A)
      {
        printf("Yes\n");
      }
      else
      {
        printf("No\n");
      }
    }
  }
  
  return 0;
  
}

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

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

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

	long long ans = LLONG_MAX;
	for (long long i = -100; i <= 100; i++) {
		long long cost = 0;
		for (int j = 0; j < n; j++) {
			cost += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
}

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

using namespace std;

vector<int> split(const string &s, char delim) {
    vector<int> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(atoi(item.c_str()));
        }
    }
    return elems;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    cin >> S;
    
    vector<int> ymd = split(S, '/');
    
    string res;
    if (ymd[1] < 4) {
        res = "Heisei";
    } else if (ymd[1] == 4 && ymd[2] < 31){
        res = "Heisei";
    } else {
        res = "TBD";
    }
    
    cout << res << endl;
    
    return 0;

}



Measured memory_bytes: 256
//0062

#include<stdio.h>

int main(void)
{
	const int N = 10;
	char str[N+1];
	int i, j;
	while(scanf("%s", str) == 1)
	{
		for(i = N; i > 1; i--)
		{
			for(j = 0; j < i-1; j++)
			{
				str[j] = (str[j] - '0' + str[j+1] - '0') %10 + '0';
			}
		}
		putchar(str[0]);
		putchar('\n');
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll N,X,T;
    cin >> N >> X >> T;
    ll count = (N-1) / X + 1;
    cout << count * T << endl;
    return 0;
}

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

int main(){
  int64_t X;
  cin>>X;
  int64_t ans=0;
  int64_t r=X/500;
  ans += 1000*r;
  X -= 500*r;
  ans += X-(X%5);

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main(void){
        int N, X, T, lot;
        scanf("%d %d %d",&N, &X, &T);
        if(N%X == 0){
            lot = N/X;
        }else{
            lot = N/X +1;
        }
        printf("%d\n",lot*T);
        return 0;
    }


Measured memory_bytes: 1712
# -*- coding: utf-8 -*- #

A, B, C, D = list(input())
OP = ['+', '-']

for op1 in OP:
    for op2 in OP:
        for op3 in OP:
            ans = A + op1 + B + op2 + C + op3 + D
            if eval(ans) == 7:
                ans = ans+"=7"
                break
        else:
            continue
        break
    else:
        continue
    break

print(ans)

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int H, W;
//int counter = 0;

bool judge(vector<P>& v, vector<string>& s) {
    //counter++;
    vector<string> s2(H);
    for (int i = 0, j = 0; i < (H + 1) / 2; i++) {
        if (v[i].first == v[i].second) {
            s2[H / 2] = s[v[i].first];
            continue;
        }
        s2[j] = s[v[i].first];
        s2[H - 1 - j] = s[v[i].second];
        j++;
    }

    vector<int> used(W, false);
    int ok = W % 2;
    for (int i = 0; i < W; i++) {
        if (used[i]) continue;
        for (int j = W - 1; j >= i; j--) {
            if (used[j]) continue;
            bool flag = true;
            for (int k = 0; k < H; k++) {
                if (s2[k][i] != s2[H - 1 - k][j]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                if (j == i) {
                    if (!ok) return false;
                    ok = false;
                }
                used[i] = true;
                used[j] = true;
                break;
            }
        }
        if (!used[i]) {
            return false;
        }
    } 
    return true;
}

bool solve(int used, vector<P> v, vector<string>& s) {
    vector<int> idxs;
    for (int i = 0; i < H; i++) {
        if (used & (1 << i)) continue;
        idxs.push_back(i);
    }

    int m = idxs.size();
    if (m == 0) {
        return judge(v, s);
    } else if (m == 1) {
        used ^= (1 << idxs[0]);
        v.emplace_back(idxs[0], idxs[0]);
        if (solve(used, v, s)) return true;
        v.pop_back();
        used ^= (1 << idxs[0]);
    } else {
        for (int ii = 0; ii < 1; ii++) {
            int i = idxs[ii];
            used ^= (1 << i);
            if (m % 2 == 1) {
                v.emplace_back(i, i);
                if (solve(used, v, s)) return true;
                v.pop_back();
            }
            for (int jj = ii + 1; jj < m; jj++) {
                int j = idxs[jj];
                used ^= (1 << j);
                v.emplace_back(i, j);
                if (solve(used, v, s)) return true;
                used ^= (1 << j);
                v.pop_back();
            }
            used ^= (1 << i);
        }
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    vector<string> s(H);

    //vector<int> cnt(26, 0);
    for (int i = 0; i < H; i++) {
        cin >> s[i];
        /*
        for (int j = 0; j < W; j++) {
            cnt[s[i][j] - 'a']++;
        }*/
    }
    
    /*
    int hoge = 0;
    for (int i = 0; i < 26; i++) {
        hoge += cnt[i] % 2;
    }
    if (hoge != (H * W) % 2) {
        cout << "NO" << endl;
        return 0;
    }*/
    
    vector<P> v;
    cout << (solve(0, v, s) ? "YES" : "NO") << endl;
    //cout << counter << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

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

	string s, t;
	cin >> s >> t;

	int a, b;
	cin >> a >> b;

	string u;
	cin >> u;

	if(s == u) a--;
	if(t == u) b--;

	cout << a << " " << b << endl;
}


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

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

using namespace std;

int nlist[20010];

int main () {
  int N;
  cin >> N;
  REP (i, 0, N) {
    int t;
    cin >> t;
    nlist[t - 1] = i;
  }
  
  int X = 40000;
  
  REP (i, 0, N) {
    cout << X * (i + 1) + nlist[i] << ' ';
  }

  cout << '\n';
  
  REP (i, 0, N) {
    cout << X * (N - i) << ' ';
  }
  
  cout << '\n';
  
  return 0;
}


Measured memory_bytes: 768
N = int(input())
dn = {}
dm = {}

for _ in range(N):
    s = input()
    if s in dn:
        dn[s] += 1
    else:
        dn[s] = 1
        
M = int(input())
for _ in range(M):
    t = input()
    if t in dm:
        dm[t] += 1
    else:
        dm[t] = 1

ans = 0
for k, v in dn.items():
    res = v
    if k in dm:
        res -= dm[k]
    ans = max(ans, res)

print(ans)


Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{s:[chars;3]};
    let mut t = 0;
    let mut idx = vec![0,0,0];
    loop {
        idx[t] += 1;
        if idx[t] == s[t].len()+1 {
            break;
        }
        match s[t][idx[t]-1] {
            'a' => t=0,
            'b' => t=1,
            'c' => t=2,
            _ => t=3,
        }

    }

    println!("{}", match t {
        0 => "A",
        1 => "B",
        2 => "C",
        _ => "_"
    });

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N,  M; cin >> N >> M;
map<int, set<int>> G;
rep(i, 0, M){
    int a, b; cin >> a >> b;
    G[a].insert(b);
    G[b].insert(a);
}

for (int n : G[1])
    if (G[N].count(n)) {
        cout << "POSSIBLE\n";
        return 0;
    }
cout << "IMPOSSIBLE\n";

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 37760
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			m = scanner.nextInt();
			n = scanner.nextInt();
			if ((m | n) == 0)
				break;
			M = new HashMap<Integer, Integer>();
			h = 1;
			a = new int[n][m];
			Y = new int[24];
			X = new int[24];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++) {
					int t = scanner.nextInt();
					if (t == 0) {
						a[i][j] = -1;
					} else if (t == 1) {
						Y[h] = i;
						X[h] = j;
						a[i][j] = h++;
					} else {
						Y[0] = i;
						X[0] = j;
						a[i][j] = 0;
					}
				}
			System.out.println(slove(0, 1));
		}
	}

	private int slove(int cur, int bit) {
		int k = cur << 24 | bit;
		if (M.containsKey(k))
			return M.get(k);
		int res = 0;
		for (int[] mo : move) {
			int y = Y[cur];
			int x = X[cur];
			while (true) {
				y += mo[0];
				x += mo[1];
				if (!isOK(y, x))
					break;
				if (a[y][x] == 0)
					if (Integer.bitCount(bit) == h) {
						return res + 1;
					}
				if (a[y][x] >= 1) {
					if ((bit >> a[y][x] & 1) == 1)
						continue;
					res += slove(a[y][x], bit | 1 << a[y][x]);
					break;
				}
			}
		}
		M.put(cur << 24 | bit, res);
		return res;
	}

	private boolean isOK(int y, int x) {
		if (0 <= y && y < n && 0 <= x && x < m)
			return true;
		return false;
	}

	int m, n, h;
	int[] Y, X;
	int[][] a;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
	Map<Integer, Integer> M;
}

Measured memory_bytes: 178704
while true
  n = gets.to_i
  break if n == 0

  if n<4
    puts 1
  else
    a = Array.new(n)
    a[0..2] = [1,2,4]
    for i in 3..n-1
      a[i] = a[i-1]+a[i-2]+a[i-3]
    end
    puts (a[-1]/10 +1)/365 +1
  end
end

Measured memory_bytes: 8580
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll a[n+1][4];
    for(ll i=1;i<=n;i++)
        {
            cin>>a[i][1]>>a[i][2]>>a[i][3];
        }
    ll dp[n+1][4];
    dp[1][1]=a[1][1];
    dp[1][2]=a[1][2];
    dp[1][3]=a[1][3];
    for(int i=2;i<=n;i++)
    {
        dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=a[i][3]+max(dp[i-1][1],dp[i-1][2]);
    }
    ll ans=max(dp[n][1],max(dp[n][2],dp[n][3]));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9804
def solve():
  N, K, C = map(int, input().split())
  workable = [i for i, s in enumerate(input(), 1) if s=="o"]
  
  if len(workable) == K:
    return workable
  
  latest = set()
  prev = workable[-1]+C+1
  for x in reversed(workable):
    if prev - x > C:
      latest.add(x)
      prev = x
  
  if len(latest) > K:
    return []
  
  def ans():
    prev = -C-1
    for x in workable:
      if x - prev > C:
        if x in latest:
          yield x
        prev = x
  return ans()

print("\n".join(map(str, solve())))


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

int dp[100001];

int main(){

	int n,k;
	scanf("%d%d",&n,&k);
	vector<int> a(n);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
	}

	memset(dp,0,sizeof dp);
	dp[0]=0;

	for(int i=1;i<n;++i){
		int ans=INT_MAX;
		for(int j=1;j<=k;++j){
			if(i>=j){
				ans = min(ans,dp[i-j]+ abs(a[i]-a[i-j]));
			}
		}
		dp[i]=ans;
	}

	printf("%d\n",dp[n-1]);

	return 0;
}

Measured memory_bytes: 4120
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		//Integer[][] array = new Integer[n][m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		for(int i=1;101>i;i++) {
			if(a%i==0&&b%i==0) {
				list.add(i);
			}
		}
		Collections.reverse(list);
		System.out.println(list.get(k-1));
	}
}



Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


// Modint
struct Mint {
	static const ll mod = (ll)(1e9 + 7);
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "WARNING: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, int b) {
	return a.pow(b);
}

int main() {
	int n; cin >> n;
	int a, b; cin >> a >> b;
	Mint ans = pow(Mint(2), n) - Mint(1);
	Mint m = 1;
	for (int i = 1; i <= a; i++) {
		m *= Mint(n - i + 1) / Mint(i);
	}
	ans -= m;
	m = 1;
	for (int i = 1; i <= b; i++) {
		m *= Mint(n - i + 1) / Mint(i);
	}
	ans -= m;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string str="";
  int ascii = 0;
  int maxnum=0;
  int maxcount =0;
  vector<string> strvec;
  map<string,int> mp;
  
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> str;
  	mp[str] += 1;
  }
   for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
     	if(maxnum < itr->second){
        	maxnum = itr->second;
          	maxcount = 0;
          	strvec.clear();
        }
     	if(maxnum == itr->second){
        	maxcount ++;
          	strvec.push_back(itr->first);
        }
    }
  if(strvec.size() != 1){
  	sort(strvec.begin(), strvec.end());
    for(string s :strvec){
    	cout << s << endl;
    }
  }else{
  	cout << strvec.at(0) << endl;
  }
  
}

Measured memory_bytes: 26868
N, M = gets.chop.split.map(&:to_i)

path_counts = Array.new(N+1, 0)

(1..M).to_a.each do |i|
  a, b = gets.chop.split.map(&:to_i)
  path_counts[a] += 1
  path_counts[b] += 1
end

puts path_counts[1..-1]

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

ll dp[100005][3];//a:0,b:1,c:2
void solve(){
    int n;
    cin>>n;
    vector<ll>a(n),b(n),c(n);
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    rep(i,n){
        rep(j,3){
            if(!j)dp[i+1][j]=max(dp[i][1],dp[i][2])+a[i];
            else if(j==1)dp[i+1][j]=max(dp[i][0],dp[i][2])+b[i];
            else dp[i+1][j]=max(dp[i][0],dp[i][1])+c[i];
        }
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

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


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll n,a[10000007];
int main()
{
    sfl(n);
    for(ll i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        {
            a[j]++;
        }
    }
    ll z =0;
    for(ll i=1;i<=n;i++)
    {
        z+=(i*a[i]);
    }
    pf("%lld\n",z);
}


Measured memory_bytes: 81900
#include <cstdio>
#include <algorithm>
using namespace std;

int a[100];
int main(){
  int n,i,r,s;
  for(;~scanf("%d",&n);printf("%d\n",r)){
    for(r=s=i=0;i<n;i++)scanf("%d",a+i);
    sort(a,a+n);
    for(i=0;i<n;i++)r+=s+=a[i];
  }
}

Measured memory_bytes: 1044
#include<stdio.h>
int main(void)
{
	int a,i,s,ss;
	for(i=0;i<5;i++){
		scanf("%d",&a);
		if(40>a){
			a=40;
		}
		s+=a;
	}
	ss=s/5;
	printf("%d\n",ss);
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
vector<vector<ll>> note;
vector<ll> vec;

ll dp(ll i,ll j,ll sum) {
  if(i==j) {
return vec[i-1];
  }
  if(i+1==j) {
return max(vec[i-1],vec[j-1]);
  }
  
  if(note[i-1][j-1]>0) {
return note[i-1][j-1];
  }
  
  
    ll s=max(sum-dp(i+1,j,sum-vec[i-1]),sum-dp(i,j-1,sum-vec[j-1]));
  note[i-1][j-1]=s;
  return s;
    
}

int main() {
  ll N;
  cin>>N;
  note=vector<vector<ll>> (N,vector<ll>(N,0));
  vec=vector<ll> (N);
  ll sum=0;

  for(ll i=0;i<N;i++) {
cin>>vec[i];
    sum+=vec[i];
  }
  
  ll X=dp(1,N,sum);
  cout<<X-sum+X<<endl;
}
  
  
  
 
  


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int H, W, A, B; cin >> H >> W >> A >> B;
    if (H/2 < B) assert(false);
    else {
        string x = "", y = "";
        FOR(i,0,A-1) x += '0', y += '1';
        FOR(i,A,W-1) x += '1', y += '0';

        FOR(i,0,B-1) {
            cout << x << '\n';
            cout << y << '\n';
        }

        FOR(i,2*B,H-1) {
            cout << x << '\n';
        }
    }
}



Measured memory_bytes: 1280
# D - Multiple of 2019
S = input()
mod = [1]+[0]*2018
tmp = 0
seki = 1
for k in range(len(S)):
    tmp = (seki*int(S[len(S)-1-k])+tmp)%2019
    mod[tmp] += 1
    seki = (seki*10)%2019
ans = 0
for k in range(2019):
    ans += mod[k]*(mod[k]-1)//2
print(ans)

Measured memory_bytes: 9280
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

#define ABS(a) ((a)>(0)?(a):-(a))

tmp_t P[50];
tmp_t Q[50];

int main()
{
  int cnt;
  int64 N;
  int i;
  int diff = 0;

  get_N(&N);

  for(i=0; i<N; i++) {
    cnt = scanf("%lld", &(P[i].a));
    Q[i].a = P[i].a;
  }

  qsort_a(P, N);
  for(i=0; i<N; i++) {
    if (Q[i].a != P[i].a) {
      diff++;
    }
  }

  if (diff <= 2) {
    printf("YES");
  } else {
    printf("NO");
  }

  return 0;
}



Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;

int main ()
{
    int A1,A2,A3;


        cin>>A1>>A2>>A3;
        if(A1+A2+A3>=22)
        {
            cout<<"bust"<<endl;
        }
        else
        {
            cout<<"win"<<endl;
        }

    return 0;
}


Measured memory_bytes: 256
function main(input) {
  input = input.trim();
  const [a,b,c,d] = input.split(" ").map(Number);
  if((a*b)>(c*d)){
    console.log(a*b);
  }else if((a*b)<(c*d)){
    console.log(c*d);
  }else{
    console.log(a*b);
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  string s, t;cin>>s>>t;
  vector<vector<ll>> sc(26);
  rep(i, s.size())sc[s[i]-'a'].push_back(i+1);

  bool f=true;
  rep(i, t.size())if(sc[t[i]-'a'].empty())f=false;
  if(!f){ cout<<-1;return 0; }

  ll s_count=0, s_index=0;
  rep(i, t.size()){
//cout<<t[i]<<':'<<s_count<<' '<<s_index<<endl;
    auto b = sc[t[i]-'a'].begin();
    auto e = sc[t[i]-'a'].end();
    auto it = upper_bound(b, e, s_index);
    // もし今見ている文字の位置情報を格納した配列の最後の値よりも
    // sの中を進んでいるインデックスが大きければ、次の連結されたsへ移動する
    if(e==it){
      s_count++;
      s_index=0;
      it = upper_bound(b, e, s_index);
    }

    // get value from it
    s_index = *it;
  }

  cout<<s.size()*s_count+s_index;

  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  string ans;
  string a;
  
  cin>>a;
  ans=a;
  if(a[1]=='B')ans[1]='R';
  else ans[1]='B';
  cout<<ans<<endl;
}

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

long long getprefixxor(long long n) {
  long long ans = 0;
  ++n;
  int bitpos = 0;
  long long msb = 1 << bitpos;
  while (msb <= n - 1) {
    long long period = msb << 1;
    long long count1 = n / period * period / 2 + max(n % period - period / 2, (long long) 0);
    if (count1 & 1) ans |= ((long long)1 << bitpos);
    //debug(bitpos, count1);
    ++bitpos; msb <<= 1;
  }
  //debug(ans);
  return ans;
}

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  long long a, b;
  cin >> a >> b;
  //cout << a << ' ' << b << endl;

  // long long testa = 0, testb = 0;
  // for (int i = 0; i <= a; ++i) testa ^= i;
  // for (int i = 0; i <= b; ++i) testb ^= i;

  //cout << bitset<64>(b) << endl;
  //long long msb = 1;
  //while (msb <= b) msb <<= 1;
  //msb -= 1;
  a = getprefixxor(a - 1);
  b = getprefixxor(b);
  //cout << bitset<64>(msb) << endl;
  //cout << bitset<64>(a) << ' ' << bitset<64>(b) << endl;
  // cerr << a << ' ' << testa << endl;
  // cerr << b << ' ' << testb << endl;
  long long ans = a ^ b;
  //cout << bitset<64>(ans) << endl;
  cout << ans << endl;
  //cerr << (1L << 33);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

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

int w,h;
int f[20][20];
int ans;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};

void rec(int n,int x, int y){

	if(n > 10)return;

	rep(i,4){
		int mx = x + dx[i];
		int my = y + dy[i];

		if(f[my][mx] == 1)continue;
		if(0>mx || mx>=w)continue;
		if(0>my || my>=h)continue;

		while(1){
			if(f[my][mx] == 3){
				if(n < ans)ans = n;
				return;
			}

			mx += dx[i], my += dy[i];
			if(0>mx || mx>=w)break;
			if(0>my || my>=h)break;

			if(f[my][mx] == 1){
				f[my][mx]=0;
				rec(n+1,mx-dx[i],my-dy[i]);
				f[my][mx]=1;
				break;
			}
		}
	}
}

int main(){

	int sx,sy;

	while(std::cin >> w >> h, (w||h)){

		rep(i,h){
			rep(j,w){
				std::cin >> f[i][j];
				if(f[i][j] == 2){
					sx = j, sy = i;
				}
			}
		}
		ans = 11;
		rec(1,sx,sy);
		if(ans > 10)ans = -1;
		std::cout << ans << std::endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  string n;
  cin >> n;
  auto pos = n.find("7");
  if(pos == string::npos) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<string>
#define INF 10000000
using namespace std;
bool judge(string s,int length,char ch)
{
    for (int i = 0; i < length; i++)
    {
        if (s[i]!=ch)
        return false;
    }
    return true;
}
int main()
{
    string a;
    cin>>a;
    string b = a;
    int ans = INF;
    for (int i = 0; i < a.length(); i++)
    {
        int length = a.length();
        b=a;
        char cur = a[i];
        int f = a.length();
        int p = 0;
        while (!judge(b,length,cur))
        {
            length--;
            for (int j = 0; j < length; j++)
            {
                if (b[j]==cur||b[j+1]==cur) b[j]=cur;
            }

        }
        ans = min(ans,f-length);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    int size = s.length();
    bool thing = false;
    FOR(j,0,size+5) {
        for (int i = size-1; i > 0; i--) {
            swap(s[i-1], s[i]);
        }
        if (s == t)
            thing = true;
    }
    if (thing)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
h1,m1,h2,m2,k = map(int, input().split())
t1 = h1 * 60 + m1
t2 = h2 * 60 + m2

if t2 > t1:
	awake = t2 - t1
else:
    awake = 24 * 60 - t1 + t2

print(awake - k)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
	int t;
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.size();i++)
	{
		sum+=s[i]-'0';
	}
	if(sum%9==0)
	{
		cout<<"Yes\n";
	}
	else cout<<"No\n";
}


Measured memory_bytes: 3732
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif
using namespace std;

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
typedef unsigned char byte;
typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

llong K;
llong res[50];

int main()
{
    while (cin >> K)
    {
        llong div = K / 50;
        llong mod = K % 50;

        cout << 50 << endl;
        for (llong i = 0; i < 50; ++i)
        {
            res[i] = 49LL - K + 51LL * (div + (bool)mod);
            if (mod)
                --mod;
            if (i)
                cout << " ";
            cout << res[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
p={}
for i in range(5):
    p[i] = int(input())
k = int(input())

flag = bool(False)
for i in range(1,5):
    for j in range(0,i-1):
        if k < p[i]-p[j] :
            flag = True

if flag == False:
    print("Yay!")
if flag == True:
    print(":(")

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

int main(){
    int n;cin >> n;
    vector<P> p(n);
    rep(i,n){
        int x,l;
        cin >>x >> l;
        p[i].first = x+l;
        p[i].second = x-l;
    }
    sort(p.begin(),p.end());
    int cnt = 1;
    int ind = 0;
    for(int i = 1;i <= n-1;i++){
        if(p[i].second<p[ind].first) continue;
        ind = i;
        cnt ++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 4040