akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

template<typename T>
struct FenwickTree {
	vector<T> v; int highestOneBit;
	FenwickTree() { }
	void init(int n) {
		highestOneBit = 1; while(highestOneBit * 2 <= n) highestOneBit *= 2;
		v.assign(n+1, T());
	}

	template<typename U> void init(const U *a, int n) {
		highestOneBit = 1; while(highestOneBit * 2 <= n) highestOneBit *= 2;
		v.resize(n+1);
		for(int i = 0; i < n; i ++) v[i+1] = a[i];
		for(int i = 1; i <= n; i ++) {
			int j = i + (i & -i);
			if(j <= n) v[j] += v[i];
		}
	}

	void add(int i, T x) {
		int n = v.size();
		for(i ++; i < n; i += i & -i) v[i] += x;
	}
	T sum(int i) const {	//[0, i)
		T r = 0;
		for( ; i > 0; i -= i & -i) r += v[i];
		return r;
	}
	T sum(int left, int right) const {	//[left, right)
		return sum(right) - sum(left);
	}
	int kth(T x) const {	//x <= sum[0,i) となる最右(右であることに注意！)のiを返す
		int n = v.size(), i = 0;
		for(int b = highestOneBit; b != 0 && i < n; b >>= 1) {
			if(i + b < n) {
				int t = i + b; T u = v[t];
				if(x >= u) { i = t; x -= u; }
			}
		}
		return i;	//ここで残りのxも意味を持つので適当にできる
	}
};

ll solve(const string& S) {
  vector<vector<int>> pos(26);
  for (int i = 0; i < S.size(); i++) {
    pos[S[i] - 'a'].push_back(i);
  }
  int odds = 0;
  vector<pair<int, int>> pairs;
  for (const auto &p: pos) {
    if (p.size() % 2 == 1) {
      ++odds;
      if (odds > 1) {
        return -1;
      }
    }
    int n = p.size();
    for (int i = 0; i <= n - i - 1; i++) {
      pairs.emplace_back(p[i], p[n - i - 1]);
    }
  }
  sort(pairs.begin(), pairs.end());
  FenwickTree<ll> bit;
  bit.init(S.size());
  ll res = 0, center = 0;
  for (auto p: pairs) {
    if (p.first != p.second) {
      res += bit.sum(0, p.first) * 2;
      res += bit.sum(p.first + 1, p.second);
      res += center;
      bit.add(p.second, 1);
    } else {
      res += bit.sum(0, p.first);
      center = 1;
    }
  }
  return res;
}

int main() {
  string S;
  cin >> S;
  cout << solve(S) << endl;
  return 0;
}


