akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b,max;

			var word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			max = a + b;
			if (max < a - b)
				max = a - b;
			if (max < a * b)
				max = a * b;
			
			Console.WriteLine(max);

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define MOD 1000000007

typedef long lint;
typedef pair<lint, lint> P;
bool lessPair(const P& l, const P& r){return l.second < r.second;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    string A; cin >> A;
    string B; cin >> B;
    string C; cin >> C;

    lint res =0;
    REP(i, N) {
      if(A[i] == B[i] && B[i] == C[i]) {
        continue;
      }
      if(A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
        res += 1;
      } else {
        res += 2;
      }
        
    }
    PRINT(res);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int>H(N);
for(int i=0;i<N;i++)cin>>H[i];
int r=H[0],cnt=0;
for(int i=0;i<N;i++){
    if(r<=H[i+1]){
    cnt++;
    r=H[i+1];
    }
}
cout<<cnt+1;
return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
  cin >> n;
  vector<int> a(n);

  for(int i=0 ; i<n ; i++){
    cin >> a[i];
  }
  vector<int> left(n+1,0), right(n+1,0);
  for(int i=0 ; i<n ; i++)  left[i+1] = max(a[i], left[i]);
  for(int i=n-1 ; i>=0 ; i--) right[i] = max(a[i], right[i+1]);
  for(int i=0 ; i<n ; i++){
    cout << max(left[i], right[i+1]) << endl;
  }
  return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
	string s;
	int a=0,ans=0;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
			a++;
		}else{
			ans=max(a,ans);
			a=0;
		}
	}
	ans=max(a,ans);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(long i=0; i<(long)(n); i++)
