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

int buf;
int gcd(int a,int b){
    if(a<b){buf=a;a=b;b=buf;}
    if(!(a%b)){return(b);}
    else{return(gcd(b,a%b));}
}

int main(){
    while(1){
        string str;
        vector<int> s;
        int i=0,a,b;
        cin>>str;
        if(str[0]=='#'){break;}
        while(i<str.size()){
            if(str[i]=='n'){
                s.push_back(0);
                i+=5;        
            }
            else{
                s.push_back(1);
                i+=4;
            }
        }
        a=0;b=1;
        reverse(s.begin(),s.end());
        for(i=0;i<s.size();i++){
            if(s[i]){a=2*a+90;}
            else{a=2*a-90;if(a<0){a=0;b=1;}}
            if(i){b*=2;}
        }
        if(!a){cout<<a<<endl;}
        else{
            int g=gcd(a,b);
            a/=g;b/=g;
            if(b==1){cout<<a<<endl;}
            else{cout<<a<<"/"<<b<<endl;}
        }
    }
    return 0;
}
    



Measured memory_bytes: 3176
#include <iostream>

using namespace std;

int main() {
	int x;
	cin >> x;
	
	if (x >= 400 && x <= 599) cout << 8 << '\n';
	else if (x >= 600 && x <= 799) cout << 7 << '\n';
	else if (x >= 800 && x <= 999) cout << 6 << '\n';
	else if (x >= 1000 && x <= 1199) cout << 5 << '\n';
	else if (x >= 1200 && x <= 1399) cout << 4 << '\n';
	else if (x >= 1400 && x <= 1599) cout << 3 << '\n';
	else if (x >= 1600 && x <= 1799) cout << 2 << '\n';
	else cout << 1 << '\n';
	
	return 0;
}

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

using namespace std;
typedef long long ll;

int main () {
    string S;
    cin >> S;

    int y = stoi(S.substr(0, 4));
    int m = stoi(S.substr(5, 2));
    int d = stoi(S.substr(8, 2));

    if (y > 2019)  cout << "TBD" << endl;
    else if (y == 2019 && m > 4)  cout << "TBD" << endl;
    else  cout << "Heisei" << endl;

}



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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String[] str = null;
		for(;;) {
			str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if(w==0&&h==0)break;
			for(int i=0;i<h;i++){
				System.out.print("#");
				for(int l=0;l<w-2;l++){
					if(i==0|i==h-1){System.out.print("#");
					}else System.out.print(".");
				}System.out.println("#");
				}System.out.println();
		}


	}
}

Measured memory_bytes: 24620
S = input()

# ACGT 

num = 0
result = [0]

    
for c in S:
  if c == 'A' or c == 'C' or c == 'G' or c == 'T':
    num += 1
  else:
    result.append(num)
    num = 0
result.append(num)
    
#print(result)
print(max(result))

Measured memory_bytes: 8724
/*
まず最大公約数を求める。
縦：Ａ、横、Ｂとすると、Ａ－１＋Ｂ－１－最大公約数＋１．
*/
#include<iostream>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    int i;
    for(i=1000;i>0;i--){
       if(x%i==0&&y%i==0)break;
    }
    cout<<x-1+y-1-i+1+2<<endl;
    return 0;
}


Measured memory_bytes: 3108
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	BigInteger[] arr = new BigInteger[N];
      	BigInteger res = new BigInteger("0");
      	for (int i = 0; i < N; i++){
        	arr[i] = sc.nextBigInteger();
          	if ((i > 0) && (arr[i].compareTo(arr[i-1]) == -1)){
            	BigInteger x = arr[i-1].subtract(arr[i]);
              	arr[i] = arr[i].add(x);
            	res = res.add(x);
            }
        }
      	
      	System.out.println(res);
    }
}

Measured memory_bytes: 63040
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=1e5+3;
string s,p,x;
//map<string,int>mp;
//vector<int>v;

