akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
int main(){
//	freopen ("1.in","r",stdin);
	int a,b;
	cin>>a>>b;
	char ch=getchar();
	for (int i=1;i<=(a+b);++i){
		ch=getchar();
		if (i==a+1){
			if (ch!='-') printf ("No\n"),exit(0);
		}
		else if (ch>'9'||ch<'0') printf ("No\n"),exit(0);
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mod 1000000007LL;
#define mkp make_pair
#define pb push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
double pi=3.1415926535;
double eps=0.000001;

void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}


int32_t main(){
/////////////////////////////////////////////////////////////////////
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(10);
	int n, W, i ,w;
	cin>>n>>W;
	vector < vector <int> > K(n+1, vector <int> (W+1, 0));
	
	
	vii wt(n), val(n);
	rep(i,0,n){
		cin>>wt[i];
		cin>>val[i];
	}
//	print(wt);
//	print(val);
	for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   	}	
//   	rep(i,0,n+1){
//   		rep(ii,0,W+1) cout<<K[i][ii]<<"\t";
//   		cout<<endl;
//	   }
   	cout<<K[n][W]<<endl;
	return 0;
	}
	


Measured memory_bytes: 80256
#include<stdio.h>
int main(){
  int h,w,i,j;
  while(scanf("%d %d",&h,&w)){
    if(h==0 && w==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
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;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int n, ans;
    R n;
    rep(i, pow(10, 5)) {
        if (i * i > n){
            co(ans);
            break;
        }
        ans = i * i;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const string target = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 16; i++) {
        if (s[i] != target[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>
#define SIZE 80

double s[SIZE]; int sp=0;

int isNum(char ch){ return (ch>='0' && ch<='9'); }

int main(void){
     double t, t2; char buf[SIZE];
     
     while(~scanf("%s",buf)){

	  if(!strcmp(buf,"+")) t=s[--sp], t+=s[--sp];
	  else if(!strcmp(buf,"-")) t=-s[--sp], t+=s[--sp];
	  else if(!strcmp(buf,"*")) t=s[--sp], t*=s[--sp];
	  else if(!strcmp(buf,"/")) t=1/s[--sp], t*=s[--sp];
	  else t = atol(buf);
	  
	  s[sp++]=t;

	  if(getchar()=='\n') printf("%f\n",s[--sp]), sp=0;
     }

     return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const ld PI=abs(acos(-1));
int n;

ll gcd(ll a, ll b){
	if(b) return gcd(b,a%b);
	else return a;
}

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

int main(){
	cin >> n;
	
	ll pos=1,t;
	REP(i,0,n){
		cin >> t;
		pos=lcm(pos,t);
	}
	
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<vector<int>> dis;
vector<vector<char>> used;
queue<P> q1;

int main(){
	int n,m,p;
	int i,j,k;
	int a,b,c;
	int x,y;
	string sa;
	cin>>n>>m>>p;
	cin>>a>>b>>x>>y;
	a--,b--,x--,y--;
	dis.assign(n,vector<int>(m,INF));
	used.assign(n,vector<char>(m,0));
	for(i=0;i<n;i++){
		cin>>sa;
		for(j=0;j<m;j++){
			if(sa[j]=='@')dis[i][j]=-1;
		}
	}
	q1.push(make_pair(a,b));
	dis[a][b]=0;
	for(i=0;!q1.empty();i++){
		j=q1.size();
		while(j--){
			a=q1.front().first,b=q1.front().second,q1.pop();
			if(dis[a][b]!=i || used[a][b])continue;
			used[a][b]=true;
			for(k=a+1;k<n && k<=a+p;k++){
				if(dis[k][b]<=i)break;
				dis[k][b]=i+1;
				q1.push(make_pair(k,b));
			}
			for(k=a-1;k>=0 && k>=a-p;k--){
				if(dis[k][b]<=i)break;
				dis[k][b]=i+1;
				q1.push(make_pair(k,b));
			}
			
			for(k=b+1;k<m && k<=b+p;k++){
				if(dis[a][k]<=i)break;
				dis[a][k]=i+1;
				q1.push(make_pair(a,k));
			}
			for(k=b-1;k>=0 && k>=b-p;k--){
				if(dis[a][k]<=i)break;
				dis[a][k]=i+1;
				q1.push(make_pair(a,k));
			}
		}
	}
	if(dis[x][y]==INF)dis[x][y]=-1;
	cout<<dis[x][y]<<endl;
}


Measured memory_bytes: 11100
#include <stdio.h>

int main(void)
{
	int i=0,x=0;
	char sip[100];
	char sck[6] = {'a','i','u','e','o','\0'};
	scanf("%100s",sip);
	for(i;i <= 4;i++)
		{if(sip[0] != sck[i])
			{x++;}
		}
	if(x == 4)
	{
		printf("vowel\n");
	}
	else
	{
		printf("consonant\n");
	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())						# 5

ans=0
if N<=9:
	ans=N
	print(ans)
	exit(0)

if N==10 or N==100 or N==1000 or N==10000 or N==100000:
	ans=10
	print(ans)
	exit(0)


s = str(N)
for c in s:
	ans += int(c)


print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
//const int INF=1e9+5;
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>dp(3);
  for(int i=0;i<3;i++)
  {
      cin>>dp[i];
  }
  for(int day=1;day<n;day++)
  {
      vector<int>new_dp(3,0);
      vector<int>c(3);
      for(int i=0;i<3;i++)
      {
          cin>>c[i];
      }
      for(int i=0;i<3;i++)
      {
          for(int j=0;j<3;j++)
          {
              if(i!=j)
              {
                  new_dp[j]=max(new_dp[j],dp[i]+c[j]);
              }
          }
      }
       dp=new_dp;
  }
 int t=max(dp[0],dp[1]);
 cout<<max(dp[2],t);
  return 0;
}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	H, W, h, w := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	fmt.Println((H - h) * (W - w))
}


Measured memory_bytes: 640
f = True
while True:
	for k in range(3):
		p = list(input())
		if p[0] == '0':
			f = False
			break
		a, b = 0, 0
		del p[0]
		for x in p:
			if x == 'A': a += 1
			else: b += 1
		if a > b: a += 1
		else: b += 1
		print(a, b)
	if not f: break


Measured memory_bytes: 5556
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,n) for(int i=0;i<(n);++i)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

ll nPk_mod(ll n, ll k){
	ll ans = 1;
	for(ll i=0; i<k; ++i){
		ans = ans * (n-i) % MOD;
	}
	return ans;
}

int main(){
	ll N,M; cin>>N>>M;

	ll small = N, big = M;
	if(small>big) swap(small, big);

	if(small != big && small+1 != big){
		ote(0);
		return 0;
	}

	ll ans =  nPk_mod(big,big) * nPk_mod(small,small) % MOD;

	if(small==big){
		ans = ans * 2 % MOD;
	}
	ote(ans);

	// ote(nPk_mod(big,big));//
	// ote(nPk_mod(small,small));//

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll a,b; cin >> a >> b;
	ll p=0,q=0;
	if(a%2==1){
		p=a;
		a++;
	}
	if(b%2==0)
		q=b;
	else
		b++;
	ll r=((b-a)/2)%2;
	ll ans=p^q; ans^=r;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
    int N; 
    long long K;
    cin >> N >> K;
    vector<pair<long long, long long> > v(N);
    for (int i = 0; i < N; ++i) cin >> v[i].first >> v[i].second;

    // ソート
    sort(v.begin(), v.end());
    
    // a_i が小さい順に b_i を合計して K 以上になる瞬間をとらえる
    long long res = 0;
    long long sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += v[i].second;
        if (sum >= K) {
            res = v[i].first; // sum >= K になった瞬間の a_i
            break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
//#include<stdint-gcc.h>

using namespace std;

map<int,int> mp;

bool sortcol(const vector<int>& v1, const vector<int>& v2 )
{
    return v1[1] < v2[1];
}

int main()
{
    int test=1;
    //cin>>test;
    while(test--)
    {
        int n;
        cin>>n;
        double prob[n+1];
        prob[0]=0.0;
        for(int i=1;i<=n;++i)
            cin>>prob[i];
        double dp[n+1][n+1];
        memset(dp,0.0,sizeof(dp));
        dp[0][0]=1.0;
        for(int i=1;i<=n;++i)
        {
            for(int j=0;j<=i;++j)
            {
                if(j==0)
                    dp[i][j]=dp[i-1][j]*(1-prob[i]);
                else
                    dp[i][j]=(dp[i-1][j-1]*prob[i])+(dp[i-1][j]*(1-prob[i]));
            }
        }
        double ans=0.0;
        for(int i=n/2+1;i<=n;++i)
        {
            ans+=dp[n][i];
        }
        cout<<fixed<<setprecision(10)<<ans;

    }

    return 0;
}



Measured memory_bytes: 70528
str1= list(raw_input())
str2 = list(raw_input())
from collections import Counter
# import operator
resstr2 = Counter(str2)
resstr1 = Counter(str1)

# a = sorted(res.values())
res1 = Counter(resstr1.values())
res2 =  Counter(resstr2.values())
result = "Yes"
for k , i in res1.iteritems():
    if res2[k] != i:
        result = "No"
        break
print result

Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, cnt = 0, ans = 0;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n, 0LL);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<ll>());
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      ans += a[i];
      cnt++;
      if (cnt >= n - 1) {
        break;
      }
    } else {
      ans += a[i];
      cnt++;
      if (cnt >= n - 1) {
        break;
      }
      ans += a[i];
      cnt++;
      if (cnt >= n - 1) {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    ll a, b, n;
    cin >> a >> b >> n;

    ll x = min(b - 1, n);
    int ans = int(a * x / b) - a * int(x / b);
    // // 全探索
    // ll ans = 0;
    // for(ll x = 0; x <= n; ++x) {
    //     ll fst = a * x / b;
    //     ll scd = x / b;
    //     scd *= a;
    //     ll flr = fst - scd;
    //     ans = max(ans, flr);
    // }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a,b,c,tmp;
    cin >> a >> b >> c;
    if ( a > b ) {
    	tmp = a;
    	a = b;
    	b = tmp;
    } 
    if ( b > c ) {
    	tmp = b;
    	b = c; 
    	c = tmp;
    }
    if ( a > b ) {
    	tmp = a;
    	a = b;
    	b = tmp;
    }
    cout << a << " " << b << " " << c << endl;
	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if(A+B > C+D){
        cout << "Left" << endl;
    }
    else if(A+B == C+D){
        cout << "Balanced" << endl;
    }
    else {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 3592
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

MOD = 10**9 + 7

N = int(readline())
C = np.array([line.split() for line in readlines()],np.int8)

def rank(A):
    if (A==0).all():
        return 0
    i = np.nonzero(A[:,0])[0]
    if len(i) == 0:
        return rank(A[:,1:])
    i = i[0]
    temp = A[i].copy()
    A[i] = A[0]
    A[0] = temp
    A[1:] ^= A[1:,0][:,None] * A[0][None,:]
    return 1 + rank(A[1:,1:])

r = rank(C)

pow2 = np.ones(301,dtype=np.int64)
for n in range(1,301):
    pow2[n] = pow2[n-1]*2%MOD

# N次元空間から、M本のベクトルを選んで、D次元部分空間を生成する方法の個数
dp = np.zeros((301,301,301),dtype=np.int64)
dp[:,0,0] = 1
for M in range(1,301):
    dp[:,M,:M] += dp[:,M-1,:M] * pow2[:M] % MOD
    dp[:,M,1:M+1] += dp[:,M-1,0:M] * (pow2[:,None]-pow2[None,0:M]) % MOD
    dp[:,M,:] %= MOD

# C=ABのrankがrとなる方法の総数
x = 0
for n in range(r,N+1):
    x += dp[N,N,n] * dp[N,n,r] % MOD * pow(2,N*(N-n),MOD) % MOD
x %= MOD

answer = x * pow(int(dp[N,N,r]),MOD-2,MOD) % MOD
print(answer)



Measured memory_bytes: 228640
/*
[abc133] D - Rain Flows into Dams
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int A[MAX_N];
int ans[MAX_N];

void solve() {
    int s = 0;
    for (int i = 0; i < N; i++) {
        s += ((i & 1) ? -1 : 1) * A[i];
    }
    ans[0] = s;
    for (int i = 1; i < N; i++) {
        ans[i] = 2 * (A[i - 1] - ans[i - 1] / 2);
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    solve();
    for (int i = 0; i < N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  
  cout << (n == m ?"Yes" : "No") << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }

  int tmp;
  // 大きい順にソート
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      if(a[i]<a[j]){
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }

  int dif=0;
  for(int i=0;i<N;i++){
    if(i==N-1){
      dif += a[i];
    }
    else{
      dif += a[i] - a[i+1];
    }
    i += 1;
  }

  cout << dif << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x;
	scanf("%d",&x);
	while(x!=0){
		int at=0,bt=0;
		for(int i=1; i<=x; i++){
			int a=0,b=0;
			scanf("%d%d",&a,&b);
			if(a>b){
				at=at+a+b;
			}else if(a<b){
				bt=bt+a+b;
			}else{
				at+=a;
				bt+=b;
			}
		}
		printf("%d %d\n",at,bt);
		scanf("%d",&x);
	}
	return 0;
}

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

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


int main(int argc, char**argv){
    string s;
    cin >> s;
    int ans = 0;
    int len = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
            len++;
        }else{
            ans = max(len, ans);
            len = 0;
        }
    }
    ans = max(len, ans);
    cout << ans << endl;

    return 0;
}














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

int main(){
    int s, w;
    cin >> s >> w;
 
    if(w >= s) cout << "unsafe" << endl;
    else{cout << "safe" << endl;}
  
    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

int main(){
    int N;
    cin >> N;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    if((N-1)%2==0){
        for(int i=N-1;i>=0;i-=2){
            cout << a[i] << " ";
        }
        for(int i=1;i<N;i+=2){
            cout << a[i] << " ";
        }
    }
    else{
        for(int i=N-1;i>=0;i-=2){
            cout << a[i] << " ";
        }
        for(int i=0;i<N;i+=2){
            cout << a[i] << " "; 
        }
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 3712
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>

typedef long long ll;
using namespace std;

int main() {
    string s; cin >> s;
    bool f_m = false, l_m = false;

    int a, b;
    a = atoi(s.substr(0,2).c_str());
    b = atoi(s.substr(2,4).c_str());

    if (0 < a && a <= 12) f_m = true;

    if (0 < b && b <= 12) l_m = true;

    if (f_m && l_m) {
        cout << "AMBIGUOUS" << endl;
    } else if (f_m) {
        cout << "MMYY" << endl;
    }
    else if (l_m) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    vector<ll> as(N);
    for (auto && i: irange(0LL, N)){
        cin >> as.at(i);
    }
    ll count{0};
    unsigned int i = 1;
    while (i < N){
        if (as.at(i-1)==as.at(i)){
            count++;
            i += 2;
        } else {
            i++;
        }
    }
    cout << count;
    return 0;
}

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

int main() {
  
  long long N,P;
  cin >> N >> P;

  if(N == 1) {
    cout << P << endl;
    return 0;
  }

  long long ans = 1;
  for(int i = 2;i <= 1000000;i++) {
    int num = 0;
    if(P < i) break;
    while(P % i == 0) {
      P /= i;
      num++;
    }
    if(num>=N) ans *= pow(i,num/N);
  }

  cout << ans << endl;
}


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

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

  if (a + b > c + d ) {
    cout << "Left" << endl;
  }

  if (a + b < c + d) {
    cout << "Right" << endl;
  }
  if (a + b == c + d) {
   cout << "Balanced" << endl;
  } 
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

static const int MAX = 1e6+5;
// static const int NIL = -1;
// static const llint INF = 1<<21;
static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

llint fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void init_combination() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

llint combination(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

llint com(llint n, llint r) {
    llint ans = 1;
    if(r<0 || n<r) return 0;
    else {
        for(int i=0;i<r;r++) {
            ans *= n-i;
        }
        for(int i=0;i<r;r++) {
            ans /= (r-i);
        }
        return ans;
    }
}

llint modpow(llint a, llint b) {
    if(b==0) return 1LL;
    if(b%2==0) {
        llint t = modpow(a, b/2);
        return t * t %MOD;
    }   
    return a*modpow(a, b-1)%MOD;
}

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

    init_combination();
    llint ans, anstmp;
    ans = modpow(10LL, n) - modpow(8LL, n);
    if(ans<0) ans += MOD;

    for(llint in=1;in<=n;++in) {
        anstmp = combination(n, in);
        anstmp %= MOD;
        anstmp *= modpow(8LL, n-in);
        anstmp %= MOD;
        anstmp *= 2;
        anstmp %= MOD;
        ans -= anstmp;
        if(ans<0) ans += MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27020
def method():
  a, v = input().split()
  b, w = input().split()
  t = int(input())

  a = int(a) # Oni cordinate
  v = int(v) # Oni Speed
  b = int(b) # Nige Cordinate
  w = int(w) # Nige Speed

  if a < b:
    distance = b - a
    relative_speed = v - w
    if relative_speed <= 0:
      return 'NO'
    else:
      if (distance / relative_speed) > t:
        return 'NO'
      else:
        return 'YES'
  else: # b < a
    distance = a - b
    relative_speed = v - w
    if relative_speed <= 0:
      return 'NO'
    else:
      if (distance / relative_speed) > t:
        return 'NO'
      else:
        return 'YES'

print(method())


  

  



Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,g,b;
    cin>>r>>g>>b;
    int a=10*g+b;
    if(a%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a[12]={1,3,5,7,8,10,12,4,6,9,11,2};
    int x,y,stx,sty,i;
    scanf("%d %d",&x,&y);
    for(i=0;i<12;i++){
        if(x==a[i]){
            stx=i;
        }
        if(y==a[i]){
            sty=i;
        }
    }
    if((stx>=0)&&(stx<=6)&&(sty>=0)&&(sty<=6)){
        printf("Yes\n");
    }else if((stx>=7)&&(stx<=10)&&(sty>=7)&&(sty<=10)){
        printf("Yes\n");
    }else if((stx==11)&&(sty==11)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] nums = new int[n];
      for(int i = 0; i < n; i++)
        nums[i] = sc.nextInt();
      Arrays.sort(nums);
      
      int num = nums[n-1] / 2;
      int maxIdx = 0;
      for(int i = 0; i < n; i++) {
        int a = nums[i];
        if(nums[i] > num) {
          a = nums[n-1] - nums[i];
        }
        if(a > nums[maxIdx])
          maxIdx = i;
      }
      System.out.println(nums[n-1] + " " + nums[maxIdx]);
  }
}

Measured memory_bytes: 49136
def game(t, s)
  cnt = 0
  t == 0 ? r = s[0] : l = s[0]
  (1...s.size).each do |i|
    t == 1 ? r = s[i] : l = s[i]
    if r % 3 == 1 && l % 3 != 1 || r % 3 == 2 && l % 3 == 0
      r, l = l, r
      cnt += 1
    else
      t = 1 - t
    end
  end
  cnt
end
 
while s = gets.chomp
  break if s == '#'
  s = s.split('').map(&:to_i)
  p [game(0, s), game(1, s)].min
end

Measured memory_bytes: 15876
// W i B
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 1000000007
#define pb push_back
#define bit(x,p) ((x>>p) & 1)
#define ll long long
#define Task "CF"
using namespace std;

const int base = 100003;
const int maxn = 100005;

int n,m,ans = 0,par[maxn];
vector<int> ke[maxn];

void DFS(int u){
    for(auto v : ke[u]){
        if(par[v]) continue;
        par[v] = 1;
        DFS(v);
    }
}

void Solve(){
    cin >> n >> m;
    for(int i = 1;i <= m;++i){
        int u,v;
        cin >> u >> v;
        ke[u].pb(v);
        ke[v].pb(u);
    }
    for(int i = 1;i <= n;++i){
        if(!par[i]){
            ++ans;
            par[i] = 1;
            DFS(i);
        }
    }
    cout << ans - 1;
}
void NumTime(){
    cerr << "Toi" << "\n";cerr << "Di" << "\n";cerr << "Chep" << "\n";cerr << "Code" << "\n";
}


int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
	if(fopen(Task".inp","r")){
		freopen(Task".inp","r",stdin);
		freopen(Task".out","w",stdout);
	}
    int test = 1;
//    cin >> test;
    while(test --){
        NumTime();
        Solve();
    }
}
 // V T An


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

#ifndef MAX
#define MAX 800000
#endif

//Range Update Query+Range Minimum Query
template<class T>
class RUQ_RMQ {
public:
	int n;
	T dat[MAX], lazy[MAX], DEFAULT;
	bool(*cmp)(T, T);
	void init(int n_,
		bool(*c)(T, T) = [](int a, int b) {return a < b; }, T d = INT_MAX) {
		cmp = c;
		DEFAULT = d;
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = DEFAULT;
		}
	}
	inline void push(int k) {
		if (lazy[k] == DEFAULT)return;
		dat[k] = lazy[k];
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}
		lazy[k] = DEFAULT;
	}
	inline void update_node(int k) {
		if (cmp(dat[k * 2 + 1], dat[k * 2 + 2]))dat[k] = dat[k * 2 + 1];
		else dat[k] = dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		if (cmp(lb, rb))return lb;
		return rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};

int bit[300000];
void add(int k,int x){
	k++;
	while(k<300000){
		bit[k]+=x;
		k+=k&-k;
	}
}
int sum(int k){
	k++;
	int ans=0;
	while(k){
		ans+=bit[k];
		k-=k&-k;
	}
	return ans;
}
RUQ_RMQ<P>tree;
int main(){
	string s;int k;cin>>s>>k;
	rep(i,s.size()-1)add(i+1,1);
	tree.init(s.size(),[](P a,P b){return a<b;},P(INT_MAX,INT_MAX));
	rep(i,s.size())tree.update(i,P(s[i],i));
	string ans;
	int a=k;
	rep(i,s.size()){
		int l=1,r=s.size();
		while(l!=r){
			int t=(l+r)/2;
			if(r-l==1)t=r;
			if(sum(t-1)<=k)l=t;
			else r=t-1;
		}
		P p=tree.query(0,l);
		ans+=p.first;
		k-=sum(p.second);
		a+=sum(p.second);
		add(p.second+1,-1);
		tree.update(p.second,P(INT_MAX,i));
		P pp=tree.query(p.second);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16812
import java.util.*;

public class Main {
  public static long MOD = (long)Math.pow(10, 9) + 7;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    long[] dp = new long[(int)k + 1];
    for(long i = k; i >= 1; i--) {
      long t = k / i;
      long s = func(t, n);
      long u = 0;
      for(long j = (2 * i); j <= k; j += i) {
        u = (u + dp[(int)j]) % MOD;
      }
      dp[(int)i] = (s + MOD - u) % MOD; 
    }
    long ans = 0;
    for(long i = 1; i <= k; i++) {
      long t = (i * dp[(int)i]) % MOD;
      ans = (ans + t) % MOD;
    }
    System.out.println(ans);
  }

  public static long func(long a, long x) {
    if(x == 0) return 1;
    if((x % 2) == 0) {
      long t = func(a, x / 2);
      return (t * t) % MOD;
    } else {
      return (a * func(a, x - 1)) % MOD;
    }
  }
}

Measured memory_bytes: 37188
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    cnt = 0
    tmp = 0
    for i in range(len(b)):
        if a[i] - b[i] >= 0:
            cnt += b[i]
            a[i] -= b[i]
        else:
            tmp = b[i]-a[i]
            cnt += a[i]
            a[i] = 0
            if a[i+1] -tmp >= 0:
                cnt += tmp
                a[i+1] -= tmp
            else:
                cnt += a[i+1]
                a[i+1] = 0
    print(cnt)

if __name__ == '__main__':
    main()


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

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


int main() {
  string s;
  cin >> s;
  int count = 0;
  rep (i, 3) {
    if (s.at(i) == '1') {
      count++;
    }
  }
  cout << count << endl;
  
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	cout<<int(a>=b)*10<<"\n";
	return 0;
}















Measured memory_bytes: 256
using System;

namespace ABC141A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s == "Sunny")
                Console.WriteLine("Cloudy");
            else if (s == "Cloudy")
                Console.WriteLine("Rainy");
            else if (s == "Rainy")
                Console.WriteLine("Sunny");
            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
public class Main {

public static void main(String[] args)
{
  Scanner sc=new Scanner(System.in);
  fact=new long[100002];
  fact[0]=1;
  for(int i=1;i<100002;i++) {
    fact[i]=(1l*fact[i-1]%mod*i%mod+mod)%mod;
  }
 int n=sc.nextInt();
 int m=sc.nextInt();
 if(Math.abs(n-m)>=2) {
   System.out.println(0);
 }
 else {
 if((n%2==0&&m%2==0)||(n%2!=0&&m%2!=0))
 System.out.println((fact[n]%mod*fact[m]%mod*2l%mod+mod)%mod);
 else
   System.out.println((fact[n]%mod*fact[m]%mod+mod)%mod);
 }
}


   
static long modInverse(long fac, int p) 
{ 
    return pow(fac, p - 2); 
} 


static long nCr(int n, int r, 
                         int p) 
{ 

  
    if (r == 0) 
        return 1; 


    long [] fac = new long [n + 1]; 
    fac[0] = 1; 

    for (int i = 1; i <= n; i++) 
        fac[i] = fac[i - 1] * i % p; 

    return (fac[n] * modInverse(fac[r], p) 
            % p * modInverse(fac[n - r], p) 
            % p) 
        % p; 
} 


public static long[] fact;
public static long[] invfact;
public static long ncr(int n, int r){
  if(r > n) return 0;
  return ((((fact[n]) * (invfact[r])) % mod)* invfact[n-r]) % mod;
}
static int mod=(int)1e9+7;
static long pow(long x,long y) {
 long res=1l;
 while(y!=0) {
   if(y%2==1) {
     res=x*res%mod;
   }
   y/=2;
   x=x*x%mod;
 }
 return res;
}


}
 








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

using namespace std;


const int BITS = 64;
long long N, K;
vector<bool> k(BITS);
vector<int> cnt(BITS);
vector<long long> pw(BITS);

vector<bool> get_bits(long long x)
{
    vector<bool> v(BITS);
    for (int i = 0; i < BITS && x; ++i) {
        if (x & 1) v[i] = 1;
        x /= 2;
    }
    reverse(v.begin(), v.end());
    return v;
}

void solve()
{
    bool match = true;
    long long ans = 0;
    for (int i = 0; i < BITS; ++i) {
        if ((N-cnt[i]) <= cnt[i]) {
            // put 0
            ans += pw[i] * cnt[i];
            if (k[i]) match = false;
        } else {
            // put 1
            if (!match || k[i])
                ans += pw[i] * (N-cnt[i]);
            else
                ans += pw[i] * cnt[i];
        }
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    pw[BITS-1] = 1;
    for (int i = BITS-2; i; --i) {
        pw[i] = 2ll * pw[i+1];
    }

    cin >> N >> K;
    k = get_bits(K);

    long long a;
    for(int i = 0 ; i < N ; i++){
        cin >> a;
        vector<bool> bits = get_bits(a);
        for (int i = 0; i < BITS; ++i) {
            cnt[i] += bits[i];
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 384
s = list(input())
n = len(s)
ans = 0

for i in range(2**(n-1)):
    subset = [0]*(n-1)
    s_temp = s[0]
    for j in range(n-1):
        if i>>j & 1:
            s_temp += "+"+s[j+1]
        else:
            s_temp += s[j+1]
    ans += eval(s_temp)


print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
 
using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);
 
 
int main(){
  FAST_IO  
  
  int h, w, d; cin >> h >> w >> d;

  pair<int, int> pts[90001];
  int prefS[90001];

  memset(prefS, 0, sizeof prefS);
  for(int row = 1; row <= h; ++row){
    for(int col = 1; col <= w; ++col){
      int x; cin >> x;
      pts[x] = MP(row, col);
    }
  }

  for(int start = d + 1; start <= h * w; ++start){
    prefS[start] = prefS[start - d] + abs(pts[start - d].F - pts[start].F)
                 + abs(pts[start - d].S - pts[start].S);
  }

  int Q; cin >> Q;
  while(Q--){
    int left, right; cin >> left >> right;
    cout << prefS[right] - prefS[left] << "\n";
  }

  return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>

using namespace std;
int x, y, z;
int main() {
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (x, y, z) = readLine()!!.split(" ").map(String::toInt)
    var count = 1
    while (true) {
        if (x < ((y + z) * count + z)) {
            println(count - 1)
            return
        } else {
            count++
        }
    }
}

Measured memory_bytes: 37920
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;


int main()
{
    ll n;
    cin >> n;
    set<char> s;
    rep(i,n){
        char x;
        cin >> x;
        s.insert(x);
    }
    if(s.size()==3) cout << "Three" <<endl;
    else cout << "Four" << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define rep(i, xtz, n) for(int i=xtz; i<n; i++)
#define repx(i, xtz, n) for(int i=xtz; i>n; i--)
#define lli long long int

using namespace std;

vector<vector<bool>> dp(1e5+1, vector<bool>(2));
vector<vector<bool>> check(1e5+1, vector<bool>(2, false));
vector<int> moves;

bool game(int k, int t){
    //cout<<moves.size()<<" "<<k<<" "<<t<<"\n";
    if(check[k][t]) return dp[k][t];
    if(t==0){
        rep(i, 0, moves.size()){
            if(k-moves[i]>=0){
                if(game(k-moves[i], 1)){dp[k][t]=true; check[k][t]=true; return true;}
            }
        }
        dp[k][t] = false; check[k][t]=true; return false;
    }
    else if(t==1){
        rep(i, 0, moves.size()){
            if(k-moves[i]>=0){
                if(!game(k-moves[i], 0)){dp[k][t]=false; check[k][t]=true; return false;}
            }
        }
        dp[k][t] = true; check[k][t]=true; return true;
    }
}

int main(){
    //freopen("i.in", "r", stdin);
    int n, k;
    cin>>n>>k;
    int tmp;
    rep(i, 0, n) {cin>>tmp; moves.push_back(tmp);}
    rep(i, 0, moves[0]){
        dp[i][0] = false;
        dp[i][1] = true;
        check[i][0] = true;
        check[i][1] = true;
    }
    (game(k, 0))?(cout<<"First"):(cout<<"Second");

}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl;
#define _GLIBCXX_DEBUG

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

  vector<vector<char>> img(n, vector<char>(n));
  vector<vector<char>> t(m, vector<char>(m));

  rep(i, n){
    rep(j, n){
      cin >> img[i][j];
    }
  }
  rep(i, m){
    rep(j, m){
      cin >> t[i][j];
    }
  }

  rep(i, n-m+1){
    rep(j, n-m+1){
      bool f = true;
      rep(k, m){
        rep(l, m){
          if(img[i+k][j+l] != t[k][l]){
            f = false;
            break;
          }
        }
        if(!f) break;
      }
      if(f){
        COUT("Yes");
        return 0;
      }
    }
  }

  COUT("No");

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int n, m;
    cin >> n >> m;
    int x[m];
    rep(i, m) cin >> x[i];

    if(n >= m){
        p(0);
        return 0;
    }

    sort(x, x + m);

    vector<int> vi(m - 1);
    for(int i = 1; i < m; i++){
        int num = abs(x[i] - x[i - 1]);
        vi[i - 1] = num;
    }

    sort(vi.begin(), vi.end());

    int ans = 0;
    for(int i = 0; i < (m - 1) - (n - 1); i++){
        ans += vi[i];
    }

    p(ans);
}


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


int main(){
  int N,X;
  cin>>N>>X;
  vector<int>m(N);
  int total=0;
  for(int i=0;i<N;i++){
    cin>>m.at(i);
    total+=m.at(i);
  }
  sort(m.begin(),m.end());
  int ans=N+(X-total)/m.at(0);

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int N;
string S;
vector<int> s_to_e;
vector<int> s_to_w;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  cin >> S;
  s_to_e.resize(N+1);
  s_to_w.resize(N+1);
  s_to_e[0] = 0;
  s_to_w[0] = 0;
  rep(i,N){
    if(S[i] == 'E'){
      s_to_e[i+1] = s_to_e[i] + 1;
      s_to_w[i+1] = s_to_w[i];
    }
    else{
      s_to_w[i+1] = s_to_w[i] + 1;
      s_to_e[i+1] = s_to_e[i];
    }
  }
  // s0 = 0
  // s1 = a1
  // s2 = a1 + a2
  // s3 = a1 + a2 + a3
  int ret = INF;
  for(int i = 0 ; i < N ; i++){
    //traverse thru leaders
    int cand = 0;
    cand = s_to_w[i] + s_to_e[N] - s_to_e[i+1];
    ret = min(ret,cand);
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3068
#include <stdio.h>

int main(void)
{
  int c, cf = 0, i, j;
  char s[101];

  scanf("%s%n", s, &c);

  for (i = 0; i < c; i++) {
    if (s[i] == 'C') {
      for (j = i; j < c; j++) {
        if (s[j] == 'F') {
          cf = 1;
          break;
        }
      }
    }
    if (cf) {
      break;
    }
  }

  if (cf) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


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

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

  int st[50][2];
  int cp[50][2];
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    st[i][0]=a;
    st[i][1]=b;
  }

  for(int i=0;i<m;i++){
    int c,d;
    cin>>c>>d;
    cp[i][0]=c;
    cp[i][1]=d;
  }

  for(int i=0;i<n;i++){
    int mind=3e8;
    int ans=0;
    for(int j=0;j<m;j++){
      int d=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1]);
      if(mind>d){
        mind=d;
        ans=j+1;
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <cstring>
 
using Pair = std::pair<int, int>;
 
int w, h;
Pair ch;
 
std::vector<int> px[10], py[10];
int map[11][11];
std::vector<Pair> houses;
unsigned int mask;
 
int dfs(int y, int x, unsigned int used) {
    used |= 1u << map[y][x];
     
    if((used & mask) == mask) {
        if(ch.first == y) {
            return 1;
        }else if(ch.second == x) {
            return 1;
        }else
            return 0;
    }
     
    int ans = 0;
    auto pxit = std::lower_bound(px[x].begin(), px[x].end(), y);
    auto pyit = std::lower_bound(py[y].begin(), py[y].end(), x);
     
    if(pxit != px[x].begin()) {
        auto it = pxit - 1;
        while(1) {
            if(!(used & (1 << map[*it][x]))) {
                ans += dfs(*it, x, used);
                break;
            }

            if(it == px[x].begin())
                break;
             
            --it;
        }
    }
     
    {
        auto it = pxit;
        
        if(pxit != px[x].end()) {
            if(*it == y)
                ++it;
            
            for(; it != px[x].end(); ++it) {
                if(!(used & (1 << map[*it][x]))) {
                    ans += dfs(*it, x, used);
                    break;
                }
            }
        }
    }
     
    if(pyit != py[y].begin()) {
        auto it = pyit - 1;
        while(1) {
            if(!(used & (1 << map[y][*it]))) {
                ans += dfs(y, *it, used);                
                break;
            }

            if(it == py[y].begin())
                break;
             
            --it;
        }
    }
    
    {
        auto it = pyit;
        
        if(pyit != py[y].end()) {
            if(*it == x)
                ++it;

            for(; it != py[y].end(); ++it) {
                if(!(used & (1 << map[y][*it]))) {
                    ans += dfs(y, *it, used);
                    break;
                }
            }
        }
    }
     
    return ans;
}
 
int main() {
    while(std::cin >> w >> h, w + h) {
    houses.clear();
    for(auto&& v : px)
        v.clear();
    for(auto&& v : py)
        v.clear();
     
    memset(map, -1, sizeof(map));
     

    int in;
    
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            std::cin >> in;
             
            if(in == 1) {
                px[j].push_back(i);
                py[i].push_back(j);
                map[i][j] = houses.size();
                houses.push_back({i, j});
            }else if(in == 2) {
                ch = {i, j};
            }
        }
    }
     
    for(int i = 0; i < houses.size(); ++i) {
        mask |= 1 << i;
    }
     
    std::cout << dfs(ch.first, ch.second, 0) << std::endl;
    }
}

Measured memory_bytes: 3132