akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int MAX = 1000005;
const ll MOD = 1000000007;
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;}

int main(){
  string s;
  cin >> s;
  if(s=="Sunny") cout << "Cloudy";
  else if(s == "Cloudy") cout << "Rainy";
  else if(s == "Rainy") cout << "Sunny";
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ", 2);
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);

        int leftHeight = 1;
        int rightHeight = 1;
        for (int i = 2; i <= 999; i++) {
            rightHeight += i;

            if (leftHeight > a && rightHeight > b && leftHeight - a == rightHeight - b) {
                System.out.println(leftHeight - a);
                return;
            }

            leftHeight += i;
        }
    }
}


Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a==25){
		cout<<"Christmas"<<endl;
	}else if(a==24){
		cout<<"Christmas Eve"<<endl;
	}else if(a==23){
		cout<<"Christmas Eve Eve"<<endl;
	}else if(a==22){
		cout<<"Christmas Eve Eve Eve"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 0;
  rep(i,N){
     cin >>a[i];
   }
  for(int i=0;i<N;i+=2){
     if(a[i]%2==1){
         ans++;
     }
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int g;
        while(true) {
            ArrayList<Integer> list = new ArrayList<Integer>();
            int d = 1024;
            try{
                g = sc.nextInt();
            }catch(Exception e) {
                break;
            }
            
            int ans = 0;
            for(int i = 1; i <= 10; i++) {
                d /= 2;
                if(g-ans < d) {
                    continue;
                }else if(g-ans > d) {
                    ans += d;
                    list.add(d);
                }else if(g-ans == d) {
                    ans += d;
                    list.add(d);
                    break;
                }
            }
            for(int i = list.size()-1; i >= 0; i--) {
                if(i != 0) {
                    System.out.print(list.get(i)+" ");
                }else {
                    System.out.println(list.get(i));
                }
            }
        } 
        
    }    
}



Measured memory_bytes: 26260
#include<bits/stdc++.h>
using namespace std;
using P = pair<string, int>;
using PP = pair<P, int>;

int main(void){
    int n;
    cin >> n;
    vector<PP> a(n);
    for(int i = 0; i < n; i++){
        string s;
        int p;
        cin >> s >> p;
        a[i] = PP(P(s, p * -1), i + 1);
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++) cout << a[i].second << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
    cin >> n;
    vi v(n), va;
    REP(i,n) {
        cin >> v[i];
        cnt = 0;
        while(v[i]%2==0){
            v[i] /= 2;
            cnt++;
        }
        va.push_back(cnt);
    }
    sort(ALL(va));

    cout << va[0] << endl;
    
}

Measured memory_bytes: 256
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")
 
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

 
map<int, vector<int>> edges;
set<int> nodes;
set<int> visited;

int friends(int curr) {
    int total = 1;
    nodes.erase(curr);
    visited.emplace(curr);
    for (int edge : edges[curr]) {
        if (visited.find(edge) != visited.end())
            continue;
        total += friends(edge);
    }
    return total;
}

int main() {
    fastio();

    int N = nxt(), M = nxt();

    for (int i = 0; i < M ; i++) {
        int Ai, Bi;
        cin >> Ai >> Bi;
        Ai--;
        Bi--;

        edges[Ai].push_back(Bi);
        edges[Bi].push_back(Ai);
    }

    for (int i = 0 ; i < N ; i++) {
        nodes.emplace(i);
    }

    int best = 0;
    while (!nodes.empty()) {
        int next = *nodes.begin();
        best = max(best, friends(next));
        visited.clear();
    }
    cout << best << endl;
    
    return 0;
}