Measured memory_bytes: 4600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);


        int N = sc.nextInt();
        boolean flg = false;


        for (int i = 0; i < 101; i++) {
            for (int j = 0; j < 101; j++) {
                int judge = 4 * i + 7 * j;
                if (N == judge) {
                    flg = true;
                }
            }
        }
        if (flg == true) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int N,A,B,C,D;cin >> N >> A >> B >> C >> D;
  A--;B--;C--;D--;
  string S;cin >> S;
  if(C<D){
    while(B<D){
      if(S[B+1]=='.') B++;
      else if(B+2<N && S[B+2] =='.'){
        B+=2;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
    while(A<C){
      if(S[A+1]=='.') A++;
      else if(A+2<N && S[A+2] =='.'){
        A+=2;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;

  }else{
    bool success = false;
    while(B<D){
      if(S[B-1]=='.'&&S[B+1]=='.'){
        success = true;
        break;
      }
      if(S[B+1]=='.') B++;
      else if(B+2<N && S[B+2] =='.'){
        B+=2;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
    if(B==D&&S[B-1]=='.'&&S[B+1]=='.')success = true;
    if(!success){
      cout << "No" << endl;
      return 0;
    }
    while(A<C){
      if(A+1==B)A+=2;
      if(S[A+1]=='.') A++;
      else if(A+2<N && S[A+2] =='.'){
        A+=2;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
    while(B<D){
      if(S[B+1]=='.') B++;
      else if(B+2<N && S[B+2] =='.'){
        B+=2;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    bool check = true;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] % 2 == 1) check = false;
    }
    int cnt = 0;
    while (check) {
        for (int i = 0; i < N; i++) {
            A[i] /= 2;
            if (A[i] % 2 == 1) check = false;
        }
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
/// ABC-ul sirurilor de caractere
   /// https://www.pbinfo.ro/?pagina=articole&subpagina=afisare&id=19

#include <bits/stdc++.h>

using namespace std;

int main() {
   int k=0,i,n;
   char s[101];
   cin.getline(s,101); ///citirea unui sir de caractere
   n=strlen(s); ///retin lungimea sirului de caractere
   for(i=0;i<=n/2-1;i++){
     ///  cout<<s[i]<<" "<<s[n-i-1]<<endl;
       if(s[i]!=s[n-i-1]){
           
           k++;
       }
   }  
   cout<<k;
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>21)
    {
        cout << "bust"<<endl;
    }
    else{
        cout << "win"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    const list = [...Array(N)].fill(0);
    
    for(let i=0; i<N-1; i++) {
        let num = i + 2;
        
        list[A[i]-1]++;
    }
    
    console.log(list.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 57980
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
 char ch;

 int count=0;
 for( char g='a'; g<='z'; g++ ){
   count++;
 }

 int char_num[count];
 for( char h='a'; h<='z'; h++ ){
   char_num[h-'a'] = 0;
 }

 while( scanf("%c", &ch) != EOF ){

  for( char i='a'; i<='z'; i++ ){
    if( ch == i || toupper(ch) == toupper(i) ){
      char_num[i-'a']++;
    }
  }
 }

 for( char j='a'; j<='z'; j++ ){
   cout << j << " : " << char_num[j-'a'] << endl;
 }

 return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
    string s;int a;cin>>a>>s;
    if(a>=3200){
    	cout<<s<<endl;
	}
	else{
		cout<<"red"<<endl;
	}
	
	//cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h,w,n,i,max=0;
    scanf("%d%d%d",&h,&w,&n);
    max=h>w?h:w;
    for(i=1;;i++)
    {
        if(max*i>=n)
        {
            printf("%d",i);
            break;
        }
    }
    return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, k;
  std::cin >> n >> k;
  vi hateNum(k);
  rep(i, k) cin >> hateNum[i];
	auto hasHateNum = [&hateNum](int target){
		int digit;
		while (target != 0) {
			digit = target % 10;
			for (auto &v : hateNum)
				if (v == digit) return true;
			target /= 10;
		}
		return false;
	};
	int ans = n;
	while (hasHateNum(ans))
		ans++;
	std::cout << ans << "\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int memo[100010];
vector<int>v[100010];
int sol(int pos){
  if(memo[pos])return memo[pos];
  int ma=0;
  for(int i:v[pos])ma=max(ma,sol(i)+1);
  return memo[pos]=ma;
}
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
		int N,M;
		cin>>N>>M;
		for(int i=0;i<M;i++){
      int a,b;
      cin>>a>>b;
      v[a-1].push_back(b-1);
		}
		int ma=0;
		for(int i=0;i<N;i++)ma=max(ma,sol(i));
		cout<<ma;
    return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	int n;
	while(cin>>n,n){
		vector<char> data[11][11];
		rep(i,n){
			int w=0,l=0;
			char t;
			cin>>t;
			rep(j,n-1){
				int a;
				cin>>a;
				if(a==0)w++;
				else if(a==1)l++;
			}
			data[w][l].push_back(t);
		}
		for(int i=n-1;i>=0;i--){
			rep(j,n)if(data[i][j].size()>0){
				for(int k=0;k<data[i][j].size();k++){
					cout<<data[i][j][k]<<endl;
				}
			}
		}
	}
}

Measured memory_bytes: 1208
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble(); 
		double c=sc.nextDouble(); 
		System.out.println(a*b*Math.sin(Math.toRadians(c))/2);
		System.out.println(a+b+Math.sqrt((a*a)+(b*b)-2*a*b*Math.cos(Math.toRadians(c))));
		System.out.println(b*Math.sin(Math.toRadians(c)));
	}

}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

// 方針：差の異なるペアをM個つくる
int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int a,b;
  if(M%2==1){
    a=1;
    b=M;
    while(a<b){
        printf("%d %d\n",a,b);
        ++a; --b;
    }
    a=M+1;
    b=M*2+1;
    while(a<b){
        printf("%d %d\n",a,b);
        ++a; --b;
    }
  }else{
    a=1;
    b=M+1;
    while(a<b){
        printf("%d %d\n",a,b);
        ++a; --b;
    }
    a=M+2;
    b=M*2+1;
    while(a<b){
        printf("%d %d\n",a,b);
        ++a; --b;
    }
  }
}

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

int main(){
    uint32_t N;
    uint64_t sum = 0;

    std::cin >> N;
    std::vector<int> A(N, 0);
    std::vector<int> B((N-1));

    for(uint8_t i = 0; i < (N-1); i++){
        std::cin >> B[i];
    }

    A[0] = B[0];

    for(uint8_t i = 0; i < (N-1); i++){
        if(A[i] > B[i]){
            A[i] = B[i];
        }
        A[i+1] = B[i];
    }

    for(uint8_t i = 0; i < N; i++){
        sum += A[i];
    }

    std::cout << sum << std::endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int ans=0;
    for (int i = 0; i < n; ++i) {
        int p;cin>>p;
        ans+=p;
    }
    vector<int> c(n);
    for (int i = 0; i < n-1; ++i) {
        cin>>c[i];
    }
    for (int i = 0; i < n-1; ++i) {
        if(a[i]+1==a[i+1])ans+=c[a[i]-1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
l1=[1,3,5,7,8,10,12]
l2=[4,6,9,11]
l3=[2]
if x in l1 and y in l1:
  print('Yes')
elif x in l2 and y in l2:
  print('Yes')
elif x in l3 and y in l3:
  print('Yes')
else:
  print('No')

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n;
  cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  
  int p = 1000000007;
  
  ll ans = 1;
  ll a = 1, b = 1;
  
  rep(i, 0, n){
    ans *= 10;
    a *= 9;
    b *= 8;
    ans %= p;
    a %= p;
    b %= p;
  }
  
  ans -= 2*a;
  ans += b;
  ans %= p;
  
  if(ans < 0)
    ans += p;
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3536
//うわあああああああ
#include <iostream>
#include <iomanip>
using namespace std;

int N, K;
int DP[3][101];

void debug(void) {
  for (int d=0; d<=N; d++) {
    for (int k=0; k<3; k++) {
      cout << setw(8) << DP[k][d];
    }
    cout << endl;
  }
} 

int main(void) {
  for (int k=0; k<3; k++) {
    DP[k][0] = -1;
    DP[k][1] = 1;
  }

  cin >> N >> K;
  for (int i=0; i<K; i++) {
    int A, B;
    cin >> A >> B;
    DP[B%3][A] = -1;
    DP[(B+1)%3][A] = -1;
  }

  for (int d=1; d<N; d++) {
    for (int k=0; k<3; k++) {
      if (DP[k][d] != -1) {
	for (int nk=0; nk<3; nk++) {
	  if (DP[nk][d+1] != -1) {
	    DP[nk][d+1] += DP[k][d];
	    if (k==nk && DP[k][d-1]!=-1) {
	      int sub = DP[k][d];
	      for (int pk=0; pk<3; pk++) {
		if (k!=pk && DP[pk][d-1]!=-1) {
		  sub -= DP[pk][d-1];
		}
	      }
	      DP[nk][d+1] -= sub;
	    }
	  }
	}
      }
      DP[k][d+1] %= 10000;
    }
  }

  int sum = 0;
  for (int k=0; k<3; k++) {
    if (DP[k][N] != -1) {
      sum += DP[k][N];
    }
  }

  cout << sum%10000 << endl;

  return 0;
}

Measured memory_bytes: 1160
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    
    if(s.charAt(2)==s.charAt(3) && s.charAt(4) == s.charAt(5))
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    bool same = true;
    if(N % 2) same = false;
    for(int i = 0; i < N/2; ++i) {
        if(S[i] != S[N/2 + i]) same = false;
    }
    if(same) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
tmp = input().split()
N = int(tmp[0])
K = int(tmp[1])
Q = int(tmp[2])

ns = []
for n in range(N):
    ns.append(K-Q)

# print(ns)

for i in range(Q):
    a = input()
    a = int(a)-1
    ns[a] = ns[a]+1
    # print(ns)

for n in ns:
    if n > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 7848
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(L[k-1])

Measured memory_bytes: 9008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
const int N = 5e6 + 10;
const ll mod = 1e9 + 7;
multiset<string> s;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    rep(i,1,a)s.insert("a");
    rep(i,1,b)s.insert("b");
    rep(i,1,c)s.insert("c");
    while (s.size()>1){
        auto i=s.begin(),j=s.end();
        j--;
        string tmp=(*i)+(*j);
        s.erase(i);s.erase(j);
        s.insert(tmp);
    }
    cout<<(*s.begin());
   return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    while(!(a%2)&&!(b%2)&&!(c%2)){
        int p=a/2,q=b/2,r=c/2;
        a=q+r;
        b=p+r;
        c=p+q;
        if(a==b&&b==c){
            cout<<"-1"<<endl;
            return 0;
        }
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	int ans = 0, tmp = 0;
	if(A[0]) {
		cout << -1 << endl;
		return 0;
	}

	FOR(i, 1, N) {
		if (A[i - 1] + 1 == A[i]) {
			ans++;
		}
		else if (A[i - 1] + 1 < A[i]) {
			cout << -1 << endl;
			return 0;
		}
		else {
			ans += A[i];
		}
	}
	cout << ans << endl;
	return 0;
}



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

int	main()
{
	int	n;	

	cin >> n;
	vector<int64_t> vec(87);
	vec.at(0) = 2;
	vec.at(1) = 1;
	for (int i = 2; i <= n; i++)
		vec.at(i) = vec.at(i - 2) + vec.at(i - 1);
	cout << vec.at(n) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin >> n >> m;
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  vector<bool> c(m,true);
  int ans=1000;
  for(int k=0;k<m;k++){
    vector<int> v(m);
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(c[a[i][j]]){
          v[a[i][j]]++;
          break;
        }
      }
    }
    int cnt=0;
    int t;
    for(int i=0;i<m;i++){
      if(cnt<v[i]){
        cnt=v[i];
        t=i;
      }
    }
    ans=min(ans,cnt);
    c[t]=false;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
int find(int a){
     if(par[a]==a)return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);if(a==b)return ;
     parent[b]=a;
}*/
 
 
 
 
 
 
 







int main(){
    ll n;
    cin>>n;
    ll a[n+1],b[n+1];
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    if((n&1)){
         ll t1=a[n/2+1];
         ll t2=b[n/2+1];
         //cout<<t1<<" "<<t2<<"\n";
         cout<<abs(t2-t1)+1;
    }
    else{
         ll t1=a[n/2+1]+a[n/2];
         ll t2=b[n/2+1]+b[n/2];
         cout<<abs(t2-t1+1);
    }
}

























Measured memory_bytes: 6632
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    int num[]={1,3,1,2,1,2,1,1,2,1,2,1};
    SPEED;
    int x,y;
    cin >> x >> y;
    if(num[x-1]==num[y-1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, ans, count;

  scanf("%d", &n);
  while(n != 0){
    ans = n;
    count = 0;
    while(ans != 1){
      count++;
      if(ans % 2 == 1){
        ans = ans * 3 + 1;
      }else{
        ans /= 2;
      }
    }
    printf("%d\n", count);
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 1852
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;
int n;
int main() {
    cin >> n;
    if(n<1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

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

using namespace std;

int main() {

        int n, cnt = 0;
        cin >> n;
        long N;
        while (cin >> N) {
                long sqr = sqrt(N);
                if (sqr < 2) {
                        cnt++;
                        continue;
                }
                bool flag = true;
                for (long j = 2; j <= sqr; j++) {
                        if ((N % j) == 0) {
                                flag = false;
                                break;
                        }
                }
                if (flag) {
                        cnt++;
                }
        }

        cout << cnt << endl;

        return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18+5LL
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (int)1e9+2
# define maxn 100006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

**************************************************/
vector<int>g[maxn];
int d[maxn];

int main()
{
  int n;
  cin >> n;
  int a,b;
  for(int i=0;i<n-1;i++)
  {
    cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
  }
  memset(d,-1,sizeof d);

  priority_queue<ii,vector<ii>,greater<ii> >pq;
  int k;
  cin >> k;
  while(k--)
  {
    int v,p;
    cin >> v >> p;
    d[v]=p;
    pq.push(mp(p,v));
  }
  while(!pq.empty())
  {
    ii p= pq.top();
    pq.pop();
    int u=p.ss;
    for(int i=0;i<g[u].size();i++)
    {
      int v=g[u][i];
       if(d[v]==-1)
         {
           d[v]=d[u]+1;
           pq.push(mp(d[v],v));
         }
    }
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<g[i].size();j++)
    {
       int v=g[i][j];
       if(abs(d[i]-d[v])!=1)
       {
         cout <<  "No"<<"\n";
         return 0;
       }
    }
  }
  cout << "Yes"<<"\n";
  for(int i=1;i<=n;i++)
  {
     cout << d[i]<<"\n";
  }
}

Measured memory_bytes: 8692
_, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
s = a.inject(:+)
ma = 0
c = s * 1.0 / (4.0 * m)

a.each do |i|
  if i >= c
    ma += 1
  end
end
if ma < m
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 1788
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] S = sc.next().split("");
    long total = 0;
    for (int i = 0; i < Math.pow(2,S.length-1); i++) {
      String s = S[0];
      for (int j = 0; j < S.length-1; j++) {
        if ((1&i>>j) == 1) {
          total += Long.parseLong(s);
          s = S[j+1];
        } else {
          s += S[j+1];
        }
      }
      total += Long.parseLong(s);
    }
    System.out.println(total);
  }
}

Measured memory_bytes: 20948
#include <iostream>
#include <algorithm>

int main()
{
    int s, i = 0;
    static int a[1000000];

    std::cin >> s;
    
    a[0] = s;
    while(1){
        if(a[i] % 2 == 0){
            a[i + 1] = a[i] / 2;
        }
        else {
            a[i + 1] = 3 * a[i] + 1;
        }

        for(int j = 0;j < i + 1;j++){
            if(a[i + 1] == a[j]){
                std::cout << i + 2;
                return 0;
            }
        }
        i++;
    }
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

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

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		ll k;
		cin >> k;

		println((binary_search(all(a), k) ? 1 : 0));
	}
}


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

using namespace std;
#define int long long

const int INF = 200000000007;


  
signed main(){
    int n;
    string s;
    cin>>n>>s;
    bool a[n];
    for(int i=0;i<n;i++){
        if(s[i]=='o')a[i]=false;
        else a[i]=true;
    }
    bool ans[n];
    if(n%3==0){
        ans[0]=0;ans[1]=0;ans[2]=0;
        for(int i=0;i<n/3;i++){
            ans[(3*i+3)%n]=ans[3*i]^a[3*i+1]^a[3*i+2];
            ans[(3*i+4)%n]=ans[3*i+1]^a[3*i+2]^a[3*i+3];
            ans[(3*i+5)%n]=ans[3*i+2]^a[3*i+3]^a[3*i+4];
        }
        if(ans[0]==0&&ans[1]==0&&ans[2]==0){
            for(int i=0;i<n;i++){
                if(ans[i]^a[1])cout<<'W';
                else cout<<'S';
            }
        }else cout<<-1;
    }else{
        ans[0]=0;
        for(int i=0;i<n;i++){
            ans[(3*i+3)%n]=ans[(3*i)%n]^a[(3*i+1)%n]^a[(3*i+2)%n];
        }
        if(ans[0]==0){
            bool k=ans[0]^ans[1]^ans[2]^a[1];
            for(int i=0;i<n;i++){
                if(ans[i]^k)cout<<'W';
                else cout<<'S';
            }
        }else cout<<-1;
    }
   
    

    
    return 0;
}

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

int main()
{

        long long N;
        cin >> N;
        set<string> s;

        for (int i = 0; i < N; ++i) {
                string str;
                cin >> str;
                s.insert(str);
        }
        cout << s.size() << endl;

}


Measured memory_bytes: 19260
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
D = LI()

D = sorted(D)

mid = len(D)//2
# 周辺だけチェックする
if D[mid-1] == D[mid]:
    # 同じ数字が中間であるので、無理
    print(0)
    exit()
else:
    res = D[mid] - D[mid-1]
    print(res)


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

int main(){
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	if(e-a>k){
		cout << ":(" << endl;
	} else{
		cout << "Yay!" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  int h,n;cin>>h>>n;
  rep(i,n){
    int a;cin>>a;
    h -= a;
  }
  if(h <= 0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int main() {
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int point[1000], min=1000000;
		for(int i=0; i<n; i++) cin >> point[i];
		for(int j=0; j<n; j++){
			for(int k=j+1; k<n; k++){
				int dif = point[k]-point[j];
				if(dif<0) dif *= -1;
				if(dif<min) min = dif;
			}
		}
		cout << min << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
nt = list(map(int,input().split()))
n = nt[0]
t = nt[1]
p = list(map(int,input().split()))
x = 0
for i in range(n-1):
    sub = p[i+1] - p[i]
    if sub < t:
        x += sub
    else:
        x += t
print(x+t)

Measured memory_bytes: 25196
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
        return 0;
    }
    if (0 < a) {
        cout << "Positive" << endl;
        return 0;
    }
    if ((b - a + 1) % 2 == 0) {
        cout << "Positive" << endl;
        return 0;
    } else {
        cout << "Negative" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int operate(char op, int a, int b){
  switch(op){
  case '+': return a+b;
  case '-': return a-b;
  case '*': return a*b;
  case ' ': return b;
  }
}

int main(){
  string str;
  while(getline(cin,str) && str.size()){
    int R1 = 0;
    int R2 = 0;
    char R3 = ' ';

    for(int i=0;; i++){
      char c = str[i];

      if(isdigit(c)){
        R2 = R2 * 10 + c - '0';
      }else{
        R1 = operate(R3,R1,R2);
        R2 = 0;
        R3 = c;
      }
      //printf("R1: %d  R2: %d  R3: %c  c: %c\n",R1,R2,R3,c);
      if(c == '=' || R1 < 0 || R1 > 9999 || R2 < 0 || R2 > 9999)
        break;
    }
    if(R1 < 0 || R1 > 9999 || R2 < 0 || R2 > 9999) puts("E");
    else printf("%d\n",R1);

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n;
  cin >> n;
  double sum = 0;
  rep(i,n) {
    double a;
    cin >> a;
    sum += (double)1/a;
  }
  double ans = (double)1/sum;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll dp[101][100001];

int main(int argc, char const* argv[])
{
  int n;
  ll W;
  cin >> n >> W;
  vector<ll> w(n);
  vector<int> v(n);
  rep(i, n){
    cin >> w[i] >> v[i];
  }
  rep(i, n+1){
    rep(j, 100001){
      dp[i][j] = linf / 2;
    }
  }
  dp[0][0] = 0;
  rep(i, n){
    rep(j, 100001){
      dp[i+1][j] = dp[i][j];
      if(j-v[i]>=0)dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]]+w[i]);
    }
  }
  for(int j = 100000; j >= 0; j--){
    if(dp[n][j] <= W){
      cout << j << endl;
      return 0;
    }
  }
	return 0;
}


Measured memory_bytes: 79104
import math

N = int(input())
L = []
LL = []

if N == 1:
	L.append(1)
elif N == 2:
	L.append(1, 2)
else:
	n = int(math.sqrt(N) // 1)
	x = 1
	for i in range(n + 2):
		if N % x == 0:
			L.append(x)
		x += 1

for i in L:
	LL.append(int(N // i))

LLL = []

for i in range(len(L)):
	LLL.append(max(len(str(L[i])), len(str(LL[i]))))

print(min(LLL))

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

using namespace std;

#define N 100000

int a[N + 2];
int c[N + 2];
int ans[N + 2];

int main(){
	int n, i;

	scanf("%d", &n);

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

		c[a[i]]++;
	}

	for (i = 1; i <= N; i++){
		ans[i - 1] += c[i];
		ans[i] += c[i];
		ans[i + 1] += c[i];
	}

	printf("%d\n", *max_element(ans, ans + N + 2));

	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	set<string> kujibiki;
	for (int i = 0; i < N; i++) {
		string S;
		cin >>S;
		kujibiki.insert(S);
	}
	cout << kujibiki.size() << endl;
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int a,b,c=INT_MAX,d=-10000000000,e=0;
  cin>>a;
  for(int i=0;i<a;i++){
      cin>>b;
      c=min(c,b);
      d=max(d,b);
      e+=b;
  }
  cout<<c<<" "<<d<<" "<<e<<endl;
}


Measured memory_bytes: 3116
n=0
for i in range(int(input())):
	if i==0:
		d1=list(map(int,input().split()))
	else:
		d2=list(map(int,input().split()))
			
		for i in range(4):
			d2[0],d2[1],d2[4],d2[5]=d2[1],d2[5],d2[0],d2[4]
			for i in range(4):
				d2[1],d2[3],d2[4],d2[2]=d2[3],d2[4],d2[2],d2[1]
				if d1[0]==d2[0] and d1[1]==d2[1] and d1[2]==d2[2] and d1[3]==d2[3] and d1[4]==d2[4] and d1[5]==d2[5]:
					n+=1
		for i in range(4):
			d2[0],d2[3],d2[5],d2[2]=d2[3],d2[5],d2[2],d2[0]
			for i in range(4):
				d2[1],d2[3],d2[4],d2[2]=d2[3],d2[4],d2[2],d2[1]
				if d1[0]==d2[0] and d1[1]==d2[1] and d1[2]==d2[2] and d1[3]==d2[3] and d1[4]==d2[4] and d1[5]==d2[5]:
					n+=1
if n==0:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 5616
using System;

namespace AIZUJudge {
    class EquisionSolver {
        static void Main(string[] args) {
            string line = "";
            while ((line = Console.ReadLine()) != null) {
                string[] set = line.Split(' ');
                int devides = 2;
                int lineLength = 3;

                Matrix eqMatrix = new Matrix(devides,lineLength-1);
                Matrix scalar = new Matrix(devides,1);

                for (int i = 0; i < devides; i++) {
                    for (int j = 0; j < lineLength-1; j++) {
                        eqMatrix.setElement(i, j, set[i*lineLength+j]);
                    }
                }
                scalar.setElement(0, 0,set[2]);
                scalar.setElement(1, 0, set[5]);

                double[] sol = eqMatrix.solveEq(scalar,2);
                Console.WriteLine(sol[0].ToString("f3") + " " + sol[1].ToString("f3"));
            }
       }
    }
    
    public class Matrix {
        double[,] element;
        public Matrix(int rowSize, int columnSize) {
            element = new double[rowSize, columnSize];
        }
        public void setElement(int row, int column, string value) {
            element[row, column] = double.Parse(value);
        }
        public double[] solveEq(Matrix scalar,int sol_Length) {
            double[] solution = new double[sol_Length];
            solution[0] = (element[1, 1] * scalar.element[0, 0] - element[0, 1] * scalar.element[1, 0]) / (element[0, 0] * element[1, 1] - element[0, 1] * element[1, 0]);
            solution[1] = (element[0, 0] * scalar.element[1, 0] - element[1, 0] * scalar.element[0, 0]) / (element[0, 0] * element[1, 1] - element[0, 1] * element[1, 0]);
            return solution;
        }
    }
}

Measured memory_bytes: 9220
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

if n%2 ==0:
    mae = []
    ushiro = []
    for i in range(0,n,2):
        ushiro.append(a[i])
    for i in reversed(range(1,n,2)):
        mae.append(a[i])
    ans = mae + ushiro
    print(*ans, sep=' ')
else:
    mae = []
    ushiro = []
    for i in range(1,n,2):
        ushiro.append(a[i])
    for i in reversed(range(0,n,2)):
        mae.append(a[i])
    ans = mae + ushiro
    print(*ans, sep=' ')

Measured memory_bytes: 25760
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Node {
    int color = 0;
    vector<int> next;
} node[100000];

int main() {
    int n, m, q, t1, t2;

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> t1 >> t2;
        node[t1].next.push_back(t2);
        node[t2].next.push_back(t1);
    }

    int color = 1;
    queue<int> que;
    while (1) {
        int start = -1;
        for (int i = 0; i < n; i++) {
            if (node[i].color == 0) {
                start = i;
                break;
            }
        }
        if (start == -1) {
            break;
        }
        
        node[start].color = color;
        que.push(start);
        while (!que.empty()) {
            int temp = que.front();
            int size = node[temp].next.size();
            for (int i = 0; i < size; i++) {
                if (node[node[temp].next[i]].color == 0) {
                    node[node[temp].next[i]].color = color;
                    que.push(node[temp].next[i]);
                }
            }
            que.pop();
        }
        color++;
    }

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> t1 >> t2;
        if (node[t1].color == node[t2].color && node[t1].color > 0 && node[t2].color > 0) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 9400