int main()
{
    ft
    ll t,i,j,n,m,l,r,c;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define eps 1e-9

ll a1,b1,a2,b2,a3,b3;
int main(){
    while(cin>>a1>>b1>>a2>>b2>>a3>>b3&&a1&&b1&&a2&&b2&&a3&&b3){
        ll a=0,b=0,c=0;
        ll x=1,y=1,z=1;
        while(1){
            a++;
            x=(a1*x)%b1;
            if(x==1)break;
        }
        while(1){
            b++;
            y=(a2*y)%b2;
            if(y==1)break;
        }
        while(1){
            c++;
            z=(a3*z)%b3;
            if(z==1)break;
        }
        ll m=b/__gcd(a,b)*a;
        cout<<c/__gcd(m,c)*m<<endl;
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	double a,b,x;
	cin >> a >> b >> x;
	double v = a*b/2*a;
	double ans;

	if(v >= x){
		double height = 2 * x / a / b;
		ans = atan(1.0*b/height);
	}else{
		double height = 2 * x / a / a - b;
		ans = atan((b-height)/a);
	}
	printf("%.10lf", ans*180/PI);

  return 0;
}


Measured memory_bytes: 256
def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())
    cnt = [0]*(K+1)

    for g in range(K, 0, -1):
        cnt[g] = pow(K//g, N, MOD) # (K//g)**N
        gg = g*2
        while gg <= K:
            cnt[g] -= cnt[gg]
            gg += g
    ans = 0
    for g in range(1, K+1):
        ans += cnt[g] * g
        ans %= MOD
    print(ans)    

if __name__ == "__main__":
    resolve()

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

int main(){
  int D,G;
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  for(int i=0;i<D;i++){
    cin >> p.at(i) >> c.at(i);
  }
  
  int ans=1e9;
  for(int mask=0;mask<(1<<D);mask++){
    bitset<10> s(mask);
    int sum=0;
    int num=0;
    int rest_max=-1;
    for(int i=0;i<D;i++){
      if(s.test(i)){
        sum += (i+1)*100*p.at(i)+c.at(i);
        num += p.at(i);
      }
      else{
        rest_max=i;
      }
    }
        
    if(sum<G){
      int s1=100*(rest_max+1);
      int need=(G-sum+s1-1)/s1;
      if(need>=p.at(rest_max))continue;
      num +=need;
    }
    ans=min(ans,num);
  }
  cout << ans << endl;
}
        
        

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int n;
long long e = 1000000001;
long long d, a, g, ans;
long long x[200000];
long long h[200000];
long long s[200000];
long long k[200000];
int f[200000];
int l, m, r;
int main() {
	scanf("%d%lld%lld", &n, &d, &a);
	d *= 2;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", x + i, h + i);
		s[i] = x[i] * e + h[i];
	}
	std::sort(s, s + n);
	for (int i = 0; i < n; i++) {
		x[i] = s[i] / e;
		h[i] = s[i] % e;
		h[i] = (h[i] - 1) / a + 1;
	}
	for (int i = 0; i < n; i++) {
		l = i;
		r = n;
		while (r - l > 1) {
			m = (r + l) / 2;
			if (x[m] <= x[i] + d)l = m;
			else r = m;
		}
		f[i] = l;
	}
	for (int i = 0; i < n; i++) {
		h[i] -= g;
		if (h[i] > 0) {
			ans += h[i];
			g += h[i];
			k[f[i]] += h[i];
		}
		g -= k[i];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 7168
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, m;
    cin >> n >> m;
    vi a(m), b(m);
    vvi c(m, vi(n));
    rep(i, m) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            cin >> c[i][j];
            --c[i][j];
        }
    }

    vvi dp(m+1, vi(1 << n, INF));
    dp[0][0] = 0;
    rep(i, m) {
        rep(j, 1 << n) {
            dp[i+1][j] = dp[i][j];
            int x = 0;
            rep(k, b[i]) {
                x |= 1<<c[i][k];
            }
            dp[i+1][j] = min(dp[i+1][j], dp[i][j & ~x] + a[i]);
        }
    }


    if(dp[m][(1<<n)-1] == INF) cout << -1 << endl;
    else cout << dp[m][(1<<n)-1] << endl;
}


Measured memory_bytes: 16384
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))

if N == 0:
    if A_list[0] == 1:
        print(1)
    else:
        print(-1)
elif A_list[0] != 0:
    print(-1)
