akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
// << left shift *2 and >>right shift /2
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
long long int dp[4000][4000];
long long int c[4000][4000];//0 mtlb i-1,j   1 mtlb i,j-1   2 mtlb i-1,j-1
void solve()
{
    string s,t;cin>>t>>s;long long int m=s.size(),n=t.size();
    if(s[0]==t[0])dp[0][0]=1,c[0][0]=2;
    for(long long int i=0;i<n;i++)
    {
        for(long long int j=0;j<m;j++)
        {
            // s ka char na lu
            if(i>0)
            dp[i][j]=dp[i-1][j],c[i][j]=0;
            // t ka char na lu
            if(j>0)
            if(dp[i][j-1]>dp[i][j])
            dp[i][j]=dp[i][j-1],c[i][j]=1;
            // agr dono same to dono lu
            if(i>0 && j>0 && s[j]==t[i] && dp[i-1][j-1]+1>=dp[i][j])
            dp[i][j]=1+dp[i-1][j-1],c[i][j]=2;
            else if(s[j]==t[i] )
            dp[i][j]=1,c[i][j]=2;
        }
    }
    string ans="";
    long long int i=n-1,j=m-1;
    while(i>=0 && j>=0)
    {
        if(c[i][j]==0)
        i--;
        else if(c[i][j]==1)
        j--;
        else
        {
            ans+=s[j],i--,j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;
    //cin>>t;long long int temp=t;
    while(t--)
    {
        //cout<<"Case "<<temp-t<<": ";
        solve();
    }
}


Measured memory_bytes: 168544
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>
#include <map>

using namespace std;

int main(){

	int a,b,c;
	cin>>a>>b>>c;
	int flag=0;
	if(a==b && b!=c)flag=1;
	if(a==c && a!=b)flag=1;
	if(b==c && a!=b)flag=1;

	if(flag==1)cout<<"Yes";
	else cout<<"No";

	cout<<endl;

	return 0;
}


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

int main(){
    string s,t; cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    map<char,int> smp,tmp;
    map<int,int> sint,tint;
    rep(i,s.size()) smp[s[i]]++;
    rep(i,t.size()) tmp[t[i]]++;
    for(auto itr=smp.begin();itr!=smp.end();++itr){
        sint[itr->second]++;//登場回数がitr->second回の文字が何種類あるか何種類あるか
    }
    for(auto itr=tmp.begin();itr!=tmp.end();++itr){
        tint[itr->second]++;//登場回数がitr->second回の文字が何種類あるか何種類あるか
    }
    for(auto itr=sint.begin();itr!=sint.end();++itr){
        if(itr->second != tint[itr->first]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String x = sc.next();
   String s = "0";
   for( int i = 0; i <= 2 ; i++){
     String y = x.substring(i, i+1);
	  if( y.equals(x.substring(i + 1, i + 2))){
        System.out.println("Bad");
        s = "1";
        break;
      }
    }
    if( s.equals("0")){
      System.out.println("Good");
    }
  }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
#define P pair<int,int>
#define pb push_back
#define lb(x) (x&(-x))
#define ALL(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int M = 120000;
const int inf = 0x3f3f3f3f;
int n,m,k;
int a[M];
int fac[M];
int inv[M];
ll dp[25][M]={0};
const int md=1e9+7;
void ini() {
	fac[0] = inv[0] = inv[1] = 1;
	fo(i,2,M-1) {
		inv[i] = 1ll*(md-md/i)*inv[md%i]%md;
	}
	fo(i,1,M-1) {
		fac[i] = 1ll*fac[i-1]*i%md;
		inv[i] = 1ll*inv[i-1]*inv[i]%md;
	}
}
int C(int n,int m){
	if(m>n) return 0;
	return 1ll*fac[n]*inv[n-m]%md*inv[m]%md;
}
int main() {
	cin>>n>>k;
	fo(i,1,k) cin>>a[i];
	ini();
	dp[0][0]=1;
	fo(i,1,k) {
		fo(x,0,a[i]){
			ll mul=1ll*C(n-x,a[i]-x)*inv[x]%md;
			fo(j,0,n-x){
				dp[i][j+x]=(dp[i][j+x]+dp[i-1][j]*mul)%md;
			}
		}
	}
	cout<<dp[k][n]*fac[n]%md<<endl;
	return 0;
}


Measured memory_bytes: 20736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<limits>

using namespace std;

int main(void) {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int h, t, b = 0;
	h = 0;
	t = s.size() - 1;
	while (h < t) {
		int u = 0;
		while (s[h] == 'x') {
			h++;
			u++;
		}
		while (s[t] == 'x') {
			t--;
			u--;
		}
		b += abs(u);
		if (s[h] != s[t]) {
			cout << -1 << endl;
			system("pause");
			return 0;
		}
		h++;
		t--;
	}
	cout << b << endl;
	system("pause");
	return 0;
}

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

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;

int n, m, q;
bool b[2000][2000];
int v[2000][2000];
int c[2000][2000];
int r[2000][2000];
int vs[2001][2001];
int cs[2001][2001];
int rs[2001][2001];

int main() {
    cin >> n >> m >> q;
    rep(i,n) rep(j,m) {
        char x; cin >> x;
        if(x == '1') b[i][j] = true;
        else b[i][j] = false;
    }
    rep(i,n) rep(j,m) {
        if(!b[i][j]) continue;
        if(i != n-1 && b[i+1][j]) v[i+1][j]++;
        if(j != m-1 && b[i][j+1]) v[i][j+1]++;
        if(i != n-1 && b[i+1][j]) r[i+1][j]++;
        if(j != m-1 && b[i][j+1]) c[i][j+1]++;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            vs[i][j] = vs[i-1][j]+vs[i][j-1]-vs[i-1][j-1]+b[i-1][j-1];
            rs[i][j] = rs[i-1][j]+rs[i][j-1]-rs[i-1][j-1]+r[i-1][j-1];
            cs[i][j] = cs[i-1][j]+cs[i][j-1]-cs[i-1][j-1]+c[i-1][j-1];
        }
    }
    rep(i,q) {
        int x, y, _x, _y;
        cin >> x >> y >> _x >> _y;
        int vv = vs[_x][_y]-vs[x-1][_y]-vs[_x][y-1]+vs[x-1][y-1];
        int rr = rs[_x][_y]-rs[x][_y]-rs[_x][y-1]+rs[x][y-1];
        int cc = cs[_x][_y]-cs[x-1][_y]-cs[_x][y]+cs[x-1][y];
        cout << vv - rr - cc << endl;
    }
}


Measured memory_bytes: 99328
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

use std::ops::Add;
use std::ops::Sub;

struct Point {
    x: f64,
    y: f64,
}

impl Point {
    fn new(x: f64, y: f64) -> Point {
        Point { x, y }
    }

    fn print(&self) {
        println!("{} {}", self.x, self.y);
    }

    fn rot(&self, theta: f64) -> Point {
        let c = theta.cos();
        let s = theta.sin();
        let x = c * self.x - s * self.y;
        let y = s * self.x + c * self.y;
        Point::new(x, y)
    }
}

impl Clone for Point {
    fn clone(&self) -> Point {
        Point::new(self.x, self.y)
    }
}

impl Add for Point {
    type Output = Point;

    fn add(self, other: Point) -> Point {
        Point::new(self.x + other.x, self.y + other.y)
    }
}

impl Sub for Point {
    type Output = Point;

    fn sub(self, other: Point) -> Point {
        Point::new(self.x - other.x, self.y - other.y)
    }
}

fn koch(n: u32, p1: &Point, p2: &Point) {
    if n == 0 {
        p1.print();
    } else {
        let sx = p1.x * 2.0 / 3.0 + p2.x / 3.0;
        let sy = p1.y * 2.0 / 3.0 + p2.y / 3.0;
        let tx = p1.x / 3.0 + p2.x * 2.0 / 3.0;
        let ty = p1.y / 3.0 + p2.y * 2.0 / 3.0;
        let s = Point::new(sx, sy);
        let t = Point::new(tx, ty);
        let tmp = t.clone() - s.clone();
        let u = s.clone() + tmp.rot(std::f64::consts::PI / 3.0);
        koch(n - 1, &p1, &s);
        koch(n - 1, &s, &u);
        koch(n - 1, &u, &t);
        koch(n - 1, &t, &p2);
    }
}

fn main() {
    let n: u32 = read();

    let p1 = Point::new(0.0, 0.0);
    let p2 = Point::new(100.0, 0.0);

    koch(n, &p1, &p2);
    p2.print();
}



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

using namespace std;

#define INF ((1LL<<31)-1)
#define D 16

struct SegTree {
	int segSize, realSegSize, nodeSize;
	vector<int> seg;

	void init(int n) {
		realSegSize = n;

		nodeSize = 0;
		for (segSize = 1; segSize < n; segSize *= D) nodeSize += segSize;

		seg = vector<int>(nodeSize+n, INF);
	}

	int get(int n) {
		if (n < (int)seg.size()) return seg[n];
		else return INF;
	}
	void set(int n, int v) {
		if (n < (int)seg.size()) seg[n] = v;
	}

	void update(int pos, int val) {
		int n = nodeSize + pos;
		set(n, val);
		while (n) {
			n = (n-1)/D;

			int r = INF;
			for (int i = 0; i < D; ++i) {
				r = min(r, seg[n*D+i+1]);
			}
			set(n, r);
		}
	}
	int get(int n, int l, int r, int L, int R) {
//		cout << n << " " << l << " " << r << endl;
		if (L <= l && r <= R) return get(n);
		else if (R <= l || r <= L) return INF;
		else {
			int ret = INF;
			int prev = l;
			for (int i = 0; i < D; ++i) {
				int next = i == D-1 ? r : prev + (r-l)/D;
				ret = min(ret, get(n*D+i+1, prev, next, L, R));
				prev = next;
			}
			return ret;
		}
	}
	int get(int L, int R) {
		return get(0, 0, segSize, L, R);
	}
};

struct Query {
	int y1, x1, y2, x2;
};

int main() {
	int H, W, Q;
	while ( cin >> H >> W >> Q, H || W || Q ) {
		vector< vector<int> > m(H, vector<int>(W, 0));

		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				cin >> m[y][x];
			}
		}

		bool isSegRow = H < W;
		vector<SegTree> seg;

		if (isSegRow) {
			seg.resize(H);
			for (int y = 0; y < H; ++y) {
				seg[y].init(W);
			}
		}
		else {
			seg.resize(W);
			for (int x = 0; x < W; ++x) {
				seg[x].init(H);
			}
		}

		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (isSegRow) seg[y].update(x, m[y][x]);
				else seg[x].update(y, m[y][x]);
			}
		}

		for (int t = 0; t < Q; ++t) {
			int y1, x1, y2, x2; cin >> y1 >> x1 >> y2 >> x2;

			int ans = INF;
			if (isSegRow) {
				for (int y = y1; y <= y2; ++y) {
					ans = min(ans, seg[y].get(x1, x2+1));
				}
			}
			else {
				for (int x = x1; x <= x2; ++x) {
					ans = min(ans, seg[x].get(y1, y2+1));
				}
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 64008
/* ex3_4
   kohei_suzuki */

#include <stdio.h>

int main(void){
    int n, m=9 ; //割られる整数nと割る整数m

    scanf("%d",&n); //nを入力

    int l = n / m; //nをmで割った整数l

    while(n % m != 0){ //9から順に1ずつ割っていき、割り切れるまで繰り返す
        m -= 1;
        l = n / m;
    }

    if(l < 10){ //割り切れてかつlが10より小さければyes
        printf("Yes\n");
    }else{ //それ以外ならno
        printf("No\n");
    }

    return 0;
}

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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    rep(i, N - 1) {
        int a;
        cin >> a;
        A[a - 1]++;
    }
    rep(i, N) {
        cout << A[i] << endl;
    }

}



Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int, int>
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	string s;
	cin >> s;
	int n = SZ(s);
	REP(i,26){
		vector<int> v(n+1,0);
		v[0] = (s[0] == 'a'+i);
		FOR(j,0,n){
			v[j+1] = v[j]+(s[j] == 'a'+i);
		}
		DEBUG(char('a'+i));
		dpite(ALL(v));
		FOR(l,2,4) REP(j,n-l+1){
			// DEBUG(l); DEBUG(ceil((l+1)/2.));
			if(v[j+l]-v[j] >= ceil((l+1)/2.)){
				cout << j+1 << ' ' << j+l << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << endl;
	return 0;
}


Measured memory_bytes: 848
x = int(input())

alphbet = lambda c: chr(c+64)

def Base_10_to_n(X, n):
    X_dumy = X
    out = []
    while X_dumy > 0:
      if X_dumy % n == 0:
        out.append( 26 )
        X_dumy = int(X_dumy / n - 1)
      else:
        out.append( X_dumy % n )
        X_dumy = int(X_dumy / n)
    return out
if 1 <= x <= 1000000000000001:
    out = Base_10_to_n(x, 26)[::-1]
    print( "".join(alphbet(i) for i in out).lower())


Measured memory_bytes: 9188
#include <iostream>
#include <vector>

using namespace std;

void descendingOrderSort(vector<int>& cards);
void swap(int& left, int& right);

int main() {
    int numOfCards = 0;
    cin >> numOfCards;
    vector<int> cards;
    int number;
    for (int i = 0; i < numOfCards; ++i) {
        cin >> number;
        cards.push_back(number);
    }
    
    descendingOrderSort(cards);
    
    int  scoreOfAlice = 0;
    for (size_t i = 0; i < cards.size(); i += 2) {
        scoreOfAlice += cards.at(i);
    }
    
    int  scoreOfBob = 0;
    for (size_t i = 1; i < cards.size(); i += 2) {
        scoreOfBob += cards.at(i);
    }    
    
    cout << scoreOfAlice - scoreOfBob << endl;
}
        
void descendingOrderSort(vector<int>& cards) {
    for (size_t i = cards.size() - 1; i > 0; --i) {
        for (size_t j = 0; j < i; ++j) {
            if (cards.at(j) < cards.at(j + 1)) {
                swap(cards.at(j), cards.at(j + 1));
            }
        }
    }
}    

void swap(int& left, int& right) {
    int temp = left;
    left = right;
    right = temp;
}


Measured memory_bytes: 3640
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        List<Long> list = new ArrayList<Long>();
        Scanner scan = new Scanner(System.in);
        long n = (long)scan.nextLong();
 
        for(int i = 0 ; i < 5; i++) {
            list.add(scan.nextLong());
        }
        long p = 0;
        long min = Collections.min(list);

        if(n % min == 0){
            p = n / min;
        } else {
            p = n / min + 1;
        }

        System.out.println(4 + p);
    }
}

Measured memory_bytes: 23764
#include <stdio.h>
#define Max(a,b) a>b?a:b
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a == b)
    {
        printf("%d\n",2 * a);
    }
    else
    {
        int max = Max(a,b);
        printf("%d\n",2 * max - 1);
        return 0;
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int n, count=0; long double d,x,y,distance;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        distance = sqrt((x*x)+(y*y));
        //cout<<"distance= "<<distance<<"\n";
        if (distance<=d)
        count++;
    }
    cout<<count;

}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red\n";
    }
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val an = Vector.fill(sc.nextInt)(sc.nextInt)
  val map: mutable.Map[Int, Int] = mutable.Map()

  for {
    a <- an
  } yield {
    update(a - 1)
    update(a)
    update(a + 1)
  }

  val ans = map.maxBy(_._2)._2

  println(ans)

  def update(a: Int): Unit = {
    map.update(a, map.getOrElse(a, 0) + 1)
  }

}


