akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],vis[5001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

    ll a,b,c,d,ans=-1000000000000000011;
    cin>>a>>b>>c>>d;
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    cout<<ans<<endl;

    return 0;
}


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

namespace ITP1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<List<int>>();
            string input;
            while ((input = Console.ReadLine()) != "0 0")
                list.Add(input.Split(' ').Select(x => Convert.ToInt32(x)).ToList());
            foreach (var l in list)
            {
                l.Sort();
                Console.WriteLine(l[0] + " " + l[1]);
            }
        }      
    }
}

Measured memory_bytes: 10272
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

class UF(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        '''
        x が属するグループを探索
        '''
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        '''
        x と y のグループを結合
        '''
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        '''
        x と y が同じグループか否か
        '''
        return self.find(x) == self.find(y)

    def get_size(self, x):
        '''
        x が属するグループの要素数
        '''
        x = self.find(x)
        return self.size[x]

N,M = II()
p = III()
p = list(map(lambda x:x-1, p))
x,y = Line(M)

place = [0]*N
for i in range(N):
    place[p[i]] = i

uf = UF(N)
for i in range(M):
    uf.union(x[i]-1, y[i]-1)

ans = 0
for i in range(N):
    if uf.is_same(i,place[i]):
        ans += 1

print(ans)

Measured memory_bytes: 108524
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
	
	string A,B,C;
	cin>>A;
	cin>>B;
	cin>>C;
	
	transform(A.begin(),A.end(),A.begin(),::toupper);
	transform(B.begin(),B.end(),B.begin(),::toupper);
	transform(C.begin(),C.end(),C.begin(),::toupper);
	
	cout<<A[0]<<B[0]<<C[0]<<endl;
	
return 0;
};

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

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(W < 2*r || H < 2*r){
		printf("No\n");
		return 0;
	}
	
	if(x >= r && x <= W - r && y >= r && y <= H - r){
		printf("Yes\n");
		return 0;
	}else{
		printf("No\n");
		return 0;
	}
}


Measured memory_bytes: 2000
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int aa[100000];
int bb[100000];

int main() {
    int a, b, m, mina = 1e9, minb = 1e9, ans = 1e9;
    cin >> a >> b >> m;
    for (int i = 0; i < a; ++i) {
        cin >> aa[i];
        mina = min(mina, aa[i]);
    }
    for (int i = 0; i < b; ++i) {
        cin >> bb[i];
        minb = min(minb, bb[i]);
    }
    ans = min(ans, mina + minb);
    int x, y, c;
    while (m--) {
        cin >> x >> y >> c;
        ans = min(ans, aa[x - 1] + bb[y - 1] - c);
    }
    cout << max(0, ans) << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str[] = br.readLine().split(" ");
	int A = Integer.parseInt(str[0]);
	int B = Integer.parseInt(str[1]);

	if (A > 0 && A < 10 && B > 0 && B < 10)
	    System.out.println(A * B);
	else
	    System.out.println(-1);
    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N, L;
    cin >> N >> L;

    vector<int> A(N);
    int ans = 0, res = 1e+9;
    REP(i, N){
        A[i] = L+i;
        ans += A[i];

        if (abs(A[i]) < abs(res)){
            res = A[i];
        }
    }

    ans = ans - res;
    cout << ans << endl;
}

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

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

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