Measured memory_bytes: 53616
unittest
{
	assert( [ "xyz", "abc" ].parse.expand.solve == "xaybzc" );
	assert( [ "atcoderbeginnercontest", "atcoderregularcontest" ].parse.expand.solve == "aattccooddeerrbreeggiunlnaerrccoonntteesstt" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto o = input.front;
	input.popFront;
	auto e = input.front;
	return tuple( o, e );
}

auto solve( string o, string e )
{
	auto ans = new char[ o.length + e.length ];
	foreach( i, ref c; ans )
	{
		if( i % 2 == 0 ) c = o[ i / 2 ];
		else             c = e[ i / 2 ];
	}
	return ans;
}


Measured memory_bytes: 256
N = gets.to_i
hs = gets.split.map(&:to_i)

costs = Array.new(N)
costs[0] = 0
costs[1] = (hs[0] - hs[1]).abs
(2...N).each do |i|
  costs[i] = [costs[i-2] + (hs[i-2] - hs[i]).abs, costs[i-1] + (hs[i-1] - hs[i]).abs].min
end
puts costs[N-1]

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint A, V;
    lint B, W;
    lint T;
    cin >> A >> V >> B >> W >> T;

    if (V <= W) {
        cout << "NO" << endl;
        return 0;
    }

    lint sub = V - W;
    lint d   = abs(A - B);

    if ((d <= sub * T)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
res = 0
for i in range(n):
  res += a[i] // 2
  if a[i] % 2 == 1:
    if i != n-1:
      if a[i+1] != 0:
        res += 1
        a[i+1] -= 1
  
print(res)

Measured memory_bytes: 12924
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int dp[100005];
int main()
{
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, s.size())
    {
        if(s[i]=='1'){
            cnt++;
        }else{
            if(cnt>=m){
                cout << -1 << endl;
                return 0;
            }
            cnt = 0;
        }
    }
    reverse(s.begin(), s.end());
    vector<int> v;
    int left = 0;
    int right = 0;
    while(left < n){
        for (int i = m; i > 0;i--){
            right = left + i;
            if(s[right] == '1')continue;
            if(right > n)continue;
            v.push_back(i);
            left = right;
            break;
        }
    }
    reverse(v.begin(), v.end());
    for(auto e:v){
        cout << e << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1144
import sys

N = int(input())
H = list(map(int, input().split()))

H.reverse()
for i in range(1, N):
	if H[i - 1] < H[i] - 1:
		print("No")
		sys.exit(0)
	elif H[i - 1] < H[i]:
		H[i] -= 1

print("Yes")

Measured memory_bytes: 14396
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	//1 + 2x <= N
	int X;
	while(~scanf("%d", &X)) {
		ll ans = 1;
		rep(i, X + 1)
			ans = ans * 2 + 1;
		printf("%lld\n", ans - 1);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a,b;
  scanf("%d %d",&a,&b);
  
  int coins=0;
  int i;
  for(i=0;i<2;i++){
    if(a>b){
      coins+=a;
      a--;
    }else{
      coins+=b;
      b--;
    }
  }
  
  printf("%d\n",coins);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll l ,r;
	cin >> l >>r;
	ll ans = LLONG_MAX;
	f(i,l,min(r+1,l+2019)){
		f(j,i+1,min(r+1,l+2019)){
			ans = min(ans,(i*j)%2019);
		}
	}
	cout << ans << '\n';
	return 0;	
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 121
	// https://atcoder.jp/contests/abc121/tasks
	public static void main(String[] args) {
      c();
	}
	
	private void a() {
		FastReader sc = new FastReader();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		System.out.println((H-h)*(W-w));
	}
	
	private void b() {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		int res = 0;
		
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			int total = 0;
			int[] k = new int[m];
			for (int j = 0; j < m; j++) {
				k[j] = sc.nextInt();
			}
			
			for (int l = 0; l < m; l++) {
				total += (k[l] * b[l]);
			}
			if (total + c > 0) { 
				res++;
			}
		}
		
		System.out.println(res);
	}
	
	private static void c() {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long res = 0;
		int[][] stores = new int[n][2];
		
		for (int i = 0; i < n; i++) {
			stores[i][0] = sc.nextInt();
			stores[i][1] = sc.nextInt();
		}
		
		Arrays.sort(stores, (a , b) -> (a[0] - b[0]));
		
		for (int i = 0; i < n; i++) {
			long buy = Math.min(m, stores[i][1]);
			res += (long)(buy * stores[i][0]);
			m -= (int)buy;
			if (m == 0) { break; }
		}
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

using namespace std;
typedef long long ll;
const int MAXN = 1.1e6;

int N;
vector <pair <int, int> > vx, vy;
int cpar[MAXN];
vector <pair <int, pair <int, int> > > info;

int cfind (int x)
{
    if (x == cpar[x]) return x;
    return cpar[x] = cfind (cpar[x]);
}

bool uni (int a, int b)
{
    a = cfind (a);
    b = cfind (b);
    if (a == b) return false;
    cpar[a] = b;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        vx.push_back(make_pair (x, i));
        vy.push_back(make_pair (y, i));
        cpar[i] = i;
    }

    sort (vx.begin(), vx.end());
    sort (vy.begin(), vy.end());
    for (int i = 0; i < N - 1; i++)
    {
        info.push_back(make_pair (vx[i+1].first - vx[i].first, make_pair (vx[i].second, vx[i+1].second)));
        info.push_back(make_pair (vy[i+1].first - vy[i].first, make_pair (vy[i].second, vy[i+1].second)));
    }
    sort (info.begin(), info.end());

    ll ans = 0;
    for (auto cnum : info)
    {
        if (uni (cnum.second.first, cnum.second.second))
            ans += cnum.first;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 7400
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n*2;i++)
		cin>>a[i];
	sort(a+1,a+n*2+1);
	for(int i=1;i<=n*2;i+=2)
		ans+=a[i];
	cout<<ans;
	return 0;
}

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

#define ll                  long long int
#define llu                 long long unsigned
#define ld                  long double
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define NUM                 1000000
#define PI		            2*acos(0.0)
#define maximum             (-1*INF)
#define READ(f) 	        freopen("f", "r", stdin)
#define WRITE(f) 	        freopen("f", "w", stdout)
const int INF = 1e5 + 10 ;

int main()
{
    ll n;
    set<string> st;
    cin>>n;
    string s;
    cin.ignore();
    while(n--)
    {
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
    return 0;
}


Measured memory_bytes: 19148
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int N;
	int a;
	int max = 0,min = 0;
	int color[9];
	
	for (int i = 0; i < 9; i++) {
		color[i] = 0;
	}

	cin >> N ;
	
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a < 400) {
			color[0] = 1;
		}
		else if (a < 800) {
			color[1] = 1;
		}
		else if (a < 1200) {
			color[2] = 1;
		}
		else if (a < 1600) {
			color[3] = 1;
		}
		else if (a < 2000) {
			color[4] = 1;
		}
		else if (a < 2400) {
			color[5] = 1;
		}
		else if (a < 2800) {
			color[6] = 1;
		}
		else if (a < 3200) {
			color[7] = 1;
		}
		else {
			color[8]++;
		}
	}
	for (int i = 0; i < 8; i++) {
		min += color[i];
	}
	max = min + color[8];
	
    
    if(min == 0){
        min = 1;
    }

	cout << min << " " <<max << endl;
	

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int a,b,c;
        a=scan.nextInt();
        b=scan.nextInt();
        c=scan.nextInt();
        if(a!=b){
            if(a==c||b==c){
                System.out.println("Yes");
            }
            else System.out.println("No");
        }
        else{
            if(a!=c){
                System.out.println("Yes");
            }
            else System.out.println("No");
        }
    }
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int n = sc.nextInt();
		int [] array = new int[n];
		int max = 0, soeji = 0, j, kijyun,hikaku = 0, x = 0;
		int daikin = 0;
		int kijikakaku = sc.nextInt();
		int sabukakaku = sc.nextInt();
		int kiji = sc.nextInt();
		for(int i = 0; i < n; i++){
			array[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			for(j = i; j < n; j++){
				if(j == i){
					max = array[j];
					 
				}
				else if (max < array[j]){
					max = array[j];
					soeji = j;
				}
			}
			array[soeji] = array[i];
			array[i] = max;
		}
		kijyun = kiji / kijikakaku;
		for(int i = 0; i < n; i++){
			hikaku = array[i] / sabukakaku;
			if(kijyun >= hikaku){
				break;
			}
			else {
				x += array[i];
				daikin =kijikakaku+(sabukakaku*(i+1));
				kijyun = (kiji + x)/daikin;
			}
		}
		System.out.println(kijyun);	
	}

}

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (ll i = 0; i < n; ++i) cin >> h.at(i);
    sort(h.rbegin(), h.rend());
    ll ans = 0;
    for (ll j = k; j < n; ++j) ans += h.at(j);
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define bs              binary_search
#define pqb             priority_queue<int>
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define test(x)         int x; cin>>x; while(x--)
#define pi              3.14159265358979323846
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
// int pow(int a, int b, int c)
// {
// 	int res = 1;
// 	while (b > 0)
// 	{
// 		if (b % 2)
// 			res = (res * a) % c;
// 		a = (a * a) % c;
// 		b >>= 1;
// 	}
// 	return res;
// }
/*********************CODE BEGINS*******************/
void solve()
{
	int num, k;
	cin >> num >> k;
	int sum = 0;
	int A[num];
	for (int i = 0; i < num; i++)
		cin >> A[i];
	sort(A, A + num);
	for (int i = 0; i < k; i++)
		sum += A[i];
	cout << sum;
}
int32_t main()
{
	c_p_c();
	// test(x)
	solve();
}

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