Measured memory_bytes: 53692
#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
using namespace std;

int main(){
	int n,c=1;
	while(cin>>n){
		if(n==0) break;

		vector<int> x,y;
		for(int i=0;i<n;i++){
			int xx,yy;
			cin>>xx>>yy;
			x.push_back(xx);
			y.push_back(yy);
		}

		double sums=x[x.size()-1]*y[0]-x[0]*y[y.size()-1];
		for(int i=0;i<x.size()-1;i++){
			sums += x[i]*y[i+1] - x[i+1]*y[i];
		}
		printf("%d %.1lf\n", c++, fabs(sums)/2.0);

		string str;
		getline(cin, str);
	}
	return 0;
}

Measured memory_bytes: 1280
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

X, K, D = map(int, input().split())

if abs(D * K) > abs(X):
    is_over = True
else:
    is_over = False

if not (is_over):
    print(abs(X) - abs(D * K))
else:
    m = abs(X) // abs(D)
    r = K - m
    val1 = abs(X) % abs(D)
    val2 = val1 - abs(D)
    # if abs(val1) <= abs(val2):
    if r % 2 == 0:
        print(abs(val1))
    else:
        print(abs(val2))
    # else:
    #     if r % 2 == 0:
    #         print(val1)
    #     else:
    #         print(val2)