#define INF 2123456789
#define IINF 9123456789123456789
#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
/*
template <typename... Args>
void dbg(Args... args) {
    ((cout << args << " "), ...);
    cout << "\n";
}
*/
//--------------------------------------------------//
int N;
vector<int> ans[100010];
void solve(int m) {
    if (m == 2) {
        ans[0] = ans[1] = {1};
        return;
    }
    solve(m - 1);
    int pv = (m - 1) * (m - 2) / 2 + 1;
    rep(i, m - 1) ans[i].push_back(pv), ans[m - 1].push_back(pv), pv++;
}
int main() {
    use_cio();
    cin >> N;
    int sq = sqrt(2LL * N);
    sq--;
    while (1LL * sq * (sq + 1) <= 2LL * N) sq++;
    if (1LL * sq * (sq - 1) == 2LL * N) {
        cout << "Yes\n";
        cout << sq << "\n";
        solve(sq);
        rep(i, sq) {
            cout << ans[i].size() << " ";
            for (auto x : ans[i]) cout << x << " ";
            cout << endl;
        }
    } else
        cout << "No\n";
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

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

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

using namespace std;

#define N 100005

ld dist(ld a, ld b) {
	return a*a + b*b;
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   pair<ld,ld> arr[n];
   
   rep(n)
        cin>>arr[i].ff>>arr[i].ss;
   
   /*pair<ld,ld> p;
   ld dis = inf;
   
   repi(x,1001)
        repi(y,1001)
        {
            ld temp = 0;
            repi(i,n)
            {
                ld temp1 = (x-arr[i].ff)*(x-arr[i].ff) + (y-arr[i].ss)*(y-arr[i].ss);
                temp = max(temp,temp1);
            }
            
            if(temp<dis)
            {
                dis = temp;
                p = mp(x,y);
            }
        }
   
 //cout<<p.ff<<" "<<p.ss<<" "<<sqrt(dis)<<"\n";
  
  for(ld i=-1;i<=1;i+=0.000001)
        {
            ld x1 = p.ff + i;
            ld y1 = p.ss;
            ld temp = 0;
            repi(i1,n)
            {
                ld temp1 = (x1-arr[i1].ff)*(x1-arr[i1].ff) + (y1-arr[i1].ss)*(y1-arr[i1].ss);
                temp = max(temp,temp1);
            }
            
            dis = min(dis,temp);
            if(dis == temp)
                p = mp(x1,y1);
        }
   
   for(ld i=-1;i<=1;i+=0.000001)
        {
            ld x1 = p.ff;
            ld y1 = p.ss+i;
            ld temp = 0;
            repi(i1,n)
            {
                ld temp1 = (x1-arr[i1].ff)*(x1-arr[i1].ff) + (y1-arr[i1].ss)*(y1-arr[i1].ss);
                temp = max(temp,temp1);
            }
            
            dis = min(dis,temp);
            if(dis == temp)
                p = mp(x1,y1);
        }
              
   
   cout<<fixed<<setprecision(12)<<sqrt(dis);*/
   
   pair<ld,ld> p = mp(0,0);
   rep(n)
        p.ff+=arr[i].ff, p.ss+=arr[i].ss;
   p.ff/=n, p.ss/=n;
   //cout<<p.ff<<" "<<p.ss<<"\n";
   ld fd = 10000000000;
   ld inc = 0.1;
   rep(500000)
   {
       ll f = 0;
       ld dis = dist(p.ff-arr[0].ff, p.ss-arr[0].ss);
       repi(j,n)
       {
           ld temp = dist(p.ff-arr[j].ff, p.ss-arr[j].ss);
           //cout<<"from "<<arr[j].ff<<" "<<arr[j].ss<<" and "<<p.ff<<" "<<p.ss<<" = "<<temp<<"\n";
           if(temp>dis)
           {
               dis = temp;
               f = j;
           }
       }
       //cout<<"at "<<p.ff<<" "<<p.ss<<" = "<<dis<<"\n";
       fd = min(fd,dis);
       //cout<<fd<<"\n";       
       p.ff +=(arr[f].ff-p.ff)*inc;
       p.ss +=(arr[f].ss-p.ss)*inc;
       inc*=0.999;
   }
   
   cout<<fixed<<setprecision(12)<<sqrt(fd);
   
   
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int n;
	cin >> n;
	vector<P> ball(n);
	rep(i,n) cin >> ball[i].first >> ball[i].second;
	sort(ball.begin(), ball.end());
	map<P, int> mp;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			int a = ball[j].first - ball[i].first;
			int b = ball[j].second - ball[i].second;
			mp[P(a, b)]++;
		}
	}
	int mx = 0;
	for(auto e: mp){
		chmax(mx, e.second);
	}
	int ans = n-mx;
	cout << ans << endl;

}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	getchar();
	if(A==B && B!=C)
	{
		printf("Yes\n");
	}
	else if (A==C && B!=A){
		printf("Yes\n");
	}
	else if (B==C && A!=B){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1640
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var a = o.a();
  var b = o.a();
  return Math.min(b,n*a);
}

