akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    if a + b > c + d {
        println!("Left");
    } else if a + b == c + d {
        println!("Balanced");
    } else {
        println!("Right");
    }
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    bool flag = false;
    repX(i,10,1){
        if(N%i!=0)continue;
        if(1<=N/i&&N/i<=9)flag = true;
    }
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int a, b, x;
    sf(a, b, x);
    int v = a * a * b;
    prln(v);
    if (v / 2 >= x) {
        double t = x * 2.0 / a / b;
        prln(t);
        double ang = atan(b / t) * 180 / pi;
        pr(b/t);prln(ang);
        printf("%.10f\n", ang);
    }else {
        double t = 2.0 * x / (a * a) - b;
        prln(t);
        double temp = b * 1.0 - t;
        prln(b);
        double ang = atan(temp * 1.0 / a) * 180 / pi;
        printf("%.10f\n", ang);
    }
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N=scan.nextLine();
        if(N.length()==1){
            char ch0=N.charAt(0);
            if(ch0=='2'||ch0=='4'||ch0=='5'||ch0=='7'||ch0=='9'){
                System.out.println("hon");
            }
            else if(ch0=='0'||ch0=='1'||ch0=='6'||ch0=='8'){
                System.out.println("pon");
            }
            else if(ch0=='3'){
                System.out.println("bon");
            }
        }
        else if(N.length()==2){
            char ch1=N.charAt(1);
            if(ch1=='2'||ch1=='4'||ch1=='5'||ch1=='7'||ch1=='9'){
                System.out.println("hon");
            }
            else if(ch1=='0'||ch1=='1'||ch1=='6'||ch1=='8'){
                System.out.println("pon");
            }
            else if(ch1=='3'){
                System.out.println("bon");
            }
        }
        else if(N.length()==3){
            char ch2=N.charAt(2);
            if(ch2=='2'||ch2=='4'||ch2=='5'||ch2=='7'||ch2=='9'){
                System.out.println("hon");
            }
            else if(ch2=='0'||ch2=='1'||ch2=='6'||ch2=='8'){
                System.out.println("pon");
            }
            else if(ch2=='3'){
                System.out.println("bon");
            }
        }
    }
}


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

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int T; cin >> T;
	while (T--) {
		int64_t N, A, B, C, D; cin >> N >> A >> B >> C >> D;
		auto go = [&]() -> int64_t {
			__int128_t ans = N * __int128_t(D);

			map<int64_t, int64_t> dist;
			priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>, greater<pair<int64_t, int64_t>>> pq;
			dist.emplace(N, 0);
			pq.emplace(0, N);

			while (!pq.empty()) {
				int64_t d = pq.top().first, cur = pq.top().second; pq.pop();
				if (d != dist[cur]) continue;
				//cerr << "row " << d << ' ' << cur << '\n';
				ans = min(ans, cur * __int128_t(D) + d);
				for (auto [p, pcost] : {pair<int, int64_t>{2, A}, {3, B}, {5, C}}) {
					for (int64_t nxt : {cur / p, (cur + p - 1) / p}) {
						int64_t nd = d + abs(nxt * p - cur) * D + pcost;
						//cerr << "nxt " << nxt << ' ' << nd << '\n';
						auto it = dist.find(nxt);
						if (it == dist.end()) {
							dist.emplace(nxt, nd);
							pq.emplace(nd, nxt);
						} else if (nd < it->second) {
							it->second = nd;
							pq.emplace(nd, nxt);
						}
					}
				}
			}

			return int64_t(ans);
		};

		cout << go() << '\n';
	}

	return 0;
}


Measured memory_bytes: 4572
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    s=readline().strip()

    if s[0]==s[1] and s[0]==s[2]:
        yn(0)
    else:
        yn(1)
    #yn(n)

    return

if doTest==0:
    resolve()
    sys.exit()

