akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll t; cin >> t;
	while(t--){
		string s,t; cin >> s >> t;
		ll m = t.size();
		for(ll i=s.size()-1; i>=0; i--){
			string tmp;
			if(s[i]=='J'){
				tmp.push_back(t[m-1]);
				tmp += t.substr(0,m-1);
			}
			if(s[i]=='C'){
				tmp = t.substr(1);
				tmp.push_back(t[0]);
			}
			if(s[i]=='E'){
				tmp = t.substr((m+1)/2,m);
				if(m & 1) tmp.push_back(t[m/2]);
				tmp += t.substr(0,m/2);
			}
			if(s[i]=='A'){
				tmp = t;
				reverse(all(tmp));
			}
			if(s[i]=='P'){
				tmp = t;
				rep(j,m){
					if(tmp[j]=='0') tmp[j] = '9';
					else if('1'<=tmp[j] && tmp[j]<='9') tmp[j]--; 
				}
			}
			if(s[i]=='M'){
				tmp = t;
				rep(j,m){
					if(tmp[j]=='9') tmp[j] = '0';
					else if('0'<=tmp[j] && tmp[j]<'9') tmp[j]++;
				}
			}
			t = tmp;
		}
		cout << t << endl;
	}
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

  double w, h, x, y;
  cin >> w >> h >> x >> y;
  ld ans1 = (w * h) / 2;
  string ans2 = " ";
  if (x + x == w && y + y == h)
    ans2 += "1";
  else
    ans2 += "0";
  cout << fixed << setprecision(12) << ans1 << ans2 << endl;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = new int[n];
        for (int i = 0; i < n; i++) {
            ary[i] = int.Parse(input.ReadLine());
        }

        Array.Sort(ary);

        long sum = ary.Sum();

        if(sum % 10 == 0) {
            foreach(var x in ary) {
                if(x %10 != 0) return sum-x;
            }
            return 0;
        }

        return sum;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT

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


Measured memory_bytes: 3600
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
#define mod 1000000007
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	string A,B;
	cin>>A>>B;
	vector<int>a(26,-1);
	vector<int>b(26,-1);
	REP(i,A.size()){
		int aa=A[i]-97;
		int bb=B[i]-97;
	
		if(a[aa]!=-1 || b[bb]!=-1){
			if(a[aa]!=bb || b[bb]!=aa){
				cout<<"No"<<endl;
				return 0;
			}
		}
		a[aa]=bb;
		b[bb]=aa;
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 916
#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 is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

ll n;

template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}

ll f(ll a,ll b){
  string s=to_string(a);
  string t=to_string(b);
  //cout<<s<<' '<<t<<'\n';
  return max(len(s),len(t));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    vector<ll> div=divisor(n);
    sort(begin(div),end(div));
    //cout_vec(div);
    ll i=div[len(div)/2];
    ll j=n/i;
    cout<<f(i,j)<<endl;
}

Measured memory_bytes: 256
public class Main {
    public static void main(String[] args) {
        java.util.Scanner c=new java.util.Scanner(System.in);
        String s=c.next(),t=c.next();
        java.util.regex.Matcher matcher=java.util.regex.Pattern.compile("(.*)"+t.replaceAll(".","[$0?]")+"(.*?)").matcher(s);
        System.out.println(matcher.matches()?matcher.replaceFirst("$1"+t+"$2").replace('?','a'):"UNRESTORABLE");
    }
}

Measured memory_bytes: 23124
from scipy.misc import comb
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

#print(C)
ans = 0
for k,v in C.items():
  ans += v * (v-1) // 2
  
for a in A:
  cnt = C[a]
  if cnt > 0:
    print(ans - cnt*(cnt-1)//2 + (cnt-1)*(cnt-2)//2)
  else:
    print(ans)

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

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

	vector<int> a(n * 2);
	for (int i = 0; i < n * 2; i++) cin >> a[i];

	sort(a.rbegin(), a.rend());

	int ans = 0;
	for (int i = 0; i < n * 2; i += 2) {
		ans += a[i + 1];
	}
	cout << ans << endl;
}

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

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int a[M],pre[M];
inline int rsum(int l,int r)
{
    return (pre[r]-pre[l-1]);
}
inline int maxi(int a,int b,int c,int d)
{
    return max(max(a,b),max(c,d));
}
inline int mini(int a,int b,int c,int d)
{
    return min(min(a,b),min(c,d));
}
 main()

