akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;

    int cnt=0;

    for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
            if(S.at(i)==S.at(j)){
                cnt++;
            }
        }
    }

    if(cnt==8){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int X;
signed main() {
    cin >> X;

    int ans = 0;
    FOR(i, 1, X + 1) {
        int tans = i;
        FOR(j, 2, X + 3) {
            tans *= i;
            if (tans > X) break;
            ans = max(ans, tans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD  1000000007

#define MAXN 100002
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init(){
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD%i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++){
		fact[i] = i*fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r){
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD*ifact[r] % MOD;
}

int n;
int a[100001];

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

	cin>>n;
	rep(i, n + 1)cin >> a[i];

	int s,t;
	map<int,int> mp;
	rep(i,n+1){
		auto it = mp.find(a[i]);
		if (it == mp.end())mp[a[i]]=i;
		else{
			s = it->second;
			t = i;
			break;
		}
	}
	int len = t-s+1;
	cout<<n<<endl;
	for (int i=2;i<=n+1;i++){
		long long ans = C(n+1,i);
		if (n + 1 - len >= i - 1){
			ans -= C(n + 1 - len, i - 1);
			ans = (ans + MOD) % MOD;
		}
		cout <<ans<<endl;
	}


	return 0;
}

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

int main() {
    int n,count=0;
    int p_0,p_1,p_2;
    cin >> n;
    for(int i=0;i<n;i++){
        if(i==0){cin >> p_0;}
        else if(i==1){cin >> p_1;}
        else{
            cin >> p_2;
            if((p_1>p_0 && p_1<p_2) ||(p_1>p_2 && p_1<p_0)){count++;}
            p_0 = p_1;
            p_1 = p_2;

        }
    }
    cout << count<<endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  string s;
  cin >> s;
  int n = s.size();
  ll cnt = 0,res = 0;
  rep(i,n){
    if(s[i] == 'S')cnt++;
    else cnt--;
    if(cnt < 0)res++,cnt = 0;
  }
  res += cnt;
  cout << res << endl;




  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
long int N, A, B, num, p;
scanf("%ld%ld%ld", &N, &A, &B);
    num=N/(A+B);
    p=N%(A+B);
if(N%(A+B)==0){
    printf("%ld\n",num*A);
}else if(N%(A+B)!=0 && p<=A){
    printf("%ld\n",num*A+p);
}else{
    printf("%ld\n",num*A+A);
}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (long long i = (a); i <= (b); i++)
#define FORD(i,a,b) for (long long i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(long long)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-8
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

long long n, val, cur, ans;
unordered_map<long long, long long> m;

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  m[0] = 1;
  while (n--) {
    cin >> val;
    cur += val;
    ans += m[cur];
    m[cur]++;
  }
  cout << ans;
}


Measured memory_bytes: 8520
function Main(input) {
    input.trim().split("\n").forEach(line => {
        var nums = line.split(" ").map(i => parseInt(i));
        var a = nums[0];
        var b = nums[1];
        var x = nums[2];
        var tan;
        if (a * a * b / 2 === x) {
            tan = b / a;
        } else if (a * a * b / 2 < x) {
            tan = a * a / 2 / (a * b - x / a)
        } else {
            tan = 2 * x / a / b / b
        }

        console.log((360 + 90 - Math.atan(tan) * 180 / Math.PI) % 360);
    });
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
var globalInput = '';
process.stdin.on('data', function(chunk) {
    globalInput += chunk;
})
process.stdin.on('end', function() {
    Main(globalInput)
})

// Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  string a,b;
  cin >> a >> b;
  string c=a+b;
  int num=stoi(c);
  int ans=0;
  for(int i=1;i<1000;i++){
    if(i*i==num){ans=1;}
  }
  if(ans==1){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

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

int main(){
    ll int x,max,k,count=0;
    cin >> x;
    for(int i=1;i<=sqrt(double(x));i++){
        k=x%i;
        if(k==0){
            max=x/i;
        }
    }
    while(max>0){
        max/=10;
        count++;
    }
    cout << count;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll t1,t2,a1,a2,b1,b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  if(a1*t1 + a2*t2 == b1*t1 + b2*t2){
    cout << "infinity" << endl;
    return 0;
  }
  
  // a is faster
  if(a1*t1 + a2*t2 < b1*t1 + b2*t2){
    swap(a1,b1);
    swap(a2,b2);
  }

  ll peak = (a1-b1)*t1;
  ll diff = (a1-b1)*t1 + (a2-b2)*t2;

  if(peak > 0){
    cout << 0 << endl;
    return 0;
  }

  peak = -peak;

  ll ans = peak/diff*2;

  if(peak%diff>0) ans ++;

  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)printf("a < b");//if：もし
    if(a>b)printf("a > b");
    if(a==b)printf("a == b");
    printf("\n");

    return 0;
}



Measured memory_bytes: 2040
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<long long int> x(n);
  vector<long long int> y(n);

  vector<long long int> u(n);
  vector<long long int> v(n);

  unsigned int o_e;

  for(int i=0;i<n;i++){
    cin >> x[i];
    cin >> y[i];
    u[i] = x[i]+y[i];
    v[i] = x[i]-y[i];
    //cout << u[i] << " " << v[i] << endl;
    //cout << abs(u[i])%2 << endl;
    if(i==0){
      o_e = abs(u[i])%2;
      //cout << o_e << endl;
    }
    else{
      if(o_e != abs(u[i])%2){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  //cout << o_e << endl;



  if(o_e == 0){
    cout << 33 << endl;
    cout << 1 << " ";
  }
  else{
    cout << 32 << endl;
  }
  for(int j=0;j<32;j++){
      cout << ((long long int)1 << j) << " ";
    }
    cout << endl;

  for(int i=0;i<n;i++){
    long long int r_u = (u[i]-(1-o_e)+(long long int)((long long int)1<<32) - (long long int)1)/(long long int)2;
    long long int r_v = (v[i]-(1-o_e)+(long long int)((long long int)1<<32) - (long long int)1)/(long long int)2;
    long long int uu=0;
    long long int vv=0;
    long long int xx=0;
    long long int yy=0;
    if(o_e == 0){
      cout << 'R';
      uu++;
      vv++;
      xx++;
    }
    for(int j=0;j<32;j++){
      //cout << ((r_u >> j) &1);

      long long int signal=((r_u >> j) &(long long int)1) + (long long int)2*((r_v >> j) &(long long int)1);
      switch(signal){
        case 0:
          cout << 'L';
          uu-=((long long int)1<<j);
          vv-=((long long int)1<<j);
          xx-=((long long int)1<<j);
          break;
        case 1:
          cout << 'U';
          uu+=((long long int)1<<j);
          vv-=((long long int)1<<j);
          yy+=((long long int)1<<j);
          break;
        case 2:
          cout << 'D';
          uu-=((long long int)1<<j);
          vv+=((long long int)1<<j);
          yy-=((long long int)1<<j);
          break;
        case 3:
          cout << 'R';
          uu+=((long long int)1<<j);
          vv+=((long long int)1<<j);
          xx+=((long long int)1<<j);
          break;
        default:
          abort();
          break;
      }
    }
    cout << endl;
    //cout << (uu+vv)/2 << " " << (uu-vv)/2 << endl;
    //cout << xx << " " << yy << endl;
    //cout << endl;
  }
    //cout << endl;



  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string x;
	cin>>x;
	int ans=0;
	for(int i=1;i<x.size();i++)
		if(x[i]!=x[i-1])
		{
			ans++;
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

// #define int long long

constexpr int inf = 1e7;

signed main(){
	constexpr int MAX = 1010;
	vector<vector<int>> table(MAX * 2, vector<int>(MAX * 2, MAX * MAX+10));
	
	vector<pair<int,int>> num((MAX*2)*(MAX*2));
	vector<bool> soe(MAX * MAX*4+10);
	
	soe[0] = soe[1] = true;
	
	for(long long i = 2; i < soe.size(); i++){
		if(soe[i] == false){
			for(long long j = i * i; j < soe.size(); j += i){
				soe[j] = true;
			}
		}
	}
	
	
	num[1] = {MAX,MAX};
	table[MAX][MAX] = 1;
	
	for(int i = 1; i < MAX; i++){ 
		int n = (i * 2 + 1) * (i * 2 + 1);
		
		for(int j = 0; j < 2 * i; j++){
			table[MAX+i][MAX+i-j] = n;
			num[n] = {MAX+i,MAX+i-j};
			n--;
		}
		for(int j = 0; j < 2 * i; j++){
			table[MAX+i-j][MAX-i] = n;
			num[n] = {MAX+i-j,MAX-i};
			
			n--;
		}
		for(int j = 0; j < 2 * i; j++){
			table[MAX-i][MAX-i+j] = n;
			num[n] = {MAX-i,MAX-i+j};
			n--;
		}
		for(int j = 0; j < 2 * i; j++){
			table[MAX-i+j][MAX+i] = n;
			num[n] = {MAX-i+j,MAX+i};
			n--;
		}
	}
	
	while(true){
		vector<vector<int>> dp(MAX * 2, vector<int>(MAX * 2));
		int maxi = 0;
		int m, n;
		int b, e;
		pair<int,int> ans;
		
		cin>>m>>n;
		
		if(!m && !n) break;
		
		if(soe[table[num[n].first][num[n].second]] == false) {
			dp[num[n].first][num[n].second] = 1;
			ans = {1, n};
		} else {
			dp[num[n].first][num[n].second] = 0;
		}
		
		b = num[n].second-1;
		e = num[n].second+1;
		
		
		for(int i = num[n].first+1; i < MAX*2 - 5; i++, b--, e++){
			bool flag = false;
			
			b = max(b, 5);
			e = min(e, MAX*2-5);
			
			for(int j = b; j <= e; j++){
				if(table[i][j] > m) continue;
				if(table[i-1][j-1] <= m && j != b) {
					flag = true;
					dp[i][j] = max(dp[i][j], dp[i-1][j-1]);
				
				}
				
				if(table[i-1][j] <= m) {
					flag = true;
					dp[i][j] = max(dp[i][j], dp[i-1][j]);
				}
				
				if(table[i-1][j+1] <= m && j != e) {
					flag = true;
						dp[i][j] = max(dp[i][j], dp[i-1][j+1]);
				}
				
				if(soe[table[i][j]] == false) {
					dp[i][j]++;
					if(ans < make_pair(dp[i][j],table[i][j])) {
						ans =  make_pair(dp[i][j],table[i][j]);
					}
				}
			}
			if(flag == false) break;
		}
		
		cout<<ans.first<<" "<<ans.second<<endl;
	}
}


Measured memory_bytes: 67388
#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)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

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;
  cin >> n;
  vector<ll>A(n);
  for(int i=0;i<n;i++) cin >> A[i];
  ll ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans = max(ans,abs(A[i]-A[j]));
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair< int , int > Pi;

int w, h, n, x1[1000], yy1[1000], x2[1000], y2[1000];
bool mas[2200][2200];

int main(){

  while(scanf("%d %d", &w, &h), w){
    fill_n( *mas, 2200 * 2200, false);

    cin >> n;
    vector< int > numx, numy;
    for(int i = 0; i < n; i++){
      scanf("%d %d %d %d", &x1[i], &yy1[i], &x2[i], &y2[i]);
      for(int j = -1; j <= 1; j++){
        if(x1[i] + j >= 0 && x1[i] + j < w) numx.push_back(x1[i] + j);
        if(x2[i] + j >= 0 && x2[i] + j < w) numx.push_back(x2[i] + j);
        if(yy1[i] + j >= 0 && yy1[i] + j < h) numy.push_back(yy1[i] + j);
        if(y2[i] + j >= 0 && y2[i] + j < h) numy.push_back(y2[i] + j);
      }
    }
    sort( numx.begin(), numx.end());
    sort( numy.begin(), numy.end());
    numx.erase( unique(numx.begin(), numx.end()), numx.end());
    numy.erase( unique(numy.begin(), numy.end()), numy.end());
  

    for(int i = 0; i < n; i++){
      int xx1 = lower_bound( numx.begin(), numx.end(), x1[i]) - numx.begin();
      int xx2 = lower_bound( numx.begin(), numx.end(), x2[i]) - numx.begin();
      int yyy1 = lower_bound( numy.begin(), numy.end(), yy1[i]) - numy.begin();
      int yy2 = lower_bound( numy.begin(), numy.end(), y2[i]) - numy.begin();
      for(int j = yyy1; j < yy2; j++){
        for(int k = xx1; k < xx2; k++){
          mas[j][k] = true;
        }
      }    
    }

    int ret = 0;
    const static signed dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};
    queue< Pi > que;
    for(int i = 0; i < numy.size(); i++){
      for(int j = 0; j < numx.size(); j++){
        if(mas[i][j]++) continue;
        ret++;
        que.push(make_pair( i, j));
        while(!que.empty()){
          Pi p = que.front(); que.pop();
          for(int i = 0; i < 4; i++){
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(ny < 0 || ny >= numy.size() || nx < 0 || nx >= numx.size()) continue;
            if(mas[ny][nx]++) continue;
            que.push(make_pair( ny, nx));
          }
        }
      }
    }
    printf("%d\n", ret);
  }
}

Measured memory_bytes: 6016
import sys
from random import randint
input = sys.stdin.readline
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [randint(0, 25) for i in range(D)]
last = [0] * 26
def score(day, score):
  for i in range(26): score -= (day - last[i]) * c[i]
  return score
def run(day):
  global last
  last = [0] * 26
  res = 0
  for d in range(day):
    contest = t[d]
    last[contest] = d + 1
    res = score(d + 1, res) + s[d][contest]
  return res


for d in range(1, D + 1):
  mx = -float("inf")
  mxx = randint(0, 25)
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx

for l in range(360, 366):
  last = [0] * 26
  run(l)
  #print(last)
  zmx = -float("inf")
  zmxz = 0
  for z in range(26):
    t[l - 1] = z

    for d in range(l + 1, D + 1):
      mx = -float("inf")
      mxx = t[d - 1]
      for x in range(26):
        t[d - 1] = x
        res = score(d, 0) + s[d - 1][x]
        if mx < res:
          mx = res
          mxx = x
      t[d - 1] = mxx
      last[mxx] = d
    zres = run(D)
    if zres > zmx:
      zmx = zres
      zmxz = z
  t[l - 1] = zmxz

for x in t: print(x + 1)

Measured memory_bytes: 80540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  //int a = N / 1000;
  //int b = N % 1000 / 100;
  //int c = N % 100 / 10;
  //int d = N % 10;
  
  if (N % 1111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N / 10 % 111 == 0) {
   cout << "Yes" << endl;
  } 
  else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define Graph vector<vector<int>>
typedef pair<int, int> PII;
typedef long long ll;

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

  vector<int> P(N);
  vector<int> Pjmin(N);
  vector<int> max(N);

  int tmpMIN = N;
  rep(i,N){
     cin >> P[i];     
     tmpMIN = min(tmpMIN,P[i]);
     Pjmin[i] = tmpMIN;
  }

  int ans = 0;
  rep(i,N){
    if(P[i] <= Pjmin[i]) ans++;
  }

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


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int factorial(int x)
{
	if (x == 0) {
		return 1;
	}
	return factorial(x-1) * x;
}

int dict(std::vector<int> &target, std::vector<int> &helper)
{
	int ans = 0;
	for (int i=0; i<target.size(); i++)
	{
		std::sort(helper.begin(), helper.end());
		int idx = 0;
		for (int j=0; j<helper.size(); j++)
		{
			if (target[i] == helper[j]) {
				idx = j;
				helper.erase(helper.begin() + j);
				break;
			}
		}

		ans += int (factorial(target.size()-i) * idx / (target.size()-i));
	}

	return ans;
}

int main(void)
{
	int n;
	std::vector<int> p, q;
	std::vector<int> qp, qq;

	cin >> n;

	for (int i=0; i<n; i++) {
		int t;
		cin >> t;
		p.push_back(t);
		qp.push_back(i+1);
	}

	for (int i=0; i<n; i++) {
		int t;
		cin >> t;
		q.push_back(t);
		qq.push_back(i+1);
	}

	int perm = factorial(n);

	int a = dict(p, qp);
	int b = dict(q, qq);

	printf("%d\n", std::abs(a-b));
}

Measured memory_bytes: 888
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-13 06:59:48
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n, k; cin >> n >> k;
  int64 ans = k;

  for (int i = 0; i < n - 1; ++i) {
    ans *= (int64) (k - 1);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int h,w;
    cin >> h >> w;
    char c[h][w];
    REP(i,h){
        REP(j,w){
            cin >> c[i][j];
        }
    }
    REP(i,h){
        REP(j,w){
            cout << c[i][j];
        }
        cout << endl;
        REP(j,w){
            cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
while line = gets
  n,x = line.split.map { |e| e.to_i }
  break if n == 0 && x == 0
  count = 0
  for i in 1..n-2
    for j in i+1..n-1
      for k in j+1..n
        count += 1 if i+j+k == x
      end
    end
  end
  puts count
end

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

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

    int a,b,c;
    // 引数の受け取り
    //
    cin >> a >> b >> c;
    if(b >= c){
    cout << "delicious"  << endl;
    
    }else if((b+a) >= c){
    cout << "safe"  << endl;
    
    }else{
    cout << "dangerous"  << endl;
    }


    // 出力
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	bool y=true;
	if(n%2==0||m%2==0)y=false;
	printf("%s\n",y?"Yes":"No"); 
	return 0;
} 

Measured memory_bytes: 256
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数


int main (){
     ll int h;
     cin >> h;
     
     ll int ans1 = h;
     if (h==1) cout << 1;
     else{
     ll int n = 1;
     while(1){
         ans1 /= 2;
         n++;
         if (ans1==1) break;
     }
     ll int ans = pow(2,n) - 1;
     cout << ans;
     }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<vector<int> > Graph;

const int MAXN = 1000006;
int N;
int M[MAXN], L[MAXN];

int main() {
  while(cin >> N) {
    Graph G(N);
    for(int i = 0; i < N; ++i) {
      cin >> M[i] >> L[i];
      if(L[i] != -1) G[L[i]].push_back(i);
    }
    vector<int> cost(N, -1);
    {
      queue<int> que;
      for(int i = 0; i < N; ++i) {
        if(L[i] == -1) {
          cost[i] = 0;
          que.push(i);
        }
      }
      while(que.size()) {
        int v = que.front(); que.pop();
        for(int i = 0; i < G[v].size(); ++i) {
          int nv = G[v][i];
          if(cost[nv] != -1) continue;
          cost[nv] = cost[v] + 1;
          que.push(nv);
        }
      }
    }
    vector<pair<int, int> > v;
    for(int i = 0; i < N; ++i) {
      v.push_back(make_pair(-cost[i], i));
    }
    sort(v.begin(), v.end());
    vector<int> len(N);
    for(int k = 0; k < N; ++k) {
      int i = v[k].second;
      len[i] += M[i];
      if(L[i] != -1) len[L[i]] += len[i];
    }
    lli res = 0;
    for(int v = 0; v < N; ++v) {
      vector<int> ws;
      for(int i = 0; i < G[v].size(); ++i) {
        int nv = G[v][i];
        ws.push_back(len[nv]);
      }
      sort(ws.begin(), ws.end(), greater<int>());
      for(lli i = 0; i < ws.size(); ++i) {
        res += i * (lli)ws[i];
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 79132
#include <iostream>

using namespace std;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int l = 0, r = 0;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    (a < x ? l : r)++;
  }
  cout << min(l, r) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <unordered_map>

#define BIG 1000000007

using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int p1 = 0;
    int p2 = 0;
    int stp = s[0] == '1' ? 1 : 0;
    vector<int> v;
    for(int i = 0;i < s.size();++i){
        if(s[i] == '1'){
            if(p1 > 0){
                v.push_back(p1);
                p1 = 0;
            }
            ++p2;
        }
        else{
            if(p2 > 0){
                v.push_back(p2);
                p2 = 0;
            }
            ++p1;
        }
    }
    if(p1 > 0){
        v.push_back(p1);
        p1 = 0;
    }
    if(p2 > 0){
        v.push_back(p2);
        p2 = 0;
    }


    int now = 0;
    int li = k * 2 + 1;
    for(int j = 0;j < li && j < v.size();++j){
        now += v[j];
    }
    int l = v[0];

    int max = 0;
    if(0 != stp)max = now;
    else if(li - 1 < v.size())max = now - v[li - 1];
    else max = now;


    for(int i = 1;i < v.size();++i){
        now -= l;
        l = v[i];
        if(i + li - 1 < v.size())now += v[i + li - 1];
        if((i % 2 != stp) && max < now)max = now;
    }


    cout << max << endl;
}


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

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    int n; cin>>n; int a[n]; for (int i = 0; i < n; i++)cin>>a[i];
    bool ans=true;
    for (int i = n-1; i >= 1; i--){
        if(a[i-1]-a[i]==1)a[i-1]-=1;
        else if(a[i-1]-a[i]>=2){ans=false;break;}
    }
    cout<<(ans?"Yes":"No")<<'\n';
}

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

int main(){
  double a, b, h, m; cin >> a >> b >> h >> m;
  
  double pi = 2*asin(1);
  
  double thita = abs(60*h-11*m)*pi/360;
  
  double l = a*a + b*b - 2*a*b*cos(thita);
  
  cout << fixed << setprecision(20);
  cout << sqrt(l) << endl;
}

Measured memory_bytes: 4176
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int N = saori.saori_hayami();
		int M = saori.saori_hayami();
		int ans = 0;
		PriorityQueue<war> pque = new PriorityQueue<>();
		for(int i = 0;i < M;i++){
			pque.add(new war(saori.saori_hayami(),saori.saori_hayami()));
		}
		while (!pque.isEmpty()){
            ans++;
			war w = pque.poll();
			
			for(;;){
				if(pque.isEmpty())break;
				if(pque.peek().a < w.b){
					pque.poll();
				} else{
					break;
				}
			}
        }
        System.out.println(ans);

	
    }
}
class war implements Comparable<war>{
	int a;
	int b;
	public war(int a,int b){
		this.a = a;
		this.b = b;
	}

	public int compareTo(war w){
		return this.b - w.b;
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 27136
from sys import stdin
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    c = [0] * (n + 1)
    for x in dat:
        c[x] += 1
    f = 0
    for i in xrange(n + 1):
        if c[i] & 1:
            print "NO"
            return
    print "YES"
main()


Measured memory_bytes: 20084
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( reinterpret_cast<T*>(array),
             reinterpret_cast<T*>(array+N),
             val );
}

// binary search
ll BSearch(ll ok, ll ng, bool (*f)(ll)){
  ll mid;
  while(abs(ok - ng) > 1LL) {
    mid =  (ok + ng) / 2LL;
    if(f(mid)) {
      debug("BSearch: f(%d) == true\n", mid);
      ok = mid;
    }
    else
    {
      debug("BSearch: f(%d) == false\n", mid);
      ng = mid;
    }
  }
  return ok;
}

ll NUM_TEST_CASE = 1;

ll N,M,K,A,B,C,D,E;
string yes = "Yes";
string no = "No";
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
void init(){
  // initialize for each test case
  // Fill(dp, -1);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // cin >> NUM_TEST_CASE;

  for (int test_case = 0; test_case < NUM_TEST_CASE; ++test_case)
  {
    init();

    cin >> N >> M >> K;

    cout << (K * M >= N ? yes : no) << endl;  
  }

  return 0;
}

Measured memory_bytes: 3640
input = gets.chomp.split(" ").map(&:to_i)

N = input[0]
A = input[1]
B = input[2]

j = []
(N+1).times{|item|
  add_result = item.to_s.split("").map(&:to_i).inject{|sum, n| sum + n}
  if (add_result >= A) && (add_result <= B)
    j << item
  end
}

puts(j.inject{|sum, n| sum + n}) 

Measured memory_bytes: 2172
#include<iostream>
using namespace std;
int main(){

  int num, div = 0,tmp;
  cin >> num;
  tmp = num;
  while (tmp / 10 != 0) {
    div += (tmp%10);
    tmp /= 10;
  }
  div += tmp;
  if (num % div == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> p(n);
  REP(i, n) cin >> p[i];

  vector<ll> a(n), b(n);
  REP(i, n) a[i] = (i+1)*20000, b[i] = (n-i)*20000;
  REP(i, n) b[p[i]-1] += i;
  REP(i, n) cout << a[i] << (i==n-1?'\n':' ');
  REP(i, n) cout << b[i] << (i==n-1?'\n':' ');
  cout << flush;

  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

// RangeAddQuery
template <typename T>
struct SegTree {
	T init_val;
	int n;
	vector<T> dat, ra;
	
	SegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(n * 2 - 1, init_val);
		ra.resize(n * 2 - 1, init_val);
	}
	
	void add(int a, int b, T x, int k, int l, int r) {
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) ra[k] += x;
		else {
			add(a, b, x, k * 2 + 1, l, (l + r) / 2);
			add(a, b, x, k * 2 + 2, (l + r) / 2, r);
		}
	}
	
	void add(int a, int b, T x) {
		add(a, b, x, 0, 0, n);
	}
	
	void add(int i, T x) {
		i += n - 1;
		dat[i] += x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = dat[i * 2 + 1] + dat[i * 2 + 2];
		}
	}
	
	void set(int i, T x) {
		dat[i + n - 1] = init_val;
		add(i, x);
	}
	
	// ??¢?´¢??????[a,b), ?????¨????????????k?????????[l,r)
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k] + ra[k];
		return ra[k] + query(a, b, k * 2 + 1, l, (l + r) / 2) + query(a, b, k * 2 + 2, (l + r) / 2, r);
	}
	
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

int main() {
	int n, q; cin >> n >> q;
	
	SegTree<ll> sg(n, 0);
	
	while (q--) {
		int a, b, c, d;
		scanf("%d", &a);
		
		if (a == 0) {
			scanf("%d %d %d", &b, &c, &d);
			sg.add(b - 1, c, d);
		}
		else {
			scanf("%d", &b);
			printf("%lld\n", sg.query(b - 1, b));
		}
	}
	return 0;
}

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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define MOD 1000000007

int main(){
    int x, a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int a1;
    int ans = 0;
    loop(i,0,5)
    {
        cin>>a1;
        if(a1==0)
            ans = i+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<map>
#include<vector>

using namespace std;

int main(){
  long long n, a[100009], mx=0, sm=0;
  map<long long, long long> m;
  vector<long long> v;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    m[a[i]]++;
    if(m[a[i]]==a[i]){
      v.push_back(a[i]);
    }
  }
  for(int i=0;i<v.size();i++){
    sm+=v[i];
  }
  cout << n - sm << endl;
}

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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  if(a + b <= 2 * c) {
    cout << a * x + b * y << endl;
  } else {
    int smaller = 0;
    int bigger = 0;
    int pizzaPrice = 0;

    if(x<y) {
      smaller = x;
      bigger = y;
      pizzaPrice = b;
    } else {
      smaller = y;
      bigger = x;
      pizzaPrice = a;
    }
    int total = 0;
    total += 2 * c * smaller;
    if(2 * c < pizzaPrice) {
      total += 2 * c * (bigger - smaller);
    } else {
      total += pizzaPrice * (bigger - smaller);
    }

    cout << total << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	for( auto &i : a ){
		cin >> i;
	}
	ll ans = 0;
	sort( a.begin(), a.end() );
	ans += abs( a[0] - a[n-1] );
	ll m = 0;
	ll M = n-1;
	for( int i = 0; i < (n/2-1); ++i ){
		ans += abs( a[M] - a[m+1] );
		ans += abs( a[m] - a[M-1] );		
		--M; ++m;
	}
	if( n % 2 == 1 ){
		ans += max( abs( a[n/2] - a[n/2+1] ), abs( a[n/2] - a[n/2-1] ) );
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N, M;cin>>N>>M;
    vector<int> cnt(M, 0);
    for(int i=0;i<N;i++){
        int K;cin>>K;
        for(int j=0;j<K;j++){
            int a;cin>>a;a--;
            ++cnt[a];
        }
    }
    int sol=0;
    for(int i=0;i<M;i++){
        if(cnt[i] == N) {
            ++sol;
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 256
from itertools import product
N, M, X = map(int, input().split())
C = [0] * N
A = [[0] * M for _ in range(N)]
for i in range(N):
    c = list(map(int, input().split()))
    C[i] = c[0]
    A[i] = c[1:]

def calc(p):
    ret = 0
    cnt = [0] * M
    for i, v in enumerate(p):
        if v == 1:
            for ia, a in enumerate(A[i]):
                cnt[ia] += a
            ret += C[i]
    return ret if all(i >= X for i in cnt) else 10 ** 30
    

ans = 10 ** 30
for p in product(range(2), repeat=N):
    ans = min(ans, calc(p))

print(ans if ans < 10 ** 30 else -1)


Measured memory_bytes: 69240
###
#main
if __name__ == "__main__":
    N = int(input())
    S = input()
    K = int(input())
    target = S[K-1]
    result = ""
    for i in range(len(S)):
        if S[i] != target:
            result += "*"
        else:
            result += S[i]
    print(result)

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

using Grid = std::vector<std::vector<bool>>;

int main() {
  size_t H, W;
  std::cin >> H >> W;

  Grid A(H, std::vector<bool>(W));

  for (size_t i=0; i<H; i++) {
    for (size_t j=0; j<W; j++) {
      char c;
      std::cin >> c;
      A[i][j] = c == '#';
    }
  }

  std::vector<bool> flags_row(H, false);
  std::vector<bool> flags_col(W, false);

  for (size_t i=0; i<H; i++) {
    for (size_t j=0; j<W; j++) {
      if (A[i][j]) {
        flags_row[i] = true;
        break;
      }
    }
  }

  for (size_t j=0; j<W; j++) {
    for (size_t i=0; i<H; i++) {
      if (A[i][j]) {
        flags_col[j] = true;
        break;
      }
    }
  }

  for (size_t i=0; i<H; i++) {
    if (! flags_row[i]) continue;
    for (size_t j=0; j<W; j++) {
      if (! flags_col[j]) continue;
      std::cout << (A[i][j] ? '#' : '.');
    }
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
//#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long int lli;
typedef pair<lli,int> mp;

int n,m,st;
vector<mp> vs[100005];//グラフの情報を持つ
lli dist[100005];//距離を持つ

int main(void){
	scanf("%d%d%d",&n,&m,&st);
	rep(i,m){
		int a,b;
		lli c;
		scanf("%d%d%lld",&a,&b,&c);
		vs[a].push_back( mp(c,b) );
	}
	
	memset(dist,-1,sizeof(dist));//最初は、無限大で初期化
	
	priority_queue<mp,vector<mp>,greater<mp> > que;
	
	que.push(mp(0,st));//stには0で行ける
	
	while(!que.empty()){//queが空になるまでやる
		
		mp pa = que.top();
		que.pop();
		//queの先頭要素(一番軽いの)を取り出す。
		
		int no = pa.second;//今の頂点
		lli co = pa.first;//今の距離
		
		if(dist[no]!=-1)continue; //もし、すでに確定していたら、飛ばす
		
		dist[no] = co;//確定させる
		
		rep(i,vs[no].size()){//今の地点から出ているすべての辺の先について、キューに突っ込んでいく
			int to = vs[no][i].second;//次の頂点
			lli tc = co + vs[no][i].first;//次の距離
			
			if(dist[to]!=-1)continue; //もし、すでに確定していたら、飛ばす
			que.push( mp(tc,to) ); //queに追加
		}
	}
	//これで、全ての頂点について、stからの距離が求まった
	
	rep(i,n){
		if(dist[i]==-1)printf("INF\n");//もし-1なら、その頂点には到達不可のう
		else printf("%lld\n",dist[i]);//そうでなければ、距離を出力
	}
	
	return 0;
}

/*
ちなみに、上の
「もし-1なら、その頂点には到達不可のう」
のコメントの、
「のう」の字を「能」にしたところ、
まともに動かなくなったことを、ここに付記しておきます。
*/

Measured memory_bytes: 20140
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

signed main(){
  ll h, n;
  cin >> h >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  for(ll i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  ll inf = 10000000000;
  ll fin = *max_element(a.begin(), a.end()) + h;
  vector<ll> dp(fin, inf);
  dp[0] = 0;
  for(ll i = 0; i < n; i++){
    for(ll j = 0; j < fin; j++){
      if(j + a[i] < fin){
        dp[j+a[i]] = min(dp[j+a[i]], dp[j]+b[i]);
      }
    }
  }
  cout << *min_element(dp.begin()+h,dp.end()) << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

struct DICE{      // struct
    int ue;
    int temae;
    int migi;
    int hidari;
    int oku;
    int shita;
};

void fancDice(char *direct, struct DICE *diceStr) {     // original_function
    int temp;
    switch (*direct) {
        case 'E':
            temp = diceStr->ue;
            diceStr->ue = diceStr->hidari;
            diceStr->hidari = diceStr->shita;
            diceStr->shita = diceStr->migi;
            diceStr->migi = temp;
            return;
        case 'S':
            temp = diceStr->ue;
            diceStr->ue = diceStr->oku;
            diceStr->oku = diceStr->shita;
            diceStr->shita = diceStr->temae;
            diceStr->temae = temp;
            return;
        case 'W':
            temp = diceStr->ue;
            diceStr->ue = diceStr->migi;
            diceStr->migi = diceStr->shita;
            diceStr->shita = diceStr->hidari;
            diceStr->hidari = temp;
            return;
        case 'N':
            temp = diceStr->ue;
            diceStr->ue = diceStr->temae;
            diceStr->temae = diceStr->shita;
            diceStr->shita = diceStr->oku;
            diceStr->oku = temp;
            return;
    }
    return;
}

int main() {    // main
    int num[6];
    char direct[101];
    
    struct DICE diceStr;
    scanf("%d", &diceStr.ue);
    scanf("%d", &diceStr.temae);
    scanf("%d", &diceStr.migi);
    scanf("%d", &diceStr.hidari);
    scanf("%d", &diceStr.oku);
    scanf("%d", &diceStr.shita);
    
    scanf("%s", direct);
    
    for (int j=0; direct[j]!='\0'; j++) {
        fancDice(&direct[j], &diceStr);
    }
    
    printf("%d\n", diceStr.ue);
    return 0;
}


Measured memory_bytes: 2148
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N;
	bool secondWillWin = true;

	scanf("%zu", &N);
	for (size_t idx = 0; idx < N; idx++) {
		uint64_t a;
		scanf("%"PRIu64, &a);
		if (idx < N - 1) {
			scanf("\n");
		}
		if (a % 2 != 0){
			secondWillWin = false;
		}
	}

	puts((secondWillWin ? "second" : "first"));

	return 0;
}


Measured memory_bytes: 256