Measured memory_bytes: 22964
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int N,L;

int main(void) {
  cin >> N >> L;
  
  int sum=0;
  int m=1000;
  for(int i=1; i<=N; i++){
    sum = sum+ L + i - 1;
    if(abs(L+i-1) < abs(m)) m = L+i-1;
  }
  
  cout << sum - m << endl;
  
  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll min=LINF;
  rep(i,5){
    ll a; cin>>a;
    chmin(min,a);
  }
  cout<<4+(n+min-1)/min<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  rep(i,sz(s)){
    if(s[i]=='?')s[i]='D';
  }
  COUT(s);
}

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

int main() {
int n;
cin >> n;
long long xa,ya,ha=0;
  vector<int> x(n);
  vector<int> y(n);
  vector<long long> h(n);

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

    for(int j=0;j<101;j++){
      for(int k=0;k<101;k++){
        long long H;
        for(int l=0;l<n;l++){
        if(h[l]!=0){
        H=abs(x[l]-j)+abs(y[l]-k)+h[l];
        break;
        }
        }
          for(int i=0;i<n;i++){
            if(h[i]!=0){
              if(abs(x[i]-j)+abs(y[i]-k)+h[i]==H)cnt++;
            }
            else if(h[i]==0){
              if(abs(x[i]-j)+abs(y[i]-k)+h[i]>=H)cnt++;
            }
          }
          if(cnt==n){
            xa=j;ya=k;ha=H;
          }
          cnt=0;
      }
    }


  cout << xa << ' ' << ya << ' ' << ha << endl;
}


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

#define int long long

