akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
 
int n;
string id;
int m;
vector<int> a;
vector<int> wcard;
 
inline int f(int n) {
    if(n<10) return n;
    int ret = n%10;
    ret += n/10;
    return ret;
}
inline bool ok(string s) {
    int sum = 0;
    int cnt=1;
    for(int i=s.size()-1;i>=0;i--) {
        if(cnt%2==0) {
            sum+=f((s[i]-'0')*2);
        }
        else {
            sum+=s[i]-'0';
        }
        cnt++;
    }
    return sum%10==0;
}
int64_t dfs(string& s,int depth,int sum) {
    if(depth == wcard.size()) return sum%10==0;
    int64_t ret = 0;
 
    rep(i,a.size()) {
        char c = s[wcard[depth]];
        s[wcard[depth]] = a[i]+'0';
        int t;
        if((id.size()-wcard[depth])%2==0) {
            t=f(a[i]*2);
        }
        else {
            t=a[i];
        }
        ret += dfs(s,depth+1,sum+t);
        s[wcard[depth]] = c;
    }
    return ret;
     
}
int fsum(string s) {
    int sum = 0;
    rep(i,s.size()) {
        if(s[i]=='*') continue;
        if((id.size()-i)%2==0) {
            sum+=f((s[i]-'0')*2);
        }
        else {
            sum+=s[i]-'0';
        }
    }
    return sum;
}
int main() {
    cin>>n;
    cin>>id;
    cin>>m;
    a.resize(m);
    rep(i,m) cin>>a[i];
    rep(i,id.size()) if(id[i]=='*') wcard.pb(i);
    int sum = fsum(id);
    int64_t ans = dfs(id,0,sum);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1368
#include <stdio.h>
int allocation(int *,int,int);
int check(int *,int,int,int);
int main(){
  int i,n,k,w[100000];
  int ans;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++)scanf("%d",&w[i]);
  ans=allocation(w,n,k);
  printf("%d\n",ans);
  return 0;
}

int allocation(int *w,int n,int k){
  int left=0,right=1000000000,v;
  int mid;
  while(right-left>1){
    mid=(right+left)/2;
    v=check(w,n,k,mid);
    if(v>=n)right=mid;
    else left=mid;
  }
  return right;
}
int check(int *w,int n,int k,int P){
  int i,j=0,x;
  for(i=0;i<k;i++){
    x=0;
    while(x+w[j]<=P){
      x+=w[j];
      j++;
      if(n==j)return n;
    }
  }
  return j;
}


Measured memory_bytes: 2220
(* O(n log n) *)
Scanf.scanf " %d" @@ fun n ->
  let sps = Array.init n @@ fun i -> Scanf.scanf " %s %d" @@ fun s p -> i + 1, s, p in
  Array.sort (fun (i, s, p) (j, s1, p1) -> p1 - p) sps;
  Array.stable_sort (fun (i, s, p) (j, s1, p1) -> compare s s1) sps; 
  Array.iter (fun (i, s, p) -> Printf.printf "%d\n" i) sps

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

#define ll long long
#define ld long double
using namespace std;

