akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

    int n;
    cin >> n;

    int four_c = 0;
    int two_c = 0;
    int not_c = 0;

    rep(i, n) {
        int a;
        cin >> a;
        if(a % 2 != 0) ++not_c;
        else {
            if(a % 4 == 0) ++ four_c;
            else ++two_c;
        }
    }

    if(two_c == 0) {
        if(not_c - four_c <= 1) {
            cout << "Yes" << endl;
            return 0;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    else {
        if(not_c <= four_c) {
            cout << "Yes" << endl;
            return 0;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    //cout << four_c << " " << two_c << " " << not_c << endl;
    return 0;
}

Measured memory_bytes: 3600
n=int(input())
l=[int(i) for i in input().split()]
ans=1
chk=-1
flg=0
for i in range(0,n):
    if chk==-1:
        chk=l[i]
    elif chk==l[i]:
        pass
    elif flg==0:
        flg=[-1,1][chk-l[i]<0]
        chk=l[i]
    elif flg==-1:
        if chk-l[i]<0:
            ans+=1
            flg=0
        chk=l[i]
    else:
        if chk-l[i]>0:
            ans+=1
            flg=0
        chk=l[i]
print(ans)


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

using namespace std;

int main() {
	int a, b, C;
	double pi, rad, c, S, L, h;

	pi = acos(-1);

	cin >> a >> b >> C;

	rad = C * (pi / 180);
	c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad));

	S = a * b * sin(rad) / 2;
	L = a + b + c;
	h = 2 * S / a;

	cout << fixed << setprecision(5) << S << endl;
	cout << fixed << setprecision(5) << L << endl;
	cout << fixed << setprecision(5) << h << endl;

	return 0;
}



Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[1000010], q, l, r;
bool v[1000010];
int cnt[1000010];


int32_t main(){
INIT
cin>>n;
int sgcd=0;
bool sw=false, pw=true;
for(int i=1; i<=n; i++){
    cin>>a[i]; cnt[a[i] ]++;
    sgcd=__gcd(sgcd, a[i]);
}
if(sgcd==1){sw=true;}


for(int i=2; i<=1000000; i++){
    if(!v[i]){
        int c=0; c+=cnt[i];
        for(int j=2*i; j<=1000000; j+=i){
            v[j]=true;
            c+=cnt[j];
        }
    if(c>1){pw=false; break;}
    }
}

if( pw ){
    cout<<"pairwise coprime";
}
else{
    if(sw){
        cout<<"setwise coprime";
    }
    else{
        cout<<"not coprime";
    }
}




return 0;
}





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

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);