Measured memory_bytes: 6768
#include<bits/stdc++.h>
using namespace std;
#define int long
#define pp pair<int,int>
#define PI M_PI
#define INF LONG_MAX
signed main() {
	int x1,y1,x2,y2,n,l;
	double res=0.0;
	cin>>x1>>y1>>x2>>y2>>n;
	vector<pp> coord;
	pp p;
	int dx=abs(x2-x1),dy=abs(y2-y1);
	vector<int> f;
	if(dx>dy){
		if(y2<y1||(y2==y1&&x2<x1))swap(x1,x2),swap(y1,y2);
		f=vector<int>(n,-1);
		for(int i=0;i<n;++i){
			cin>>p.first>>p.second;
			if(min(x1,x2)<=p.first && p.first<=max(x1,x2) && min(y1,y2)<=p.second && p.second<=max(y1,y2))coord.push_back(p);
		}
		sort(coord.begin(),coord.end(),[](pp& a,pp& b){return a.second<b.second;});
		for(int i=0;i<(int)coord.size();++i)f[i]=coord[i].first;
		f.erase(remove(f.begin(),f.end(),-1),f.end());
		vector<int> dp(f.size(),INF);
		if(x1>x2)reverse(f.begin(),f.end());
		for(int i=0;i<(int)f.size();++i)*lower_bound(dp.begin(),dp.end(),f[i])=f[i];
		l=lower_bound(dp.begin(),dp.end(),INF)-dp.begin();
	}
	else{
		if(x2<x1||(x2==x1&&y2<y1))swap(x1,x2),swap(y1,y2);
		f=vector<int>(n,-1);
		for(int i=0;i<n;++i){
			cin>>p.first>>p.second;
			if(min(x1,x2)<=p.first && p.first<=max(x1,x2) && min(y1,y2)<=p.second && p.second<=max(y1,y2))coord.push_back(p);
		}
		sort(coord.begin(),coord.end(),[](pp& a,pp& b){return a.first<b.first;});
		for(int i=0;i<(int)coord.size();++i)f[i]=coord[i].second;
		f.erase(remove(f.begin(),f.end(),-1),f.end());
		vector<int> dp(f.size(),INF);
		if(y1>y2)reverse(f.begin(),f.end());
		for(int i=0;i<(int)f.size();++i)*lower_bound(dp.begin(),dp.end(),f[i])=f[i];
		l=lower_bound(dp.begin(),dp.end(),INF)-dp.begin();
	}
	bool fl=min(dx,dy)+1==l;
	res=(dx+dy)*100.0+(5.0*PI-20.0)*(l-fl)+(10.0*PI-20.0)*fl;
	cout<<fixed<<setprecision(15)<<res<<endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb push_back
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD= 1e9+7 ;
const ll inf=1e18;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

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

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}

bool compare(string a, string b){
	if(a.length()==b.length())
		return a<b;
	return a.length()<b.length();
}

int main()
{
    fast;
    int t;
    t = 1;
    //~ cin>>t;
    
    while(t--){
		ll n;
		cin>>n;
		ll ans =0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					ans += __gcd(i, __gcd(j,k));
				}
			}
		}
		cout<<ans;
	}
    
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
 
using namespace std;
 