int  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    for (ll i = 1; i <= 3500; i++){
        for (ll j = 1; j <= 3500; j++){
            ld k = ((ld)(n*i*j)/(ld)(4.0*i*j-n*j-n*i));
            ll kk = k;
            if (4*i*j*kk == n*i*j+n*i*k+n*j*k && kk > 0){
                cout << i << " " << j << " " << kk << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

static ll p = 1000000000+7;

int main(){
  int n; cin >> n;
  ll dp[n][64];
  fill(dp[0],dp[1],1);
  dp[0][11] = 0; //AGC
  dp[0][14] = 0; //ACG
  dp[0][35] = 0; //GAC

  REP(i,n-3){
    REP(j,64){
      dp[i+1][j] = (((dp[i][j/4]+dp[i][j/4+16])%p+dp[i][j/4+32])%p+dp[i][j/4+48])%p;
    }

    dp[i+1][11] = 0;
    dp[i+1][14] = 0;
    dp[i+1][35] = 0;

    dp[i+1][27] += p - dp[i][6]; //ATGC
    dp[i+1][39] += p - dp[i][9]; //AGTC
    dp[i+1][43] += p - dp[i][10]; //AGGC

    REP(j,64){
      dp[i+1][j] %= p;
    }
  }

  ll ans = 0;
  REP(j,64){
    ans += dp[n-3][j];
    ans %= p;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string input;
    cin >> input;

    string input2;
    input2.reserve(input.size());
    reverse_copy(input.begin(), input.end(), back_inserter(input2));

    int ans1 = 0;
    int ans2 = 1;
    int ans3 = 0;
    int ans4 = 1;
    unsigned long length = input.length();
    string my1;
    string my2;
    my1.push_back(input[0]);
    if (input[0] == '0') {
        my2.push_back('1');
    } else {
        my2.push_back('0');
    }
    string my3;
    string my4;
    my3.push_back(input2[0]);
    if (input2[0] == '0') {
        my4.push_back('1');
    } else {
        my4.push_back('0');
    }

    for (int i = 1; i < length; ++i) {
        if (my1[i-1] != input[i]) {
            my1.push_back(input[i]);
        } else {
            ans1++;
            if (input[i] == '0') {
                my1.push_back('1');
            } else {
                my1.push_back('0');
            }
        }

        if (my2[i-1] != input[i]) {
            my2.push_back(input[i]);
        } else {
            ans2++;
            if (input[i] == '0') {
                my2.push_back('1');
            } else {
                my2.push_back('0');
            }
        }

        if (my3[i-1] != input2[i]) {
            my3.push_back(input2[i]);
        } else {
            ans3++;
            if (input2[i] == '0') {
                my3.push_back('1');
            } else {
                my3.push_back('0');
            }
        }

        if (my4[i-1] != input2[i]) {
            my4.push_back(input2[i]);
        } else {
            ans4++;
            if (input2[i] == '0') {
                my4.push_back('1');
            } else {
                my4.push_back('0');
            }
        }
    }


    int min = ans1;
    if (min > ans2) {
        min = ans2;
    }
    if (min > ans3) {
        min = ans3;
    }
    if (min > ans4) {
        min = ans4;
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
    char s[7];
    scanf("%s",s);
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split(" "))
    if a == b and b != c:
        print("Yes")
    elif a == c and c != b:
        print("Yes")
    elif c == b and b != a:
        print("Yes")
    else:
        print("No")
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int dp[1005][1005];     /*dp[i][j]表示表示A串从第0个字符开始到第i个字符和B串从第0个
字符开始到第j个字符，这两个字串的编辑距离。字符串的下标从1开始。*/
char a[1005],b[1005];   //a,b字符串从下标1开始
const int INF=1005;
int EditDis()
{
    int len1 = strlen(a+1);
    int len2 = strlen(b+1);
    //初始化
    for(int i=1;i<=len1;i++)
        for(int j=1;j<=len2;j++)
            dp[i][j] = INF;
    for(int i=1;i<=len1;i++)
        dp[i][0] = i;
    for(int j=1;j<=len2;j++)
        dp[0][j] = j;
    for(int i=1;i<=len1;i++)
    {
        for(int j=1;j<=len2;j++)
        {
            int flag;
            if(a[i]==b[j])
                flag=0;
            else
                flag=1;
            dp[i][j]=min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+flag));
            //dp[i-1][j]+1表示删掉字符串a最后一个字符a[i]
            //dp[i][j-1]+1表示给字符串添加b最后一个字符
            //dp[i-1][j-1]+flag表示改变,相同则不需操作次数,不同则需要,用flag记录
        }
    }
    return dp[len1][len2];
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>a+1>>b+1;
    cout<<EditDis()<<endl;
}
/* 
acac
acm

1 ≤ length of s1 ≤ 1000
1 ≤ length of s2 ≤ 1000
 */


Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

int main() {
  int n, k; cin >> n >> k;
  string s; cin >> s;
  int res = 0;
  rep(i,n-1) {
    if (s[i] == s[i+1]) res++;
  }
  int ans = min(res+2*k, n-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
  
#define MAX_COUNT 10000
#define MIN_COUNT 1
  
#define MAX_VALUE 1000000
#define MIN_VALUE -1000000
  
#define IS_ERR_COUNT(n) (n < MIN_COUNT || n > MAX_COUNT)
#define IS_ERR_VALUE(n) (n < MIN_VALUE || n > MAX_VALUE)
  
int main(void)
{
  
    long long int n, i, d, min, max, sum;
    min = MAX_VALUE + 1;
    max = MIN_VALUE - 1;
    sum = 0;
  
    scanf("%lld", &n);
  
    if(IS_ERR_COUNT(n)) return -1;
  
    for(i=0;i<n;i++)
    {
        scanf("%lld", &d);
  
        if(IS_ERR_VALUE(d)) return -1;
  
        if(min > d) min = d;

        if(max < d) max = d;

        sum += d;
    }
  
    printf("%d %d %lld\n", min, max, sum);
  
    return 0;
}


Measured memory_bytes: 2140
from operator import xor

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

D = {}

for a in A :
    if not a in D :
        D[a] = 1
    else :
        D[a] += 1

if len(D) == 1 :
    if D.get(0, 0) == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 2 :
    if D.get(0, 0) * 3 == N :
        ans = "Yes"
    else :
        ans = "No"
elif len(D) == 3 :
    K = list(D.keys())
    V = list(D.values())
    
    if (xor(xor(K[0], K[1]), K[2]) == 0) and (V[0] == V[1] == V[2]) :
        ans = "Yes"
    else :
        ans = "No"
else :
    ans = "No"

print(ans)


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll n,m,d;
  cin>>n>>m>>d;
  long double ans = (2*(long double)(n-d)/n)*((long double)(m-1LL)/n);
  if(d==0) ans/=2;
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

// #define _GLIBCXX_DEBUG

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  vi v(3); rep(i,3) cin>>v[i];
  sort(all(v));
  if(v[0]==v[1]&&v[1]<v[2]) out("Yes");
  else if(v[0]<v[1]&&v[1]==v[2]) out("Yes");
  else out("No");
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC155A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int cnt = 0;
            if (a[0] == a[1]) cnt++;
            if (a[1] == a[2]) cnt++;
            if (a[0] == a[2]) cnt++;
            Console.WriteLine(cnt == 1 ? "Yes" : "No");
        }
    }
}


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

int main(){
   int n,q;
   cin >> n >> q;
   string s;
   cin >> s;
   vector<int> l(q),r(q),ans(n,0);
   rep(i,q) cin >> l[i] >> r[i];
   rep(i,n-1){
       ans[i+1]=ans[i];
       if(s[i]=='A' && s[i+1]=='C'){
           ans[i+1]++;
       }
   }
   rep(i,q){
       cout << ans[r[i]-1]-ans[l[i]-1] << endl;
   }
}

Measured memory_bytes: 2176
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


MY_NAMESPACE(ABC168E)
ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	if (a % b == 0)
		return b;
	return gcd(b, a % b);
}

ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

class HashPair
{
public:
	static size_t m_hash_pair_random;

	template<class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const {

		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);

		size_t seed = 0;
		seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		seed ^= m_hash_pair_random + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		return seed;
	}
};