elif N == 1:
    if A_list[1] == 1 or A_list[1] == 2:
        print(A_list[1] + 1)
    else:
        print(-1)
else:
    ans = 1
    deathable_node = 1
    sum_rest_A = sum(A_list)
    for i in range(1, N + 1):
        now_A = A_list[i]
        deathable_node = min(sum_rest_A, deathable_node * 2) - now_A

        if deathable_node < 0:
            print(-1)
            break

        sum_rest_A -= now_A
        ans += deathable_node + now_A
#         print(i, now_A, sum_rest_A, deathable_node, ans)
#         if deathable_node == 0 and i != N:
#             print(-1)
#             break
    else:
        if deathable_node == 0:
            print(ans)
        else:
            print(-1)

Measured memory_bytes: 20548
#include <cstdio>

template<class T>void fr(T &a) {
    T w=0,s=1;char c=getchar();
    while(c<'0'||c>'9') {if(c=='-')s=-1;c=getchar();}
    while(c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
    a=w*s;
}
template<class T>T fr() {T a;fr(a);return a;}
#define R() fr<int>()

int main() {
    int a=R(),b=R();
    if(a>9||b>9)return !printf("-1\n");
    return !printf("%d\n",a*b);
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, m, a[101010];
bool b[101010];
i64 dp[101010];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i];
		b[a[i]] = 1;
	}
	
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		if(b[i]) continue;
		if(i!=1) dp[i] = dp[i-1]+dp[i-2];
		else dp[i] = dp[i-1];
		dp[i] %= INF;
	}
	cout << dp[n] << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

string process(string s) {
  string ret = "";
  ret += s[0];
  int idx = 0;
  bool flag = false;
  while(idx < s.size()) {
    char c = s[idx];
    if (flag) {
      ret += c;
      flag = false;
    }
    if (c == 'a'
        || c == 'i'
        || c == 'u'
        || c == 'e'
        || c == 'o') {
      flag = true;
    }

    idx++;
  }
  return ret;
}