int main() {
	int D,N;
 
	cin >> D >> N;

	if (N == 100) {
		N ++;
	}  
 
	if (D == 0) {
		cout << N << endl;
	}  else  if (D == 1) {
 
		cout << 100 * N << endl;
	} else if (D==2) {
		cout << 100 * 100 * N << endl;
 
	} 
 
	return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    A = read_list()
    B = read_list()

    KA = 0
    KB = 0
    for a, b in zip(A, B):
        if a == b:
            continue

        if a > b:
            KB += a - b
            continue

        if a % 2 != b % 2:
            KB += 1
            b += 1

        KA += (b - a) // 2

    print("Yes" if KA >= KB else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 5488
#include<stdio.h>
int main()
{
	int i,j,k,n;
	char A[10000];
	scanf("%d",&n);
	scanf("%d",&j);
	for(i=1;i<=n+1;i++)
	{
		scanf("%c",&A[i]);
	}
	A[j+1]=A[j+1]+32;
	for(i=1;i<=n+1;i++)
	{
		printf("%c",A[i]);
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
// 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) { 
            int w = sc.nextInt();//たて
            int n = sc.nextInt();//よこ
            int[] values = new int[w];
            
            for (int i = 0; i < values.length; i++) { 
                values[i] = i + 1;
            }//番号の割振り
            
            for (int i = 0; i < n; i++) {
                String str = sc.next();
                String[] ab = str.split(",");//分割

                int a = Integer.parseInt(ab[0]) - 1; 
                int b = Integer.parseInt(ab[1]) - 1;
                 // aとbを使ってvaluesを操作しよう
                int c;

                c=values[a];
               values[a]=values[b];
                values[b]=c;
        }
        for(int q=0;q<values.length ; q++){
        System.out.println(values[q]);
    }
// valuesを出力しよう

        } 
    }
}
  


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

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int>a(q);
  vector<int>b(n,k-q);
  rep(i,q){
    cin>>a[i];
    --a[i];
    b[a[i]]++;
  }
  
  rep(j,n){
    if(b[j]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if (n <= 81 ) {
            for (int i = 9; i >= 1; i--) {
                if (n % i != 0) {
                    continue;
                }
                if (n / i < 10) {
                    System.out.println("Yes");
                    return;
                }
            }

        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
string n[120];
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a == 5 && b == 7 && c == 5)||(a == 7 && b == 5 && c == 5)||(a == 5 && b == 5 && c == 7))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  string S;
  ll K;
  cin >> S >> K;
  int num = -1;
  char next;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == '1') num = i + 1;
    else{
      next = S.at(i);
      break;
    }
  }
  if(K <= num) cout << 1 << endl;
  else cout << next << endl;
}