size_t HashPair::m_hash_pair_random = (size_t)random_device()();

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

	ll modval = 1000000007;

	int n;
	cin >> n;
	//map<pll, int> cnt;
	unordered_map<pll, int, HashPair> cnt;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a != 0 && b != 0)
		{
			if (a < 0)
			{
				a *= -1;
				b *= -1;
			}
			ll g = gcd(abs(a), abs(b));
			cnt[{a / g, b / g}]++;
		}
		else if (a == 0 && b == 0)
			cnt[{0, 0}]++;
		else if (a == 0)
			cnt[{0, 1}]++;
		else  // b == 0
			cnt[{1, 0}]++;
	}

	ll num00 = cnt[{0, 0}];
	cnt.erase(make_pair(0, 0));

	ll num = 1;
	while (!cnt.empty())
	{
		auto this_item = cnt.begin();
		pll this_pair = this_item->first;
		pll anti_pair = { this_pair.second, -this_pair.first };
		if (anti_pair.first < 0)
			anti_pair = { -this_pair.second, this_pair.first };
		else if (anti_pair.first == 0)
			anti_pair = { 0, 1 };
		if (cnt.find(anti_pair) == cnt.end())
			cnt[anti_pair] = 0;
		auto anti_item = cnt.find(anti_pair);

		num = num * (modpow(2, this_item->second, modval) - 1 + modpow(2, anti_item->second, modval) - 1 + 1) % modval;
		cnt.erase(this_item);
		cnt.erase(anti_item);
	}
	ll retval = (num00 + (num - 1) + modval) % modval;  // -1 for nothing chosen case
	cout << retval << "\n";

	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 14644