const long MOD=998244353;
int main(){
long N, K; cin >> N >> K; long L[K], R[K];
REP(i, K){ cin >> L[i] >> R[i]; }
long ans[N+1]={}, sum[N+1]={}; ans[1]=1; sum[1]=1;
for(long i=2; i<=N; i++){ 
  REP(j, K){ 
    if(i<=L[j]){ continue; }
    long l=L[j], r=min(i-1, R[j]);
    ans[i]=(ans[i]+MOD+sum[i-l]-sum[i-r-1])%MOD;
  }
  sum[i]=(sum[i-1]+ans[i])%MOD;
}
cout << ans[N] << "\n";
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(N);
	vector<int> b(N);
	vector<int> c(M);
	vector<int> d(M);

	rep(i, N) {
		cin >> a.at(i) >> b.at(i);
	}
	rep(i, M) {
		cin >> c.at(i) >> d.at(i);
	}

	for(int i = 0; i < N; i++) {
		int ans = 1;
		int min_dist = abs(a.at(i) - c.at(0)) + abs(b.at(i) - d.at(0));

		for(int j = 1; j < M; j++) {
			int dist = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
			if(min_dist > dist) {
				min_dist = dist;
				ans = j + 1;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 100005
ll MOD;
ll d[MAXN];
ll u[MAXN];
vector<ll> adj[MAXN];
ll ord[MAXN];
vector<vector<ll>> pre(MAXN);
vector<vector<ll>> suf(MAXN);

void DFS1(ll s,ll p)
{
    d[s] = 1;
    ll c = 0;
    for(ll i=0;i<adj[s].size();++i)
    {
        ll v = adj[s][i];
        if(v != p)
        {
            ord[v] = c++;
            
            DFS1(v,s);
            d[s] = (d[s] * (1 + d[v])) % MOD;
        }
    }
    
    for(auto it: adj[s])
    {
        ll v = it;
        if(v != p)
        {
            if(pre[s].empty())
                pre[s].push_back(1 + d[v]);
            else
                pre[s].push_back((pre[s].back() * (1 + d[v])) % MOD);
        }
    }
    if(pre[s].empty()) //leaf node
        pre[s].push_back(1);
    
    for(ll i=(adj[s].size() - 1);i>=0;--i)
    {
        ll v = adj[s][i];
        if(v != p)
        {
            if(suf[s].empty())
                suf[s].push_back(1 + d[v]);
            else
                suf[s].push_back((suf[s].back() * (1 + d[v])) % MOD);
        }
    }
    if(suf[s].empty()) //leaf node
        suf[s].push_back(1);
    
    reverse(suf[s].begin(),suf[s].end());
}

void DFS2(ll s,ll p)
{
    if(s == 1) //root
        u[s] = 1;
    
    for(auto it: adj[s])
    {
        ll v = it;
        if(v != p)
        {
            ll one = 1;
            ll two = 1;
            
            if(ord[v] > 0)
                one = pre[s][ord[v] - 1];
            
            if(ord[v] + 1 < suf[s].size())
                two = suf[s][ord[v] + 1];
            
            one = (one * two) % MOD;
            
            u[v] = (1 + u[s] * one) % MOD;
            
            //cout<<s<<" "<<v<<" "<<u[s]<<" "<<ord[v]<<" "<<one<<" "<<two<<" "<<u[v]<<endl;
            DFS2(v,s);
        }
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,M; cin>>N>>M;
    MOD = M;
    
    for(ll i=0;i<(N - 1);++i)
    {
        ll u,v; cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    DFS1(1,-1);
    DFS2(1,-1);
    
    /*for(ll i=0;i<suf[3].size();++i)
        cout<<suf[3][i]<<" ";
    cout<<endl;
    
    cout<<u[2]<<endl;
    
    cout<<"-----"<<endl;*/
    for(ll i=1;i<=N;++i)
        cout<<(u[i]*d[i])%MOD<<endl;
    
}

Measured memory_bytes: 28692
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, K;
        string S;
        cin >> N >> K >> S;
        K--;
        S[K] = (char) (S[K] - 'A' + 'a');
        cout << S << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
/**
*    author:  Dooloper
*    created: 17.04.2020 13:15:39
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;

int main() {
    cin.tie(0);
    ll K;cin>>K;
    queue<ll> Q;
    for(int i = 1; i < 10; i++){
        Q.push(i);
    }
    ll take;
    for (ll i = 0; i < K; i++)
    {
        take = Q.front();
        Q.pop();
        if(take%10 != 0)
            Q.push(take * 10 + (take % 10) - 1);
        Q.push(take * 10 + take % 10);
        if(take % 10 != 9)
            Q.push(take * 10 + (take % 10) +1);
    }
    
    cout<<take<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
cube = [nil, [5, 3, 2, 4], [3, 6, 4, 1], [6, 2, 1, 5], [1, 2, 6, 5], [3, 1, 4, 6], [2, 3, 5, 4]]
roll = {'North' => 0, 'East' => 1, 'South' => 2, 'West' => 3}
turn = {'Left' => -1, 'Right' => 1}
until (n = gets.to_i) == 0
  eye = 1
  round = 0
  puts n.times.map {
    r = cube[eye]
    case op = gets.chomp
    when 'Left', 'Right'
      round += turn[op]
    else
      dir = roll[op]
      before_eye = eye
      eye = cube[before_eye][(dir + 2 - round) % 4]
      round = (dir - cube[eye].index(before_eye)) % 4
    end
    eye
  }.reduce(1, :+)
end

Measured memory_bytes: 6148
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	if(_gcd!=1)cerr<<"WA";
	else return mpow(a,mod-2,mod);
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
int n,m;
vector<int>a;
int dp[MAX];
int solve(int n){
	if(n==0)return 0;
	if(dp[n]!=-1)return dp[n];
	int best=1000000;
	for(int i=0;i<m;i++){
		if(a[i]<=n){
			int temp=solve(n-a[i]);	
			best=min(best,temp+1);
		}
	}
	return dp[n]=best;
}

int main(){reduce200ms;
cin>>n;
memset(dp,-1,sizeof dp);
a.pb(1);
for(int i=1;pow(6,i)<=n;i++){
	a.pb(pow(6,i));
}
for(int i=1;pow(9,i)<=n;i++){
	a.pb(pow(9,i));
}
m=(int)a.size();
cout<<solve(n);
return 0;
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define lll __int128
#define ull unsigned long long
#define fi first
#define se second
#define db double
#define ld long double
#define lld __float128

/// order_of_key, find_by_order

template<class T, class COMP>
using custom_set = tree<T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U>
using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd_64(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ll a, b, c; cin >> a >> b >> c;
    cout << min(c, a+b+1) + b;
}






































/// shche ne vmerla Ykraina


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Cats and Dogs
            var line = ReadLine();
            int A = line[0];
            int B = line[1];
            int X = line[2];

            if (A > X)
            {
                Console.WriteLine("NO");
            }
            else if (A + B >= X)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=200005;
const int Mod=1000000007;
struct Frac
{
    ll x,y;
    Frac(ll _x,ll _y):x(_x),y(_y)
    {
        if(y<0 || (y==0 && x<0))
            x=-x,y=-y;
        ll g=__gcd(x,y);
        x/=g,y/=g;
    }
    Frac ninv()
    {
        return Frac(-y,x);
    }
    bool operator < (const Frac &t)const
    {
        return x==t.x ? y<t.y : x<t.x;
    }
};
int pw[MAXN];
int main()
{
    for(int i=(pw[0]=1);i<MAXN;i++)
        pw[i]=2*pw[i-1]%Mod;
    int n,res=1,zero=0;
    scanf("%d",&n);
    vector<Frac> f;
    map<Frac,int> mp;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        scanf("%lld%lld",&x,&y);
        if(x==0 && y==0)zero++;
        else
        {
            Frac r=Frac(x,y);
            f.push_back(r);
            mp[r]++;
        }
    }
    n=(int)f.size();
    set<Frac> vis;
    for(int i=0;i<n;i++)
    {
        if(vis.count(f[i]) || vis.count(f[i].ninv()))continue;
        res=1LL*res*(pw[mp[f[i]]]+pw[mp[f[i].ninv()]]-1)%Mod;
        vis.insert(f[i]),vis.insert(f[i].ninv());
    }
    return 0*printf("%d\n",(res+zero+Mod-1)%Mod);
}


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

int main() { 	
 int A,B,C,D,E,F,G;
 cin >>A>>B;
 vector<int> AA(1);
  vector<int> BB(1);
  
A--; 
    for(int i=0;i<A*2+1;i++){
	cout <<B-A+i<<endl; 
    }
 
}

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

int main() {
    string S;
    string T;
    cin >> S;
    cin >> T;
    int counter = 0;


    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) != T.at(i)) {
          ++counter;
     }
    }
    cout << counter << endl;
}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
string a,b;
int ans=INT_MAX;
int main(){
	cin>>a>>b;
	for(int i=0;i<a.length()-b.length()+1;i++){
		int cnt=0;
	    for(int j=i;j<i+b.length();j++)cnt+=a[j]!=b[j-i];
	    ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int a;
  cin >> a;
  int ans = a+a*a+a*a*a;
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std ;
int main(){
    int N;
    cin >> N;
    char S[N][128];
    for(int i=0;i<N;i++)cin >> S[i];
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<N;i++){
        if(strcmp(S[i],"AC")==0){
            a++;
        }else if(strcmp(S[i],"WA")==0){
            b++;
        }else if(strcmp(S[i],"TLE")==0){
            c++;
        }else if(strcmp(S[i],"RE")==0){
            d++;
        }
    }
    cout << "AC x " << a << "\n";
    cout << "WA x " << b << "\n";
    cout << "TLE x " << c << "\n";
    cout << "RE x " << d << "\n";
}

Measured memory_bytes: 16120
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum;

int main()
{
	fast;
	cin>>n;
	cout<<n*n*n;


}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    LL A,B;
    cin >> A >> B;
    if(A > B) swap(A, B);
    LL det = B-A;
    if(det&1) cout << "IMPOSSIBLE" << endl;
    else cout << A+det/2LL << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		K, A, B int
		ok bool
	)
	fmt.Scan(&K, &A, &B)

	for i := A; i <= B; i++ {
		if i % K == 0 {
			ok = true
		}
	}

	if ok {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << a << ' ' << b << ' ' << -a - b + 3 * c << '\n' << -2 * a - b + 4 * c << ' ' << c << ' ' << 2 * a + b - 2 * c << '\n' << a + b - c << ' ' << -b + 2 * c << ' ' << -a + 2 * c << '\n';
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		System.out.println(S.substring(0,N/2).equals(S.substring(N/2, N)) ? "Yes" : "No");
	}
}

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

int getOnesPlace(int num)
{
    return num % 10;
}

int calcTime(int num)
{
    if (num % 10 == 0) {
        return num;
    }

    return (num / 10 + 1) * 10;
}

int main()
{
    vector<int> list(5);

    for (int i = 0; i < 5; i++) {
        cin >> list[i];
    }

    int min = list[0];
    int sum = 0;

    for (int i = 1; i < 5; i++) {
        int onesPlace = getOnesPlace(list[i]);
        if (onesPlace > 0 && onesPlace < getOnesPlace(min)) {
            sum += calcTime(min);
            min = list[i];
        } else {
            sum += calcTime(list[i]);
        }
    }

    cout << sum + min;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000003;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll l,n;
ll x[e5];
ll y[e5];
ll ans = 0;

int main(){
  cin >> l >> n;
  for(ll i = 1;i <= n;i++) cin >> x[i];
  for(ll i = 1;i <= n;i++){
    y[i] = l-x[n-i+1];
  }
  for(ll i = 1;i <= n;i++){
    x[i] += x[i-1];
    y[i] += y[i-1];
  }
  for(ll i = 1;i <= n;i++){
    ll a = i-1;
    ll nokori = n-a;
    if(nokori%2 == 0){
      ll mem = 0;
      mem += (x[i+nokori/2-1]-x[i-1])*2;
      mem += (y[nokori/2]-y[0])*2;
      mem -= (y[nokori/2]-y[nokori/2-1]);
      ans = max(ans,mem);
      mem = 0;
      mem += (y[i+nokori/2-1]-y[i-1])*2;
      mem += (x[nokori/2]-x[0])*2;
      mem -= (x[nokori/2]-x[nokori/2-1]);
      ans = max(ans,mem);
    }else{
      ll mem = 0;
      mem += (x[i+nokori/2-1]-x[i-1])*2;
      mem += (y[nokori/2]-y[0])*2;
      mem += (x[i+nokori/2]-x[i+nokori/2-1]);
      ans = max(ans,mem);
      mem = 0;
      mem += (y[i+nokori/2-1]-y[i-1])*2;
      mem += (x[nokori/2]-x[0])*2;
      mem += (y[i+nokori/2]-y[i+nokori/2-1]);
      ans = max(ans,mem);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	ll a[x], b[y], c[z], ab[x * y];
	for (int i = 0; i < x; cin >> a[i++]);
	for (int i = 0; i < y; cin >> b[i++]);
	for (int i = 0; i < z; cin >> c[i++]);

	for (int i = 0; i < x; i++)
		for (int j = 0; j < y; j++)
			ab[i * y + j] = a[i] + b[j];
	sort(ab, ab + x * y, greater<ll>());

	vector<ll> ans;
	for (int i = 0; i < min(k, x * y); i++)
		for (int j = 0; j < z; j++)
			ans.pb(ab[i] + c[j]);

	sort(ans.rbegin(), ans.rend());
	for (int i = 0; i < k; i++)
		cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 42980
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;

signed main(){
  ll n;cin >> n;
  vector< vector<ll> > a(n,vector<ll>(n,0));
  vector< vector<ll> > b(n,vector<ll>(n,0));
  for(ll i=0;i<n;i++)for(ll j=0;j<n;j++) cin >> a[i][j];
  bool f=false;
  for(ll k=0;k<n;k++){
    for(ll i=0;i<n;i++){
      for(ll j=0;j<n;j++){
        if(a[i][j]>a[i][k]+a[k][j]){
          f=true;
        }else if(i!=j and i!=k and j!=k and a[i][j]==a[i][k]+a[k][j]){
          b[i][j]=1;
        }
      }
    }
  }
  # if 0
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      cout << b[i][j] << " ";
    }
    cout << endl;
  }
  #endif
  if(f){
    cout << -1 << endl;
  }else{
    ll cnt=0;
    for(ll i=0;i<n;i++){
      for(ll j=0;j<n;j++){
        if(b[i][j]==0){
          cnt+=a[i][j];
        }
      }
    }
    cout << ll(floor(cnt/2)) << endl;
  }

}


Measured memory_bytes: 1664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int p[] = new int[N];
        for(int i=0;i < N;i++){
            p[i] = scan.nextInt();
        }
        Arrays.sort(p);
        int sum = 0;
        for(int i=0;i < N;i++){
            if(i == N - 1){
                sum += p[i] / 2;
            }
            else{
                sum += p[i];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define Inf 0x3F3F3F3F
#define Loc freopen("baka.in", "r", stdin)
typedef long long LL;
using namespace std;

LL Read() {
	LL ___ = 0, __ = 1; char _ = getchar();
	while (_ < 48 || _ > 57)  if (_ == 45) __ = -1, _ = getchar();
	while (_ >= 48 && _ <= 57) ___ = ___ * 10 + _ - 48, _ = getchar();
	return ___ * __;
}

string str;
int G, P, ans;

int main() {
	cin >> str;
	for (int pos = 0; pos < str.size(); pos++) {
		if (str[pos] == 'g') {
			if (P < G) ans++, P++;
			else G++;
		}
		else {
			if (P < G) P++;
			else G++, ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, K = map(int,input().split())
    D = set(input().split())
    for ans in range(N,1000000):
        f = 0
        for e in str(ans):
            if e in D:
                f = 1
                break
        if f == 0:
            print(ans)
            exit(0)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,res=INF;
vi a;

void dfs(int I,vp b){
	if(I==n){
		ll x=0;
		for(auto p:b) x+=p.second;
		res=min(res,x);
		return;
	}
	b.push_back({1<<I,a[I]});
	dfs(I+1,b);
	b.pop_back();
	int m=b.size();
	for(int i=0;i<1<<m;i++){
		int t=0,cnt=0;
		for(int j=0;j<m;j++) if(i&1<<j){
			if(t&b[j].first){
				t=-1;
				break;
			}
			t|=b[j].first;
			cnt++;
		}
		if(t==-1||cnt>a[I]) continue;
		vp c;
		if(cnt<a[I]) c.push_back({1<<I,a[I]-cnt});
		for(int j=0;j<m;j++){
			if(i&1<<j){
				P p=b[j];
				if(p.second>1){
					c.push_back({p.first+(1<<I),1});
					c.push_back({p.first,p.second-1});
				}
				else c.push_back({p.first+(1<<I),p.second});
			}
			else c.push_back(b[j]);
		}
		dfs(I+1,c);
	}
}

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	dfs(0,vp());
	cout<<res<<endl;
}


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

int main(){
  char s[4];
  for(int i=0;i<4;i++) cin>>s[i];
  sort(s,s+4);
  if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[3]) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long m = long.Parse(input[1]);
    long oneTime = 1900*m + 100*(n-m);
    long probability = 1;
    for(int i = 0; i < m; i++)
    {
      probability *= 2;
    }
    long answer = oneTime * probability;
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13140
N = int(input())
A = []
d = {}
for i in range(N):
    a = int(input())
    d[a] = 0
    A.append(a)
S = []
for i in range(N):
    if d[A[i]] == 0:
        S.append(A[i])
    d[A[i]] += 1
ans = 0
for i in S:
    ans += (d[i]%2)
print(ans)

Measured memory_bytes: 15624
/**
 *    author:  tourist
 *    created: 10.05.2020 20:36:15       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int ok = 1;
    for (int j : g[i]) {
      if (h[i] <= h[j]) {
        ok = 0;
        break;
      }
    }
    ans += ok;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 8652
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
vector<int>graph[100005];
int dp[100005];
int solve(int k)
{
    if(dp[k]!=-1)
    return dp[k];
    bool l=0;
    int best=0;
    for(auto child:graph[k])
    {
        l=1;
        best=max(best,solve(child));
    }
    if(l==0)
    dp[k]=0;
    else
    dp[k]=1+best;
    return dp[k];
}
int main() {
    int n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
    }
    int ans=0,i;
    for(i=1;i<=n;i++)
    {
        ans=max(ans,solve(i));
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>
#include<stdlib.h>

int main(){
    int N,K;
    double sum=0.0;
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++){
        int cnt=0;
        double sk=0.0;
        for(int j=i;j<K;j*=2){
            cnt++;
        }
        sk=pow(1/2.0,(double)cnt);
        sum+=sk/N;
    }
    printf("%.12f\n",sum);
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long

const int maxn=1e5+10;

char str[4];

int main()
{
    scanf("%s",str);
    sort(str,str+4);
    if (str[0]==str[1] && str[2]==str[3] && str[1]!=str[2])
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, w, n, buf, set[31], inbuf1, inbuf2;

	//init
	for(i=0; i<31; i++){ set[i] = i; }

	scanf("%d %d", &w, &n);
	getchar();
	for(i=0; i<n; i++){
		scanf("%d,%d", &inbuf1, &inbuf2);

		buf = set[inbuf1];
		set[inbuf1] = set[inbuf2];
		set[inbuf2] = buf;
	}

	for(i=1; i<=w; i++){ printf("%d\n", set[i]); }
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll N; cin >> N;
    vector<ll> vec(1e5+1);
    ll tmp;
    rep(i, N) {
        cin >> tmp;
        vec[tmp]++;
    }
    ll S = 0;
    rep(i, 1e5+1) {
        S += i*vec[i];
    }
    ll Q; cin >> Q;
    ll B, C;
    rep(i, Q) {
        cin >> B >> C;
        S += (C-B)*vec[B];
        cout << S << endl;
        vec[C] += vec[B];
        vec[B] = 0;
    }
}


Measured memory_bytes: 4044
#include <stdio.h>
int main(void)
{
	int n, a[1000], i;
	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);		
	}
	
	for (i = n - 1; i >= 0; i--)
	{
		printf("%d", a[i]);
		if (i != 0)
		{
			printf(" ");
		}
	}
	printf("\n");
}


Measured memory_bytes: 2056
#include <stdio.h>

int main(int argc, char const* argv[])
{
	int masu[1100];
	int dice[1000];
	int n, m;
	int cur;
	int i;

	while (1) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0){
			break;
		}
		for (i = 0; i < n; i++) {
			scanf("%d", &masu[i + 1]);
		}

		cur = 1;
		for (i = 0; i < m; i++) {
			scanf("%d", &dice[i]);
		}
		for (i = 0; i < m; i++) {
			cur += dice[i];
			if (cur >= n){
				break;
			}
			cur += masu[cur];
			if (cur >= n){
				break;
			}
		}

		printf("%d\n", i + 1);
	}
	
	return 0;
}

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

// n個の重複しない整数(min ~ max)用いてsを表す組み合わせの数
int ci(int n, int s, int min, int max) {
  if (s < min || n < 1) return 0;
  if (n == 1) return (s > max)? 0: 1;
  int r = 0;
  for (int i=min; i<s && i<=max; i++) {
    r += ci(n - 1, s - i, i + 1, max);
  }
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, 9) << endl;
  }
  return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	long long a[n];
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) a[i + 1] += a[i];
	int k = 0;
	for (int i = 0; i < n - 1; i++)
		if (a[i] * 3 < a[i + 1]) k = i + 1;
	printf("%d\n", n - k);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
string ans = "No";
int a[3];
int k;

bool dfs(int c){
    if(a[0]<a[1] && a[1]<a[2]){
        return true;
    }
  	if(c == k){
        return false;
    }
    for (int i = 0; i < 3; i++)
    {
        a[i] *= 2;
        if(dfs(c+1)) return true;
        a[i] /= 2;
    }
    return false;
}
int main() {
    
    cin >> a[0] >> a[1] >> a[2] >> k;
    if(dfs(0)) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>

#define N 500001
#define NIL 2000000001

void maxHeapify(int);
void buildMaxHeap();

int heap[N],n;

int main(){
  int i;

  for(i=0;i<N;i++){
    heap[i]=NIL;
  }

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&heap[i]);
  }

  buildMaxHeap();

  for(i=1;i<=n;i++){
    printf(" %d",heap[i]);
  }    

  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int l,r,largest,a;
    l = 2*i; 
    r = 2*i+1;
  
    if(l<=n && heap[l]>heap[i]){
      largest = l;
    }
    else largest = i;
  
    if(r<=n && heap[r]>heap[largest]){
      largest = r;
    }

    if(largest!=i){
      a=heap[largest];
      heap[largest]=heap[i];
      heap[i]=a;
      maxHeapify(largest);
    }
}

void buildMaxHeap(){
  int i;
  for(i=n/2;i>=1;i--){
    maxHeapify(i);  
  }
}

Measured memory_bytes: 2552
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

int main(){
    unordered_map<string, int> hashTable;
    int n;
    char cmd[7];
    char str[12];

    scanf("%d", &n);

    for (int i=0; i<n; i++){
        scanf("%s %s", cmd, str);
        if (cmd[0] == 'i'){
            hashTable[str] = 1;
        } else {
            if (hashTable[str] == 1) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}

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

void merge(vector<int> &v, int left, int mid, int right) {
    int len = right - left;
    vector<int> tmp(len);

    int i_tmp = 0, i_left = left, i_right = mid;
    while (i_left < mid and i_right < right) {
        if (v[i_left] <= v[i_right])
            tmp[i_tmp++] = v[i_left++];
        else
            tmp[i_tmp++] = v[i_right++];
    }

    while (i_left < mid) tmp[i_tmp++] = v[i_left++];
    while (i_right < right) tmp[i_tmp++] = v[i_right++];

    for (int i = 0; i < len; ++i)
        v[left + i] = tmp[i];
}

void merge_rec(vector<int> &v, int left, int right) {
    int len = right - left;
    if (len <= 1)
        return;
    
    int mid = left + len / 2;
    merge_rec(v, left, mid);
    merge_rec(v, mid, right);

    merge(v, left, mid, right);
}

void merge_sort(vector<int> &v) {
    merge_rec(v, 0, v.size());
}

int main()
{
    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        cin >> v[i];
    
    merge_sort(v);

    int a1 = 0, a2 = 0;
    int id1 = N - 1, id2 = N - 2;
    while (id1 >= 0) {
        a1 += v[id1];
        id1 -= 2;
    }
    while (id2 >= 0) {
        a2 += v[id2];
        id2 -= 2;
    }
    cout << a1 - a2 << endl;

    return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
m = []
tmp = x
ans = 0

for i in range(n):
    m.append(int(input()))

for i in range(n):
    x -= m[i]
    ans += 1

m.sort()

while 1:
    x -= m[0]

    if x >= 0:
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 3060
n=input()
k=int(input())

n1,n2,n3=int(n[-1]),0,0
a1,a2,a3=9,0,0
for i in n[-2::-1]:
    i=int(i)
    if i!=0:
        n1,n2,n3=i+a1,(i-1)*a1+n1+a2,(i-1)*a2+n2+a3
    a1,a2,a3=9+a1,9*a1+a2,9*a2+a3
print([n1,n2,n3][k-1])

Measured memory_bytes: 38384
#include<stdio.h>

int main(void){

int n;
int i,j;
int max=0;
int dummy;

scanf("%d",&n);

long int h[n];
int kaisu;

for(i=0;i<n;i++){
  scanf("%ld",&h[i]);
  //ここで回数をゼロにする
}
i=0;
j=0;
while(j<n-1){
  kaisu=0;
  for(j=i;j<n-1;j++){
    if(h[j]>=h[j+1]){
      kaisu++;
    }
    else{
      i=j+1;
      break;
    }
  }
  if(max<kaisu)
  max=kaisu;

}

printf("%d",max);





    return 0;
}


Measured memory_bytes: 1024
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int s, w; cin >> s >> w;
	if (w >= s) cout << "unsafe\n";
	else cout << "safe\n";
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

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

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

	vector<int> m(n),a(n),b(n);
	a[0]=0,b[0]=0,m[0]=0;
	a[1]=abs(h[0]-h[1]),b[1]=0,m[1]=a[1];

	for(int i=2; i<n; i++){
		a[i]=abs(h[i-1]-h[i]);
		b[i]=abs(h[i-2]-h[i]);
		m[i]=min(m[i-1]+a[i],m[i-2]+b[i]);
	}

	cout<<m[n-1]<<endl;	
}

Measured memory_bytes: 1920
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = [None] * N
    for i in range(N):
        ans[A[i]-1] = i+1
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55852
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main()
{
	double fX1, fX2, fY1, fY2;
	double fDis2 = 0, fDist = 0;
	cin >> fX1 >> fY1 >> fX2 >> fY2;
	fDis2 = pow((fX1 - fX2), 2) + pow((fY1 - fY2), 2);
	fDist = sqrt(fDis2);
	printf("%.8lf\n", fDist);


	//system("pause");
	return 0;
}

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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int n,m;
	cin>>n>>m;
	vector<int> ans(n,0);
	REP(i,m){
		int a,b;
		cin>>a>>b;
		ans[a-1]++;
		ans[b-1]++;
	}
	REP(i,n){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3592
#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()
{
	int N, M;
	cin >> N >> M;

	unordered_map<int, pair<int, int>> map;
	int p, ac = 0, wa = 0;
	string s;
	rep(i, M)
	{
		cin >> p >> s;
		if (map[p].second) continue;
		if (s == "AC") {
			map[p].second = 1;
			ac++;
			wa += map[p].first;
		}
		else
			map[p].first++;
	}

	cout << ac << " " << wa << endl;
}


Measured memory_bytes: 4388
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        }
        qsort(a,n,sizeof(int),compare);
        while(1){
            int i;
    for(i=0;i<n;i++){
        if(a[i]==0)continue;
        if(a[i]==1){
            printf("1");
            return 0;
        }
        if(i==n-1){
            printf("%d",a[n-1]);
            return 0;
        }
        break;
    }
        for(int j=i+1;j<n;j++){
            a[j]=a[j]%a[i];
            }
            qsort(a,n,sizeof(int),compare);
        }

    return 0;
}


Measured memory_bytes: 1012
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int n, m;
     cin >> n >> m;
     char a[55][55], b[55][55];

     REP(i, n){
         REP(j, n){
            cin >>a[i][j];
         }
     }

     REP(i, m){
         REP(j, m){
             cin >> b[i][j];
         }
     }

     bool exist = false;

     REP(i, n){
         REP(j, n){
                if(i + m > n || j + m > n) continue;

            bool match = true;
            REP(y, m){
                 REP(x, m){
                    if(a[i + y][j + x] != b[y][x]) match = false;
                 }
            }
            if(match) exist = true;
         }
     }

     if(exist) cout << "Yes" << endl;
     else cout << "No" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX

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

    int n;
    cin >> n;
    ll a, b;
    vector <ll> vec;
    ll mn = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        vec.pb(a + b);
        mn += b;
    }
    sort(allr(vec));
    ll ans = 0;
    for (int i = 0; i < n; i += 2) {
        ans += vec[i];
    }
    cout << ans - mn << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
int n;
vector<int> v[MAXN];
long long f[MAXN],ans;
void dptree(int x,int fa){
	long long cnt1,cnt2;
	cnt1=0,cnt2=0;
	for(int i=0;i<v[x].size();i++){
		if(v[x][i]==fa) continue;
		cnt1++;
		dptree(v[x][i],x);
		if(f[v[x][i]]) cnt2++;
		f[x]+=f[v[x][i]];
	}
	f[x]+=max(cnt1-cnt2-1,0ll);
	
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		x++,y++;
		v[x].push_back(y);
		v[y].push_back(x);
    }
	int mx=1;
	for(int i=2;i<=n;i++){
		if(v[i].size()>v[mx].size()) mx=i;
	}
	dptree(mx,0);
	ans=max(f[mx],1ll);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 14208
s = input()
k = int(input())

c = s[0]
l = 1
a = []
for i in range(1, len(s)):
    if s[i] == c:
        l += 1
    else:
        a.append(l)
        c = s[i]
        l = 1
a.append(l)

ans = 0
if len(a) == 1:
    # s consists of one character
    ans += (a[0] * k) // 2
elif s[0] == s[-1]:
    ans += a[0] // 2
    ans += ((a[0] + a[-1]) // 2) * (k - 1)
    for i in range(1, len(a) - 1):
        ans += (a[i] // 2) * k
    ans += a[-1] // 2
else:
    for i in range(len(a)):
        ans += (a[i] // 2) * k

print(ans)


Measured memory_bytes: 3064
{-# OPTIONS_GHC -Wno-tabs #-}
import Data.List (unfoldr, scanl1)

main :: IO ()
main = readLn >>= print . solve

solve :: Integer -> Integer
solve n = (scanl1 (+) $ take 40 $ iterate (*2) 1) !! m
	where
    	m  = subtract 1 $ length $ f n

f :: Integer -> [Integer]
f = unfoldr g
	where
        g :: Integer -> Maybe (Integer, Integer)
        g 0 = Nothing
        g m = Just (m `mod` 2, m `div` 2)

Measured memory_bytes: 3924
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
cnt = 0
sum1 = 0
sum2 = 0
for i in range(n):
	if cnt % 2 == 0:
		sum1 += a[i]
	else:
		sum2 += a[i]
	cnt += 1
print(sum1 - sum2)

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

int main(){
    while(1){
        int w,h,k;
        cin>>w>>h;
        if(w==0&&h==0)return 0;
        cin>>k;  
        vector<vector<bool>> ikeru(w+1,vector<bool> (h+1,true));
        vector<vector<int>> dp(w+1,vector<int> (h+1,0));
        rep(i,k){
            int a,b;
            cin>>a>>b;
            ikeru[a][b]=false;
        }
        rept(i,1,w+1){
            rept(j,1,h+1){
                if(i==1&&j==1) dp[i][j]=1;
                else if(ikeru[i][j]) dp[i][j]=dp[i][j-1]+dp[i-1][j];
            }
        }
       cout<<dp[w][h]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3032
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let Read3Int () = ReadNextInt (), ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module AGC016 =
    let private Shrinking () =
        let cal len l =
            //printfn "L: %A" l
            let rec loop d =
                let cur = l |> Seq.map (fun x -> x - d, x)
                let covered = 
                    [0..len-d-1]
                    |> Seq.forall (fun x ->
                        l |> Seq.exists (fun y ->
                            x <= y && x + d >= y))
                //printfn "\t%d: %A" d covered
                if covered then d else loop (d + 1)
            loop 0
        let str = ReadNext ()
        str
        |> Seq.mapi (fun i c -> i, c)
        |> Seq.groupBy snd
        |> Seq.map (snd >> Seq.map fst >> Seq.cache >> cal str.Length)
        |> Seq.min
        |> printfn "%d"

    let Entry = Shrinking

AGC016.Entry ()

Measured memory_bytes: 19544