Measured memory_bytes: 256
/*
Contest: -
Problem: Atcoder Grand Contest 024 E
Author: tzc_wk
Time: 2020.7.22
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define y1			y1010101010101
#define y0			y0101010101010
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
int n=read(),k=read(),m=read();
int C[305][305],s[305][305],dp[305][305];
signed main(){
	fz(i,0,300){
		C[i][0]=1;
		fz(j,1,i)	C[i][j]=(C[i-1][j]+C[i-1][j-1])%m;
	}
//	printf("%d\n",C[5][3]);
	fz(i,0,k)	dp[1][i]=1;
	fd(i,k,0)	s[1][i]=(s[1][i+1]+dp[1][i])%m;
	fz(i,2,n+1){
		fz(j,0,k)
			fz(l,1,i-1)
				dp[i][j]=(dp[i][j]+C[i-2][l-1]*dp[i-l][j]%m*s[l][j+1]%m)%m;
		fd(j,k,0)	s[i][j]=(s[i][j+1]+dp[i][j])%m;
	}
	printf("%lld\n",dp[n+1][0]);
	return 0;
}

Measured memory_bytes: 5784
n = int(input())
ws = list(map(int,input().split()))

diff = 99999999999999999999999999
wf = 0
for i in range(n):
  wf += ws.pop()
  wl = sum(ws)
  d = abs(wl-wf)
  if d< diff:
    diff = d
print(diff)

Measured memory_bytes: 3060
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define ll long long
#define db double
#define P pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define INF 0x3f3f3f3f3f3f3f3f
#define N 200100
#define M 
using namespace std;

ll n,gg,ans,deep[N];
vector<ll>to[N];

void dfs(ll now,ll last)
{
    ll i,t;
    if(deep[now]>ans)
    {
	ans=deep[now];
	gg=now;
    }
    for(i=0;i<to[now].size();i++)
    {
	t=to[now][i];
	if(t==last) continue;
	deep[t]=deep[now]+1;
	dfs(t,now);
    }
}

int main()
{
    ll i,j,p,q;
    cin>>n;
    for(i=1;i<n;i++)
    {
	scanf("%lld%lld",&p,&q);
	to[p].push_back(q);
	to[q].push_back(p);
    }
    deep[1]=1;
    dfs(1,-1);
    deep[gg]=1;
    dfs(gg,-1);
    if(ans<=2)
    {
	if(ans==1) puts("First");
	else puts("Second");
	return 0;
    }
    if(ans%3==2) puts("Second");
    else puts("First");
}


Measured memory_bytes: 19712
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef long long ll;

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

int dis[100][100][4];

struct P {
  int y,x,d;
};
P p[100*100*4];

int main() {
  int h,w;
  ll l;
  char dir[4] = {'N','E','S','W'};
  
  while(cin>>h>>w>>l, h||w||l) {
    char ba[h][w];
    int x, y, d;
    REP(i,h) {
      REP(j,w) {
        cin >> ba[i][j];
        if (ba[i][j] != '.' && ba[i][j] != '#') {
          y = i;
          x = j;
          char c = ba[i][j];
          if (c=='N') d = 0;
          else if (c=='E') d = 1;
          else if (c=='S') d = 2;
          else if (c=='W') d = 3;
        }
      }
    }
    memset(dis, 0, sizeof(dis));
    memset(p, 0, sizeof(p));
    int cnt = 0;
    P ans;
    bool f = 0;
    while(1) {
      // if (f)
      //   printf("%d %d,%d %d\n",cnt, x,y,d);
      if (cnt == l) {
        ans = (P){y,x,d};
        break;
      }
      if (f&&dis[y][x][d]) {
        ll hoge = cnt - dis[y][x][d];
        l -= dis[y][x][d];
        //cout << l << endl;
        l %= hoge;
        //cout << l << " " << hoge << " " << l + dis[y][x][d] <<endl;
        ans = p[l + dis[y][x][d]];
        break;
      }
      if (f) {
        p[cnt] = (P){y,x,d};
        dis[y][x][d] = cnt;
      }
      f = 0;
      
      int yy = y+dy[d];
      int xx = x+dx[d];
      if (yy<0||yy>=h||xx<0||xx>=w||ba[yy][xx]=='#') {
        d = (d+1)%4;
      } else {
        x = xx;
        y = yy;
        cnt++;
        f = 1;
      }
    }
    // if (ans.y==34&&ans.x==37) {
    //   cout << "adslkfumsdlkfu" << endl << "................." << endl;
    //   cout << h << " " << w << " " <<  l << endl;
    // }
    printf("%d %d %c\n", ans.y+1, ans.x+1, dir[ans.d]);
  }
}

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

int main() {
    int n,a;
    cin>>n>>a;
    if (n%500<=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,t;cin>>n>>t;
  int mn = 1001;
  for(int i = 0; n > i; i++){
    int q,w;cin>>q>>w;
    if(t >= w)mn = min(mn,q);
  }
  if(mn == 1001)cout << "TLE" << endl;
  else cout << mn << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
    std::ios::sync_with_stdio(false);
	std::cin.tie(0);
    LL K,A,B;
    cin >> K >> A >> B;
    for(LL n = A;n <= B;n++){
        if(n%K == 0){
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
	return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    vector<int> V(5);
    rep(i,0,5)cin >> V[i];
    sort(V.begin(), V.end());
    ll mini = INF;
    do{
        ll t = 0;
        rep(i,0,5){
            t = (t + 9) / 10 * 10;
            t += V[i];
        }
        mini = min(mini, t);
    }while(next_permutation(V.begin(), V.end()));
    cout << mini << endl;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
p = [[a,'A'],[b,'B'],[c,'C'],[d,'D']]
p.sort()

if (p[1][1] == 'B' and p[2][1] == 'C') or (p[1][1] == 'D' and p[2][1] == 'A'):
    print(0)
else:
    print(p[2][0] - p[1][0])

Measured memory_bytes: 3064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<"\n";}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n){
		int a;cin>>a;
		in[i]-=a;
	}
	sort(all(in));
	int sum=0,co=0;
	rep(i,n)if(in[i]<0)sum-=in[i],co++;
	for(int i=n-1;i>=0;i--){
		if(sum<=0)break;
		if(in[i]>0){
			sum-=in[i];
			co++;
		}
	}
	if(sum>0)cout<<-1<<endl;
	else cout<<co<<endl;
}









Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int M = sc.nextInt();
			
			long[] as = new long[A];
			long[] bs = new long[B];
			for(int i = 0; i < A; i++) {
				as[i] = sc.nextLong();
			}
			for(int i = 0; i < B; i++) {
				bs[i] = sc.nextLong();
			}
			
			long answer = Arrays.stream(as).min().getAsLong() + Arrays.stream(bs).min().getAsLong();
			
			for(int i = 0; i < M; i++) {
				final int x = sc.nextInt() - 1;
				final int y = sc.nextInt() - 1;
				final long c = sc.nextLong();
				
				answer = Math.min(answer, as[x] + bs[y] - c);
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 56588
#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>;

//最大公約数を求める関数
ll gcd(ll a,ll b){
    ll c,d,e;
    c=max(a,b);
    d=min(a,b);
    while(1){
        c=c%d;
        if(c==0){
            break;
        }
        e=d;
        d=c;
        c=e;
    }
    return d;
}

int main(){
    ll n;
    cin >> n;
    vector <ll> a(n);
    vector <vector <ll>> bb(18);
    rep(i,n){
        cin >> a[i];
        bb[0].push_back(a[i]);
    }

    
    ll n2;
    n2=n;
    ll l;
    int k3;
    

   rep(i,17){
        if(n2%2==1){
            l=bb[i].size();
           bb[i].push_back(bb[i][l-1]);
       }
       if(n2==1){
           k3=i;
           break;
       }
       n2=(n2+1)/2;
       
      
       rep(j,n2){
           bb[i+1].push_back(gcd(bb[i][2*j],bb[i][2*j+1]));
       }
   }

   //rep(i,k3){
   //    l=bb[i].size();
   //    cout << "  " << i << endl;
   //    rep(j,l){
   //        cout << bb[i][j] << endl;
   //    }
   //}

   ll k4=1,ans,k5=0;
   vector <int> b(17,0),b2(17,0);
   ll ans2;
   ans2=gcd(bb[k3-1][0],bb[k3-1][1]);

   rep(i,n){
       b=b2;
       k4=1;
       k5=0;
       ans=bb[k3-1][0]*bb[k3-1][1];
       rep(j,k3){
           b[j]=((i>>(k3-j-1))&1);
            k5+=b[j];
            //cout << i << " " << b[j] << endl;
            if(b[j]==0){
                ans=gcd(ans,bb[k3-j-1][k5+1]);
            }
            else{
                ans=gcd(ans,bb[k3-j-1][k5-1]);
            }
            k5*=2;
       }
       //cout << ans << endl;
       ans2=max(ans,ans2);
   }

   cout << ans2 << endl;


    

    return 0;
}

Measured memory_bytes: 2676
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll a[323456],papa[312345],upd[312345],ans[312345];
int main(){
    std::ios::sync_with_stdio(false);
  ll n,m,i;
  ll sumi=0;
  cin>>n>>m;
  rep(i,n){
    cin>>a[i];
   
    
  }
  rep(i,n-1){
  	 if(a[i+1]>a[i])
      sumi+=a[i+1]-a[i];
    else
      sumi+=m+a[i+1]-a[i];
  }
 // cout<<sumi<<endl;
  ll haha=0;
  ll lol=0;
  rep(i,n-1){
    if(a[i]<a[i+1]){
      upd[a[i]+1]++;
      upd[a[i+1]]--;

      ans[a[i+1]]+=a[i+1]-a[i]-1;
    }
    else{
      upd[a[i]+1]++;
      upd[a[i+1]+m]--;
      ans[a[i+1]+m]+=m+a[i+1]-a[i]-1;
    }
  }
  haha=0;
  lol=0;
  rep(i,2*m+2){
    haha+=lol;
    papa[i%m]+=haha;
    haha-=ans[i];
    lol+=upd[i];
  }
  ll maxi=0;
  rep(i,m+1){
  	//cout<<sumi-papa[i]<<" ";
    maxi=max(maxi,papa[i]);
  }     
  //cout<<endl;
  cout<<sumi-maxi<<endl;

    
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

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

    if(s.size()<= k){
        cout << s << endl;
    } else {
        for (int i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;


int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,b,w;
    //float f,g,h;
    //char now,pre;
    string s;
    cin>>w>>a>>b;
    if(a<b)
    {
        if(a+w<b) cout<<b-a-w;
        else cout<<0;
    }
    else if(a==b) cout<<0;
    else
    {
        if(b+w<a) cout<<a-b-w;
        else cout<<0;
    }
    return 0;
}



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

using namespace std;

int main() {

	int k;
	cin >> k;
	string s;
	cin >> s;

	if (s.size() <= k) {
		cout << s << endl;
		return 0;
	}
	else {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}


	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int subtract;
    if((n%1000)==0){
        subtract = 1000;
    }
    else{
        subtract = n%1000;
    }
    int ans = 1000 - subtract;

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


Measured memory_bytes: 3464
N, M, Q = map(int, input().split())

query = []

for _ in range(Q):
    query.append(tuple(map(int, input().split())))

res = 0


def solve(A):
    global res
    if len(A) == N:
        tmp = 0
        for q in query:
            a, b, c, d = q

            if A[b - 1] - A[a - 1] == c:
                tmp += d
        res = max(res, tmp)
        return

    for i in range(A[-1], M + 1):
        solve(A + [i])


for i in range(1, M + 1):
    solve([i])
print(res)


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;

bool isprime(int x)
{

    int n=sqrt(x);
    for(int i = 2;i<=n;i++)
        if(x%i==0)
        return false;
    return true;
}

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

while(!isprime(x))
    x++;

    cout<<x<<endl;
 return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int num_of_two(int n) {
    int ans = 0;
    while(n % 2 == 0) {
        ans++;
        n /= 2;
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        ans += num_of_two(tmp);
    }
    cout << ans << endl;
}

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

int main(void){
  int N;
  cin >> N;
  vector<string> s(N);
  vector<int> t(N);
  string X;
  for(int i = 0; i < N; i++){
    cin >> s.at(i) >> t.at(i);
  }
  cin >> X;

  int flag;
  for(int i = 0; i < N; i++){
    if(s.at(i) == X){
      flag = i;
      break;
    }
  }

  int ans;
  if(flag+1 == N){
    ans = 0;
  }else{
    ans = accumulate(next(t.begin(),flag+1), t.end(), 0);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline

H,W=list(map(int,input().split()))
N=int(input())
a=list(map(int,input().split()))
ans = []
for i,ai in enumerate(a):
    ans +=[i+1]*ai
ans = np.array(ans).reshape(H,W).tolist()
for i in range(len(ans)):
    if i%2 == 0:
        print(*ans[i])
    else:
        print(*(ans[i][::-1]))



Measured memory_bytes: 27472
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  cout << (n - 2) * 180 << endl;

  return 0;
}


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

#define rep(i,m,n) for(int i=m;i<n;i++)
#define pb push_back
#define ll long long 
#define out(n) cout<<#n<<' = '<<'\n'

using namespace std;

const int maxn=2e5+10;
int a[maxn];
int ans[maxn];

int main()
{
    int n;
    cin>>n;
    rep(i,0,n-1)
    {
        cin>>a[i];
        ans[a[i]]++;
    }
    rep(i,1,n+1) cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 5196
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(){
    int D;
	cin >> D;
    if(D == 25){
        cout<<"Christmas"<<endl;
    } else if(D == 24){
        cout<<"Christmas Eve"<<endl;
    }else if(D==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else if(D==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
	
	
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 998244353 
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   int m,d;
   cin>>m>>d;
   int ans=0;
   for(int i=1;i<=m;i++)
   {
   	for(int j=1;j<=d;j++)
   	{
   		string t;
   		int x=j;
   		while(x)
   		{
   			t.pb('0'+x%10);
   			x=x/10;
   		}
   		if(t.size()==2)
   		{
   			if(t[0]-'0'>=2&&t[1]-'0'>=2)
   			{
   				if(i==(t[0]-'0')*(t[1]-'0'))
   					ans++;
   			}
   		}
   	}
   }
   cout<<ans<<endl;
}        

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char n;
	cin>>n;
	if(n=='T')cout<<"A"<<endl;
	if(n=='A')cout<<"T"<<endl;
	if(n=='G')cout<<"C"<<endl;
	if(n=='C')cout<<"G"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] oddCount = new int[100001];
        int[] evenCount = new int[100001];

        int oddMostAppearedCount = 0;
        int oddMostAppearedValue = 0;

        int evenMostAppearedCount = 0;
        int evenMostAppearedValue = 0;

        for (int i = 0; i < N; i++) {
            int value = sc.nextInt();
            if (i % 2 == 0) {
                evenCount[value] = evenCount[value] + 1;
                if (evenCount[value] > evenMostAppearedCount) {
                    evenMostAppearedValue = value;
                    evenMostAppearedCount = evenCount[value];
                }
            } else {
                oddCount[value] = oddCount[value] + 1;
                if (oddCount[value] > oddMostAppearedCount) {
                    oddMostAppearedValue = value;
                    oddMostAppearedCount = oddCount[value];
                }
            }
        }
        Arrays.sort(evenCount);
        Arrays.sort(oddCount);

        if (oddMostAppearedValue != evenMostAppearedValue) {
            System.out.println(N - evenCount[100000] - oddCount[100000]);
        } else {
            // evenの方を２番めに多いもので書き換える場合
            int evenOverWrite = (N / 2) - evenCount[99999] + (N / 2) - oddCount[100000];
            // oddの方を２番めに多いもので書き換える場合
            int oddOverWrite = (N / 2) - oddCount[99999] + (N / 2) - evenCount[100000];

            System.out.println(Math.min(evenOverWrite, oddOverWrite));
        }
    }


}


Measured memory_bytes: 60252
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  vector<int> data(4);
  data.at(0) = A;
  data.at(1) = B;
  data.at(2) = A - 1;
  data.at(3) = B - 1;
  sort(data.begin(), data.end());
  cout << data.at(2) + data.at(3) << endl;
  return 0;
}

Measured memory_bytes: 256
// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 1e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
const int N = 1e5 + 5;
int n, k, x[N];
int main() {
    SYNC
    cin >> n >> k;
    FOR0(i, n) cin >> x[i];
    vector<int> v1({0}), v2({0});
    FOR0(i, n) {
        if(x[i] > 0) v1.push_back(x[i]);
        else v2.push_back(-x[i]);
    }
    sort(v2.begin(), v2.end());
    // FOR(i, 1, v1.size()) v1[i] += v1[i-1];
    // FOR(i, 1, v2.size()) v2[i] += v2[i-1];
    int ans = inf;
    for(int x : v1) cerr << x << endl;
        for(int x : v2) cerr << x << endl;
    FOR(i, 0, min(k+1, (int)v1.size())) {
        if(k - i < v2.size()) {
            ans = min(ans, v1[i] + v1[i] + v2[k-i]);
        }
    }
    swap(v1, v2);
    FOR(i, 0, min(k+1, (int)v1.size())) {
        if(k - i < v2.size()) {
            ans = min(ans, v1[i] + v1[i] + v2[k-i]);
        }
    }
    if(v1.size() > k) ans = min(ans, v1[k]);
    if(v2.size() > k) ans = min(ans, v2[k]);
    cout << ans;
}

Measured memory_bytes: 1404
/*
	边覆盖与不覆盖作为状态非常不好 dp
	可能有多个点覆盖这条边然后就转移不了
	考虑容斥, 这样子我就可以只关注图的某种连通性了
	说到连通性 dp, 常见套路是枚举断不断父边, 然后就可以做了 
*/
#include <bits/stdc++.h>
#define N 5005

