akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int deg[4];

void MAIN() {
    REP (i, 3) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	deg[x]++;
	deg[y]++;
    }
    int cnt = 0;
    REP (i, 4) cnt += deg[i] % 2;
    puts(cnt <= 2? "YES": "NO");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(){
	long long n,t = 0;
	cin >>n;
	t += n / 500 * 1000;
  	n -= n / 500 * 500;
  	t += n / 5 * 5;
  	cout << t << endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    ll N;
    cin >> N;

    ll min = N+100;
    ll a=0, b=0;
    for (ll i = 1; i <= sqrt(N); i++) {
        if (N%i == 0) {
            if (N/i + i - 2 < min) {
                min = N/i + i - 2;
            }
        }
    }
    
    cout << min << endl;
    return 0;
}

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

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int x,y,a;
    int left = 0;
    int right = w;
    int up = h;
    int bottom = 0;
    rep(i,n){
        cin >> x >> y >> a;
        // left, bottomは大きいものをとる
        // right,upは小さいものをとる
        if(a == 1) left = max(left,x);
        if(a == 2) right = min(right,x);
        if(a == 3) bottom = max(bottom,y);
        if(a == 4) up = min(up,y);
    }
    if(left >= right || up <= bottom) printf("%d\n",0);
    else printf("%d\n",(right-left)*(up-bottom));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
   priority_queue<int, vector<int>, greater<int>> pq;
   for(int i=0;i<n;i++){
       int a;
       cin>>a;
       pq.push(a);
   }
   double s=0.0;
   s=pq.top();
   while(!pq.empty()){
       s=(s+pq.top())/2.0;
       pq.pop();
   }
   cout<<s<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char str[50];
int main()
{
	while(cin>>str)
	{
		int len=strlen(str);
		for(int i=0;i<len;i++)
		{
			if(str[i]==',')
			str[i]=' ';
		}
		cout<<str<<endl;
	}
return 0;
}

Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int x, y, n, m, k;
        cin >> x >> y >> n >> m >> k;
        vector<int> a(n), b(m), c(k);
        for(auto &&  x : a)
            cin >> x;
        for(auto &&  x : b)
            cin >> x;
        for(auto &&  x : c)
            cin >> x;

        sort(a.begin(), a.end(), greater<int>());
        sort(b.begin(), b.end(), greater<int>());
        sort(c.begin(), c.end(), greater<int>());

        vector<int> ans;
        for(int i = 0; i < x; i++)
            ans.push_back(a[i]);
        for(int i = 0; i < y; i++)
            ans.push_back(b[i]);
        for(int i = 0; i < min(x + y, k); i++)
            ans.push_back(c[i]);
        sort(ans.begin(), ans.end(), greater<int>());

        int tot = accumulate(ans.begin(), ans.begin() + (x + y), 0LL);
        cout << tot << '\n';
        
    }
    
    return 0;
}



Measured memory_bytes: 9648
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
from math import sqrt
n = int(stdin.readline())
cnt = 0
for _ in range(n):
    v = int(stdin.readline())
    if v == 2:
        cnt += 1
    elif v % 2 == 1:
        for i in xrange(3, int(sqrt(v))+1, 2):
            if v % i == 0:
                break
        else:
            cnt += 1
print(cnt)

Measured memory_bytes: 4492
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = mutableListOf<String>()
    for (i in 1..n) {
        aList.add(readLine()!!)
    }

    val map = mutableMapOf<Char, Int>()
    aList[0].toCharArray().sorted().forEach { map[it] = (map[it] ?: 0) + 1 }

    for (i in 1 until n) {
        for ((key, value) in map) {
            val count = aList[i].count { it == key }
            if (count < value) map[key] = count
        }
    }

    for ((key, value) in map) {
        for(i in 0 until value){
            print(key)
        }
    }
    println()
}


Measured memory_bytes: 38296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

int exp_mod(long long a, long long b, int m) {
	long long res = 1;
	while (b > 0) {
		if (b&1)
			res = (res * a)%m;
		a = (a * a)%m;
		b >>= 1;
	}
	return (int)res;
}

int fact_mod(int n, int m) {
	long long res = 1;
	for (int i=n; i>0; --i)
		res = (res * i)%m;
	return (int)res;
}