//main function
int main() {
    int r = iin();
    iout(r*r);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

#define FOR(i,j,k) for(int i=j;i<=(k);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define ll long long

const int maxn = 1005;
int n, ans;
int sum[maxn], in[maxn];
int tot, go;

inline int calmin(int h, int m)
{
    return h*60+m;
}

inline int caldate(int mm ,int dd)
{
    return mm*31+dd;
}

int main()
{
    int mm, dd, h, m, id;
    int curdate, lasttime;
    char io[3];
    while (scanf("%d", &n) == 1 && n)
    {
        memset(sum, 0, sizeof(sum));
        curdate = 0; tot = 0;
        for (int i=0;i<n;i++)
        {
            scanf("%d/%d %d:%d %s %d", &mm, &dd, &h, &m, io, &id);
            int t = calmin(h, m);
            if (curdate == caldate(mm, dd))
            {
                lasttime = 0;
                memset(in, 0, sizeof(in));
            }
            if (io[0] == 'I')
            {
                if (go)
                {
                    for (int i=1;i<=tot;i++)
                        if (in[i]) sum[i] += t - lasttime;
                }
                if (id == 0) go = 1;
                in[id] = 1;
                tot = max(tot, id);
            }
            else
            {
                if (go)
                {
                    for (int i=1;i<=tot;i++)
                        if (in[i]) sum[i] += t - lasttime;
                }
                if (id == 0) go = 0;
                in[id] = 0;
            }
            lasttime = t;
        }
        ans = 0;
        for (int i=1;i<=tot;i++)
            ans = max(ans, sum[i]);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  string s;
  int ans = 0;
  cin >> n >> s;
  for(int i=0;i<n;i++){
    ans++;
    while(1){
      if(s[i]==s[i+1]) i++;
      else break;
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int a[50000];
int b[50000];
int o[50000];

int rc[2][50000];

int main(){
  int rcs[2], q;

  while(scanf("%d%d%d", &rcs[0], &rcs[1], &q), rcs[0] + rcs[1] + q){
    REP(i,q) scanf("%d%d%d", &a[i], &b[i], &o[i]);

    int rrcc[2] = {0};
    int ans = 0;

    memset(rc[0], 0, sizeof(int) * rcs[0]);
    memset(rc[1], 0, sizeof(int) * rcs[1]);

    for(int i = q - 1; i >= 0; i--){
      if(!rc[a[i]][b[i]]){
	rc[a[i]][b[i]] = 1;
	rrcc[a[i]]++;
	if(o[i] == 1) ans += rcs[!a[i]] - rrcc[!a[i]];
      }
    }

    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  ll n, a, t;
  cin >> n >> t >> a;
  vector<ll> h(n);
  for(ll i = 0; i < n; i++) cin >> h[i];
 
  double mintem = 1e9;
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    double tem = t - h[i]*0.006;
    if(abs(a-tem) < abs(a-mintem)){
      mintem = tem;
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;


class MainClass
{
	static void Main(string[] args)
	{
		int a, b;
		string s;
		string[] str;

		while ((s = Console.ReadLine()) != null)
		{
			str = s.Split(' ');

			a = int.Parse(str[0]);
			b = int.Parse(str[1]);

			Console.WriteLine(a + b);
		}
	}
}

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

int main() {
  ll n;
  cin >> n;
  vector<string> s(n);
  vector<string> sm;
  vector<string> sa;
  vector<string> sr;
  vector<string> sc;
  vector<string> sh;
  rep(i,n) {
    cin >> s[i];
    if(s[i].at(0)=='M') sm.push_back(s[i]);
    if(s[i].at(0)=='A') sa.push_back(s[i]);
    if(s[i].at(0)=='R') sr.push_back(s[i]);
    if(s[i].at(0)=='C') sc.push_back(s[i]);
    if(s[i].at(0)=='H') sh.push_back(s[i]); 
  }
  ll m = sm.size();
  ll a = sa.size();
  ll r = sr.size();
  ll c = sc.size();
  ll h = sh.size();
  ll ans = 0;
  ans += m*a*r;
  ans += m*a*c;
  ans += m*a*h;
  ans += m*r*c;
  ans += m*r*h;
  ans += m*c*h;
  ans += a*r*c;
  ans += a*r*h;
  ans += a*c*h;
  ans += r*c*h;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11636
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main(signed argc, char ** argv) {
    int k, t;
    cin >> k >> t;
    vi a(t);
    rep (i, t) cin >> a[i];

    int pre = -1;
    int ans = 0;
    while (k--) {
        pii ma(-1, -1);
        rep (i, t) {
            if (i == pre) continue;
            if (a[i] == 0) continue;
            chmax(ma, pii(a[i], i));
        }
        if (ma.second == -1) {
            ans++;
            a[pre]--;
        }
        else {
            a[ma.second]--;
            pre = ma.second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  long long L[87];
  L[0]=2LL,L[1]=1LL;
  for ( int i =2; i <= N ; i ++) {
    L [ i ]= L [i -2]+ L [i -1];
  }
  cout<<L[N]<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char a[21][21];

int main()
{
  int n,x,y,m,s;
  int i;
  char d[3];

  while(1){
    scanf("%d", &n);
    if(n==0)
      break;

    memset(a,0,sizeof(a));

    for(i=0;i<n;i++){
      scanf("%d%d", &x, &y);
      a[x][y]=1;
    }

    scanf("%d", &m);
    x=10,y=10;
    while(m-- > 0){
      scanf("%s%d", d, &s);
      while(s-- > 0){
	if(d[0] == 'E')x++;
	else if(d[0] == 'S')y--;
	else if(d[0] == 'W')x--;
	else if(d[0] == 'N')y++;
	
	if(a[x][y]){
n--;
a[x][y]=0;
}
      }
    }

    if(n==0)
      printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}



Measured memory_bytes: 2512
#include<iostream>
int main(){
	int a, b, c;
  std::cin >> a >> b >> c;
  if(a==b && b==c && a==c) std::cout << "No" << std::endl;
  else if( a!=b && b!=c && a!=c) std::cout << "No" << std::endl;
  else std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back

const double eps  = 1e-10;
const int inf = (1 << 21);

class state{
public:
  int t,now,ori;
  int cnt;
  bool operator<(const state & a)const{
    if (now*a.t != a.now*t)return now*a.t < a.now*t;
    return t > a.t;
  }
};

int solve(int n,vector<state>& in){
  int ans=0;
  sort(ALL(in));
  int m= n;

  while(n){
    int mint = inf;
    rep(i,n){
      mint = min(mint,in[i].t-in[i].now%in[i].t);
    }
    
    rep(i,n){
      in[i].now+=1;
      int tnow=in[i].now-1,tt=in[i].t;
      rep(j,n){
	if (i == j)continue;
	if ((tnow)*in[j].t >=(in[j].now)*tt)continue;
	if (in[i].t <= in[j].t)continue;
	double t = (in[i].t*in[j].t)*(in[j].now-in[i].now)/(double)(in[j].t-in[i].t);
	if (t <0)continue;
	if (t < mint){
	  mint=(int)(t+1);
	}
      }
      in[i].now-=1;
    }
    
    rep(i,n){
      in[i].now+=mint;
      int tnow=in[i].now-mint,tt=in[i].t;
      rep(j,n){
	if (i == j)continue;
	if ((tnow)*in[j].t >=(in[j].now)*tt)continue;
	if ((in[i].now)*in[j].t >= (in[j].now+mint)*in[i].t){
	  in[i].now=in[j].now+mint;
	  in[i].t=in[j].t;
	}
      }
      in[i].now-=mint;
    }

    rep(i,n){
      in[i].now+=mint;
    }

    rep(i,n){
      if (in[i].now%in[i].t == 0){
	if (in[i].now/in[i].t == 1){
	  in[i].t=in[i].ori;
	  in[i].now=in[i].ori;
	}else if (in[i].now/in[i].t==2){
	  in[i].t=in[i].ori;
	  in[i].now=0;
	  in[i].cnt--;
	  if (in[i].cnt == 0)in[i].now=inf,m--;
	}
      }
    }
    
    sort(ALL(in));
    for(int i=n-1;i>=0;i--){
      if (in[i].now == inf)n--;
    }
    ans+=mint;
  }
  return ans;
}

main(){
  int n;
  while(cin>>n && n){
    vector<state> in;
    rep(i,n){
      int t;
      int lap;
      cin>>t>>lap;
      in.pb((state){t,0,t,lap});
    }
    cout << solve(n,in) << endl;
  }
}

Measured memory_bytes: 912
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const long long M = 1000000007;

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

    vector<long long> x(n), y(m);
    rep(i,n){ cin >> x[i]; }
    rep(i,m){ cin >> y[i]; }

    long long xlen = 0, ylen = 0;
    rep(i,n) (xlen += i * x[i] - (n - i - 1) * x[i]) %= M;
    rep(i,m) (ylen += i * y[i] - (m - i - 1) * y[i]) %= M;

    cout << xlen * ylen % M << endl;
}


Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n = read::<u64>();
    let a = read::<u64>();
    let b = read::<u64>();
    let c = read::<u64>();
    let d = read::<u64>();
    let e = read::<u64>();

    let v = vec![a, b, c, d, e];
    let min = *v.iter().min().unwrap();
    if n <= min {
        println!("5");
    } else {
        let time = if n % min == 0 { n / min } else { n / min + 1 };
        println!("{}", time + 4);
    }

    /*
    let mut v = vec![n, 0, 0, 0, 0, 0];
    let ds = vec![a, b, c, d, e, 0];
    let mut time = 0;
    loop {
        for i in (0..5).rev() {
            if v[i] >= ds[i] {
                v[i + 1] += ds[i];
                v[i] = v[i] - ds[i];
            } else {
                v[i + 1] += v[i];
                v[i] = 0;
            }
        }
        time += 1;
        println!("{}: {:?}", time, v);

        if v[5] >= n {
            break;
        }
    }
    println!("{}", time);
    */
}


Measured memory_bytes: 4352
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

h, w, m = map(int, input().split())
List = [list(map(int, input().split())) for i in range(m)]
B = set()
for e in List:
    B.add(tuple(e))

hb = [0]*h
wb = [0]*w
for e in B:
    hb[e[0]-1] += 1
    wb[e[1]-1] += 1

hm = max(hb)
wm = max(wb)

hlist = []
for i, e in enumerate(hb):
    if e == hm:
        hlist.append(i)
wlist = []
for i, e in enumerate(wb):
    if e == wm:
        wlist.append(i)

for he in hlist:
    for we in wlist:
        if (he+1, we+1) not in B:
            print(hm+wm)
            exit()

print(hm+wm-1)


Measured memory_bytes: 194820
# coding: utf-8
N=int(input())
A=list((map(int,input().split())))
A.insert(0,0)

d=[]
skip_d=[]

for i in range(N):
    d.append(abs(A[i+1]-A[i]))
    if i<N-1:
        skip_d.append(abs(A[i+2]-A[i]))
    else:
        skip_d.append(abs(A[0]-A[i]))

d.append(abs(A[-1]))

sum_d=sum(d)

for i in range(N):
    ans=sum_d-(d[i]+d[i+1])+skip_d[i]
    
    print(ans)

Measured memory_bytes: 17116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <map>

using ll = long long;

ll F(ll N)
{
    if (N % 2 == 1)
    {
        ll i = (N / 2) % 2 == 0 ? 1 : 0;
        return i;
    }
    else
    {
        ll i = (N / 2) % 2 == 1 ? 1 : 0;
        return i ^ N;
    }
}

int main()
{
    ll A, B;
    std::cin >> A >> B;

    if (A == 0)
    {
        std::cout << B << std::endl;
    }
    else
    {
        std::cout << (F(A - 1) ^ F(B)) << std::endl;
    }

    return 0;
}

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

int card(char c){
	switch(c){
		case 'S':
			return 0;
		case 'H':
			return 1;
		case 'C':
			return 2;
		case 'D':
			return 3;
	}
}

char card2(int i){
	switch(i){
		case 0:
			return 'S';
		case 1:
			return 'H';
		case 2:
			return 'C';
		case 3:
			return 'D';
	}
}

int main(){
	int n,b;
	cin>>n;
	char c;
	bool a[4][13]={};
	for(int i=0;i<n;i++){
		cin>>c>>b;
		a[card(c)][b-1]=1;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			if(!a[i][j]){
				cout<<card2(i)<<" "<<j+1<<endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3080
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
NUM = 20005
 
table = [""]*NUM
 
 
while True:
 
    T = str(input())
    if T == '-':
        break
 
    left = 0
    right = 0
    #長い配列にパターン文字列を転記
    for i in range(len(T)):
        # print(T[right])
        table[left+right] = T[right]
        right += 1
 
    num_suffle = int(input())
 
    for loop in range(num_suffle):
        pick_num = int(input())
        #先頭からpick_num文字を末尾に転記し、論理削除
        for i in range(pick_num):
            table[right+i] = table[left+i]
        left += pick_num
        right += pick_num
 
    for i in range(left,right):
        print("%s"%(table[i]),end = "")
    print()


Measured memory_bytes: 5740
main :: IO ()
main = do
  mn <- getLine
  if mn == "0"
    then return ()
    else do
      let [m,n] = map (read :: String -> Int) (words mn)
          ans = (haming' n) - (haming' (m-1))
      putStrLn $ show ans
      main

haming2 :: Int -> Int -> Int
haming2 x y
  | x > y = 0
  | x == y = 1
  | otherwise = 1 + (haming2 (2*x) y) + (haming3 (3*x) y) + (haming5 (5*x) y)

haming3 :: Int -> Int -> Int
haming3 x y
  | x > y = 0
  | x == y = 1
  | otherwise = 1 + (haming3 (3*x) y) + (haming5 (5*x) y)

haming5 :: Int -> Int -> Int
haming5 x y
  | x > y = 0
  | x == y = 1
  | otherwise = 1 + (haming5 (5*x) y)

haming' :: Int -> Int
haming' y = haming2 1 y

Measured memory_bytes: 4020
import time
start = time.time()
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
s = [0 for i in range(n)] #それぞれ何試合目か
ans = 0
need = n*(n-1)//2
while need:
    c = [0 for i in range(n)] #今日試合をするかどうか
    ans += 1
    for first in range(n):
        if c[first] == 0 and s[first] < n-1:
            second = a[first][s[first]]-1 # firstが対戦したい相手
            second_num = s[second] # #secondの対戦番号
            if c[second] == 0 and a[second][second_num]-1 == first:
                c[first] = 1
                c[second] = 1
                s[first] += 1
                s[second] += 1
                need -= 1
    if sum(c) == 0:
        print(-1)
        exit()
    now = time.time()-start
    if now > 1.835:
        print(n*(n-1)//2)
        exit()
print(ans)

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

int main() {
	long long int N, K;
	cin >> N >> K;
	if(K == 0){
		cout << N * N << endl;
		return 0;
	}
	long long int ans = 0;
	for(int i = K + 1; i <= N; i++){
		ans += N / i * (i - K) + max(0LL, N % i - K + 1);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

int main(void)
{
	while(1) {
		int n, w, d;
		cin >> n >> w >> d;
		if (n == 0 && w == 0 && d == 0) break;
		vec<pair<int, int>> sq(1);
		sq[0] = {w, d};
		rep(i, n) {
			int p, s;
			cin >> p >> s;
			pair<int, int> keep = sq[p - 1];
			for (int i = p; i < (int)sq.size(); i++) sq[i - 1] = sq[i];
			
			pair<int, int> a, b;
			s = s % ((keep.first + keep.second) * 2);
			if (s < keep.first) {
				if (s < keep.first - s) {
					a = {s, keep.second};
					b = {keep.first - s, keep.second}; 
				} else {
					b = {s, keep.second};
					a = {keep.first - s, keep.second}; 
				}
			} else if (s < keep.first + keep.second) {
				if (s - keep.first < keep.second - s + keep.first) {
					a = {keep.first, s - keep.first};
					b = {keep.first, keep.second - s + keep.first};
				} else {
					b = {keep.first, s - keep.first};
					a = {keep.first, keep.second - s + keep.first};
				}
			} else if (s < keep.first * 2 + keep.second) {
				if (s - keep.first - keep.second < keep.first * 2 + keep.second - s) {
					a = {s - keep.first - keep.second, keep.second};
					b = {keep.first * 2 + keep.second - s, keep.second};
				} else {
					b = {s - keep.first - keep.second, keep.second};
					a = {keep.first * 2 + keep.second - s, keep.second};
				}
			} else {
				if (keep.first * 2 + keep.second * 2 - s < s - keep.first * 2 - keep.second) {
					a = {keep.first, keep.first * 2 + keep.second * 2 - s};
					b = {keep.first, s - keep.first * 2 - keep.second};
				} else {
					b = {keep.first, keep.first * 2 + keep.second * 2 - s};
					a = {keep.first, s - keep.first * 2 - keep.second};
				}
			}
			sq[(int)sq.size() - 1] = a;
			sq.push_back(b);
		}

		vec<int> l(n + 1);
		rep(i, n + 1) l[i] = sq[i].first * sq[i].second;
		sort(l.begin(), l.end());
		rep(i, n) cout << l[i] << " ";
		cout << l[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
 
namespace ABC045Coloring
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong H, W;
            int N;
            string[] vals = Console.ReadLine().Split(' ');
            H = ulong.Parse(vals[0]);
            W = ulong.Parse(vals[1]);
            N = int.Parse(vals[2]);
            ulong[,] ab;
            if (N >= 1)
                ab = new ulong[N, 2];
            else
                ab = new ulong[1, 2];
            for(int i=0; i < N; i++)
            {
                vals = Console.ReadLine().Split(' ');
                ab[i, 0] = ulong.Parse(vals[0]);
                ab[i, 1] = ulong.Parse(vals[1]); 
            }
 
            ulong[] totalCount = new ulong[10];
            totalCount[0] = (W - 2) * (H - 2);
 
            Dictionary<ulong, int> count = new Dictionary<ulong, int>();
            for(int i=0; i < N; i++)
            {
                ulong a, b;
                ulong n;
                for(uint y=0; y < 3; y++)
                {
                    for(uint x=0; x < 3; x++)
                    {
                        a = ab[i, 0] - y;
                        b = ab[i, 1] - x;
                        if (a < 1 || a > H - 2 || b < 1 || b > W - 2)
                            continue;
                 
                        n = (a - 1) * (W - 2) + (b - 1);
                        //Console.WriteLine("Square " + i + " is in (" + a + "," + b + ") n=" + n);
 
                        if (count.ContainsKey(n))
                        {
                            count[n]++;
                        }
                        else
                        {
                            totalCount[0]--;
                            count[n] = 1;
                        }
                    }
                }
            }
 
            foreach(var n in count.Keys)
            {
                if(count[n] <= 9)
                    totalCount[count[n]]++;
            }
            for (int i = 0; i <= 9; i++)
                Console.WriteLine(totalCount[i]);
 
        }
    }
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] arr = line.split(" ");
		long a = Long.parseLong(arr[0]);
		long b = Long.parseLong(arr[1]);
		System.out.printf("%d %d %.8f%n", a / b, a % b, (double) a / b);
	}
}

Measured memory_bytes: 17080
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

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

  ll x, y;

  cin >> x >> y;

  int ans = 0;

  while (x <= y) {
    ans++;
    x <<= 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n,ans=0;cin>>n;
    vector<ll> vec(10000000);
    for(ll i=0;i<1000;i++){
        for(ll j=0;j<10000;j++){
            for(int k=0;k<50;k++){
                vec.at(i+j+k)++;
            }
        }
    }
    cout<<n*n*n<<endl;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define mod 1000000007
#define mx 100003
#define ss second
#define ff first
#define ld long double
#define pii pair<int, int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS;
    int n, k;
    cin >> n >> k;
    int a[n + 2], dp[n + 2];
    for(int i = 0; i <= n; i++) dp[i] = 1e9 + 1;
    rep(i,1,n) cin >> a[i];
    dp[2] = abs(a[1] - a[2]);
    dp[1] = 0;
    rep(i,3,n)
    {
        for(int j = max(1, i - k); j < i; j++)
            dp[i] = min(dp[j] + abs(a[i] - a[j]), dp[i]);
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;

bool mx[105][105];

int main() {
	int n;
	cin >> n;
	Loop1(i, n) {
		Loop1(j, n) {
			mx[i][j] = 0;
		}
	}
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(j, k) {
			int v;
			cin >> v;
			mx[u][v] = 1;
		}
	}
	Loop1(i, n) {
		Loop1(j, n - 1) {
			cout << mx[i][j] << " ";
		}
		cout << mx[i][n] << endl;
	}
	return 0;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int r, g, b, n, ans = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i < n / r + 1; i++) {
		for (int j = 0; j < (n - r * i) / g + 1; j++){
			int x = n - r * i - g * j;
			if (x >= 0 && x % b == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

#define REP(i, n, N) for(int i=(n); i<(N); i++)
#define RREP(i, n, N) for(int i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int A, B;
int main() {
	cin >> A >> B;
	if(B % A == 0){
		p(A+B);
	}else{
		p(B-A);
	}
	return 0;
}


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

int main(){
    int N , a ;
    cin >> N;
    a = 1;
    while(a<=9){
        if((N % a == 0) && (N / a < 10)){
            cout << "Yes" << endl;
            break;
        }
    a += 1;   
    }
    if(a == 10){
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
const MOD: i64 = 1000000000 + 7;
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let l = sc.chars();
    let mut dp: Vec<Vec<i64>> = vec![vec![0; 2]; l.len() + 1];

    dp[0][0] = 1;

    for i in 0..l.len() {
        let d = l[i];
        for j in 0..2 {
            if d == '1' {
                //0 0
                dp[i + 1][1] += dp[i][j];
                dp[i + 1][1] %= MOD;

                //0 1
                //1 0
                dp[i + 1][j] += 2 * dp[i][j];
                dp[i + 1][j] %= MOD;
            } else {
                //0 0
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= MOD;

                //0 1
                //1 0
                if j == 1 {
                    dp[i + 1][j] += 2 * dp[i][j];
                    dp[i + 1][j] %= MOD;
                }
            }

        }
    }
    let result = (dp[l.len()][0] + dp[l.len()][1]) % MOD;
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14716
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 998244353
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 300001

using namespace std;

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

ll frac[MAX_N];

void init() {
  frac[0] = 1;
  for (ll i = 1; i < MAX_N; i++) {
    frac[i] = mod(frac[i-1] * i);
  }
}

ll bit_pow(ll x, ll n) {
  ll tmp = x;
  n >>= 1;
  while (n > 0) {
    tmp = mod(tmp * tmp);
    if (n & 1) {
      x = mod(tmp * x);
    }
    n >>= 1;
  }
  return x;
}


ll comb(ll n, ll r) {
  return mod(frac[n] * mod(bit_pow(mod(frac[n-r] * frac[r]), MOD-2)));
}

int main() {
  ll N, A, B, K;
  cin >> N >> A >> B >> K;

  init();

  ll ans = 0;

  for (ll i = 0; i <= N; i++) {
    ll j = (K - A * i) / B;
    if ((K - A * i) >= 0 && (K - A * i) % B == 0 && j <= N) {
      ans = mod(ans + mod(comb(N, i) * comb(N, j)));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e3+5;
const int inf=80000;
#define endl '\n'

int vs[N][N];
int p[N],idx[N];
bool vis[N],flag;

int getint()
{
	int w = 0, q = 0;
	char c = getchar();
	while (c<'0' || c>'9'&&c != '-')c = getchar();
	if (c == '-')q = 1, c = getchar();
	while (c >= '0'&&c <= '9')w = w * 10 + c - '0', c = getchar();
	return q ? -w : w;
}

int main(){
	int n,sum;
	n=getint();
	for(int i=1;i<=n;i++)
	for(int j=1;j<n;j++)
	vs[i][j]=getint();
	
	for(int i=1;i<=n;i++) p[i]=1;
	
	flag=0;
	sum=0;
	memset(vis,0,sizeof(vis));
	while(!flag&&sum<inf){
		flag=1;
		int cnt=0;
		for(int i=1;i<=n;i++){
			if(p[i]==n) continue;
			int cp=vs[i][p[i]];
			if(p[cp]==n) continue;
			int tp=vs[cp][p[cp]];
			if(tp==i&&!vis[i]&&!vis[cp]){
			vis[i]=vis[cp]=1;
			p[i]++;
			p[cp]++;
			idx[cnt++]=i;
			idx[cnt++]=cp;
			if(flag) flag=0;
			}
		}
		for(int i=0;i<cnt;i++) vis[idx[i]]=0;
		sum++;
	}
	
	if(sum==inf){
		printf("%d\n",n*(n-1)/2);
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(p[i]!=n){
			flag=0;
			break;
		}
	}
	
	if(!flag) sum=0;
	printf("%d\n",sum-1);
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n;
    cin >> n;
    vector<int> p(n);
    VCIN(p);

    int mmin = numeric_limits<int>::max();
    int cnt = 0;
    for(int i=0; i<n; i++){
        if(p[i] < mmin){
            cnt++;
            mmin = p[i];
        }
    }

    COUT(cnt);

    return 0;
}

Measured memory_bytes: 1024
c,d = list(map(int,input().split()))

if d>c:
    a = d
    b = c
else:
     a = c
     b = d

def gcd(x,y):
    if y == 0:
        return x
    else:
        r = x%y
        return gcd(y,r)
    
print(gcd(a,b))
    



Measured memory_bytes: 5600
using System;   

 class Program
    {
        static void Main(string[] args)
        {
            int[] n = new int[10];
            
            for(int i = 0; i <= 9; i++)
            {
                n[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(n);

            for (int i = 9; i >= 7; i--)
                Console.WriteLine(n[i]);
        }
    }

Measured memory_bytes: 9276
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    int b[n];

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

    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j <= i; j++){
            sum += a[j];
        }
        for(int j = i; j < n; j++){
            sum += b[j];
        }
        mx = max(mx,sum);
    }
    cout << mx << endl;  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 1e4 + 5, MAXM = 2e5 + 5, BOUND = 1e7, MOD = 1e9 + 7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
ll n, ans;
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	ll m;
	rep(i, 2, sqrt(n)) {
		if (n%i == 0) {
			m = i - 1;
			if (n / m == n / i)ans += m;
			ll tmp = n / i;
			if (tmp == i)continue;
			m = tmp - 1;
			if (n / m == n / tmp)ans += m;
		}
	}
	if (n > 1 && n / (n - 1) == 1)ans += n - 1;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

using P = pair<int, int>;

int d, g;
int p[10];
int c[10];

P allAC(int flg) {
    int cnt = 0;
    int score = 0;
    rep(i, d) {
        if((flg & (1 << i)) > 0) {
            score += 100 * (i+1) * p[i] + c[i];
            cnt += p[i];
        }
    }
    return P(score, cnt);
}

int main() {
    cin >> d >> g;
    rep(i, d) cin >> p[i] >> c[i];
    int ans = 10000;
    rep(flg, 1 << d) {
        P a = allAC(flg);
        int score = a.first;
        int cnt = a.second;
        if(g <= score) {
            chmin(ans, cnt);
        } else {
            repr(i, d) {
                if((flg & (1 << i)) != 0) continue;
                if(score + 100 * (i+1) * (p[i]-1) < g) continue;
                FOR(n, 1, p[i]) {
                    if(g <= score + 100 * (i+1) * n) {
                        chmin(ans, cnt + n);
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{

	std::stack<int> s;
	int i, j, out, num=0,num1;
	string in;
	
	while(cin >> in){
	  if((int)in[0]>='0'&&(int)in[0]<='9'){
	    stringstream ss;
	    ss << in;
	    ss >> num;
	    s.push(num);
	  }
	    
	  if((int)in[0]=='+'){
	    num = 0;
	    num = s.top();
	    s.pop();
	    num += s.top();
	    s.pop();
	    s.push(num);
	  }
	  else if((int)in[0]=='-'){
	    num = 0;
	    num = s.top();
	    s.pop();
	    num1 = s.top();
	    s.pop();
	    s.push(num1-num);
	  }
	  else if((int)in[0]=='*'){
	    num = 0;
	    num = s.top();
	    s.pop();
	    num *= s.top();
	    s.pop();
	    s.push(num);
	  }
	}

	cout << s.top() << "\n";

	return 0;
}

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e6 + 5;

ll K;
vector < ll > v;
ll dp[105][2][105];

ll solve(ll idx, ll smaller, ll k){
  if(idx == v.size()){
    if(k == K) return 1;
    return 0;
  }

  if(dp[idx][smaller][k] != -1) return dp[idx][smaller][k];

  ll ans = 0;
  if(smaller){
    for(int i = 0; i < 10; i++){
      ans += solve(idx + 1, 1, i == 0 ? k : k + 1);
    }
  }else{
    for(int i = 0; i <= v[idx]; i++){
      ans += solve(idx + 1, i == v[idx] ? 0 : 1, i == 0 ? k : k + 1);
    }
  }

  dp[idx][smaller][k] = ans;
  return ans;
}

ll preprocess(string s){
  ll n = s.length();
  v.resize(n);
  memset(dp, -1, sizeof(dp));
  for(int i = 0; i < n; i++){
    v[i] = s[i] - '0';
  }

  return solve(0, 0, 0);
}

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

  string n;
  cin >> n;
  cin >> K;
  cout << preprocess(n);
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

class Prime {
public:
    Prime(ll n) {
        mPrimeTbl.clear();
        vector<bool> u(n, false);
        for (ll i = 2; i <= n; ++i) {
            if (u[i])
                continue;
            mPrimeTbl.push_back(i);
            for (ll p = i; p <= n; p += i)
                u[p] = true;
        }
    }

    ~Prime() {}

    ll num() {
        return static_cast<ll>(mPrimeTbl.size());
    }

    ll get(ll index) {
        return mPrimeTbl[index];
    }

private:
    vector<ll> mPrimeTbl;
};

int main() {
    ll N;
    cin >> N;
    Prime p(N + 5);
    vector<ll> v(p.num(), 1);

    for (ll i = 2; i <= N; ++i) {
        ll n = i;
        REP(j, p.num()) {
            ll t = p.get(j);
            while (n % t == 0) {
                n /= t;
                v[j]++;
            }
        }
    }

    ll ans = 1;
    REP(i, v.size()) {
        ans = (ans * v[i]) % MOD;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  for(int i = 0; i < N; i++) cin >> S[i];
  for(int i = 0; i < N; i++) {
    if(S[i] == "AC") {
      ac++;
    } else if(S[i] == "WA") {
      wa++;
    } else if(S[i] == "TLE") {
      tle++;
    } else if(S[i] == "RE") {
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

Measured memory_bytes: 6360
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (2500)
#define MOD (1000000007)


typedef struct list
{
    int val;
    struct list* next;
}list;

list* to[5000];
list* ot[5000];

typedef struct
{
    int a;
    int b;
    int c;
}edge;

edge es[5000];

bool reach1[MAXN];
bool reachN[MAXN];
bool ok[MAXN];

void dfs1(int i)
{
    if(reach1[i]) return;
    reach1[i] = true;
    list* l = to[i];
    while(l!=NULL)
    {
        dfs1(l->val);
        l = l->next;
    }
}

void dfsN(int i)
{
    if(reachN[i]) return;
    reachN[i] = true;
    list* l = ot[i];
    while(l!=NULL)
    {
        dfsN(l->val);
        l = l->next;
    }
}

int main(void)
{
    int n,m,p;

    scanf("%d %d %d",&n,&m,&p);

    for(int i=0;i<m;i++)
    {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        a--;
        b--;
        c -= p;
        c *= -1;

        list* l = malloc(sizeof(list));
        l->val = b;
        l->next = to[a];
        to[a] = l;

        l = malloc(sizeof(list));
        l->val = a;
        l->next = ot[b];
        ot[b] = l;

        es[i].a = a;
        es[i].b = b;
        es[i].c = c;
    }

    //関係のないノード検出
    dfs1(0);
    dfsN(n-1);
    for(int i=0;i<n;i++) ok[i] = reach1[i] && reachN[i];

    //ベルマンフォード
    int bf[n];
    bf[0] = 0;
    for(int i=1;i<n;i++) bf[i] = INT_MAX-200000; //重みを足すので
    int step = 0;
    bool update = true;
    while(update)
    {
        update = false;
        for(int i=0;i<m;i++)
        {
            if(ok[es[i].a] && ok[es[i].b])
            {
                int n = bf[es[i].a] + es[i].c;
                if( n < bf[es[i].b])
                {
                    bf[es[i].b] = n;
                    update = true;
                }
            }
        }
        step++;
        if(step > n)
        {
            printf("-1\n");
            return 0;
        }
    }

    printf("%d\n", max( -bf[n-1],0));

    return 0;
}





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

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

const int N = 1e5 + 11;
const int M = 1e6 + 11;
const int MOD = 1e9 + 7;

int a[N], b[N], c[N];
int main(int argc, char **args){
    std::ios::sync_with_stdio(false);
    int A, B, M;
    cin >>A >>B>>M;
    for(int i = 1; i <= A; i++){
        cin >>a[i];
    }
    for(int i = 1; i <= B; i++){
        cin >>b[i];
    }
    int ans = 1e9;
    for(int i = 1; i <= M; i++){
        int x, y, c; cin >> x >>y >>c;
        ans = min(ans, (a[x] + b[y]) - c);
    }
    sort(a + 1, a + A + 1);
    sort(b +1, b + B +1);
    ans = min(ans, a[1] + b[1] );
    cout <<ans <<"\n";
return 0;
}

Measured memory_bytes: 1024