using namespace std;

const int mod = 1e9 + 7;

int n;
int head[N], nex[N << 1], to[N << 1], cntE;
int f[N][N], g[N], siz[N], tmp[N];

inline void addE(int u, int v) {
	to[++cntE] = v;
	nex[cntE] = head[u], head[u] = cntE;
}
void dfs(int u, int fa) {
	f[u][siz[u] = 1] = 1;
	for(int i = head[u], v; i; i = nex[i]) {
		v = to[i];
		if(v == fa) continue;
		dfs(v, u);
		memset(tmp, 0, sizeof tmp);
		for(int i = 1; i <= siz[u]; ++i)
			for(int j = 0; j <= siz[v]; ++j)
				tmp[i + j] = (tmp[i + j] + 1LL * f[u][i] * f[v][j]) % mod;
		siz[u] += siz[v];
		for(int i = 1; i <= siz[u]; ++i)
			f[u][i] = tmp[i];
	}
	for(int i = 2; i <= siz[u]; ++i)
		f[u][0] = (f[u][0] - 1LL * f[u][i] * g[i] % mod + mod) % mod;
}

int main() {
	scanf("%d", &n);
	for(int i = 1, u, v; i < n; ++i) {
		scanf("%d %d", &u, &v);
		addE(u, v), addE(v, u);
	}
	
	g[0] = 1;
	for(int i = 2; i <= n; i += 2)
		g[i] = (i - 1LL) * g[i - 2] % mod;
	
	dfs(1, 0);
	
	printf("%d\n", mod - f[1][0]);
	return 0;
}