{
    fast
    int n,sum=0;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
        pre[i]=sum;
    }
    int l=1,r=3,ses=inf;
    f(i,2,n)
    {
        while(l+2<=i && abs(rsum(1,l)-rsum(l+1,i)) > abs(rsum(1,l+1)-rsum(l+2,i)))l++;
        while(r+2<=n && abs(rsum(i+1,r)-rsum(r+1,n)) > abs(rsum(i+1,r+1)-rsum(r+2,n)))r++;
        int a=rsum(1,l),b=rsum(l+1,i),c=rsum(i+1,r),d=rsum(r+1,n);
        ses=min(ses,maxi(a,b,c,d)-mini(a,b,c,d));
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 6748
#include<bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 3e5 + 233;
map <int, int> mp;
int n, ans = 0;
int a[N];
main(void) {
  read(n);
  for (int i = 1; i <= n; i ++) {
    read(a[i]); if (i & 1) mp[a[i]] = 1;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i ++) {
    if (i & 1) {
      if (!mp.count(a[i]))
        ++ ans;
    } else
      if (mp.count(a[i]))
        ++ ans;
  }
  cout << (ans + 1) / 2;
}


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

int main() {
  int64_t N;
  cin >> N;
  int64_t ans = 1;
  vector<int64_t> A(N);
  bool flag = true;
  for(int64_t i = 0;i < N;i++){
    cin >> A.at(i);
    if(A.at(i) == 0) {
      flag = false;
      break;
    }
  }
  if(flag && ans >= 0){
    for(int64_t i = 0;i < N; i++) {
    ans *= A.at(i);
      if(ans > 1000000000000000000 || ans <= 0){
      ans = -1;
      break;
      }
    }
  cout << ans << endl;
  }
  else if(flag == false){
    cout << 0 << endl;
  }
//  cout << pow(10,18) << endl;
}
    




Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

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

	int n = s.size();
	vector<bool> f( n );
	
	rep(i,0,n){
		if( s[i] == '0' ) f[i] = 0;
		else f[i] = 1;
	}

	int ans1 = 0 , ans2 = 0;
	rep(i,0,n){
		if(f[i] && i%2 ) ans1++;
		if(f[i] && !(i%2) ) ans2++;
		if(!f[i] && !(i%2) ) ans1++;
		if(!f[i] && i%2 ) ans2++;
	}

	cout << min(ans1 , ans2 ) << endl;

	ret 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  int a = 0;
  for(int i = 1; 100 >= i; i++){
    bool nw = false;
    for(int j = 0; n > j; j++){
      if(!nw && A[j]>=i){
        nw = true;
        a++;
      }else if(nw && A[j] < i){
        nw = false;
      }
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int k, resp;

int mdc(int a, int b){
	return (b == 0)? a: mdc(b, a%b);
}

int main(){
	cin >> k;
	resp = 0;
	
	for(int i = 1; i <= k; i ++){
		for(int j = 1; j <= k; j ++){
			for(int w = 1; w <= k; w ++){
				resp += mdc(mdc(i, j), w);
		
			}
		}
	}
	cout << resp;
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


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

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------



int main(){
  int K;
  cin >> K;
  cout<<K*K/4<<endl;
  return 0;
}




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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Apr  5 11:25:59 2017

@author: syaga
"""
import math


def getMan(x, y):
    man = math.fabs(x[0]-y[0])+math.fabs(x[1]-y[1])
    return man

if __name__ == "__main__":
    student = []
    check = []
    answer = []
    N, M = list(map(int, input().split()))
    for i in range(N):
        student.append(list(map(int, input().split())))
    for i in range(M):
        check.append(list(map(int, input().split())))
    for i in student:
        min_tmp = 1000000000000000000
        min_index = 0
        for j in check:
            man = getMan(i, j)
            if min_tmp > man:
                min_tmp = man
                min_index = check.index(j)+1
        answer.append(min_index)
    for i in answer:
        print(i)


Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	switch {
	case n < 1000:
		fmt.Println("ABC")
	default:
		fmt.Println("ABD")
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#define REP(i,n,m) for(i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

struct Team{
	char name[2];
	int win,lose;
	int id;
}t[10];

int main(void){
	int i,j;
	int n,r;

	while(scanf("%d",&n) && n){
		rep(i,n){
			t[i].win = t[i].lose = 0;
			t[i].id = i;

			scanf("%s",t[i].name);
			rep(j,n-1){
				scanf("%d",&r);
				if(r == 0) t[i].win++;
				else if(r == 1) t[i].lose++;
			}
		}

		rep(i,n-1)REP(j,i+1,n){
			if(t[i].win < t[j].win || t[i].win == t[j].win && (t[i].lose > t[j].lose || t[i].lose == t[j].lose && t[i].id > t[j].id)){
				struct Team tmp = t[i];
				t[i] = t[j];
				t[j] = tmp;
			}
		}

		rep(i,n){
			printf("%s\n",t[i].name);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n > 2 && m > 2) {
        ans = (n - 2) * (m - 2);
    }
    else if (n == 2 || m == 2) {
        ans = 0;
    }
    else if (n == 1 && m == 1) {
        ans = 1;
    }
    else if (n == 1) {
        ans = m - 2;
    }
    else {
        ans = n - 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int R,G,B,N;
cin>>R>>G>>B>>N;
int ans=0;
for(int i=0;i<=N/R;i++){
  for(int j=0;j<=(N-i*R)/G;j++){
    if((N-i*R-j*G)%B==0){
      ans+=1;
    }
  }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  ll n,k;
  cin>>n>>k;

  if(k==0){
    cout << n*n << endl;
    return 0;
  }

  ll ans=0;
  for(ll i=k+1;i<=n;i++){
    ans+=((n-k)/i+1)*(i-k);
    ans-=max((((n-k)/i)*i+i-1-n),0ll);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<int>a(n);
    rep(i, n)   cin >> a[i];
    sort(a.begin(), a.end());
    bool flag = true;
    rep(i, n-1){
        if(a[i] == a[i+1])  flag = false;
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 1024
<?php
    $input_line1 = intval(trim(fgets(STDIN)));
    $input_line2 = trim(fgets(STDIN));
    
    $nums = array_map('intval', explode(' ', $input_line2));
    
    sort($nums);
    echo $nums[0];
    echo " ";
    echo $nums[$input_line1-1];
    echo " ";
    echo array_sum($nums);
    echo "\n";
?>


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

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a;
    cin>>a;
    n-=a;
  }
  if(n<0){
    cout<<-1<<endl;
    return 0;
  }
  cout<<n<<endl;
}

Measured memory_bytes: 3636
n = gets.to_i
s = gets.chomp.split('')
black_num_list = s.inject([0]){|list,str| list << list[-1] + (str == '#' ? 1 : 0)}
min = n - black_num_list[-1]
(1..n).each do |i|
 tmp_min = black_num_list[i] + n - i - black_num_list[-1] + black_num_list[i]
 min = tmp_min if tmp_min < min
end
puts min

Measured memory_bytes: 18428
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	
	int[] score=new int[20];
	int a=0;
	
	while(true){
    int n=sc.nextInt();
    if(n==0) break;
    int[] s=new int[n];
    int sum=0;
    
    for(int i=0;i<n;i++){
    	s[i]=sc.nextInt();
    }
    
    for(int i=0;i<n;i++){
    	for(int j=i+1;j<n;j++){
    	int temp=0;
    		if(s[i]>=s[j]){	//?°??????????
    			temp=s[i];
    			s[i]=s[j];
    			s[j]=temp;
    		}
    	}	
    }
    
    for(int i=1;i<n-1;i++){
    	sum +=s[i];
    }
    int ave=sum/(n-2);
    score[a]=ave;
    a++;
    
	}
	
	for(int i=0;i<a;i++){
	 System.out.printf("%d\n",score[i]);
	}
}
}

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

int main(void){
    int n;
    cin >> n;
    int r[n];
    for(int i = 0; i < n; i++) cin >> r[i];
    int mn = r[0], mx = -1000000001;
    for(int i = 1; i < n; i++){
        mx = max(mx, r[i] - mn);
        mn = min(mn, r[i]);
    }
    cout << mx << endl;
    return 0;
}


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

int t,Max,ng;
string num;
vector<int> ans,s;

void dfs(vector<int> v,int k){
    if (k==num.size()){
        int sum=accumulate(v.begin(),v.end(),0);
        if (t<sum) return;
        else if (Max<sum){
            Max=sum,ng=0;
            ans=v;
        } else if (Max==sum) ng=1;
        return;
    }
    if (!v.empty()){
        v.back()=v.back()*10+(num[k]-'0');
        dfs(v,k+1);
        v.back()/=10;
    }
    v.emplace_back(num[k]-'0');
    dfs(v,k+1);
}

void solve(){
    ans.clear();
    Max=0; ng=0;
    dfs(s,0);
    if (!Max) cout << "error" << '\n';
    else if (ng) cout << "rejected" << '\n';
    else {
        cout << Max;
        for (int x:ans) cout << ' ' << x;
        cout << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> t >> num,t){
        solve();
    }
}


Measured memory_bytes: 3124
import queue
K = int(input())
q = queue.Queue()
for i in range (1,10):
  q.put(i)
for j in range(K):
  x = q.get()
  r = x % 10
  if r != 0:
    q.put(10 * x + r - 1)
  q.put(10 * x + r)
  if r != 9:
    q.put(10 * x + r + 1)
print(x)

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

M = 0
box_dict = {}
for i in reversed(range(N)):
    idx = i + 1
    multi_sum = 0
    if N // idx < 2:
        if a_list[i] == 0:
            box_dict[idx] = 0
        else:
            box_dict[idx] = 1
            M += 1
    else:
        for j in range(2, (N // idx) + 1):
            multi_sum += box_dict[idx * j]
        if a_list[i] - (multi_sum % 2) == 0:
            box_dict[idx] = 0
        else:
            box_dict[idx] = 1
            M += 1

print(M)
if M > 0:
    b_list = [key for key, value in box_dict.items() if value == 1]
    print(" ".join(map(str, b_list)))

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

int main(){
  double a,b,x,theta;
  cin >> a >> b >> x;
  x /= a;
  if (x <= a*b/2) {
    theta = 90- atan(x*2/b/b)*180/3.1415926538;
    }
  else{
    x = a*b-x;
    theta = atan(x*2/a/a)*180/3.14159265358;
    }
  cout << setprecision(10) << theta << endl;
  }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;
static const int INF = 9999999;
struct SEdge
{
	int To;
	int Cost;
};
int V, E;
vector<int> mincost;
vector< vector<SEdge> > Edge;
bool used[128];

int Prim()
{
	fill(used, used + V, false);
	fill(mincost.begin(), mincost.end(), INF);
	mincost[0] = 0;
	priority_queue<P, vector<P>, greater<P> > PQue;
	PQue.push(P(0, 0));
	int res = 0;
	while(!PQue.empty())
	{
		P p = PQue.top();
		PQue.pop();
		int v = p.second;
		if(mincost[v] < p.first || used[v])
		{
			continue;
		}
		used[v] = true;
		res += mincost[v];
		for(int i = 0; i < Edge[v].size(); ++i)
		{
			SEdge e = Edge[v][i];
			if(mincost[e.To] > e.Cost)
			{
				mincost[e.To] = e.Cost;
				PQue.push(P(mincost[e.To], e.To));
			}
		}
	}
	return(res);
}

void solve()
{
	while(cin >> V >> E, V || E)
	{
		mincost.clear();
		mincost.resize(V);
		for(int i = 0; i < Edge.size(); ++i)
		{
			Edge[i].clear();
		}
		Edge.clear();
		Edge.resize(V);
		for(int i = 0; i < E; ++i)
		{
			int From, To, Cost;
			cin >> From >> To >> Cost;
			SEdge e1, e2;
			e1.To = To;
			e2.To = From;
			e1.Cost = e2.Cost = Cost;
			Edge[From].push_back(e1);
			Edge[To].push_back(e2);
		}
		cout << Prim() << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define TRUE 1
#define FALSE 0
#define INFTY 2000000000
typedef struct{
  char name;
  int num;
}CARD;
void quick(CARD *,int,int);
int func(CARD *,int,int);
void swap(CARD *,CARD *);
int stable(CARD *,CARD *);
void merge(CARD*,int,int);
void func2(CARD*,int,int,int);

int n;
int main(){
  int i,j,k,left,right;
  CARD a[100000],b[100000];
  char str[2];


 
 
  
  scanf("%d",&n);

  left=0;
  right=n;
  
  for(i=0;i<n*2;i++){
    scanf("%s",str);
    if(i%2!=0){a[i/2].num=b[i/2].num=atoi(str);}
    else a[i/2].name=b[i/2].name=str[0];
  
  }
  merge(b,left,right);
  quick(a,0,n-1);

  if(stable(a,b))printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n",a[i].name,a[i].num);
  }
  
  return 0;
}
void quick(CARD a[],int p,int r){
  int q;
  if(p<r){
    q=func(a,p,r);
    quick(a,p,q-1);
    quick(a,q+1,r);
  }
  return;
}
    
int func(CARD a[],int p,int r){
  int x,i,j,base;
  CARD temp;
  x=a[r].num;
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(a[j].num<=x){
      i=i+1;
      swap(&a[i],&a[j]);
    }
  }
  swap(&a[i+1],&a[r]);
  base=i+1;
  return base;
}
int stable(CARD a[],CARD b[]){
  int i;
  for(i=0;i<n;i++){
    if(a[i].num==b[i].num && a[i].name!=b[i].name) return FALSE;
  }
  return TRUE;
}
void swap(CARD *c1,CARD *c2){
  CARD temp;
   temp =*c1;
    *c1=*c2;
    *c2=temp;
}
void merge(CARD a[],int left, int right){
  int mid;
  if((left+1)<right){
    mid=(left+right)/2;
    merge(a,left,mid);
    merge(a,mid,right);
   func2(a,left,mid,right);
  }
}
void func2(CARD a[],int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid-left;
  n2 = right-mid;
  CARD l[n1+1],r[n2+1];
  for(i=0;i<n2;i++){
    r[i]=a[mid+i];
    
  }
  for(i=0;i<n1;i++){
    l[i]=a[left+i];
  }
  l[n1].num=r[n2].num=INFTY;
  i=j=0;
  for(k=left;k<right;k++){
   
    if(l[i].num<=r[j].num){
      a[k]=l[i];
      i++;
    
      
    }
    else{
      a[k]=r[j];
      j++;
   
    }
  }
return;
}


  



Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    string a,b;
    cin>>a>>b;
    bool flag=true;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]!=b[i])
        {
            flag=false;
            break;
        }
    }
    if(flag==true)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s; cin >> s;
	FOR(i, 0, SZ(s)) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
	

	return 0;
}


Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    double n,t,a,h;
    cin>>n>>t>>a;
    double mini=mod;int pnt=0;
    for(int i=0;i<n;i++){
	cin>>h;
	double dis=abs(t-h*0.006-a);
	if(mini>dis){
	    mini=dis;
	    pnt=i;
	}
    }
    cout<<pnt+1<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
cond = [0] * M
for i in range(M):
    cond[i] = list(map(int, input().split()))
p = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    switch = bin(i)[2:].zfill(N)
    ok = 1
    for j in range(M):
        sum_s = 0
        for k in range(cond[j][0]):
            if switch[cond[j][k+1] - 1] == '1':
                sum_s += 1
        if sum_s % 2 != p[j]:
            ok = 0
    if ok:
        ans += 1
print(ans)

Measured memory_bytes: 42736
a = gets().to_i
b = gets().to_i
c = gets().to_i
d = gets().to_i
e = gets().to_i
k = gets().to_i

flag = true
arr = [a, b, c, d, e]
0.upto(3) {|i|
	(i + 1).upto(4) {|j|
		flag = false if arr[j] - arr[i] > k
	}
}

puts (flag ? "Yay!" : ":(")


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

#define ll long long
#define vl vector<ll>
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    ll X;
    ll stock = 100;
    ll year = 1;
    cin >> X;

    while(1){
        stock *= 1.01;
        if(stock >= X){
            cout << year << endl;
            break;
        }
        year++;
    }
       
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3632
N,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
mod = 10**9+7

E = [[] for _ in [0]*N]
for a,b in AB:
    E[a-1].append(b-1)
    E[b-1].append(a-1)

ans = K
q = [0]
V = [False for _ in [0]*N]
V[0] = True
while q:
    qq = []
    for i in q:
        #tmp = sorted(set(V[i]))
        #cSet = list(range(tmp[0])) + list(range(tmp[0]+1,tmp[-1])) + list(range(tmp[-1]+1,K))
        l = K-2+(i==0)
        for j in E[i]:
            if V[j]:continue
            ans = ans * l % mod
            if ans == 0:break
            qq.append(j)
            V[j] = True
            l -= 1
    q = qq
print(ans)

Measured memory_bytes: 83288
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>

using namespace std;

void solve() {
    int n;
    cin >> n;
    int w = n % 10;
    if (w == 2 || w == 4 || w == 5 || w == 7 || w == 9) {cout << "hon";}
    else if (w == 0 || w == 1 || w == 6 || w == 8) {cout << "pon";}
    else {cout << "bon";}
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


Measured memory_bytes: 3520
def calc(n, count, k)
  if n == 0
    return count 
  else
    calc(n-1, count * 2 + k, k)
  end
end

def solve(n, k, total_p, total, ans)
  if k == 0 && n != 0
    return ans
  elsif k == 0 && n == 0
    return ans + 1
  elsif k == (total - 1) / 2
    return ans + (total_p + 1) / 2
  elsif k == total - 1
    return ans + total_p
  end
  if (total - 1) / 2 > k
    solve(n - 1, k - 1, (total_p - 1) / 2, (total - 3) / 2, ans)
  else
    solve(n - 1, k - (total + 1) / 2 , (total_p - 1) / 2, (total - 3) / 2, ans + (total_p + 1) / 2)
  end
end
  
n, k = gets.split.map(&:to_i)
p = calc(n, 1, 1)
t = calc(n, 1, 3)

puts solve(n, k - 1, p, t, 0)


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const long long mod = 1e9 + 7;
 
int main()
{
    std::string n;
    std::cin >> n;
    for(int i=0; i<n.length(); i++)
    {
        if(n[i]=='7')
        {
            std::cout << "Yes\n";
            return 0;
        }
    }
    
    std::cout << "No\n";
    
    return 0;
}

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

int main(){
  long long N,M;
  cin >>N>>M;
  long long ans=0;
  if((N>1)&&(M>1)){
    ans=(M+N)*2-4;
  }
  if((M==1)&&(N>1)){
    ans=2;
  }
  if((M>1)&&(N==1)){
    ans=2;
  }
  if((M==1)&&(N==1)){
    ans=0;
  }
  cout<<setprecision(15)<<M*N-ans<<endl;
  return 0;
}

  
    
  

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int n,m;
map<string,int> t;
map<string,vector<string> > t2;

int f(string s){
	if(t2.find(s)==t2.end())return t[s];
	int c=0;
	rep(i,t2[s].size())c+=f(t2[s][i]);
	return min(t[s],c);
}

int main(){
	while(cin>>n&&n){
		t.clear();t2.clear();
		int p;
		string s,g;
		rep(i,n){
			cin>>s>>p;
			t[s]=p;
		}
		cin>>m;
		rep(i,m){
			cin>>s>>p;
			vector<string> v;
			rep(j,p){
				string st;
				cin>>st;
				v.push_back(st);
			}
			t2[s]=v;
		}
		cin>>g;
		cout<<f(g)<<endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  ll N, ans = 0;
  cin >> N;
  vector<ll> A(N+1, 0), B(N+1, 0), C(N+1, 0),D(N+1, 0);

  for (ll i = 1; i <= N; i++) {
    cin >> A[i];
  }

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

  for (ll i = 1; i <= N; i++) {
    D[i] = B[i] * C[i];
  }

  for (ll i = 1; i <= N; i++) {
    ans += D[i];
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9524
//たてH cm よこ W cm の枠を描くプログラム
#include <stdio.h>

int main(void)
{
    //変数定義
    int iHeight;        //縦の長さ
    int iWidth;         //横の長さ
    int iHeightCount;   //縦の長さカウンタ
    int iWidthCount;    //横の長さカウンタ

    //変数の初期化
    iHeight = 1;
    iWidth = 1;

    
    while (iHeight != 0 && iWidth != 0)
    {
        //Input:縦 横
        scanf("%d %d",&iHeight,&iWidth);

        //入力データ: 0 0の時はbreak
        if (iHeight == 0 && iWidth == 0)
        {
            break;
        }

        //for:縦の長さが入力したデータと一致するまでループ
        for (iHeightCount = 1; iHeightCount <= iHeight; iHeightCount++)
        {
             //for:横の長さが入力したデータと一致するまでループ
             for (iWidthCount = 1; iWidthCount <= iWidth; iWidthCount++)
             {
                //if:行末なら#と改行を出力する
                if (iWidthCount == iWidth)
                {
                    printf("#\n");
                }
                //else if:開始行または終了行または行頭であれば'#'を出力する
                else if (iHeightCount == 1 || iHeightCount == iHeight || iWidthCount == 1)
                {
                    printf("#");
                }
                //else:'.'を出力する
                else
                {
                    printf(".");
                }
             }
        }
        //入力データごとに改行する。
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int h,w,ans=0;
vvc a,b(2,vc(2));
vector<vip> c;

void Judge(int x,int y){
	vp T,F;
	for(int i=0;i<2;i++) for(int j=0;j<2;j++){
		if(b[i][j]==a[i+x][j+y]) T.push_back(P(i+x,j+y));
		else F.push_back(P(i+x,j+y));
	}
	if(T.size()==4){
		for(int i=0;i<2;i++) for(int j=0;j<2;j++){
			int dx=i+x,dy=j+y;
			c[dx][dy].first--;
			c[dx][dy].second.first--;
			c[dx][dy].second.second--;
		}
		ans++;
	}
	else if(T.size()==3){
		int dx=F[0].first,dy=F[0].second;
		char joi=b[dx-x][dy-y];
		if(joi=='J') c[dx][dy].first++;
		else if(joi=='O') c[dx][dy].second.first++;
		else c[dx][dy].second.second++;
	}
}

int main(){
	cin>>h>>w;
	a=vvc(h,vc(w));
	c=vector<vip>(h,vip(w));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[i][j];
	for(int i=0;i<2;i++) for(int j=0;j<2;j++) cin>>b[i][j];
	for(int i=0;i<h-1;i++) for(int j=0;j<w-1;j++) Judge(i,j);
	int M=0;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) M=max(M,max(c[i][j].first,max(c[i][j].second.first,c[i][j].second.second)));
	cout<<ans+M<<endl;
}

Measured memory_bytes: 27424
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int a;
	int b[3];
	int s = 0;
	cin >> a;
	b[0] = a / 100;
	b[1] = a % 100 / 10;
	b[2] = a % 10;
	for (int i = 0; i < 3; i++) {
		if (b[i] == 1)
			s++;
	}
	cout << s << endl;

	return 0;
}

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

int main(){
  string S, T;
  int i = 0;
  T = "";
  cin >> S;
  while (true) {
    if (S.size()-T.size() < 5) {
      cout << "NO" << endl;
      break;
    }
    if (S.at(i) == 'd' && S.at(i+1) == 'r' && S.at(i+2) == 'e' && S.at(i+3) == 'a' && S.at(i+4) == 'm') {
      T += "dream";
      if (S.size() == T.size())
        break;
      if (S.at(i+5) == 'e' && S.at(i+6) == 'r') {
        T += "er";
        if (S.size() == T.size())
          break;
        if (S.at(i+7) == 'a' && S.at(i+8) == 's' && S.at(i+9) == 'e') {
          T += "ase";
          if (S.size() == T.size())
            break;
          if (S.at(i+10) == 'r') {
            T += "r";
            if (S.size() == T.size())
              break;
          }
        }
      }
    }
    else if (S.at(i) == 'e' && S.at(i+1) == 'r' && S.at(i+2) == 'a' && S.at(i+3) == 's' && S.at(i+4) == 'e') {
      T += "erase";
      if (S.size() == T.size())
        break;
      if (S.at(i+5) == 'r') {
        T += "r";
        if (S.size() == T.size())
          break;
      }
    }
    else {
      cout << "NO" << endl;
      break;
    }
    i = T.size();
  }
  if (S == T) {
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 640
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005
ll col[N],vis[N];
std::vector<pii> adj[N];
void dfs(ll node)
{
	vis[node]=1;
	for(auto i:adj[node])
	{
		if(!vis[i.F])
			{
				ll x=node;
				ll y=i.F;
				ll z=i.S;
				if(z%2)
				{
					if(col[x]==-1 && col[y]==-1)
					{
						col[x]=0;
						col[y]=1;
						
					}
					else if(col[x]!=-1 && col[y]==-1)
					{
						col[y]=!col[x];
						
					}
					else if(col[x]==-1 && col[y]!=-1)
					{
						col[x]=!col[y];
						
					}
					else
						col[x]=!col[y];
				}
				else
				{
					if(col[x]==-1 && col[y]==-1)
					{
						col[x]=0;
						col[y]=0;
						
					}
					else if(col[x]!=-1 && col[y]==-1)
					{
						col[y]=col[x];
						
					}
					else if(col[x]==-1 && col[y]!=-1)
					{
						col[x]=col[y];
						
					}
					else
						col[x]=!col[y];
				}
				dfs(i.F);
			}
	}
}
int main()
{
	
	io
	ll n;
	cin>>n;
	if(n==1)
	{
		cout<<"0";
		exit(0);
	}
	
	rep(i,1,n+1)
	{
		col[i]=-1;
	}
	rep(i,0,n-1)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		adj[x].pb({y,z});
		adj[y].pb({x,z});
		
	}
	dfs(1);
	rep(i,1,n+1)
	{
		cout<<col[i]<<endl;
	}
	
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int inf=1e9+7;
signed main(){
    int n,t[50];
    string s[50],x;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>s[i]>>t[i];
    cin>>x;
    bool a=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(a)
            ans+=t[i];
        if(s[i]==x)
            a=1;
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) {
		pv(s);
	}
	else {
		ps(red);
	}
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	int taro = 0, hanako = 0;
	while (n--) {
		string t, h;
		cin >> t >> h;
		if (t > h) 
			taro += 3;
		else if (t < h)
			hanako += 3;
		else {
			taro++;
			hanako++;
		}
	}
	cout << taro << " " << hanako << endl;
}



Measured memory_bytes: 3256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split(' ').Select(input => int.Parse(input)).ToArray();
			var x1 = inputs[0];
			var y1 = inputs[1];
			var x2 = inputs[2];
			var y2 = inputs[3];
			var diffX = x1 - x2;
			var diffY = y1 - y2;

			var x3 = x2 + diffY;
			var y3 = y2 - diffX;
			var x4 = x3 + diffX;
			var y4 = y3 + diffY;

			Console.WriteLine($"{x3} {y3} {x4} {y4}");

			return;
		}
	}
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<ll> A(N); rep(i,N) std::cin >> A[i];
  
  auto B = A;
  rep(i,N) B[i] += (i+1);

  auto C = A;
  rep(i,N) C[i] = (i+1) - C[i];

  ll ans = 0;
  std::unordered_map<ll,ll> map;
  rep(k, N) {
    ans += map[C[k]];
    map[B[k]]++; 
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 23224