Measured memory_bytes: 65576
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	string s;
	cin >> s;
	int n = s.size();
	if ((s.front() == s.back()) ^ (n&1))
	{
		cout << "First" << endl;
	}
	else
	{
		cout << "Second" << endl;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

void solve() {
	int n, m;
	cin >> n >> m;
	vector<set<pair<int, int>>> res(n);
	for (int i = 0; i < m; i++) {
		int p, x;
		cin >> p >> x;
		res[p - 1].insert({x, i});
	}
	vector<string> id(m);
	for (int i = 0; i < n; i++) {
		int k = 1;
		for (auto x : res[i]) {
			string pref = to_string(i + 1);
			pref = string(6 - pref.size(), '0') + pref;
			string suf = to_string(k);
			suf = string(6 - suf.size(), '0') + suf;
			id[x.second] = pref + suf;
			k++;
		}
	}
	for (int i = 0; i < m; i++) {
		cout << id[i] << '\n';
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 15940
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int Max=0;
    vector<vector<int>> vec(n+1,vector<int>(n+1,0));
    vec[n][n]=1;
    for(int i=n;i>=1;i--){
        for(int j=n;j>=1;j--){
            if(i==n&&j==n)continue;
             else if(i==j){
                vec[i][j]=vec[i+1][j+1]+1;
                continue;
            }
            else if(j==n){
                if(s[i-1]==s[n-1]){
                    vec[i][j]=1;
                }else{
                    vec[i][j]=0;
                }
                continue;
            }
            else if(i==n){
                if(s[j-1]==s[n-1]){
                    vec[i][j]=1;
                }
                continue;
            }
            else if(s[i-1]==s[j-1]){
                vec[i][j]=vec[i+1][j+1]+1;
            }else{
                vec[i][j]=0;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
          //  cout<<vec[i][j]<<" ";
            if(j>=i+vec[i][j]){
                Max=max(Max,vec[i][j]);
            }
        }
       // cout<<endl;
    }
    cout<<Max<<endl;
}

Measured memory_bytes: 98176
//2020-05-12 22:28:36
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)

using namespace std;
using ll = long long;
struct query
{
    ll n, x, m;
    query(ll n, ll x, ll m):n(n),x(x),m(m){}
};

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll k, q; cin >> k >> q;
    vector<ll> d;
    rep(i, k){
        ll di; cin >> di;
        d.push_back(di);
    }
    vector<query> v;
    rep(i, q){
        ll n, x, m; cin >> n >> x >> m;
        v.push_back(query(n, x, m));
    }
    vector<ll> di(k);
    for (auto &&i : v){
        di[0] = d[0] % i.m;
        ll cnt0 = (d[0]%i.m==0);
        for (int j = 1; j < k; j++){
            di[j] = di[j-1] + d[j] % i.m;
            cnt0 += (d[j]%i.m==0);
        }
        ll y = di[k-1] * ((i.n-1) / k);
        cnt0 *= (i.n-1)/k;
        rep(j, (i.n-1)%k){
            y += d[j]%(i.m);
            cnt0 += (d[j]%i.m==0);
        }
        ll ans = i.n-1 - (i.x%i.m + y) / i.m - cnt0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s[] = new String[n];
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
			if(s[i].equals("AC"))
				ac++;
			else if(s[i].equals("WA"))
				wa++;
			else if(s[i].equals("TLE"))
				tle++;
			else if(s[i].equals("RE"))
				re++;
		}
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
		
	}

}