Measured memory_bytes: 97152
import java.util.*;

class Main{
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();

	if (a < b){
		System.out.println("a < b");
	}else if (a > b){
		System.out.println("a > b");
	}else
		System.out.println("a == b");
	}
}


Measured memory_bytes: 26332
n, k = map(int, input().split())
a = list(map(int, input().split()))
# score = [0 for i in range(n)]
# # cnt = 1
# for i in range(n):
#     if i < k - 1:
#         score[i] = a[i]
#     elif i == k - 1:
#         score[i] = score[i - 1] * a[i]
#     else:
#         score[i] = score[i - 1] * a[i] / a[i - k]
# # print("score =", score)
# for i in range(k, n):
#     if score[i] > score[i - 1]:
#         print("Yes")
#     else:
#         print("No")
for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 94100
while true 
    m, f, r = gets.split.map {|s| s.to_i} 
    if m == -1 && f == -1 && r == -1 
        break    
    end 
    
    if m == -1 || f == -1 
        puts "F"
    elsif m + f >= 80 
        puts "A"
    elsif m + f >= 65 
        puts "B"
    elsif m + f >= 50 
        puts "C"
    elsif m + f >= 30
        if r >= 50
            puts "C"
        else
            puts "D"
        end 
    else
        puts "F"
    end
end


Measured memory_bytes: 6868
import sys
input = sys.stdin.readline
Q = 10**9+7
def main():
    N = int( input())
    S = input()
    left = 0
    ans = 1
    for i in range(N*2):
        s = S[i]
        if s == "B":
            if left%2 == 0:
                left += 1
            else:
                ans *= left
                left -= 1
        else:
            if left%2 == 1:
                left += 1
            else:
                ans *= left
                left -= 1
        ans %= Q
    if left > 0 or ans == 0:
        print(0)
        return
    for i in range(1,N+1):
        ans *= i
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()

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

int main(){
    int N; cin >> N;
    map<string,ll> A; //<key,value>
    
    rep(i,N){
        string S; cin >> S;
        sort(S.begin(),S.end());
        A[S]++;
    }
    
    ll ans=0;
    for (auto i:A){
        ll x=i.second;
        ans+=x*(x-1)/2;
    }
    
    cout << ans;
    
    
}

Measured memory_bytes: 11136