signed main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;

	priority_queue<pair<int,int> > h;

	while(a--){
		int w;
		cin>>w;
		h.push(make_pair(w,1));
	}
	
	while(b--){
		int w;
		cin>>w;
		h.push(make_pair(w,2));
	}
	
	while(c--){
		int w;
		cin>>w;
		h.push(make_pair(w,3));
	}
	
	int z=x+y;
	int ans=0;
	
	while(z){
		pair<int,int> f=h.top();
		h.pop();
		if(f.second==3){
			ans+=f.first;
			--z;
		}
		else if(f.second==1 && x){
			ans+=f.first;
			--x;
			--z;
		}
		else if(f.second==2 && y){
			ans+=f.first;
			--y;
			--z;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    long long sum = 0;
    
    vector<int> R, G, B;
    for (int i = 0; i < n; i++) {
        switch (s[i]) {
            case 'R':
                R.push_back(i);
                break;
            case 'G':
                G.push_back(i);
                break;
            case 'B':
                B.push_back(i);
                break;
        }
    }
    
    for (auto r : R) {
        for (auto g : G) {
            sum += B.size();

            int s = min(r, g);
            int l = max(r, g);
            // rが小さく、gが大きくなる
            
            // 幅を求める
            int w = l - s;
            
            // 幅が偶数の時
            if (w % 2 == 0) {
                auto p = find(B.begin(), B.end(), s + w/2);
                if (p != B.end())
                    sum--;
            }
            
            // 
            auto p = find(B.begin(), B.end(), s - w);
            if (p != B.end())
                sum--;
            auto q = find(B.begin(), B.end(), l + w);
            if (q != B.end())
                sum--;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
//  Created by ZJYelizaveta on 2017年11月18日 星期六 21时25分50秒
//  Copyright (c) 2017年 ZJYelizaveta. All rights reserved.

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
template<typename T> T readIn() {
	T 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;
}
const int MAX_N = 200 + 3;
const int INF = 0x3f3f3f3f;
int h, w;
int c[MAX_N][MAX_N];
int a[MAX_N][MAX_N];
int dis[MAX_N][MAX_N];

int main()
{
	h = readIn<int>(); w = readIn<int>();
	for (int i = 0; i <= 9; ++i) {
		for (int j = 0; j <= 9; ++j) {
			c[i][j] = readIn<int>();
			dis[i][j] = c[i][j];
		}
	}
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) a[i][j] = readIn<int>();
	}

	for (int k = 0; k <= 9; ++k) {
		for (int i = 0; i <= 9; ++i) {
			for (int j = 0; j <= 9; ++j) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) if (a[i][j] != -1 && a[i][j] != 1) {
			ans += dis[a[i][j]][1];
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define maxn -20000000000 //negative value to break code and force you to put right constraint

#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 100000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;


const ll mod = 1e9 + 7;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int> f(62);
	for(int i=0;i<n;i++)
	{
		ll x;cin>>x;
		for(int j=0;j<62;j++)
		{
			if(x & (1LL<<j) ){
				f[j]++;
			}

		}
	}
	ll ans=0;
	for(int i=0;i<62;i++)
	{
	
		ll prod=(1LL<<i)%mod;
		prod=(prod*f[i])%mod;
		prod=(prod*(n-f[i]))%mod;
		ans=(ans+prod)%mod;
	}
	cout<<ans;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int32_t N;
int64_t a[334334];

int64_t kohan_sum_cache[334334];

struct heap_t {
	int32_t count;
	int64_t data[334334];
};

struct heap_t zenhan, kohan;

void heap_adjust(int64_t heap[], int64_t heap_count, int32_t pos) {
	for (;;) {
		int32_t next_idx = pos;
		int64_t next_value = heap[pos];
		if (pos * 2 + 1 < heap_count && heap[pos * 2 + 1] < next_value) {
			next_value = heap[next_idx = pos * 2 + 1];
		}
		if (pos * 2 + 2 < heap_count && heap[pos * 2 + 2] < next_value) {
			next_value = heap[next_idx = pos * 2 + 2];
		}
		if (next_idx == pos) {
			if (pos == 0) break;
			pos = (pos - 1) / 2;
		} else {
			int64_t t = heap[pos];
			heap[pos] = heap[next_idx];
			heap[next_idx] = t;
			pos = next_idx;
		}
	}
}

void heap_add(struct heap_t* heap, int64_t num) {
	heap->data[heap->count++] = num;
	heap_adjust(heap->data, heap->count, heap->count - 1);
}

int64_t heap_top(const struct heap_t* heap) {
	return heap->count <= 0 ? 0 : heap->data[0];
}

void heap_pop(struct heap_t* heap) {
	if (heap->count > 1) heap->data[0] = heap->data[heap->count - 1];
	if (heap->count > 0) {
		heap->count--;
		heap_adjust(heap->data, heap->count, 0);
	}
}

int main(void) {
	int32_t i;
	int64_t zenhan_sum = 0, kohan_sum = 0;
	int64_t answer;
	if (scanf("%" SCNd32, &N) != 1) return 1;
	for (i = 0; i < 3 * N; i++) {
		if (scanf("%" SCNd64, &a[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		heap_add(&zenhan, a[i]);
		heap_add(&kohan, -a[3 * N - 1 - i]);
		zenhan_sum += a[i];
		kohan_sum -= a[3 * N - 1 - i];
	}
	kohan_sum_cache[N] = kohan_sum;
	for (i = 0; i < N; i++) {
		heap_add(&kohan, -a[2 * N - 1 - i]);
		kohan_sum = kohan_sum - a[2 * N - 1 - i] - heap_top(&kohan);
		heap_pop(&kohan);
		kohan_sum_cache[N - 1 - i] = kohan_sum;
	}
	answer = zenhan_sum + kohan_sum_cache[0];
	for (i = 0; i < N; i++) {
		heap_add(&zenhan, a[N + i]);
		zenhan_sum = zenhan_sum + a[N + i] - heap_top(&zenhan);
		heap_pop(&zenhan);
		if (zenhan_sum + kohan_sum_cache[i + 1] > answer) answer = zenhan_sum + kohan_sum_cache[i + 1];
	}
	printf("%" PRId64 "\n", answer);
	return 0;
}

/*
数列を前半と後半に分ける (それぞれのサイズはN以上2N以下)
分け方を全探索
それぞれの分け方について、前半は小さいやつから外し、後半は大きいやつから外す
*/


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#define modulus 1000000007
#define ll long long
using namespace std;

int n, x, mini = -1, res = -1;
vector<int> arr(105);

int main(){
    cin >> x >> n;
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr.begin(), arr.begin()+n);
    // cout << binary_searcnegateh(arr.begin(), arr.begin()+n, 6) << endl;
    for(int i = 0; i <= 200; i++){
        if(!binary_search(arr.begin(), arr.begin()+n, i)){
            if(mini == -1 || abs(i - x) < mini){
                mini = abs(i - x);
                res = i;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3676
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
using namespace std::chrono; 

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
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;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define db cout << " HERE " << endl;
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001;
int vis[1000002];
int n ;
vi adj[MX];
ll path[MX];
void dfs(int x) {
	if(path[x]!=-1)
	return ;
	path[x] = 0 ;
	for(auto i : adj[x]) {
		dfs(i);
		path[x] = max(path[x],path[i]+1);
	}
}
int main() {
	int n , m ;
	cin >> n >> m ;
	memset(path , -1 , sizeof path);
	while(m--) {
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
	}
	F0R(i,n+1) {
		dfs(i);
	}
	ll ans = 0;
	F0R(i,n+1) {
		ans = max(ans,path[i]);
	}
	cout << ans << endl;
}
// template by benq


Measured memory_bytes: 14956
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const selectionSort = arr => {
    let count = 0;
    for (let i = 0; i < arr.length; i++) {
        let min = i;
        for (let j = i; j < arr.length; j++) {
            if (arr[j] < arr[min]) {
                min = j;
            }
        }
        const tmp = arr[i];
        arr[i] = arr[min];
        arr[min] = tmp;
        if (i !== min) count++;
    }
    
    console.log(arr.map(x => x.toString()).join(' '));

    return count;
}

console.log(selectionSort(line[1].split(' ').map(x => parseInt(x))));


Measured memory_bytes: 15636
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int dp[100005][3];

int main() {
    int N; cin >> N;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < N; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]});
    return 0;
}

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

int main(int argc, const char * argv[]) {
    int r, D, x;
    
    cin >> r >> D >> x;
    int x2 = 0;
    for (int i = 0; i < 10; i++) {
        x2 = r * x - D;
        cout << x2 << endl;
        x = x2;
    }
    
    return 0;
}

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int count = 1;//最後の文字
  for(int i = 0; i < n-1; i++){
    if(s[i] != s[i+1]) count++;
  }
  cout << count;
}

Measured memory_bytes: 512
import math
n, m = map(int, input().split())
if n <= 1:
    a = 0
else:
    a = math.factorial(n)//(2*math.factorial(n-2))
if m <= 1:
    b = 0
else:
    b = math.factorial(m)//(2*math.factorial(m-2))
print(a + b)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int n,a[100100][3];
int dp[100100][3];
/*
a 0
b 1
c 2
*/

int main() {
 cin>>n;
  rep(i,n) cin>>a[i+1][0]>>a[i+1][1]>>a[i+1][2];
  ///
  for(int i=1;i<=n;i++){
    rep(j,3){
       rep(k,3){
         if(j==k) continue;
  		 chmax(dp[i][j],dp[i-1][k]+a[i][j]); 
       }
    }
  }
  int ans=0;
  rep(i,3){
    ans=max(ans,dp[n][i]);
  }
  cout<<ans <<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int b[25];
int main(void){
	int n,m,c; scanf("%d %d %d",&n,&m,&c);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	int dab = 0;
	for(int i=0;i<n;i++){
		int ans = 0;
		for(int j=1;j<=m;j++){
			int x; scanf("%d",&x);
			ans += x*b[j];
		}
		ans+=c;
		if(ans>0) dab++;
	}
	printf("%d",dab);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<set>
#include<string>
#include<stdlib.h>
typedef long long ll;
using namespace std;

//stringの使い方
int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c) {
		cout << "Yes" << endl;
		return 0;
	}
	if (b == a + c) {
		cout << "Yes" << endl;
		return 0;
	}
	if (c == b + a) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
  	return 0;
}

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

bool is_prime(int n) {
  for (int i=2; i<=sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin>>n;
  vector<int> v;
  for (int i=3; i<=55555; i+=2) {
    if (is_prime(i) && i % 5 == 1) {
      v.push_back(i);
      if (v.size() > n) {
        break;
      }
    }
  }
  for (int i=0; i<n; i++) {
    cout<<v[i];
    if (i != n - 1) {
      cout<<" ";
    }
  }
  cout<<endl;
}

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

int main(){
  string sa,sb,sc,s(3,1);
  cin>>sa>>sb>>sc;
  s[0]=sa[0]-32;
  s[1]=sb[0]-32;
  s[2]=sc[0]-32;
  cout<<s<<endl;
  
 return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
	string s;
	cin >> s;
	bool a = 0, b = 0;
	for (char &c : s) {
		if (c == 'A') a = 1;
		else b = 1;
	}
	cout << (a && b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main() {
	int a=read();
	if (a%1000==0) cout<<0<<endl;
	else cout<<1000-a%1000<<endl;
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<tuple<int,vector<int>,int>> a(M);
  for(auto &i:a){
    int j;
    cin>>j;
    vector<int> p(j);
    for(int &k:p){
      int o;
      cin>>o;
      k=o-1;
    }
    i=make_tuple(j,p,0);
  }
  for(auto &i:a)
    cin>>get<2>(i);
  int l=0;
  for(int tmp=0;tmp<(1<<N);tmp++){
    bitset<10> s(tmp);
    bool bo=true;
    for(auto &i:a){
      int k=0;
      for(auto &j:get<1>(i))
        if(s.test(j))
          k++;
      if(k%2!=get<2>(i)){
        bo=false;
        break;
      }
    }
    if(bo)
      l++;
  }
  cout<<l<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
const int mod=998244353;
LL jc[2500005];
void add(LL &x,LL y){x=(x+y)%mod;}
LL sqrr(LL x){return x*x%mod;}
LL ksm(LL x,int y){
    if (y==0) return 1;if (y==1) return x;
    LL ans=sqrr(ksm(x,y>>1));
    if (y&1) ans=ans*x%mod;
    return ans;
}
LL ny(LL x){return ksm(x,mod-2);}
LL C(int n,int m){return jc[n]*ny(jc[m])%mod*ny(jc[n-m])%mod;}
LL calf(int n,int s){
    return C(n+s-1,s);
}
LL cal1(int n,int m,int k){
    if (k>n) return 0;
    if ((k^m)&1) return 0;
    return C(n,k)*calf(n,(m*3-k)/2)%mod;
}
LL cal2(int n,int m,int k){
    if (k>n) return 0;
    return C(n,k)*k%mod*calf(k,m-k)%mod;
}
void init(){
    const int n=2500000;
    jc[0]=1;
    for (int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mod;
}
int main(){
   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    init();
    int n,m,m3;cin>>n>>m;m3=m*3;
    LL ans=calf(n,m3);
    for (int i=m+1;i<=m3;i++) add(ans,mod-cal1(n,m,i));
    for (int i=1;i<=m;i++) add(ans,mod-cal2(n,m,i));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 19712
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列
#include <map> //map



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

int n;
string S[200010];
map<string, int> M;
int Max;




int main() {
	cin >> n;
	rep(i, n) {
		cin >> S[i];
		M[S[i]] += 1;
		Max = max(Max, M[S[i]]);
	}
	for (auto itr = M.begin(); itr != M.end(); itr++) {
		if (itr->second == Max) {
			cout << itr->first << endl;
		}
	}

	return 0;
}



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

Measured memory_bytes: 1808
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		long N = long.Parse(str[3]);
		long ans = 0;
		for(var i=0;i<=N/A;i++){
			for(var j=0;j<=N/B;j++){
				long c1 = (N-(i*A+j*B))/C;
				if(i*A+j*B+c1*C==N && c1>=0){
					ans += 1;
				}
			}
		}
		Console.WriteLine(ans);
	}
}

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

int a[200000]{};

int main() {
    int n;

    cin >> n;
    
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    int maxv{-99999999999}, minv{a[0]};
    
    for(int j = 1; j < n; j++) {
        maxv = (maxv > (a[j] - minv)) ? maxv : (a[j] - minv);
        minv = (minv < a[j]) ? minv : a[j];
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef int64_t lint;
constexpr lint LINF = LLONG_MAX/2;

int main() {
	int N;
	cin >> N;
	lint a=LINF, b=0, c=LINF, d=0, x, y, z=1000000007;
	rep(i, N) {
		cin >> x >> y;
		a = min(x+y, a);
		b = max(x+y, b);
		c = min(x+(z-y), c);
		d = max(x+(z-y), d);
	}
	std::cout << max(b-a, d-c) << '\n';
}


Measured memory_bytes: 3528
#include <stdio.h>
#include <string.h>

int main (int argc,char **argv)
{
	char x[2],y[2];
	int a = 0;

	scanf("%s %s",x,y);

	a = strcmp(x,y);
	if (a == 0)
	{
		printf("=\n");
	}

	else if (a < 0)
	{
		printf("<\n");
	}

	else
	{
		printf(">\n");
	}

	return 0;
}

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

int map[21][21];
int main() {
  int n,m,x,y;
  string s;
  while(cin>>n, n) {
    for(int i=0; i<=20; ++i)
      for(int j=0; j<=20; ++j)
	map[i][j] = 0;

    for(int i=0; i<n; ++i) {
      cin>>x>>y;
      map[x][y] = 1;
    }

    cin>>m;
    int nx=10,ny=10,count = 0;
    for(int i=0; i<m; ++i) {
      cin>>s>>x;
      if(s == "N") {
	for(int j=0; j<x; ++j) {
	  ny++;
	  if(map[nx][ny]) {
	    count++;
	    map[nx][ny] = 0;
	  }
	}
      }else if(s == "E") {
	for(int j=0; j<x; ++j) {
	  nx++;
	  if(map[nx][ny]) {
	    count++;
	    map[nx][ny] = 0;
	  }
	}
      }else if(s == "W") {
	for(int j=0; j<x; ++j) {
	  nx--;
	  if(map[nx][ny]) {
	    count++;
	    map[nx][ny] = 0;
	  }
	}
      }else if(s == "S") {
	for(int j=0; j<x; ++j) {
	  ny--;
	  if(map[nx][ny]) {
	    count++;
	    map[nx][ny] = 0;
	  }
	}
      }
    }

    if(count == n) {
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 0
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    v<P> A(N);
    rep(i,N){
        auto& [a,b]=A[i];
        cin>>a;
        b=i;
    }
    RSORT(A);
    ll dp[N+1][N+1]={}; // 何人見てる, 上に入れた数 うれしさ
    rep(i,N){
        rep(j,N){
            if(i<j) continue;
            ll ue=j,sita=N-1-(i-j);
            auto [a,b]=A[i];
            maxi(dp[i+1][j+1],dp[i][j]+a*abs(ue-b));
            maxi(dp[i+1][j],dp[i][j]+a*abs(sita-b));
        }
    }
    ll ans=0;
    rep(i,N+1){
        maxi(ans,dp[N][i]);
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; while(Qkai--) Main();
    Main();
}
//-----------------------------------------

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        if(x + y == 3){
            System.out.println(3);
        }else if(x + y == 4){
            System.out.println(2);
        }else{
            System.out.println(1);
        }

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
struct node
{
	ll a,b;
}c[100005];
ll cmp(node x,node y)
{
	return x.a<y.a;
}
int main()
{
    ll n,m;
    while(cin>>n>>m){
    	memset(c,(0,0),sizeof(c));
    	for(ll i=0;i<n;i++) cin>>c[i].a>>c[i].b;
    	sort(c,c+n,cmp);
    	ll sum=0;
    	ll t=m;
    	for(ll i=0;i<n;i++){
    		if(c[i].b<=t){
    			t-=c[i].b;
    			sum+=c[i].b*c[i].a;
    		}else{
    			sum+=c[i].a*t;
    			break;
    		}
    	}
    	cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		char[][]a=new char[H][W];
		for(int i=0;i<H;i++) {
			String s=sc.next();
			a[i]=s.toCharArray();
		}
		int[]alph=new int[26];
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				alph[a[i][j]-'a']++;
			}
		}
		int g1=(H%2)*(W%2);
		int g2=(H/2)*(W%2)+(W/2)*(H%2);
		int g3=(H/2)*(W/2);
		
		
		for(int i=0;i<26;i++) {
			g3-=alph[i]/4;
			alph[i]%=4;
			
			g2-=alph[i]/2;
			alph[i]%=2;
			
			g1-=alph[i]%2;
		}
		String ans="Yes";
		if(g3>0)ans="No";
		g2+=2*g3;
		if(g2>0)ans="No";
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N,A,B,i,j,sum = 0;
    cin >> N >> A >> B;

    for(i = 1; i <= N; i++) {
        int C = 0,D = i;
        for(j = 0; j < 5; j++) {
            C += D % 10;
            D /= 10;
        }
        if(A <= C && C <= B) {
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a/gcd(a,b)*b;}
// head

int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);
	
		
	int n;
	cin >> n;
	VI a(n), dp(n);
	rep(i, 0, n) cin >> a[i];
	dp[0] = 0; dp[1] = abs(a[1] - a[0]);
	rep(i, 2, n){
		dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] - a[i]));
	}
	cout << dp[n-1] << endl;
}




Measured memory_bytes: 1024
const line = require('fs').readFileSync('/dev/stdin','utf8').trim()
const n = parseInt(line)

var numberOfUnevenNumbers = 0
for(i=1;i<=n;i++) {
  var iString = i.toString()

  if(iString.length % 2 === 1) {
    numberOfUnevenNumbers++
  }
}

console.log(numberOfUnevenNumbers)


Measured memory_bytes: 10944
N=int(input())
l=[[] for i in range(N)]
color=[0]*N
mem=[]
for i in range(N-1):
   a,b=list(map(int,input().split()))
   a-=1;b-=1
   l[a].append(b)
   mem.append(b)
from collections import deque
que=deque([0])
while que:
   node=que.popleft()
   c=1
   for i in l[node]:
      if color[node]==c:
         c+=1
      color[i]=c
      c+=1
      que.append(i)
print(max(color))
for i in mem:
   print(color[i])


Measured memory_bytes: 92420
#include<bits/stdc++.h>
#define ll long long
#define f first
#define  s second
#define pii pair<int,int>
#define pll pair<ll,l>
#define ull unsigned ll
#define mp make_pair
#define pb push_back

using namespace std;

int n;
vector<int>t[2000001];
map<int,int>used;
int a[500001];
int b[500001];

void build(int v,int l,int r){
	if(l==r){
		t[v].pb(b[l]);
		return;
	}
	int m=(l+r)/2;
	build(2*v,l,m);
	build(2*v+1,m+1,r);
	t[v].resize((int)t[2*v].size()+(int)t[2*v+1].size());
	merge(t[2*v].begin(),t[2*v].end(),t[2*v+1].begin(),t[2*v+1].end(),t[v].begin());
}
int x;
int get(int v,int l,int r,int tl,int tr){
	if(l==tl&&r==tr){
		int k=upper_bound(t[v].begin(),t[v].end(),x)-t[v].begin();
		return (int)t[v].size()-k;
	}
	int tm=(tl+tr)/2;
	if(r<=tm)return  get(2*v,l,r,tl,tm);
	if(l>tm)return get(2*v+1,l,r,tm+1,tr);
	return get(2*v,l,tm,tl,tm)+get(2*v+1,tm+1,r,tm+1,tr);
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int q;
	cin>>n>>q;
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for(int i=n;i>=1;i--){
		if(used[a[i]]==0){
			used[a[i]]=i;
			b[i]=INT_MAX;
		}
		else b[i]=used[a[i]],used[a[i]]=i;
	}
	build(1,1,n);
	while(q--){
		int l,r;cin>>l>>r;
		x=r;
		cout<<get(1,l,r,1,n)<<"\n";
	}
	return 0;
}


Measured memory_bytes: 140720
K = int(input())
table = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
c = 9
result = []
for i in table:
  runrun = i
  if runrun[-1] == '0':
    table.extend([runrun + str(int(runrun[-1])), 
                   runrun + str(int(runrun[-1])+1)])
    c += 2
  elif runrun[-1] == '9':
    table.extend([runrun + str(int(runrun[-1])-1), 
                   runrun + str(int(runrun[-1]))])
    c += 2
  else:
    table.extend([runrun + str(int(runrun[-1])-1), 
                   runrun + str(int(runrun[-1])), 
                   runrun + str(int(runrun[-1])+1)])
    c += 3
  if c>=K:
    print(table[K-1])
    exit()


Measured memory_bytes: 50268