Measured memory_bytes: 64376
N = int(input())
points = []
for i in range(0, N):
    points.append(list(map(int, input().split(' '))))
X = dict()
Y = dict()
count = 0
for p in points:
    if p[0] not in X.keys():
        X[p[0]] = []
    X[p[0]].append(p[1])
    if p[1] not in Y.keys():
        Y[p[1]] = []
    Y[p[1]].append(p[0])
while len(X.items()) > 0:
    item = list(X.items())[0]
    del X[item[0]]
    queue = [item]
    point_dict = {'x': [], 'y': []}
    queue_is_x = [True]
    while len(queue) > 0:
        item = queue.pop(0)
        is_x = queue_is_x.pop(0)
        if is_x:
            point_dict['x'].append(item[0])
            for i in item[1]:
                if i in Y.keys():
                    queue.append((i, Y[i]))
                    queue_is_x.append(False)
                    del Y[i]
        else:
            point_dict['y'].append(item[0])
            for i in item[1]:
                if i in X.keys():
                    queue.append((i, X[i]))
                    queue_is_x.append(True)
                    del X[i]
    # print((point_dict['x']))
    # print(len((point_dict['x'])))
    # print((point_dict['y']))
    # print(len((point_dict['y'])))
    count += len(set(point_dict['x'])) * len(set(point_dict['y']))