int main() {
  int n;
  while (cin >> n, n) {
    vector<string> S;
    while(n--) {
      string s; cin >> s;
      // cerr << s << "=>" << process(s) << endl;
      S.push_back(process(s));
    }
    sort(S.begin(), S.end());
    int ans = -1;
    for(int k = 1; k <= 50; k++) {
      set<string> tmp;
      for(string s:S) tmp.insert(s.substr(0, k));
      if(tmp.size() == S.size()) {
        ans = k;
        break;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3116
using System;
using System.CodeDom.Compiler;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		long n = long.Parse(Console.ReadLine());
		long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

		long by4 = 0;
		long by2 = 0;
		long ki = 0;
		
		for (long l = 0; l < n; l++)
		{
			if(inputLongArray[l] % 4 == 0)
			{
				by4++;
			}
			else if (inputLongArray[l] % 2 == 0)
			{
				by2++;
			}
			else
			{
				ki++;
			}
		}
		if(by4 >= ki || ( by4 + 1 == ki && by2 == 0))
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int dp[101010];
vector<int> g[101010];
int f(int v) {
  int &ret = dp[v];
  if (ret != -1)
    return ret;
  ret = 0;
  for (auto u : g[v]) {
    chmax(ret, f(u)+1);
  }
  return ret;
}
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  rep(i, 0, 101010) dp[i] = -1;

  int N, M;
  cin >> N >> M;
  vector<int> deg(N);
  loop(M) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].eb(y);
    deg[y]++;
  }
  vector<int> s;
  rep(i, 0, N) {
    if (deg[i] == 0)
      f(i);
  }
  int ans=0;
  rep(i,0,N){
    chmax(ans,dp[i]);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>

using namespace std;
typedef long long ll;

bool solve(int N, vector<int> &a) {
  map<int, int> s;
  for (int i = 0; i < N; i++) {
    s[a[i]]++;
  }
  if (s.size() > 3) {
    return false;
  }
  pair<int, int> v[3];
  int j = 0;
  for (auto it = s.begin(); it != s.end(); ++it, j++) {
    v[j] = *it;
  }
  if (s.size() == 3) {
    if (v[0].second == v[1].second && v[1].second == v[2].second) {
      if ((v[0].first ^ v[1].first ^ v[2].first) == 0) {
        return true;
      }
    }
    return false;
  } else if (s.size() == 2) {
    if (v[0].second < v[1].second) {
      swap(v[0], v[1]);
    }
    if (v[0].second == v[1].second * 2) {
      if ((v[0].first ^ v[0].first ^ v[1].first) == 0) {
        return true;
      }
    }
    return false;
  } else {
    if (v[0].first == 0) {
      return true;
    }
    return false;
  }
}

int main() {
  int N;
  scanf("%d", &N);
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  printf("%s\n", solve(N, a) ? "Yes" : "No");
}


Measured memory_bytes: 4224
/*
g++ -std=c++11 -o2 -Wall ABC112B.cpp -o .\out\ABC112B.out
.\out\ABC112B.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  int ans = 10000;
  int c, t;
  for (int i = 0; i < N; ++i) {
    cin >> c >> t;
    if (t <= T) {
      ans = min(ans, c);
    }
  }
  if (ans == 10000) cout << "TLE\n";
  else cout << ans << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,n,temp,mini;
  int cnt = 0;
  int array[100];

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ) scanf("%d",&array[i]);

  for( i = 0 ; i < n ; i++ ){
    mini = i;
    for( j = i ; j < n ; j++ ){
      if( array[j] < array[mini] ) mini = j;
    }
    temp = array[i];
    array[i] = array[mini];
    array[mini] = temp;
    if( i != mini ) cnt++;
  }
  for( i = 0 ; i < n ; i++ ){
    if( i < n - 1 ) printf("%d ",array[i]);
    else printf("%d\n",array[i]);
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  int K,A,B;
  cin >> K >> A >> B;
  if(A/K < B/K){
    cout << "OK" <<endl;
  }
  else if(A%K==0 || B%K==0){
    cout << "OK" <<endl;
  }
  else{
    cout << "NG" << endl;
  }
  
  
}



Measured memory_bytes: 3480
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
i = 0
while 1:
    if i*(i+1)//2 >= x:
        print(i)
        quit()
    i += 1
 

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = 1000000007;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ll N = (int)1e5+5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n,m;
vector< pair<int, ll> > adj[N];
ll dist[N];
bool vis[N];

void bfs(int src)
{
    queue<int> Q;
    vis[src]= true;
    Q.push(src);
    while(!Q.empty())
    {
        int curr = Q.front();
        Q.pop();
        for(auto it : adj[curr])
        {
            int i = it.first;
            ll w = it.second;
            if(!vis[i])
            {
                vis[i] = true;
                dist[i] = dist[curr] + w;
                Q.push(i);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    memset(vis,false,sizeof(vis));
    cin>>n;
    m = n - 1;
    f(i,m)
    {
        int u,v;
        ll w;
        cin>>u>>v>>w;
        adj[u].pb({v, w});
        adj[v].pb({u, w});
    }
    bfs(1);
    rep(i, 1, n){
        if(dist[i] & 1) cout<<"0\n";
        else cout<<"1\n";
    }
    return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
bool a[101];
int main(){
	ios::sync_with_stdio(false);
	int n,ans=0;
	char x;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>x;
		a[x-'A']=1;
	}
	for (int i=0;i<26;i++)
	if (a[i]) ans++;
	if (ans==4) cout<<"Four";
	if (ans==3) cout<<"Three";
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
// using mP = pair<modint, modint>;

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




void solve() {
    int a, b;
    while(true){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        if(a > b){
            cout << b << " " << a << endl;
        }else{
            cout << a << " " << b << endl;
        }
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int K;

int calc(int x)
{
    return (x + K - 1) / K;
}

int main()
{
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    int sx, sy;
    rep(y, H) {
        rep(x, W) {
            if (S[y][x] == 'S') {
                S[y][x] = '.';
                sx = x, sy = y;
            }
        } 
    }

    queue<pair<PII, int>> Q;
    vector<vector<bool>> vis(H, vector<bool>(W));
    vis[sy][sx] = true;
    Q.emplace(PII(sx, sy), 0);
    set<PII> visitable;

    while (Q.size()) {
        pair<PII, int> p = Q.front(); Q.pop();
        if (p.second <= K) visitable.insert(p.first);
        
        if (p.second < K) {
            rep(i, 4) {
                int nx = p.first.first + dx[i], ny = p.first.second + dy[i];
                if (in_range(nx, ny, W, H) && !vis[ny][nx] && S[ny][nx] == '.') {
                    Q.emplace(PII(nx, ny), p.second + 1);
                    vis[ny][nx] = true;
                }
            }
        }
    }

    int ans = INF;
    for (PII p : visitable) {
        int tmp = min({
            calc(p.first),
            calc(p.second),
            calc(W - p.first - 1),
            calc(H - p.second - 1)
        });
        ans = min(ans, tmp);
    }

    cout << ans + 1 << endl;
}

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

typedef vector <long long> vi;
typedef vector <vi> vvi;
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define ll long long
#define MAXN 3005

ll in[MAXN];
ll dp[MAXN][MAXN][2];

ll fun(ll l, ll r, ll t)
{
    if (r < l)
        return 0;
    
    if (dp[l][r][t] == -1)
    {
        if (t == 1)
        {
            dp[l][r][t] = max(fun(l + 1, r, 0) + in[l], fun(l, r - 1, 0) + in[r]);
            //cout << l << " " << r << " " << t << "\n" << fun(l + 1, r, 0) + in[l] << "\n" << fun(l, r - 1, 0) + in[r] << "\n\n";
        }
        else
        {
            dp[l][r][t] = min(fun(l + 1, r, 1) - in[l], fun(l, r - 1, 1) - in[r]);
            //cout << l << " " << r << " " << t << "\n" << fun(l + 1, r, 1) - in[l] << "\n" << fun(l, r - 1, 1) - in[r] << "\n\n";
        }
    }
    return dp[l][r][t];
}

int main(void)
{
    memset(dp, -1, sizeof(dp));
    ll n;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> in[i];
    
    cout << fun(0, n - 1, 1) << "\n";
}


Measured memory_bytes: 141440
#import bisect,collections,copy,heapq,itertools,math,numpy,string
#from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
mod = 10**9+7
dict = {}
N,K = LI()

summax = 0 
summin = 0
ans = 0

first = K
for i in range(1,K):
	#print(i,"個選ぶとき(対象外)")
	summax+=N-i+1
	summin+=i-1
#print(summin,summax)

for k in list(range(K,N+2)):
	#print(k,"個選ぶとき(対象)")
	summax+=N-k+1
	summin+=k-1
	ans+=summax-summin+1
	ans%=mod
	#print(summin,summax)
print(ans)


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


int main()
{
    int n,c;
    cin >> n >> c;
    vector<ll> v(n),w(n);
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i] ;
    }
    ll dp[n][c + 1];
    memset(dp,0,sizeof(dp));
    for(int i = 1; i <= c; i++)
    {
        if(i >= w[0])
            dp[0][i] = v[0];
    }
    for(int i = 1; i < n; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if(j >= w[i])
            {
                dp[i][j] = max(dp[i][j] , v[i] + dp[i - 1][j - w[i]]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < n;i++)
    {
        ans = max(ans,dp[i][c]);
    }
    cout << ans << '\n' ;
    return 0;
}

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

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

using namespace std;

struct SCC{
  int V;
  vector<vector<int> > G,rG;
  vector<bool> used;
  vector<int> cmp,vs;

  SCC(int V=0):V(V){
    G.resize(V,vector<int>()), rG.resize(V,vector<int>()), cmp.resize(V), used.resize(V);
  }

  void add_edge(int s,int t){
    G[s].push_back(t);
    rG[t].push_back(s);
  }

  void dfs(int v){
    used[v] = true;
    for(int i=0;i<G[v].size();i++) if( !used[G[v][i]] ) dfs(G[v][i]);
    vs.push_back(v);
  }

  void rdfs(int v,int k){
    used[v] = true;
    cmp[v] = k;
    for(int i=0;i<rG[v].size();i++) if( !used[rG[v][i]] ) rdfs(rG[v][i],k);
  }

  int scc(){
    rep(i,V) used[i] = false;
    vs.clear();
    rep(v,V) if( !used[v] ) dfs(v);
    rep(i,V) used[i] = false;
    int k = 0;
    for(int i=vs.size()-1;i>=0;i--) if( !used[vs[i]] ) rdfs(vs[i],k++);
    return k;
  }

};

int main() {
  int n;
  cin >> n;
  SCC scc(210);
  rep(_,n) {
    int u,d;
    string s;
    cin >> u >> s >> d;
    if( s[0] == 'l' ) scc.add_edge(101+d,u);
    else              scc.add_edge(u,101+d);
  }
  cout << (scc.scc()!=210) << endl;
  return 0;
}

Measured memory_bytes: 3220
def solve():
	n = int(input())
	arr = list(map(int,input().split()))
	dic = {}
	for i in arr:
		if i not in dic:
			dic[i]=1
		else:
			dic[i]+=1
	arr.sort()
	ele = arr[n-1]
	count = [0]*(ele+1)
	for i in arr:
		mul = i
		k=2
		if dic[i]>1:
			count[i]=1
		while mul*k<=ele:
			if mul*k in dic:
				count[mul*k]+=1
			k+=1
	ans=0
	for i in range(0,n):
		if count[arr[i]]==0:
			ans+=1
		# print(count[arr[i]],ans)
		# print(arr[i],count[arr[i]],ans)
	print(ans)
	


if __name__ == "__main__":
	solve()


Measured memory_bytes: 121488
#include<stdio.h>
main(k,i,j,c,N){scanf("%d",&N);for(k=i=0;i<N;i++,k=c==N-1?i:k)for(c=j=0;j<=N;j++)c+=getchar()=='o'?1:0;for(i=1000;i--;)printf("%d\n",k?k:rand()%N+1);}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<int, int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;

P calc(int n) {
  int a = n % 10;

  while (n >= 10) {
    n /= 10;
  }

  int b = n;

  return make_pair(b, a);
}

ll d[10][10];

int main () {
  cin >> N;

  rep(i, N) {
    P tmp = calc(i);
    //cout << i<< "\n";
    //cout << tmp.first<< tmp.second << "\n";
    d[tmp.first][tmp.second]++;
  }

  ll ans = 0;

  for (int i=1;i<=9;++i) {
    for (int j=1;j<=9;++j) {
      if (i == j) {
        ans += (d[i][i] * d[i][i]);
      } else {
        ans += (d[i][j] * d[j][i]);
      }

      //cout << i << " " << j << "\n";
      //cout << ans << "\n";

    }
  }

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

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := nextInt(sc)
	b := nextInt(sc)
	c := nextInt(sc)
	wtr := bufio.NewWriter(os.Stdout)
	fmt.Fprintf(wtr, "%d %d\n", min(a, min(b, c)), max(a, max(b, c)))
	wtr.Flush()
}



Measured memory_bytes: 1136
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
vector<int> ans[1000];
void push(int s,int t,int i){
for(int j=s;j<=t;j++){
  ans[i].push_back(j);
}
i++;
for(int j=s;j<=t;j++){
  ans[i].push_back(j);
  i++;
  }
}
int main(){
  int n;
  cin>>n;
  vector<int> ok;
  rep1(i,n){
    ok.push_back((i+2)*(i+1)/2);
    if(i*(i+1)/2>n)break;
  }
  bool tag=false;
  int k;
  int num=ok.size();
  rep(i,num){
    if(n==ok[i]){
      tag=true;
      k=i+3;
    }
  }
if(tag){
  cout<<"Yes"<<endl;
  cout<<k<<endl;
  int kk=k-1;
  int s=1;int t=kk;
  rep1(i,kk){
    push(s,t,i);
    s=t+1;
    t+=kk-i;
  }
  rep1(i,k){
    cout<<kk<<" ";
    rep(j,kk){
      cout<<ans[i][j];
      if(j<kk-1)cout<<" ";
    }
    cout<<endl;
  }
}
else{
  if(n==1){
    cout<<"Yes"<<endl;
    cout<<2<<endl;
    cout<<"1 1"<<endl;
    cout<<"1 1"<<endl;
  }
  else
  cout<<"No"<<endl;
}
  return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int a, b;
    cin >> a >> b;
    int counter = 0;

    // int aa = atoi(a.c_str());
    // int bb = atoi(b.c_str());

    for (int i = a; i <= b; i++){
        string istr = to_string(i);
        if (istr[0] == istr[4] && istr[1] == istr[3]) counter++;
    }
    cout << counter << endl;

    return 0;
}







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

int FindSumOfDigit(int N){ //N:対象の数，i:何桁目か？
  int sum_digit =0;
  while( N >0){
    sum_digit += N%10;
    N /=10;
  }
  return sum_digit;
}

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  
  int sum = 0;
  
  for( int i=1; i<N+1; i++ ){
    int total = FindSumOfDigit(i);
    if ( A<=total && total<=B )
      sum += i;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;

int main(){
	vector<int> vec;
	for(int i = 0; i < 3; i++){
	 	int t; cin >> t;
	 	vec.pb(t);
	}
	sort(vec.begin(), vec.end());
	int sum = 0;
	for(int i = 1; i < vec.size(); i++){
	 	sum += vec[i]-vec[i-1];
	}
	cout << sum << endl;
	return 0;
}                  


Measured memory_bytes: 3600
def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod

  return K * x # 指数を割り続け n が 1 に至ったら終了

def cmbmod(n, r,mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = result*int(numerator[k])%mod
    return result

n,a,b=map(int,input().split())

c=powmod(2, n,10**9+7)
d=cmbmod(n,a,10**9+7)
e=cmbmod(n,b,10**9+7)
print((c-d-e-1)%(10**9+7))

Measured memory_bytes: 27700
#include <iostream>

int main(int argc, char *argv)
{
	int d;
	std::cin >> d;
	
	switch(d) {
	case(25):
		std::cout << "Christmas" << std::endl;
		break;
	case(24):
		std::cout << "Christmas Eve" << std::endl;
		break;
	case(23):
		std::cout << "Christmas Eve Eve" << std::endl;
		break;
	case(22):
		std::cout << "Christmas Eve Eve Eve" << std::endl;
		break;
	default:
		break;
	}
	
	return 0;
}

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

int main(void){
    int N,K;
    cin>>N>>K;
    
    vector<int> h(N);
    for(int i=0;i<N;i++) cin>>h[i];
    
    sort(h.begin(),h.end());
    
    int gap=1000000001;
    for(int i=0;i<N-K+1;i++){
        if(abs(h[i+K-1]-h[i])<gap) gap=abs(h[i+K-1]-h[i]);
    }
    
    cout<<gap<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m);
    vector<ll> c(3);
    rep(i,m){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<1000;i++){
        int keta=0;
        int x=i;
        int k=0;
        bool flag=true;
        do{
            c[k]=x%10;
            x/=10;
            keta++;
            k++;
        }while(x!=0);
        if(keta!=n) continue;
        for(int j=0;j<m;j++){
            int keta2=n-a[j];
            if(c[keta2]!=b[j]) flag=false;
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }
    
    cout << "-1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

typedef long long ll;
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc136/tasks/abc136_d
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
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); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

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

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

void setval(vector<int> &ans, int r, int l, int idx) {
  debug(r,l,idx);
  ans[idx-1] = ans[idx] = r / 2;
  if (r % 2 == 1) {
    ans[idx-1]++;
  }
  ans[idx-1] += l / 2;
  ans[idx] += l / 2;
  if (l % 2 == 1) {
    ans[idx]++;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  auto ans = make_v<int>(s.size());
  int r=0,l=0,idx=0;
  REP(i,s.size()) {
    if((s[i] == 'R') && l != 0) {
      setval(ans, r, l, idx);
      r = l = idx = 0;
    }
    if(s[i] == 'R') {
      r++;
    } else {
      if (l == 0) {
        idx = i;
      }
      l++;
    }
  }
  setval(ans, r, l, idx);
  stringstream ss;
  for (auto v : ans) {
    ss << v << " ";
  }
  cout << ss.str() << endl;
  return 0;
}


Measured memory_bytes: 1492
#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 (a == b) {
		cout << c << endl;
	} else if (a == c) {
		cout << b << endl;
	} else {
		cout << a << endl;
	}
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int cnt=3;
  if(a==b&&a==c&&b==c){
   cout << 1 << endl;
  }else if(a==b||a==c||b==c){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }
}


Measured memory_bytes: 256
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n,m = inm()
h = inl()
p = [True] * n
for i in range(m):
    a,b = inm()
    a -= 1
    b -= 1
    if h[a] >= h[b]:
        p[b] = False
    if h[b] >= h[a]:
        p[a] = False
ans = sum(p)
print(ans)

Measured memory_bytes: 85680
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using LL=long long;
using namespace std;
typedef long long int llint;
#define pub push_back
#define mp make_pair
#define fir first
#define sec second
#define res resize
const int big=((llint)1<<30);
int main(void){
	int i,j,q,w,ans=0,a,b,c,z,e;
	cin>>a>>b>>c;
	for(ans=0;ans<10000000;ans++){
		if(a%2==1||b%2==1||c%2==1){ break; }
		q=(b+c)/2;
		w=(c+a)/2;
		e=(a+b)/2;
		a=q;
		b=w;
		c=e;
	}
	if(ans==10000000){ ans=-1; }
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int main() {

	int h, w, d;
	cin >> h >> w >> d;

	V<V<T>> place(d);

	rep(i, h)rep(j, w) {
		int a;
		cin >> a;
		a--;
		place[a % d].push_back(T(a, i, j));
	}
	
	rep(i, d)sort(all(place[i]));
	vvi sum(d, { 0 });

	rep(i, d)rep(j, place[i].size() - 1) {
		int dist = 0;
		dist += abs(get<1>(place[i][j + 1]) - get<1>(place[i][j]));
		dist += abs(get<2>(place[i][j + 1]) - get<2>(place[i][j]));
		sum[i].push_back(sum[i][sum[i].size() - 1] + dist);
	}

	int q;
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		l--;r--;
		cout << sum[r % d][r / d] - sum[l % d][l / d] << endl;
	}
}

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

int N,H;
vector<int> G[410],R[410];
bool vis[410];
vector<int> ele;

void DFS(int v)
{
    if(vis[v])return;
    vis[v] = true;
    ele.push_back(v);
    for(int i = 0; i < G[v].size(); i++)DFS(G[v][i]);
    for(int i = 0; i < R[v].size(); i++)DFS(R[v][i]);
    return;
}

int main()
{
    scanf("%d%d",&N,&H);
    for(int i = 0; i < N; i++)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int s,t;
        if(c == 0)s = a;
        else s = c + 200;
        if(d == 0)t = b + 200;
        else t = d;
        G[s].push_back(t);
        R[t].push_back(s);
    }

    for(int i = 0; i < 410; i++)if(!vis[i])
    {
        if(G[i].size() == 0 && R[i].size() == 0)continue;
        ele.clear();
        DFS(i);
        bool flag = true;
        for(int j = 0; j < ele.size(); j++)
        {
            int now = ele[j];
            if(G[now].size() == R[now].size())continue;
            flag = false;
            if(G[now].size() > R[now].size() && now >= 201)
            {
                printf("NO\n");
                return 0;
            }
            if(G[now].size() < R[now].size() && now < 201)
            {
                printf("NO\n");
                return 0;
            }
        }
        if(flag)
        {
            printf("NO\n");
            return 0;
        }
    }

    printf("YES\n");
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	long i;
	int building;
	int floor;
	int room_number;
	int visiter[4][3][10] = {0};
	for (i = 0; i < n; i++) {
		int Visiter;
		cin >> building >> floor >> room_number >> Visiter;
		visiter[building - 1][floor - 1][room_number - 1] += Visiter;
	}
	for (i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << setw(2) << visiter[i][j][k];
			}
				cout << endl;
		}
		if (i == 3) break;
		cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
A,B,C,D=map(int,input().split())
if A<=C:
  if D>=B:
    t=B-C
  else:
    t=D-C
else:
  if D>=B:
    t=B-A
  else:
    t=D-A
if t<=0:
  print(0)
else:
  print(t)

Measured memory_bytes: 9176