import java.util.*;

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

    int e = Math.abs(a-c);
    int f = Math.abs(a-b);
    int g = Math.abs(b-c);

    if (e <= d || (f <= d && g <= d)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } 
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};

typedef pair<double,int> pdi;

const double EPS = 1e-9;

struct Cell{
    vector<double> pos;
    double r;
    Cell(vector<double> p,double rr) : pos(p),r(rr) {};
};
double pow2(double a){
    return a*a;
}

double dist(Cell a,Cell b){
    double d2=0;
    for(int i=0;i<3;i++){
        d2 += pow2(a.pos[i]-b.pos[i]);
    }
    double d = sqrt(d2);
    if(d <= a.r+b.r){
        return 0;
    }else{
        return d-(a.r+b.r);
    }
}

int main(){
    cout << fixed << setprecision(3);
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<Cell> cells;
        for(int i=0;i<n;i++){
            vector<double> pos(3);
            for(int j=0;j<3;j++) cin >> pos[j];
            double r;
            cin >> r;
            cells.push_back(Cell(pos,r));
        }

        vector<vector<double> > dists(n,vector<double>(n));
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dists[i][j] = dist(cells[i],cells[j]);
            }
        }

        vector<char> used(n,false);
        priority_queue<pdi,vector<pdi>,greater<pdi> > que;
        que.push(make_pair(0,0));
        double ret = 0;
        while(not que.empty()){
            double cost = que.top().first;
            int where = que.top().second;
            que.pop();
            if(used[where]) continue;
            used[where] = true;
            ret += cost;
            for(int i=0;i<n;i++){
                que.push(make_pair(dists[where][i],i));
            }
        }
        cout << ret << endl;
    }
    return 0;
}

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