int comb_mod(int n, int r) {
	long long res = 1;
	for (int i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}

struct Pony
{
    long s, t, x;

    Pony(long s_, long t_, long x_)
    {
        s = s_;
        t = t_;
        x = x_;
    }

    bool operator<(const Pony &another) const
    {
        return x < another.x;
    };
};

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

  string s;

  cin >> s;

  int cnt = 15-s.size();
  
  rep(i, s.size()) {
    if (s[i] == 'o') {
      cnt++;
    }
  }

  if (cnt >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  
}


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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
#define mp make_pair
#define pb push_back
# define PI acos(-1)
# define double long double
const int MxN = 10005 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)

/* VARIABLES */
ll n ; 
/* END OF VARIABLES */

int dig(ll n) {
	int ans = 0 ;
	while(n) {
		n = n / 10 ; 
		ans++;
	}
	return ans ; 
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	int ans = 1e9 ; 
	cin >> n ; 
	for(ll i = 1 ; i <= sqrt(n) ; i++) {
		if(n%i == 0) 
			ans = min(ans,dig(max(i,n/i))) ; 
	} 
	cout << ans ; 
	return 0 ; 
}



Measured memory_bytes: 3612
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-23-03.25.36 Sunday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 maxn = 3100;
const i64 mod = 998244353;
i64 dp[maxn][maxn], n, s, a[maxn], ans=0;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> s;
    for1(i, n) cin >> a[i];
    ms(dp, 0);
    for (int i = 1; i <= n; ++i) {
//        for (int j = s; j >= a[i]; --j) dp[j] = (dp[j]+dp[j-a[i]])%mod;
//        dp[a[i]] = (dp[a[i]]+i)%mod;
//        ans = (ans+dp[s])%mod;
        for (int j = 0; j < a[i]; ++j) {
            dp[i][j] = dp[i-1][j];
        }
        for (int j = a[i]; j <= s; ++j) {
            dp[i][j] = (dp[i-1][j]+dp[i-1][j-a[i]])%mod;
        }
        dp[i][a[i]] = (dp[i][a[i]]+i)%mod;
        ans = (ans+dp[i][s])%mod;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 75392
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int a,b;
	int d[110]={};
	while(1){
		cin>>a>>b;
		if(cin.eof()) return 0;
		d[a]++; d[b]++;
		if(a+b==0){
			int f=0;
			if(d[1]%2 && d[2]%2) f=1;
			rep(i,3,101){
				if(d[i]%2){
					f=0; break;
				}
			}
			o((f?"OK":"NG"));
			fill(d,d+101,0);
		}
	}
}

Measured memory_bytes: 1152
"use strict";

function Main(input) {
  input = input.split("\n");
  const rules = input[0].split(" ");
  const K = parseInt(rules[1]);
  const heightArr = input[1].split(" ").map(str => parseInt(str, 10));
  let result = 0;

  heightArr.forEach(height => {
    if (height >= K) {
      result += 1;
    }
  });

  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 16576
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) return b;
    gcd(b, a%b);
}

template<typename U>
U gcd_multi(vector<U> A) {
    int n = A.size();
    if (n == 1) return A[0];
    U G = gcd(A[0], A[1]);
    if (n == 2) return G;
    for (int i = 2; i < n; ++i) G = gcd(G, A[i]);
    return G;
}

template<typename U>
U lcm(U a, U b) {
    U ans = a*b/gcd(a, b);
    return ans;
}

template<typename U>
U lcm_multi(const vector<U> &A) {
    int n = A.size();
    if (n == 1) return A[0];
    U ans = lcm(A[0],A[1]);
    for (int i = 2; i < n; ++i) ans = lcm(ans,A[i]);
    return ans;
}