print(count - len(points))

Measured memory_bytes: 43924
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7
 

def main():
    n = int(input())
    d = dict()
    for _ in range(n):
        s = input()
        d.setdefault(s, 0)
        d[s] += 1
    d = sorted(d.items(), key=lambda x: (-x[1], x[0]))
    maxc = d[0][1]
    for row in d:
        if row[1]<maxc:
            exit()
        print(row[0])
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 57436
#include <stdio.h>

int check(int y, int m, int d, int e);

int iy, im, id;

int main(void) {
	int e;
	while (scanf("%d %d %d", &iy, &im, &id) != EOF) {
		e = check(1868, 9, 8, 0);
		e = check(1912, 7, 30, e);
		e = check(1926, 12, 25, e);
		e = check(1989, 1, 8, e);
		switch(e) {
			case 0:
				printf("pre-meiji\n");
				break;
			case 1:
				printf("meiji %d %d %d\n", iy -1868+1, im, id);
				break;
			case 2:
				printf("taisho %d %d %d\n", iy -1912+1, im, id);
				break;
			case 3:
				printf("showa %d %d %d\n", iy -1926+1, im, id);
				break;
			case 4:
				printf("heisei %d %d %d\n", iy -1989+1, im, id);
				break;
		}
	}
	return 0;
}

int check(int y, int m, int d, int e) {
	if (y < iy || ((y == iy) && ((m < im) || ((m == im) && (d <= id)))))
		return e+1;
	else
		return e;
}

Measured memory_bytes: 608
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

bool dMap[10];

int findMin(int num) {
    int i = num;
    for (; i < 10; i++) {
        if (!dMap[i])
            return i;
    }
    return -1;
}

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

    REP(i, K) {
        int di;
        cin >> di;
        dMap[di] = true;
    }

    int n[6] = {0};
    int k = 0;
    while (N > 0) {
        n[k] = N % 10;
        k++;
        N /= 10;
    }
    k--;

    int minNum = findMin(0);

    for (int i = k; i >= 0;) {
        if (!dMap[n[i]]) {
            i--;
            continue;
        }

        for (int j = 0; j < i; j++)
            n[j] = minNum;
        
        int m = findMin(n[i]);
        if (m != -1) {
            n[i] = m;
            i--;
        } else {
            n[i] = minNum;
            n[i + 1]++;
            k = max(k, i + 1);
            i++;
        }
    }

    int base = 1;
    int r = 0;
    for (int i = 0; i <= k; i++) {
        r += base * n[i];
        base *= 10;
    }
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = 0;
		}
		for (int i = 0; i < N - 1; i++) {
			A[Integer.parseInt(sc.next()) - 1]++;
		}

		for (int i = 0; i < N; i++) {
			System.out.println(A[i]);
		}
	}
}


Measured memory_bytes: 50416
#include<stdio.h>

int compare_int(const void *a,const void *b){
    return *(int*)a - *(int*)b;
}