signed main(){
  int N,M,D,ans=0;
  cin>>N>>M>>D;
  for(int i=N;i<=M;i++){
    if(i%D==0)ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
def main():
    c = []
    for i in range(3):
        t = input().split(" ")
        c.append([int(i) for i in t])

    da = [c[0][0] - c[0][1], c[0][1] - c[0][2]]
    db = [c[0][0] - c[1][0], c[1][0] - c[2][0]]
    for i in range(1,3):
        if c[i][0] - c[i][1] != da[0]:
            print("No")
            return
        if c[i][1] - c[i][2] != da[1]:
            print("No")
            return
        if c[0][i] - c[1][i] != db[0]:
            print("No")
            return
        if c[1][i] - c[2][i] != db[1]:
            print("No")
            return
    for i in range(2):
        for j in range(2):
            if c[i][j] + c[i+1][j+1] != c[i+1][j] + c[i][j+1]:
                print("No")
                return
    print("Yes")
main()


Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            if (a % 2 == 0) {
                System.out.println("Even");
                return;
            }

            int b = sc.nextInt();
            if (b % 2 == 0) {
                System.out.println("Even");
                return;
            }

            System.out.println("Odd");
            return;
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> t;
  int d,g;
  cin>>d>>g;
  for(int i=0;i<d;i++){
    int tmp1,tmp2;
    cin>>tmp1>>tmp2; 
    vector<int> y={i+1, tmp1,tmp1*100*(i+1)+tmp2 };
    t.push_back(y);
  }
  int ans=1000;
  for(int tmp=0; tmp<(1<<d);tmp++){
    int rate=0;
    int solve=0;
    bitset<10> s(tmp);
    int max=0,maxi=0;
    for(int i=d-1; i>=0;i--){
      if(!s.test(i)&&max==0){
        max=(i+1)*(t.at(i).at(1)-1)*100;
        maxi=i+1;
      }
      else if(s.test(i)){
        rate +=t.at(i).at(2);
        solve +=t.at(i).at(1);
      }
    }
    if(g-rate<=max&&rate<g&&maxi!=0){
      while(rate<g){
        solve++;
        rate +=maxi*100;
      }
    }
    if(rate>=g){
      ans=min(ans,solve);
    }
  }
  cout<<ans<<endl; 
  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define SENTINEL 2000000000
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int a[100000];

int partition(int p, int r) {
    int x = a[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (a[j] <= x) {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i + 1], a[r]);
    return i + 1;
}

int main() {
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    int num = partition(0, n - 1);
    rep(i, n) {
        if (i != 0)
            cout << " ";
        if (i == num)
            cout << "[";
        cout << a[i];
        if (i == num)
            cout << "]";
    }
    cout << endl;
}


Measured memory_bytes: 3440
#include <iostream>

using namespace std;

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

   int a[7] = {1, 3, 5, 7, 8, 10, 12};
   int b[4] = {4, 6, 9, 11};
   int c[1] = {2};

   for(auto& v : a){
       if(x == v){
           x = 13;
       }
       if(y == v){
           y = 13;
       }
   }
   for(auto& v : b){
       if(x == v){
           x = 14;
       }
       if(y == v){
           y = 14;
       }
   }
   for(auto& v : c){
       if(x == v){
           x = 15;
       }
       if(y == v){
           y = 15;
       }
   }

    if(x != y){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
ll power_of_2_not_less(ll n)
{
	if(!n)
	{
		return 1;
	}
	n--;
	n |= n>>1;
	n |= n>>2;
	n |= n>>4;
	n |= n>>8;
	n |= n>>16;
	n |= n>>32;
	n++;
	return n;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
int main(void)
{
	fastio
	ll n,m;
	cin>>n>>m;
	ll ans = (n*(n-1))/2;
	ans += (m*(m-1))/2;
	cout<<ans<<"\n";
	return 0;
}

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

const int MAXN = 100010;
int h[MAXN], dp[MAXN];
int n;

int calc(int pos) {
    if(pos == n) return 0;
    int &y = dp[pos];
    if(y != -1) return y;
    y = calc(pos+1) + abs(h[pos] - h[pos+1]);
    if(pos+1 != n) y = min(y, calc(pos+2) + abs(h[pos] - h[pos+2]));
    return y;
}

int main() {
    memset(dp, -1, sizeof(dp));
	cin >> n;
	for(int i=1; i<=n; ++i) {
	    cin >> h[i];
	}
	cout<<calc(1)<<endl;
	return 0;
}


Measured memory_bytes: 8968
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> arr(n, k - q);
    for (int i = 0; i < q; i++) {
        int temp;
        cin >> temp;
        temp--;
        arr[temp]++;
    }
    for (auto &it: arr) {
        if (it <= 0) {
            cout << "No\n";
        }
        else  {
            cout << "Yes\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  long long N, res;
  rd(N);
  res = N * (N-1) / 2;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// {
//   ll N, res;
//   rd(N);
//   res = N * (N-1) / 2;
//   wt(res);
// }


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[17]:


abcde = []
for _ in range(5):
    abcde.append(int(input()))
print(sum(-(-x//10)*10 for x in abcde) + min(x%10 if x%10 != 0 else 10 for x in abcde ) - 10)


# In[ ]:






Measured memory_bytes: 2940
N,M=list(map(int,input().split()))
g=[list(map(int,input().split())) for _ in range(M)]

par=[0]*(N+1)

def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def same(x,y):
    return find(x)==find(y)

def unite(x,y):
    x=find(x)
    y=find(y)

    if x==y:
        return
    
    par[y]=x

ret=0

for i in range(M):
    par=list(range(N+1))

    for j in range(M):
        if i==j:
            continue
        a,b=g[j]

        unite(a,b)
    
    for j in range(1,N+1):
        if not same(1,j):
            ret+=1
            break
    

print(ret)

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k)cout<<k<<endl;
    if(a<k and a+b>=k)cout<<a<<endl;
    if(a+b<k)cout<<(a+(k-a-b)*(-1))<<endl;
return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int l=s.size();
  if(s[l-1]=='s')
    s=s+"es";
    else if(s[l]!='s')
        s=s+"s";
    cout<<s<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int a, b, mul;
    scanf("%d %d", &a, &b);
    mul=a*b;
    if(a>0 && a<10 && b>0 && b<10){
        printf("%d\n", mul);
    }
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const ll INF = (ll)1e18 + 9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> g(n);
    vector<ll> dist(n, -INF);
    dist[0] = 0;
    ll ans = 0;
    
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].emplace_back(b, c);
    }
    
    rep(i, n - 1) {
        rep(ii, n) {
            for (auto edge : g[ii]) {
                dist[edge.first] = max(dist[edge.first], dist[ii] + edge.second);
            }
        }
    }
    
    rep(i, n - 1) {
        rep(ii, n) {
            for (auto edge : g[ii]) {
                if ((dist[ii] == INF) || (dist[edge.first] < (dist[ii] + edge.second))) {
                    dist[edge.first] = INF;
                }
            }
        }
    }
    
    ans = dist[n - 1];
    
    if (ans == INF) {
        cout << "inf" << endl;
    }
    else {
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int X,N,p;
map<int,bool>m;
int main(){
    cin>>X>>N;
    for(int i=0;i<N;i++){
        cin>>p;
        m[p]=true;
    }
    for(int d=0;;d++){
        if(m[X-d]==false){cout<<X-d<<endl;return 0;}
        if(m[X+d]==false){cout<<X+d<<endl;return 0;}
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n,a,b; cin >> n >> a >> b;
  cout << min(a,b) << " " << max(0, a+b-n);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int MIN=9999;
string S;
long long int MOD = 1000000007;
const int MAX = 1000001;
long long int fac[MAX],finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<MAX;i++){
        fac[i] = fac[i-1]* i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long COM(int n,int k){
    if(n < k)return 0;
    if(n < 0 || k< 0)return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}

int main(){
    long long int N,K,p[200001],k[200001],A[200001];
    cin >> N;
    for(int i=0;i<N;i++)
        cin >> A[i];
    vector<int> vec;
    for(int i=0;i<N;i++){
        int ind = -1;
        if(vec.size()==0){
            vec.push_back(A[i]);
        }else if(vec[vec.size()-1] >= A[i])
            vec.push_back(A[i]);
        else{
            ind = vec.size() - (lower_bound(vec.rbegin(),vec.rend(),A[i]) - vec.rbegin());
            if(ind == vec.size() || ind == -1){
                vec[0] = A[i];
            }else{
                vec[ind] = A[i];
            }
        }
        /*
        cout << "---" << endl;
        cout << "ind : " << ind << endl; 
        for(int i=0;i<vec.size();i++)
            cout << vec[i] << " ";
        cout << endl;
        */
    }
    cout << vec.size() << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;

long order(int digit){
    long a = 1;
    for(int i = 0; i < digit;i++){
        a *= 10;
    }
    return a;
}

int main() {
    long k;
    cin >> k;
    long counter = 0;
    for(long i = 1;i < 32346000000;){
        long workI = i;
        int digitCounter = 0;
        for(;;){
            if(workI < 10){
                counter++;
                if(counter == k ){
                    cout << i << endl;
                }
                i++;
                break;
            }
            if(abs((workI % 10) - ((workI / 10) % 10)) <= 1){
                //cout << workI << "a" <<abs((workI % 10) - ((workI / 10) % 10)) << endl;
                digitCounter++;
                workI /= 10;
            }else{
                long a = order(digitCounter);
                i += a;
                i /= a;
                i *= a;
                break;
            }
        }
        if(counter == k){break;}
    }
//--------------------
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            StringBuilder ans = new StringBuilder();
            for (int i = 0; i < S.length(); i++) {
                ans.append("x");
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i <n; i++)
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
#define def 0
template<class V, int NV> struct SegTree { //[l,r)の最大値を得ていることに注意
    V comp(V& l, V& r) { return min(l, r); };

    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x, int y, int l = 0, int r = NV, int k = 1) {
        if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2); 
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v) {
        i += NV; val[i] = v;
        while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};

int N, H[201010], A[201010];
SegTree<ll, 1 << 18> dp;

int main(){
    int N; cin >> N;
    ll ans = 0;
    vector<int> A(N);
    rep(i, N ) cin >> A[i];
    if(A[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    /* for(int i = 1; i < N; i++){
        if(A[i] - A[i-1] > 1) cout << -1 << endl;
        return 0;
    } */
    map<int, int> MP;

    for(int i = N - 2; i >= 0; i--){
        if(A[i+1] > 0){
            if(MP[A[i+1] - i - 1] != 0) continue;
            else{
                if(A[i+1] - A[i] > 1){
                    cout << - 1 << endl;
                    return 0;
                }
                MP.clear();
                MP[A[i+1] - i - 1]++;
                ans += A[i+1];
            }
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();

			List<P> list = new ArrayList<>();
			List<Integer> target = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				long c = in.nextLong();
				list.add(new P(i, c));
			}

			long max = 0;
			for (int i = 0; i < n; i++) {
				if (max < list.get(i).c) {
					max = list.get(i).c;
					target.add(list.get(i).k);
				}
			}

			Collections.sort(list, (x, y) -> (int)x.c - (int)y.c);

			max = 0;
			int idx = 0;
			long sum = 0;
			long[] ans = new long[n];
			for (int i = 0; i < n; i++) {
				long c = list.get(i).c;
				if (max < c && list.get(i).k == target.get(idx)) {
					ans[list.get(i).k] = sum + (c - max)*(long)(n - i);
					max = c;
					idx++;
					sum = 0;
				} else {
					sum += list.get(i).c - max;
				}
			}

			for (long l : ans) {
				System.out.println(l);
			}

		}
	}
	static class P {
		int k; long c;

		public P(int k, long c) {
			this.k = k;
			this.c = c;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

#define abs(a) ((a) > 0) ? (a) : (-(a))

int main () {
    int N;
    scanf("%d", &N);
    int *W = malloc((1 + N) * sizeof(int));
    for (int i = 1; i <= N; i++) {
        scanf("%d", &W[i]);
    }

    // initialize
    int S1 = W[1];
    int S2 = 0;
    for (int i = 2; i <= N; i++) {
        S2 += W[i];
    }

    int ans = abs(S1 - S2);
    for (int i = 2; i < N; i++) {
        S1 += W[i];
        S2 -= W[i];
        int current = abs(S1 - S2);
        if (current < ans)
            ans = current;
    }

    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi h(n);
    rep(i,n) cin >> h[i];
    vi dp(n,LINF);
    dp[0] = 0;
    rep(i,n)loop(j,1,k+1)if(i+j < n){
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true){

			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if(op.equals("?"))break;

			int ans = 0;

			switch(op){
			case "+":
				ans = a+b;
				break;
			case "-":
				ans = a-b;
				break;
			case "*":
				ans = a*b;
				break;
			case "/":
				ans = a/b;
				break;
			}

			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 26316
/**
 *    author:  Taichicchi
 *    created: 21.09.2020 22:45:50
 **/

#include <bits/stdc++.h>

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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

    string S;
    cin >> S;

    int K;
    cin >> K;

    char s = S[K - 1];

    rep(i, N) {
        if (S[i] != s) {
            S.replace(i, 1, "*");
        }
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void*p,const void*q)
{
	return (*(int*)p-*(int*)q);
}
int a[300000],b[300000],c[300000],d[300000];
int main()
{
	int n,m,i,j,k,l,r,z; 
	scanf("%d%d",&n,&m);
	for(k=j=i=0;i<m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]==1)
			c[j++]=b[i];
		if(b[i]==n)
			d[k++]=a[i];
	}
	z=0;
	if(c[0]!=0&&d[0]!=0)
	{
		qsort(d,k,sizeof(d[0]),cmp);
		for(z=i=0;i<=j;i++)
		{
			l=0;r=k;
			while(l<=r)
			{
				int m=(l+r)/2;
				if(d[m]<c[i])
					l=m+1;
				else if(d[m]>c[i])
					r=m-1;
				else
				{
					z=1;
					break;
				}
			}
		}
	}
	if(z)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;

signed main(){
    int N;
    pair<int,int> O[114514],E[114514];
    cin >> N;
    REP(i,114514){
        O[i].second=i;
        E[i].second=i;
        O[i].first=0;
        E[i].first=0;
    }
    REP(i,N/2){
        int w,x;
        cin >> w >> x;
        E[w].first++;
        O[x].first++;
    }
    sort(E,E+100000,greater<Pp>());
    sort(O,O+100000,greater<Pp>());
    
    int a,b;
    a=E[0].first;
    b=O[0].first;
    //cout << a << " " << b << endl;
    if(E[0].second==O[0].second){
        if(O[1].first>E[1].first){
            b=O[1].first;
        }else{
            a=E[1].first;
        }
    }
    cout << N-a-b << endl;
    
    return 0;
}   


Measured memory_bytes: 3840
#include<cstdio>
const int inf=1<<29;
int N,M;
int G[15][15],g[1<<15],f[1<<13][15];
void cmax(int&a,int b){b>a?a=b:1;}
int main(){
	scanf("%d%d",&N,&M);
	while(M--){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		--a,--b;
		G[a][b]=G[b][a]=c;
	}
	for(int S=1;S<1<<N;S++){
		int i=N;while(!(S>>i&1))i--;
		g[S]=g[S-(1<<i)];
		for(int j=i;j--;)if(S>>j&1)g[S]+=G[i][j];
	}
	int ans=-inf;
	for(int S=0;S<1<<N-2;S++){
		for(int i=1;i<N;i++)if(S>>i-1&1){
			int F=-inf;
			for(int T=S;T;T=T-1&S)
				if(T>>i-1&1)cmax(F,f[S-T][i]+g[T<<1]);
			f[S][i]=F;
			if(G[0][i])cmax(ans,F+g[(1<<N-1)-1-S*2]+G[0][i]);
		}
		for(int i=1;i<N;i++)if(!(S>>i-1&1)){
			int F=-inf;
			for(int j=1;j<N;j++)if((S>>j-1&1)&&G[i][j])cmax(F,f[S][j]+G[i][j]);
			if(G[i][N-1])cmax(F,g[S<<1|1<<N-1]+G[i][N-1]);
			f[S][i]=F;
		}
		if(G[0][N-1])cmax(ans,g[S<<1|1<<N-1]+g[(1<<N-1)-1-S*2]+G[0][N-1]);
	}
	printf("%d\n",g[(1<<N)-1]-ans);
}

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

int main() {
  int N;
  cin >> N;
  int min;
  int number=1;
  int indicator = 0;
  while (indicator == 0){
  min = N*number;
  if (min % 2 == 0){
    indicator = 1;
   }
  else {
    number += 1;
   }
  }
  cout << min;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,c;
  cin >> n >> c;
  int d[c][c];
  int f[n][n];
  rep(i,c){
    rep(j,c){
      cin >> d[i][j];
    }
  }
  rep(i,n){
    rep(j,n){
      cin >> f[i][j];
      f[i][j]--;
    }
  }
  ll cost[3][c];
  rep(i,3){
    rep(j,c){
      cost[i][j]=0;
    }
  }
  rep(k,c){
    rep(i,n){
      rep(j,n){
        cost[(i+j)%3][k]+=d[f[i][j]][k];
      }
    }
  }
  ll res=INF;
  rep(i,c){
    rep(j,c){
      if(i==j)continue;
      rep(k,c){
        if(k==i || k==j)continue;
        chmin(res,cost[0][i]+cost[1][j]+cost[2][k]);
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1280