int main(){
  string s;cin>>s;
  for(int i=0;i<26;++i) for(int j=i+1;j<26;++j){
    char a='A'+i,b='A'+j;
    string t;
    t=t+a+a+b+b;
    do{
      if(s==t){
        cout<<"Yes"<<endl;
        return 0;
      }
    }while(next_permutation(begin(t),end(t)));
  }
  cout<<"No"<<endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int N, A, B, C;
vector<int> L;

int calc(int i, int a, int b, int c) {
	if (i == N) {
		if (a > 0 && b > 0 && c > 0)
			return abs(A - a) + abs(B - b) + abs(C - c) - 30;
		else
			return INF;
	}

	int ret = calc(i + 1, a, b, c);
	ret = min(ret, calc(i + 1, a + L[i], b, c) + 10);
	ret = min(ret, calc(i + 1, a, b + L[i], c) + 10);
	ret = min(ret, calc(i + 1, a, b, c + L[i]) + 10);
	return ret;
}

int main () {
	cin >> N >> A >> B >> C;
	L.resize(N);
	rep(i, N) cin >> L[i];
	cout << calc(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#define bp(x) __builtin_popcountll(x)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ll int64_t
#define fw(i, l, r, c) for(ll i = l; i <= r; i += c)
#define bw(i, r, l, c) for(ll i = r; i >= l; i -= c)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
const ll mod = 1e9 + 7, inf = 1061109567, N = 105;
const long long infll = 4557430888798830399;

int a[2][N];

signed main(){
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	fastio;
	int n;
	cin >> n;
	fw(i, 0, 1, 1){
		fw(j, 0, n - 1, 1){
			cin >> a[i][j];
			if(i == 0 and j > 1) a[i][j] += a[i][j - 1];
		}
	}
	if(n == 1){
		cout << a[0][0] + a[1][0];
		return 0;
	}
	bw(j, n - 3, 0, 1){
		a[1][j] += a[1][j + 1];
	}
	int summax = -1, cur;
	fw(i, 0, n - 1, 1){
		if(i == 0){
			cur = a[1][0];
		}else if(i == n - 1){
			cur = a[0][n - 1];
		}else{
			cur = a[0][i] + a[1][i];
		}
		summax = max(summax, cur);
	}
	cout << summax + a[0][0] + a[1][n - 1];
//	cout << "\n";
//	fw(i, 0, 1, 1){
//		fw(j, 0, n - 1, 1){
//			cout << a[i][j] << " ";
//		}
//		cout << "\n";
//	}
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    char s[n + 1];
    scanf("%s", s);
    if(n % 2 == 1){
        printf("No\n");
        return 0;
    }
    for(int i = 0; i <  n / 2; i++){
        if(s[i] != s[i + n / 2]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  cin >> n;
  ll a[3 * n];
  for(int i = 0; i < 3 * n; i++) cin >> a[i];
  sort(a, a + 3 * n);
  ll sum = 0;
  for(int i = 3 * n - 2; i >= n; i -= 2) sum += a[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n,m;
    cin >> n >> m;
    cout << pow(2,m)*(m*1900+(n-m)*100)<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
int main(){
ll n;cin>>n;
ll a[n+1],b[n];
rep(i,n+1)cin>>a[i];
rep(i,n)cin>>b[i];
ll cnt=0;
rep(i,n){
    int left=min(a[i],b[i]);
    cnt+=left;
    a[i]-=left;
    b[i]-=left;
    int right=min(a[i+1],b[i]);
    cnt+=right;
    a[i+1]-=right;
    b[i]-=right;
}
 cout<<cnt<<endl;
}

Measured memory_bytes: 1792
loop do
  n = gets.to_i
  break if n==0
  max = max_n = -100000
  r = 0
  n.times do
    m = gets.to_i
    max_n = [max_n, m].max
    r = [r+m, 0].max
    max = [max, r].max
  end
  puts max_n > 0 ? max : max_n
end

Measured memory_bytes: 8752
#include<bits/stdc++.h>
using namespace std;
char x[20],y[16]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
int main()
{
	int nu=0;
	cin>>x;
	for(int i=0;i<16;i++)
	if(x[i]!=y[i])nu++;
	cout<<nu<<endl;
	return 0;
}

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


int main(){
  stack<int> s;
  string c;

  while(cin >> c){
    if(c == "+"){
      int t = 0;
      t += s.top(); s.pop();
      t += s.top(); s.pop();
      s.push(t);
    }else if(c == "-"){
      int t = 0;
      t -= s.top(); s.pop();
      t += s.top(); s.pop();
      s.push(t);
    }else if(c == "*"){
      int t = 0;
      int x;
      x = s.top(); s.pop();
      t = s.top(); s.pop();
      s.push(t*x);
    }else{
      s.push(stoi(c));
    }
  }
  cout << s.top() << endl;
}



Measured memory_bytes: 3204
#include "bits/stdc++.h"
using namespace std;
bool use[10000][1260]; //[i][j]:??????i?????????j~j+1???PC????????¨????????????
int login[1000]; //[i]:-1?????¨???????????°?????????????????? ????????\????????¨???????????°??????????????????
int main() {
	int N,M,r,q;
	while(scanf("%d %d",&N,&M),N) {
		memset(use,0,sizeof(use));
		scanf("%d",&r);
		for(int i=0;i<r;i++) {
			int t,n,m,s;
			scanf("%d %d %d %d",&t,&n,&m,&s);n--;m--;
			if(s) {
				login[n]=t;
			} else {
				for(int j=login[n];j<t;j++) use[m][j]=1;
			}
		}
		scanf("%d",&q);
		for(int i=0;i<q;i++) {
			int ts,te,m;
			scanf("%d %d %d",&ts,&te,&m);m--;
			int ans=0;
			for(int j=ts;j<te;j++) {
				if(use[m][j]) ans++;
			}
			printf("%d\n",ans);
		}
	}
}

Measured memory_bytes: 15404
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string str;
  cin>>str;
  int xcnt=0;
  int alfa[26]={};
  string str2="";
  for(int i=0;i<str.size();i++){
    alfa[str[i]-'a']++;
    if(str[i]=='x')
      xcnt++;
    else
      str2+=str[i];
  }
  int flag=0;
  for(int i=0;i<str2.size()/2;i++){
    if(str2[i]!=str2[str2.size()-i-1]){
      flag=1;
      break;
    }
  }
  int ans=0;
  if(str2.size()%2==1){
    int left=0;
    int right=str.size()-1;
    while(left!=right){
      //cout<<left<<" "<<right<<endl;
      //cout<<str[left]<<" "<<str[right]<<endl;
      if(str[left]==str[right]){
	left++;right--;
      }else if(str[left]=='x'){
	  left++;
	ans++;
      }else if(str[right]=='x'){
	  right--;
	ans++;
      }else{
	ans=-1;
	break;
      }
    }
    cout<<ans<<endl;
  }else{
    int left=0;
    int right=str.size()-1;
    while(left!=right){
      if(str[left]==str[right]){
	if(right-left==1)
	  break;
	left++;right--;
      }else if(str[left]=='x'){
	left++;
	ans++;
      }else if(str[right]=='x'){
	right--;
	ans++;
      }else{
	ans=-1;
	break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

void dfs(int cur, int prev, vector<vector<int>> &graph, vector<int> &cnt, vector<int> &ans) {
    ans[cur] += cnt[cur];
    for (int next : graph[cur]) {
        if (next == prev) continue;
        ans[next] = ans[cur];
        dfs(next, cur, graph, cnt, ans);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> graph(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    vector<int> cnt(n);
    while (q--) {
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    vector<int> ans(n);
    vector<bool> visited(n, false);
    queue<int> que;
    que.push(0);
    while (!que.empty()){
        int cur = que.front();
        que.pop();
        visited[cur] = true;
        ans[cur] += cnt[cur];
        for (int next : graph[cur]) {
            if (visited[next]) continue;
            ans[next] += ans[cur];
            que.push(next);
        }
    }
    for (int x : ans) cout << x << " ";
    cout << endl;

    return 0;
}


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

const int N = 100010;
vector<P> G[N];
vector<bool> seen(N);
vector<int> D(N, 1e9);

int n, m;

bool dfs(int now){
    seen[now] = true;
    for(int i = 0; i < G[now].size(); i++){
        P p = G[now][i];
        int to = p.first;
        int cost = p.second;

        if(seen[to]){
            if(D[to] != D[now] + cost) return false;
        }else{
            D[to] = D[now] + cost;
            if(!dfs(to)) return false;
        }
    }
    return true;
}

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

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }

    for(int i = 0; i < n; i++){
        if(!seen[i]){
            if(!dfs(i)){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 12032
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

$map = array(array());
$arrX = array();
$arrY = array();
$posX = array();
$posY = array();
fscanf(STDIN, "%d %d", $N, $K);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $x[$i], $y[$i]);
    $arrX[$x[$i]]++;
    $arrY[$y[$i]]++;
}
ksort($arrX);
ksort($arrY);
// exit;
$posX = array_keys($arrX);
$posY = array_keys($arrY);
// exit;

$idxX = array_flip($posX);
$idxY = array_flip($posY);
if (DEBUG) var_dump($arrX);
if (DEBUG) var_dump($arrY);
if (DEBUG) var_dump($idxX);
if (DEBUG) var_dump($idxY);
$mapXY = array(array());
for ($i = 0; $i < $N; $i++) {
    // $mapXY[]
    $xx = $idxX[$x[$i]];
    $yy = $idxY[$y[$i]];
    if (DEBUG) echo "{$xx} {$yy}\n";
    $mapXY[$xx][$yy]++;
}
if (DEBUG) var_dump($mapXY);
for ($x = 0; $x < count($idxX); $x++) {
    for ($y = 0; $y < count($idxY); $y++) {
        $mapXY[$x][$y] = $mapXY[$x-1][$y] + $mapXY[$x][$y-1] - $mapXY[$x-1][$y-1] + $mapXY[$x][$y];
        if (DEBUG) echo "{$x} {$y} num:{$mapXY[$x][$y]} {$cur1} {$cur2}\n";
    }
}

$ans = PHP_INT_MAX;

for ($x1 = 0  ; $x1 < count($idxX); $x1++) {
for ($x2 = $x1; $x2 < count($idxX); $x2++) {
for ($y1 = 0  ; $y1 < count($idxY); $y1++) {
for ($y2 = $y1; $y2 < count($idxY); $y2++) {
    $posX1 = $posX[$x1];
    $posX2 = $posX[$x2];
    $posY1 = $posY[$y1];
    $posY2 = $posY[$y2];
    $numXY = $mapXY[$x2][$y2] - $mapXY[$x1-1][$y2] - $mapXY[$x2][$y1-1] + $mapXY[$x1-1][$y1-1];
    $width = max(1, $posX2 - $posX1);
    $height = max(1, $posY2 - $posY1);
    if ($numXY >= $K) {
        $ans = min($ans, $width * $height);
    }
    if (DEBUG) printf("posX1:%d posX2:%d posY1:%d posY2:%d num:%d ans:%d\n", $posX1, $posX2, $posY1, $posY2, $numXY, $ans);
}    
}    
}    
}

echo $ans . PHP_EOL;


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
#define mod2 998244353

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int N,M;
int A[105];
int sum;
signed main(){
	cin>>N>>M;
	rep(i,N){
		cin>>A[i];sum+=A[i];
	}
	int cnt=0;
	rep(i,N){
		if((double)sum/(double)(4*M)<=A[i])cnt++;
	}
	if(cnt>=M)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+10;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	
	ll a; long double b;
	cin >> a >> b;

	cout << setprecision(0) << fixed << floor(a*b) << '\n';

	return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;



int main()
{
    int N;
    double x[11];
    vector<string> u(11);

    cin >> N;
    for( int i = 0; i < N; ++i ) cin >> x[i] >> u[i];

    double ans = 0;
    for( int i = 0; i < N; ++i ){
        if( u[i] == "JPY" )  ans += x[i];
        else ans += x[i] * 380000.;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b)

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

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    ll d = a;
    if(b != 0)
    { 
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;        
    }
    return d;
}

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

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

    int N; cin >> N;
    vl T(N); REP(i, N) cin >> T[i];
    ll ans = 1;
    REP(i, N) ans = lcm(ans, T[i]);
    cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  ll k, x = 0;
  cin >> k;
  rep(i, 1ll, k * 2) {
    x = (x * 10 + 7) % k;
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3636
class Heap:
    def __init__(self):
        self._nodes = []

    @classmethod
    def create(cls, li):
        heap = cls()
        heap._nodes = li
        return heap

    def __iter__(self):
        self.cur = 0
        return self

    def __next__(self):
        if self.cur >= len(self._nodes):
            raise StopIteration
        self.cur += 1

        node = self._nodes[self.cur-1]
        if self.cur//2 - 1 >= 0:
            parent = self._nodes[self.cur//2 - 1]
        else:
            parent = None

        if self.cur*2 - 1 < len(self._nodes):
            left = self._nodes[self.cur*2 - 1]
        else:
            left = None

        if self.cur*2 < len(self._nodes):
            right = self._nodes[self.cur*2]
        else:
            right = None

        return (node, parent, left, right)


def run():
    _ = int(input())

    nodes = [int(i) for i in input().split()]
    heap = Heap.create(nodes)

    for (i, node) in enumerate(heap):
        n, p, nl, nr = node
        s = "node {}: key = {}, ".format(i+1, n)
        if p is not None:
            s += "parent key = {}, ".format(p)
        if nl is not None:
            s += "left key = {}, ".format(nl)
        if nr is not None:
            s += "right key = {}, ".format(nr)

        print(s)


if __name__ == '__main__':
    run()



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
ll c[10][10];
ll dis[10];
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
void f(int i, ll d, int lim, int first) {
  if (lim < d) return;
  REP(j, 10) {
    if (i == j) continue;
    if (j == 1) {
      chmin(dis[first], d + c[i][j]);
      continue;
    }
    f(j, d + c[i][j], lim, first);
  }
}
int main() {
  int H, W;
  cin >> H >> W;
  REP(i, 10) { dis[i] = 1e10; }
  REP(i, 10) REP(j, 10) { cin >> c[i][j]; }
  REP(i, 10) {
    dis[i] = c[i][1];
    f(i, 0, c[i][1], i);
  }
  ll ans = 0;
  REP(i, H) REP(j, W) {
    int a;
    cin >> a;
    if (a == -1 || a == 1) continue;
    ans += dis[a];
  }
  cout << ans << endl;
}

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

int main() {
    string N;
    int K,counter=0;
    cin >>N>>K;
    if(N.size()==1){
    cout<<N.at(0)<<endl;}
    else{
    for(int i=0;i<N.size();i++){
    if(N.at(counter)=='1'){
    counter++;
    continue;}
    else break;}
    if(K<=counter)
    cout<<1<<endl;
    else
    cout<<N.at(counter)<<endl;}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
int main(){
     
  int N;
     
  string str[100001];
     
  int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
     
  cin>>N;
      
  for(int i=0;i<N;i++){
        
    cin>>str[i];
     
     
    if(str[i]=="AC"){
      cnt1++;
    }else if(str[i]=="WA"){
     
      cnt2++;
          
    }else if(str[i]=="TLE"){
     
      cnt3++;
     
    }else if(str[i]=="RE"){
     
      cnt4++;
     
          
    }
  }
     
  cout<<"AC x "<<cnt1<<endl;
  cout<<"WA x "<<cnt2<<endl;
  cout<<"TLE x "<<cnt3<<endl;
  cout<<"RE x "<<cnt4<<endl;
  


     
      
      
      
      
  return 0;
     
}


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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
//3ゲーム目の最後の得点をどちらがとったのかが分からない。
//↑は考察不足。ゲームが終了するには、リードしている方が点を取る必要があるので、最後はリードしている方が点を取った。
#include<iostream>
#include<string.h>
using namespace std;

char s[3][102];

int main(){
	int i,j;
	while( cin >> s[0] ){
		if( s[0][0] == '0' )
			break;
		cin >> s[1] >> s[2];
		
		for( i = 0;i < 3;i++ ){
			int cnt[2] = {0};
			for( j = 1;j < strlen( s[i] );j++ ){
				cnt[ s[i][j]-'A' ]++;
			}
			if( i == 2 ){
				if( cnt[ 0 ] > cnt[ 1 ] )
					cnt[0]++;
				else
					cnt[1]++;
			}
			if( i < 2 ){
				cnt[ s[i+1][0]-'A' ]++;
			}
			cout << cnt[0] << " " << cnt[1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll cnt[10][10];

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

    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int x=s[0]-'0';
        int y=s.back()-'0';
        cnt[x][y]++;
    }

    ll ans=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=cnt[i][j]*cnt[j][i];
        }
    }

    cout<<ans<<endl;
} 


Measured memory_bytes: 3736
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    int n, m;
    string *r, *b;
    cin >> n;
    r = new string[n];
    for (int i = 0; i < n; i++)
        cin >> r[i];
    cin >> m;
    b = new string[m];
    for (int i = 0; i < m; i++)
        cin >> b[i];

    map<string, int> cards;
    
    for (int i = 0; i < n; i++) {
        if(cards[r[i]] == 0) {
            cards[r[i]] = 1;
        }
        else {
            cards[r[i]]++;
        }
    }
    for (int i = 0; i < m; i++) {
        if(cards[b[i]] == 0) {
            cards[b[i]] = -1;
        }
        else {
            cards[b[i]]--;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, cards[r[i]]);
    }
    for (int i = 0; i < m; i++) {
        ans = max(ans, cards[b[i]]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def dist(p1, p2):
    total = 0
    for x, y in zip(p1, p2):
        total += (x - y) ** 2
    return total

N, D = map(int, input().split())
point_list = [None] * N

for i in range(N):
    point_list[i] = list(map(int, input().split()))

count = 0
for i in range(N):
    for j in range(i + 1, N):
        dis = math.sqrt(dist(point_list[i], point_list[j]))
        if dis == int(dis):
            count += 1
print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

const int N = 1e5 + 3;
int n, k;
int x[N];
stack<int> neg;
vector<int> pos;
int z = -1, ans = INT_MAX;

void input() {
  scanf("%d %d", &n, &k);
  forn(i, 0, n) {
    scanf(" %d", &x[i]);
  }
}

void solve() {
  int s = (int)pos.size();
  forn(i, 0, n) {
    if (i >= k - 1) {
      int first = x[i - k + 1];

      if (first < 0 && x[i] > 0) {
        if (abs(first) < x[i]) {
          ans = min(ans, 2 * abs(first) + x[i]);
        } else {
          ans = min(ans, abs(first) + 2 * x[i]);
        }
      } else if (first < 0) {
        ans = min(ans, abs(first));
      } else {
        ans = min(ans, x[i]);
      }
    }
  }
  printf("%d\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
//  freopen("output", "w", stdout);
//  gen();
#endif
  input();
  solve();
  return 0;
}


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

int a[ 1 + 'z' ];
bool b[ 1 + 'z' ];

int Chk()
{
int i;
int iCnt;

	iCnt = 0;
	for( i = 'a'; i <= 'z'; i++ )
	{
		if( a[ i ] > 0 && b[ i ] ) iCnt++;
	}

	return iCnt;
}

int main()
{
int i;
int N;
int iCnt;
int iMax;
char S[ 110 ];

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> S;

	for( i = 0; i < N; i++ ) a[ S[ i ] ]++;

	iMax = 0;
	for( i = N - 1; i > 0; i-- )
	{
		a[ S[ i ] ]--;
		b[ S[ i ] ] = true;
		iCnt = Chk();
		iMax = max( iMax, iCnt );
	}

	cout << iMax << endl;

	return 0;
}






Measured memory_bytes: 256
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c


a, b, c = gets.split.map(&:to_i)

if c-a-b<=0
    puts 'No'
    exit
end



x=(c-a-b)*(c-a-b)-a*b*4;
cond=false
if x>0
    cond=true
end

puts cond ? 'Yes' : 'No'


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

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	sort(l.begin(), l.end());

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (l[i] + l[j] <= l[k]) break;
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long res;
  if (2 * n > m) res = m / 2;
  else res = n + (m - 2 * n) / 4;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
def insertionSort(l,n):
    ans = map(str,l)
    print(" ".join(ans))
    for i in range(1,n):
        v = l[i]
        j = i - 1
        while j>=0 and l[j]>v:
            l[j+1]=l[j]
            j -= 1
        l[j+1] = v
        ans = map(str,l)
        print(" ".join(ans))
insertionSort(l,n)



Measured memory_bytes: 5600