int main(void){
    int N=0,M=0,ans=0;

    scanf("%d %d",&N,&M);

    int X[M],comp[M-1];

    for(int i=0;i<M;i++){
        scanf("%d",&X[i]);
        
    }
    
    qsort(X,M,sizeof(int),compare_int);
    
    for(int i=0;i<M-1;i++){
        comp[i]=X[i+1]-X[i];
    }

    qsort(comp,M-1,sizeof(int),compare_int);
    
    for(int i=0;i<M-N;i++){
        ans+=comp[i];
    }

    printf("%d",ans);
    

    return 0;
}

Measured memory_bytes: 1396
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read()[0];
    let mut a: Vec<i64> = read();
    a.sort();
    let mut ans: i64 = 0;
    for i in 0..n {
        ans += a[n + 2 * i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 13428
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,k,q;
		n = sc.nextInt();
		k = sc.nextInt();
		q = sc.nextInt();
		Map<Integer,Integer> mp = new HashMap<>();
		for(int i = 0;i < n; ++i){
			mp.put(i,k);
		}
		for(int i = 0;i < q; ++i){
			int x = sc.nextInt();
			--x;
			mp.put(x,mp.get(x) + 1);
		}
		for(int i = 0;i < n; ++i){
			int cur = mp.get(i);
			if(cur - q > 0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 87200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int a, b, x;
  cin >> a >> b >> x;
  if(a<=x && a+b>=x){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let h: usize = sc.read();
    let w: usize = sc.read();

    let board: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect();
    let mut blue = vec![vec!['.'; w]; h];
    let mut red = vec![vec!['.'; w]; h];
    for i in 0..h {
        for j in 0..w {
            if j == 0 {
                red[i][j] = '#';
            } else if j == w - 1 {
                blue[i][j] = '#';
            } else if i % 2 == 0 {
                red[i][j] = '#';
            } else {
                blue[i][j] = '#';
            }

            if board[i][j] == '#' {
                red[i][j] = '#';
                blue[i][j] = '#';
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            print!("{}", red[i][j]);
        }
        println!();
    }
    println!();
    for i in 0..h {
        for j in 0..w {
            print!("{}", blue[i][j]);
        }
        println!();
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int bit_count(int x) {
    int res = 0;
    while (x>0 && x%2==0) {
        res++;
        x /= 2;
    }
    return res;
}

int main() {
	int n;
	cin >> n;
    string s;
    cin >> s;
    vector<int> a(n);
    rep(i,n) a[i] = s[i] - '1';

    vector<int> comb_bit_count(n);
    comb_bit_count[0] = 0;
    rep(i,n-1) {
        comb_bit_count[i+1] = comb_bit_count[i] + bit_count(n-1-i) - bit_count(i+1);
        // cout << comb_bit_count[i+1] << endl;
    }

    int ans = 0;
    rep(i,n) {
        if (comb_bit_count[i]==0) {
            ans += a[i];
            ans %= 2;
        }
    }
    // 答えは0,1,2のどれか
    // 1なら1で確定
    if (ans==1) {
        cout << ans << endl;
        return 0;
    }
    // 入力に2(変換後1)が含まれていれば2にはならないので0
    rep(i,n) {
        if (a[i]==1) {
            cout << 0 << endl;
            return 0;
        }
    }
    // 1/2で0,2を判定、結果を2倍して出力
    ans = 0;
    rep(i,n) {
        if (comb_bit_count[i]==0) {
            ans += a[i]/2;
            ans %= 2;
        }
    }
	cout << ans*2 << endl;
	return 0;
}


Measured memory_bytes: 9220
/**
*    author:  y_takano
*    created: 18.06.2020 15:14:49
**/

#include <bits/stdc++.h>

using namespace std;

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

  cout << i/3600 << ":" << i%3600/60 << ":" << i%60 << "\n";

  return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MOD = 1000000007;

int main(){
    string S;
    while(cin >> S){
        vector<int> dp(13, 0);
        dp[0] = 1;
        int m = 1;
        for(int i=S.size()-1;i>=0;i--){
            vector<int> next(13, 0);
            for(int j=0;j<10;j++){
                if(S[i] == '?' || S[i]-'0' == j){
                    for(int k=0;k<13;k++){
                        int key = (m*j+k)%13;
                        next[key] = (next[key] + dp[k]) % MOD;
                    }
                }
            }
            dp = next;
            m = (10*m)%13;
        }
        cout << dp[5] << endl;
    }
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {

      int m = sc.nextInt();
      int n = sc.nextInt();
      if ((m | n) == 0) {
        break;
      }
      int c = 0;

      boolean[] ck = new boolean[7368792];
      int i = m - 1;
      while (i < 7368791) {
        i++;
        if (ck[i]) {
          continue;
        }
        if (c >= n) {
          break;
        }
        c++;
        for (int j = i; j < 7368792; j += i) {
          ck[j] = true;
        }
      }
      System.out.println(i);
    }
  }
}

Measured memory_bytes: 58492
#include <cstdio>
#include <iostream>

#define MAX 305
#define ll long long 
#define Mod 1000000007

using namespace std ;
int i, j, k, o, l, r, x, N, M, ans ; 
int tk[MAX], base[MAX][MAX][2], dp[MAX][MAX][MAX];

int main(){
    cin >> N >> M ;
    dp[1][0][0] = 1 ;
    for (i = 1 ; i <= M ; ++ i)
        cin >> l >> r >> x, base[r][++ tk[r]][0] = l, base[r][tk[r]][1] = x ; 
    for (i = 1 ; i <= N ; ++ i){
        for (j = 1 ; j <= tk[i] ; ++ j){
            int l0 = base[i][j][0], x0 = base[i][j][1] ;
            for (k = 0 ; k < i ; ++ k)
                for (o = 0 ; o <= max(0, k - 1) ; ++ o)
                    if (x0 == 1 && k >= l0) dp[i][k][o] = 0 ;
                    else if (x0 == 3 && o < l0) dp[i][k][o] = 0 ;   
                    else if (x0 == 2 && (k < l0 || o >= l0)) dp[i][k][o] = 0 ;
        }	
        for (j = 0 ; j < i ; ++ j)
            for (k = 0 ; k <= max(0, j - 1) ; ++ k)
                if (dp[i][j][k]){
                    dp[i + 1][j][k] = (1LL * dp[i + 1][j][k] + dp[i][j][k]) % Mod ;
                    dp[i + 1][i][k] = (1LL * dp[i + 1][i][k] + dp[i][j][k]) % Mod ;
                    dp[i + 1][i][j] = (1LL * dp[i + 1][i][j] + dp[i][j][k]) % Mod ;
                }
    }
    for (i = 0 ; i < N ; ++ i)
        for (j = 0 ; j <= max(0, i - 1) ; ++ j)
            ans = (1LL * ans + dp[N][i][j]) % Mod ; 	
    cout << 3LL * ans % Mod << endl ; return 0 ;
}	

Measured memory_bytes: 109568
n = int(input())
current_time = 0
current_pos = 0
ans = True
for _ in range(n):
    t, x, y = map(int, input().split())
    time_dif = t - current_time # 3
    pos_dif = (x+y) - current_pos # 3
    if time_dif % 2 == 1 and pos_dif % 2 == 1 and pos_dif <= time_dif:
        current_time += time_dif
        current_pos += pos_dif
    elif time_dif % 2 == 0 and pos_dif % 2 == 0 and pos_dif <= time_dif:
        current_time += time_dif
        current_pos += pos_dif
    else:
        ans = False

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    from collections import Counter as cc
    a = cc(a)
    ans = len(a)
    flag = 0
    for x in a:
        if a[x]%2 == 0:
            flag ^= 1
    print(ans-flag)
                
if __name__ == '__main__':
    main()

Measured memory_bytes: 22084
#include<bits/stdc++.h>
using namespace std;
int n;
int ans;
string s; 
int main(){
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll n,k,i,j;
    double ans=0,d;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        d=1/(1.0*n);
    for(j=i;j<k;j*=2)
    {
        d*=0.5;
    }
    ans+=d;
    }
    cout.setf(ios::fixed);
    cout.precision(12);

    cout<<ans<<endl;


    return 0;
}





Measured memory_bytes: 3792
#include <iostream>
#include <string>
using namespace std;
int main(){
  int i,j,n,k[100],l,len,h;
  string s,out;
  char data[52]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  while(1){
    out="";
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> k[i];
    }
    cin >> s;
    len=s.size();
    for(i=0,l=0;i<len;i++,l++){
      if(l==n) l=0;
      for(j=0;j<52;j++){
	if(s[i]==data[j]){
	  if(j-k[l]<0){
	    h=k[l]-j;
	    out+=data[52-h];
	  }
	  else out+=data[j-k[l]];
	}
      }
    }
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cstdio>
using namespace std;
#define INF 1LL<<60

typedef long long Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(auto &f:g[e.dst]) {
      if (dist[f.dst] > e.weight+f.weight) {
        dist[f.dst] = e.weight+f.weight;
        Q.push(Edge(f.src, f.dst, e.weight+f.weight));
      }
    }
  }
}

int main(){
	int N,M,K,S,P,Q;
	scanf("%d%d%d%d%d%d",&N,&M,&K,&S,&P,&Q);
	unordered_map<int,int>depth;
	queue<int>q;
	for(int i=0;i<K;i++){
		int a;
		scanf("%d",&a);a--;
		depth[a]=0;
		q.push(a);
	}
	Graph g(N);
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d%d",&a,&b);a--,b--;
		g[a].push_back(Edge(a,b,b==N-1?0:depth.find(b)==depth.end()?P:INF));
		g[b].push_back(Edge(b,a,a==N-1?0:depth.find(a)==depth.end()?P:INF));
	}
	for(;!q.empty();){
		int cur=q.front();q.pop();
		if(depth[cur]==S)continue;
		for(auto &e:g[cur]){
			if(depth.find(e.dst)==depth.end()){
				depth[e.dst]=depth[cur]+1;
				q.push(e.dst);
			}
		}
	}
	for(int i=0;i<N;i++)for(auto &&e:g[i]){
		if(depth.find(e.dst)!=depth.end()&&e.weight==P)e.weight=Q;
	}
	vector<Weight>dist;
	vector<int>prev;
	shortestPath(g,0,dist,prev);
	printf("%lld\n",dist[N-1]);
}

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int dx=c-a;
    int dy=d-b;
    int e=c-dy;
    int f=d+dx;
    int g=e-dx;
    int h=f-dy;
    cout<<e<<' '<<f<<' '<<g<<' '<<h<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1e9+7
using namespace std;

int main(){
  long int N,V,ans = 0;
  cin >> N >> V;
  vector<long int> a(N),b(N),c(N),d(N),sum1,sum2;
  FOR(i,0,N)cin >> a[i];
  FOR(i,0,N)cin >> b[i];
  FOR(i,0,N)cin >> c[i];
  FOR(i,0,N)cin >> d[i];
  FOR(i,0,N)FOR(j,0,N)sum1.push_back(a[i]+b[j]);
  FOR(i,0,N)FOR(j,0,N)sum2.push_back(c[i]+d[j]);
  sort(sum2.begin(),sum2.end());
  for(auto x:sum1)ans += upper_bound(sum2.begin(),sum2.end(),V-x)-lower_bound(sum2.begin(),sum2.end(),V-x);
  cout << ans << endl;
}



Measured memory_bytes: 23104
#include<stdio.h>

int main(void){
        int n;
        scanf("%d", &n);
        int a[n];
        for(int i=0; i<n; i++) scanf("%d", &a[i]);

        for(int i=n-1; i>=0; i--){
                printf("%d", a[i]);
                if(i) putchar(' ');
                else putchar('\n');
        }
        return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char X, Y; cin >> X >> Y;
    if(X < Y) cout << "<" << endl;
    else if(X == Y) cout << "=" << endl;
    else cout << ">" << endl;
    return 0;
}

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

using namespace std;
typedef pair <int, int> pii;

const int maxn = 10001;

int h,w,a[maxn],p=1,n;
stack <int> v;
void input();
void solve();

int main(){
	input();
	solve();
	
	return 0;
}
void input(){
	cin>>h>>w>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
}
void solve(){
	for (int j=0;j<h;j++){
		if (j%2==0){
			for (int i=0;i<w;i++){
				if (a[p]>1){
					cout<<p<<" ";
					a[p]--;
				}
				else{
					cout<<p<<" ";
					a[p]--;
					p++;
				}
			}
		}
		else{
			for (int i=0;i<w;i++){
				if (a[p]>1){
					v.push(p);
					a[p]--;
				}
				else{
					v.push(p);
					a[p]--;
					p++;
				}
			}
			for (int i=0;i<w;i++){
				cout<<v.top()<<" ";
				v.pop();
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int motosum = 0;
		int min = l;
		for (int i=0; i<n; i++) {
			motosum += (l + i);
			if (Math.abs(min) > Math.abs(l + i)) {
				min = l + i;
			}
		}
		
		System.out.println(motosum - min);

	}

}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    t.pop_back();

    if (s == t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextInt();
		long r = sc.nextInt();

		if(r-l+1 >= 2019) {
			System.out.println("0");
			return;
		}
		long ans = 2019;
		for(long i=l; i<r; i++) {
			for(long j=i+1; j<=r; j++) {
				long tmp = (i*j)%2019;
				ans = Math.min(ans, tmp);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e5;
vector < int > DP(N + 5, -2e9);
vector < int > Edges[N + 5];
int dfs(int node) {
  int longest_path = 0;
  if (DP[node] != -2e9) {
    return DP[node];
  }
  for (auto it : Edges[node]) {
    longest_path = max(longest_path, dfs(it));
  }
  return DP[node] = longest_path + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  // DP[i] --> longest path wich starts in i
  int n, m; cin >> n >> m;
  while(m--) {
    int x, y;
    cin >> x >> y;
    Edges[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    if (DP[i] == -2e9) {
      dfs(i);
    }
  }
  int ans = -2e9;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, DP[i]);
  }
  cout << ans - 1 << "\n";
  return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;
    
#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int n;
long a[200001];
long b[200001];

// , index
pair<long, long> mainData[200001];
int main(){
    cin >> n;

    rep(i,n){
        cin >> a[i] >> b[i];
        mainData[i] = make_pair(b[i], i);
    }

    sort(mainData, mainData+n);

    long time = 0;
    for(int i=0; i<n; i++){
        time += a[mainData[i].second];

        if(time > b[mainData[i].second]){
            cout << "No" << endl;
            return 0;
        }

    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6528
x,y = map(int,input().split())
 
if y % 2 == 1 or x * 4 < y:
    print("No")
    exit() 

 
for turu in range(x+1):
    kame = x - turu
    #print(kame,turu)
    asi = kame * 4 + turu * 2
    if asi == y:
        print("Yes")
        exit()

print("No")

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

int main() {
	int n;
	cin >> n;
	vector<int> h(n), dp(n, 1e9);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		if (i >= 1) dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
		if (i >= 2) dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024