int main(int argc, char const *argv[]) {
    input_init();
    ll n,m; cin>>n>>m;
    vector<ll> a(n);
    rep(i,n) {
        cin>>a[i];
        a[i]/=2;
    }
    ll lc = lcm_multi(a);
    ll x = m/lc;
    bool ok = true;
    rep(i,n) {
        ll y = lc/a[i];
        if (y%2 == 0) ok = false;
    }
    if (ok) cout << (x+2-1)/2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1152
a, b, c, d, e, f = map(int, input().split())

water_mass = []
for i in range(f // (100 * b) + 1):
	for j in range(f // (100 * a) + 1):
		if 0 < 100 * b * i + 100 * a * j <= f and 100 * b * i + 100 * a * j not in water_mass:
			water_mass.append(100 * b * i + 100 * a * j)

ans_gross = 100 * a
ans_sugar = 0
c_max = 0
c_lim = e / (100 + e)

for water in water_mass:
	for i in range((f - water) // d + 1):
		for j in range((f - water - i * d) // c + 1):
			if i != 0 or j != 0:
				if c_max < (j * c + i * d) / (j * c + i * d + water) <= c_lim:
					c_max = (j * c + i * d) / (j * c + i * d + water)
					ans_sugar = j * c + i * d 
					ans_gross = ans_sugar + water

print(ans_gross, ans_sugar)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<list>
#include<set>
#include<map>
#include<stack>
using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	
	
	return 0;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pp pair<int,int>
#define Pi acos(-1)
#define pq priority_queue
#define mz 1000000007

using namespace std;

int x,k,q,t;
int r[100005];
int d[100005];
int lu[100005],ld[100005],ru[100005],rd[100005];

int main()
{
    int a,ans,nowlu,nowld,nowru,nowrd,temp=0;
    scanf("%d",&x);
    scanf("%d",&k);
    for(int i=1;i<=k;i++)
        scanf("%d",&r[i]);
    for(int i=1;i<=k;i++)
        d[i]=min(r[i]-r[i-1],x);
    lu[0]=ru[0]=x;
    ld[0]=rd[0]=0;
    r[k+1]=mz;
    for(int i=1;i<=k;i++)
    {
        if(i%2)
        {
            nowld=d[i];
            nowlu=x;
            nowrd=0;
            nowru=x-d[i];
        }
        else
        {
            nowld=0;
            nowlu=x-d[i];
            nowrd=d[i];
            nowru=x;
        }
        if(ru[i-1]<nowld || rd[i-1]>nowlu)
        {
            if(i%2)
            {
                ld[i]=x;
                lu[i]=x;
                rd[i]=0;
                ru[i]=0;
            }
            else
            {
                ld[i]=0;
                lu[i]=0;
                rd[i]=x;
                ru[i]=x;
            }
        }
        else
        {
            if(rd[i-1]<=nowld)
            {
                ld[i]=ld[i-1]+nowld-rd[i-1];
                rd[i]=nowrd;
            }
            else
            {
                ld[i]=ld[i-1];
                rd[i]=nowrd+rd[i-1]-nowld;
            }
            if(ru[i-1]>=nowlu)
            {
                lu[i]=lu[i-1]-(ru[i-1]-nowlu);
                ru[i]=nowru;
            }
            else
            {
                lu[i]=lu[i-1];
                ru[i]=nowru-(nowlu-ru[i-1]);
            }
        }
    }
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d%d",&t,&a);
        while(r[temp+1]<=t)
            temp++;
        if(a>=ld[temp] && a<=lu[temp])
            ans=a-ld[temp]+rd[temp];
        else
        {
            if(a<=ld[temp])
                ans=rd[temp];
            else
                ans=ru[temp];
        }
        if(temp%2)
            ans=min(x,ans+(t-r[temp]));
        else
            ans=max(0,ans-(t-r[temp]));
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };

int N = 1e3 + 7;


int main() {
	fastIO;
	int n;
	cin >> n;
	int mxFrq = 0;
	map<string, int> frq;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		frq[s]++;
		mxFrq = max(mxFrq, frq[s]);
	}

	for (auto i : frq) {
		if (i.second == mxFrq) {
			cout << i.first << "\n";
		}
	}

}


Measured memory_bytes: 23808
import java.io.*;
import java.util.*;

public class Main {
	
	static long[] sumLengthOfDigitNumber = new long[19];
	static long[] digit10 = new long[19];
				
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int AB = sc.nextInt();
		int BC = sc.nextInt();
		int CA = sc.nextInt();
		System.out.println(AB*BC/2);
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int A, B, C;
	cin >> A >> B >> C;

	if ((A * 100 + B * 10 + C) % 4) co("NO");
	else co("YES");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
const LL INF = 1e16;
const int N = 8;

int sum[(1<<N)], v[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n, a, b, c, i, j, k;
	cin >> n >> a >> b >> c;
	for (i=0;i<n;i++) cin >> v[i];
	for (i=1;i<(1<<n);i++) {
		for (j=0;j<n;j++) if (i & (1<<j)) {
			sum[i] += v[j];
		}
	}
	n = (1<<n);
	int ans = abs(v[0]-a) + abs(v[1]-b) + abs(v[2]-c);
	for (i=1;i<n;i++)
		for (j=1;j<n;j++)
			for (k=1;k<n;k++) {
				if ((i&j) != 0) continue;
				if ((j&k) != 0) continue;
				if ((k&i) != 0) continue;
				int add = (__builtin_popcount(i) + __builtin_popcount(j) + __builtin_popcount(k) - 3) * 10;
				ans = min(ans, abs(sum[i]-a) + abs(sum[j] - b) + abs(sum[k] - c) + add);
			}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) { cin >> x; });

  ll ans = 0;
  for (ll i = 0; i < N - 1; i++) {
    for (ll j = i + 1; j < N; j++) {
      ans += A[i] * A[j];
    }
  }

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


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

#define lp(i,n) for(int i=0;i<n;i++)
#define INF (1<<28)
int w,h;
//x y direction
vector<vector<vector<int> > > dp;
vector<vector<int> > mp;
int cost[4];
int mx[]={1,0,-1,0},my[]={0,1,0,-1};

class point{
   public:
   int x;
   int y;
   int time;
   int dir;
   point(int a,int b,int c,int d):x(a),y(b),time(c),dir(d){}
};

bool operator<(const point &a,const point &b){
   return a.time < b.time;
}
bool operator>(const point &a,const point &b){
   return a.time > b.time;
}
bool operator==(const point &a,const point &b){
   return a.time == b.time;
}
int func(){
   dp.clear();
   mp.clear();
   dp.resize(30);
   mp.resize(30);
   lp(i,30){
      mp[i].resize(30);
      dp[i].resize(30);
      lp(j,30){
         dp[i][j].resize(4,INF);
      }
   }
   lp(y,h){
      lp(x,w){
         cin >> mp[y][x];
      }
   }
   lp(i,4){
      cin >> cost[i];
   }
   priority_queue<point,vector<point>,greater<point> > que;
   que.push(point(0,0,0,0));
   dp[0][0][0]=0;
   while(!que.empty()){
      point d = que.top();
      que.pop();
      if(dp[d.y][d.x][d.dir]!=d.time)continue;
      lp(i,4){
         int ndir = (d.dir + i) % 4;
         point nd = point(d.x + mx[ndir],d.y + my[ndir],d.time + (i==mp[d.y][d.x]?0:cost[i]),ndir);
         if(nd.x < 0 || nd.x == w || nd.y < 0 || nd.y == h)continue;
         if(dp[nd.y][nd.x][nd.dir] <= nd.time)continue;
         dp[nd.y][nd.x][nd.dir] = nd.time;
         que.push(nd);
      }
   }
   int res = dp[h-1][w-1][0];
   lp(i,4){
      res = min(res,dp[h-1][w-1][i]);
   }
   return res;
}
int main(){
   while(cin >> w >> h && w){
      cout << func() << endl;
/*      lp(y,h){
         lp(x,w){
            int count = 1<<20;
            lp(k,4){
               if(dp[x][y][k]!=-1)
                  count = min(count,dp[x][y][k]);
            }
            cout << count << " ";
         }
         cout << endl;
      }*/
   }
   return 0;
}



Measured memory_bytes: 3188
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VI s(n);
    REP(i, n) cin >> s[i];
    int sum = 0;
    REP(i, n) sum += s[i];
    if(sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    sort(ALL(s));
    REP(i, n) {
        if(s[i] % 10 != 0) {
            cout << sum - s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define tt long t;cin>>t;while(t--)
#define tez ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define plli pair<lli,lli>
#define vlli vector<lli>
#define vplli vector<plli>
#define pqlli priority_queue <lli>
#define pqplli priority_queue <plli>
#define mplli map<lli,lli>
#define all(v) v.begin(),v.end()
#define alll(s) s.begin(),s.end(),s.begin(), ::tolower
#define allu(s) s.begin(),s.end(),s.begin(), ::toupper

#define mod 1000000007
#define ff first
#define ss second
#define fori(i,a,b)    for(int i=a;i<b;i++)
#define ford(i,a,b)    for(int i=a;i>=b;i--)
#define br cout<<endl
#define sz(v) (long)v.size()
#define YS cout<<"YES"<<endl
#define ys cout<<"yes"<<endl
#define Ys cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define no cout<<"no"<<endl
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define bs binary_search
#define mp make_pair
#define llmn LLONG_MIN
#define llmx  LLONG_MAX
#define stp setprecision
#define fxd fixed
#define tu (char)toupper
#define tl (char)tolower
#define coutv(v) for(lli index=0;index<v.size();index++) {cout<<v[index]<<" ";} br;

using namespace std;

/*
lli count01(string s,char ch){
  lli mx=0,c=0;
  if(ch=='0'){

   fori(i,0,sz(s)){
     if(s[i]=='0'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

   }

  }
  else{

    fori(i,0,sz(s)){
     if(s[i]=='1'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}

    }

  }
return mx;

}*/
/*
vector<lli> prime(lli n){
  bool a[n+1];
  memset(a,true,sizeof(a));
  for(lli i=2;i*i<=n;i++){
    if(a[i]){
      for(lli j=i*i;j<=n;j+=i)
      {  a[j]=false;}
    }
  }
  vector<lli>v;
  for(lli i=2;i<=n;i++){
    if(a[i]){
      v.pb(i);
    }
  }
  return v;
}

*/
void solve(){
    lli n,m;
    cin>>n;
    vlli v(n);
    lli ans=0;
    for(lli i=0;i<n;i++){
        cin>>v[i];
        ans^=v[i];
    }
    for(lli i=0;i<n;i++){
        lli k=ans^v[i];
        cout<<k<<" ";
    }

   


}

int main(){
tez
    solve();
return 0;
}


Measured memory_bytes: 4780
#include <iostream>

using namespace std;

int p, q, a;

int solve(int n, int d, int prod, int sum) {
  int cnt=0;
  for (int i=d; prod*i<=a; i++) {
    int left = p * (prod * i);
    int right = sum * i + prod;
    if (left < right * q) { continue; }
    if (left == right * q) { cnt++; continue; }
    if (n == 1) { continue; }
    cnt += solve(n-1, i, prod * i, right);
  }

  return cnt;
}

int main() {
  int n;
  while (cin >> p >> q >> a >> n, (p || q || a || n)) {
    cout << solve(n, 1, 1, 0) << endl;
  }

  return 0;
}

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

int main(){
	int n;
	int s[102];
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&s[i]);
	
	int dp[102][10]={};
	for(int i=1;i<10;i++){
		dp[0][i]=-100000;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			int k=(j+10-s[i]%10)%10;
			dp[i+1][j]=max(dp[i][j],dp[i][k]+s[i]);
		}
	}
	int ret=0;
	for(int i=1;i<10;i++){
		ret=max(ret,dp[n][i]);
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
  int n;
  cin >> n;
  vector<int> line(n);
  foreach(i,line)cin>>i;
  int num = 0;
  ll ans = 0;
  foreach(i,line){
    int d = num+1;
    if(i<=d){
      chmax(num,i);
      continue;
    }
    ans += (i - 1) / d;
    chmax(num,1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int A[n];
for(int i=0 ; i<n ; i++) cin>>A[i];
int len = 0;
int mx = 0;
for(int i=0 ; i<n-1 ; i++){
    if(A[i]>=A[i+1]) len++ , mx = max(mx , len);
    else
        len = 0;
}
cout<<mx<<endl;
}


Measured memory_bytes: 4020
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

#[allow(dead_code)]
const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let ps: Vec<(i64, i64)> = (0..n).map(|_| {
        let x: i64 = sc.cin();
        let y: i64 = sc.cin();
        (x, y)
    }).collect();
    let mut ans = n + 10;

    if n == 1 {
        put!(1);
        return;
    }
    if n == 2 {
        put!(1);
        return;
    }

    use std::collections::HashSet;
    let mut ps_set = HashSet::new();
    for i in 0..n {
        ps_set.insert(&ps[i]);
    }

    for i in 0..n {
        for j in i+1..n {
            let p = ps[j].0 - ps[i].0;
            let q = ps[j].1 - ps[i].1;
            let mut cost = 0;
            for k in 0..n {
                if ! ps_set.contains(&(ps[k].0 - p, ps[k].1 - q)) {
                    cost += 1;
                }
            }
            ans = min(ans, cost);
        }
    }

    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin>>d.at(i);
  }
  vector<int> ans(N);
  for(int i=0; i<N; i++){
    ans.at(d.at(i)-1) = i+1;
  }
  for(int i=0; i<N; i++){
    cout<<ans.at(i)<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	while(cin>>n&&n)
	{
		unsigned long long v[4001]={};
		vector<int> id,ans;
		for(int i=0;i<n;i++)
		{
			unsigned long long a,b,c;
			cin>>a>>b>>c;
			id.push_back(a);
			v[a]+=b*c;
		}
		for(int i=0;i<=4000;i++)
		{
			if(v[i]>=1000000)ans.push_back(i);
		}
		bool ok=true;
		for(int i=0;i<id.size();i++)
		{
			if(binary_search(ans.begin(),ans.end(),id[i]))
			{
				auto it=lower_bound(ans.begin(),ans.end(),id[i]);
				ans.erase(it);
				cout<<id[i]<<endl;
				ok=false;
			}
		}
		if(ok)cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
  vector <char> s, t;
  string S, T;
  cin >> S >> T;
  for (unsigned int i = 0; i < S.length(); i++) {
    char c = S[i];
    s.push_back(c);
  }
  for (unsigned int i = 0; i < T.length(); i++) {
    char c = T[i];
    t.push_back(c);
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), [](const int& x, const int& y) {return x > y;});
  bool ans = false;
  for (int i = 0; i < t.size(); i++) {
    if (i >= s.size()) {
      ans = true;
      break;
    }
    if (s[i] < t[i]) {
      ans = true;
      break;
    }
    if (s[i] > t[i]) {
      ans = false;
      break;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <deque>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n, m;
  string s;
  cin >> n >> m >> s;
  vector<int> ans(n + 1);
  deque<pair<int, int> > d;
  for (int i = 0; i < n; i++) {
    ans[i] = -1;
  }
  ans[n] = 0;
  d.push_back({0, n});
  for (int i = n - 1; i >= 0; i--) {
    if (!d.empty() && d[0].second > i + m) {
      d.pop_front();
    }
    if (!d.empty() && s[i] == '0') {
      ans[i] = d[0].first + 1;
      d.push_back({ans[i], i});
    }
  }
  if (ans[0] == -1) {
    cout << -1 << endl;
  } else {
    int p = 0;
    for (int i = 0; i <= n; i++) {
      if (ans[i] == ans[p] - 1) {
        cout << i - p << " ";
        p = i;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
from collections import defaultdict


N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

primes_total = defaultdict(int)

for a in A:
    tmp = a
    primes_a = defaultdict(int)
    p = 2
    while p * p <= tmp:
        while tmp % p == 0:
            primes_a[p] += 1
            tmp //= p
        p += 1
    if tmp != 1:
        primes_a[tmp] += 1

    for k in primes_a.keys():
        primes_total[k] = max(primes_total[k], primes_a[k])

lcm = 1
for k in primes_total.keys():
    lcm *= pow(k, primes_total[k], MOD)
    lcm %= MOD

ans = 0

for a in A:
    # フェルマーの小定理より
    ans += lcm * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 47964
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b,k; cin>>a>>b>>k;
  if (k<=a) cout<<a-k<<" "<<b<<endl;
  else if (k<=a+b) cout<<0<<" "<<b-k+a<<endl;
  else cout<<"0 0"<<endl;
}

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

int main(){
	set<int> s;
	int a, b, c;
	cin >> a >> b >> c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size()==2)printf("Yes\n");
	else printf("No\n");
}

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

int main() {
  string n;
  cin >>n;
  for(int i=0;i<3; i++){
  if(n.at(i)=='1'){
   n.at(i)='9';
  }
  else if(n.at(i)=='9'){
  n.at(i)='1';
  }
  }
  cout << n <<endl;    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m; cin>>n>>m;
    vector<pii>stu,ch;
    vi v;
    rep(i,n){
        pii hoge; cin>>hoge.first>>hoge.second;
        stu.push_back(hoge);
    }
    rep(i,m){
        pii hoge;
        cin>>hoge.first>>hoge.second;
        ch.push_back(hoge);
    }
    rep(i,n){
        int cnt=INF;
        int ans = 0;
        rep(j,ch.size()){
            int temp=abs(stu[i].first-ch[j].first)+abs(stu[i].second-ch[j].second);
            if(temp<cnt){ans=j;cnt=temp;}
        }
        v.push_back(ans+1);
    }
    rep(i,n)cout<<v[i]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t N;
	cin >> N;

	vector<int32_t> A(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	bool valid = true;
	if (A.size() % 2 == 0) {
		for (int32_t i = 0; i < N; i += 2) {
			if (A[i] != i + 1 || A[i + 1] != i + 1) {
				valid = false;
				break;
			}
		}
	} else {
		if (A[0] == 0) {
			for (int32_t i = 1; i < N; i += 2) {
				if (A[i] != i + 1 || A[i + 1] != i + 1) {
					valid = false;
					break;
				}
			}
		} else {
			valid = false;
		}
	}
	if (!valid) {
		cout << 0 << endl;
		return 0;
	}

	int64_t res = 1;
	for (int32_t i = 0; i < N / 2; i++) {
		res *= 2;
		res %= 1000000007;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const long long INF = 1LL << 60;
int N;
long long h[100010];
long long dp[100010];
int main()
{	
  int N; cin >> N;
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  for (int i = 0; i < 100010; i++){
    dp[i] = INF;
  }
  dp[0] = 0;
  for (int i = 1; i < N; i++){
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1){
      chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int h1, h2, m1, m2, k;
    scanf("%d%d",&h1,&m1);
    scanf("%d%d",&h2,&m2);
    scanf("%d",&k);
    int d = 60 * (h2 - h1) + (m2 - m1);
    printf("%d\n",d - k);
    return 0;
}

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

int a, b;
string as, bs;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> a >> b;
    for (int i = 0; i < b; i++)
    {
        as.push_back(a + '0');
    }
    for (int i = 0; i < a; i++)
    {
        bs.push_back(b + '0');
    }

    cout << (as < bs ? as : bs);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
// typedef vector<int64_t> vec;
// typedef vector<vec> mat;

using namespace std;

const int MOD = 998244353;

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

    ll N;
    cin >> N;
    vector<ll> D(N);
    vector<ll> cnt(N+1, 0);
    ll ans = 1;
    Rep (i, N) {
        cin >> D[i];
        cnt[D[i]]++;
        if (i == 0 && D[i] != 0) ans = 0;
        if (i != 0 && D[i] == 0) ans = 0;
    }

    for (ll i = 1; i < N; i++) {
        ans = ans * cnt[D[i]-1] % MOD;
    }

    cout << ans << endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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 (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int N, K;
vector<long double> p;
vector<bool> used;

long double memo_p(int i) {
    if (i >= K) {
        return 1;
    }
    if (used[i]) {
        return p[i];
    }
    used[i] = true;
    return p[i] = 0.5 * memo_p(2 * i);
}

int main() {
    cin >> N >> K;
    p.resize(K);
    used.assign(K, false);
    p[0] = 0;
    used[0] = true;
    long double result = 0;
    FOR(i, 1, N + 1) {
        result += memo_p(i);
    }
    result /= N;
    cout << setprecision(15) << result << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

map<int, int> dp;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    dp[0] = 1;
    int c = 0;
    ll r = 0;
    for(int i = 1; i <= n; i++) {
        int t;
        scanf("%d", &t);
        c += t;
        c %= m;
        r += dp[c]++;
    }
    printf("%lld\n", r);
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include<math.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define Min(a,b) (a<b?a:b)
#define Max(a,b) (a>b?a:b)
#define PI 3.1415926535897932
using namespace std;






int main()
{
int n,w;
cin>>n>>w;
int val[n][2];
for(int i=1;i<=n;i++){
	cin>>val[i][0]>>val[i][1];
}
long long  dp[n+1][w+1];
for(int i=0;i<=w; i++){
	dp[0][i]=0;
}
for(int i=0;i<=n; i++){
	dp[i][0]=0;
}

for(int i=1;i<=n; i++){
	for(int j=1; j<=w; j++){
		if(j<val[i][0])
			dp[i][j]=dp[i-1][j];
		else{
			dp[i][j]=max(dp[i-1][j], dp[i-1][j-val[i][0]]+val[i][1]);
			// dp[i][j]=max(dp[i][j-val[i][0]]+val[i][1],dp[i-1][j] );
		}
	}
}
// for(int i=0; i<=n;i++){
// 	for(int j=0; j<=w; j++){
// 		cout<<dp[i][j]<<" ";
// 	}
// cout<<endl;
// }


cout<<dp[n][w];











return 0;

}



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

int main(){
    int n,k,a = 0;
    cin >> n >> k;
    vector<int> x(n);
    for(int i = 0;i < n;i++){
        cin >> x[i];
        if(x[i]*2 > (k-x[i])*2)a += (k-x[i])*2;
        else a += x[i]*2;
    }
    cout << a;
}

Measured memory_bytes: 256