akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll modpow(ll a, ll n=MOD-2, ll mod=MOD){ // a^n % MOD の計算
    ll res = 1;
    while (n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a  % mod;
        n >>= 1;
    }
    return res;
}
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    vector<ll> B(N,0);
    rep(i,N-1) B[i]=A[i+1]-A[i];
    ll ans2=1;
    rep(i,N-1){
        ans2*=(i+1);
        ans2%=MOD;
    }
    ll now=0;
    ll ans=0;
    rep(i,N-1){
        now+=modpow(i+1);
        now%=MOD;
        ans+=now*B[i];
        ans%=MOD;
    }
    ans*=ans2;
    ans%=MOD;
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1792
N, W = (int(i) for i in input().split())
dp = [0] * (W + 1)

for i in range(N):
    v, w = (int(i) for i in input().split())
    for j in range(w, W + 1):
        dp[j] = max(dp[j], dp[j - w] + v)

print(dp[W])

Measured memory_bytes: 7032
#include<stdio.h>
    #include<string.h>
    int main(void){
       char c[3][3];
       int i,j;
       for(i=0;i<3;i++){
             scanf("%s",&c[i]);
       }  
       printf("%c%c%c",c[0][0],c[1][1],c[2][2]);
       return 0;
    }

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

int main()
{
    int x, n, tmp, upper, lower;
    cin >> x >> n;

    if(!n)
    {
        cout << x << "\n";
        return 0;
    }

    vector<int> v(101, 0);

    for(int i = 0; i < n; ++i)
    {
        cin >> tmp;
        v[tmp]++;
    }

    for(int i = x; i <= 101; ++i)
    {
        if(v[i] == 0)
        {
            upper = i;
            break;
        }
    }
    for(int i = x; i >= 0; --i)
    {
        if(v[i] == 0)
        {
            lower = i;
            break;
        }   
    }

    cout << (upper - x < x - lower ? upper : lower) << "\n";
    return 0;
}

Measured memory_bytes: 3640
N = int(input())

D = []
for i in range(N):
    d1, d2 = map(int, input().split())
    D.append([d1, d2])

count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            break
    else:
        count = 0

print("Yes") if count == 3 else print("No")


Measured memory_bytes: 62492
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int N, M;
vector<int> id;
vector<vector<int>> A;
unordered_set<int> se;
int ans = inf;
void dfs() {
  map<int, int> mp;
  rep(i, N) mp[A[i][id[i]]]++;
  int mx = 0;
  for(auto m: mp) mx = max(m.second, mx);
  ans = min(mx, ans);
  if(se.size() == 1) return;
  vector<int> tmpId(N);
  rep(i, N) tmpId[i] = id[i];
  for(auto m: mp) {
    if(m.second == mx) {
      se.erase(m.first);
      rep(i, N) while(id[i]<M && !se.count(A[i][id[i]])) id[i]++;
      dfs();
      break;
      se.insert(m.first);
      rep(i, N) id[i] = tmpId[i];
    }
  }
}
int main() {
  cin >> N >> M;
  A = vector<vector<int>>(N, vector<int>(M));
  rep(i, N) rep(j, M) cin >> A[i][j];
  id = vector<int>(N);
  rep(i, M) se.insert(i+1);
  dfs();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
int32_t main()
{
    int n,m,k; cin >> n >> m >> k;
    cout  << (n + m -1) / m * k;		
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;

#define MAX_N 100000
int h[MAX_N + 2019];
int status[2];
int main() {
	int N;
	cin >> N;
	
	for(int i = 0; i < N; ++i)
		scanf("%d", &h[i]);
	
	if(N == 2) {
		cout << sqrt((h[0] - h[1]) * (h[0] - h[1]));
		return 0;
	}
	status[0] = sqrt((h[0] - h[1]) * (h[0] - h[1]));
	status[1] = sqrt((h[0] - h[2]) * (h[0] - h[2]));
	
	for(int i = 3; i < N; ++i) {
/*
		cout << i << endl;
		cout << status[0] << "  " << status[1] << endl;//*/
		int k = min(status[0] + sqrt((h[i] - h[i - 2]) * (h[i] - h[i - 2])),
						status[1] + sqrt((h[i] - h[i - 1]) * (h[i] - h[i - 1])));
		status[0] = status[1];
		status[1] = k; 
/*
		cout << status[0] + sqrt((h[i] - h[i - 2]) * (h[i] - h[i - 2]) << endl;
		cout << status[1] + sqrt((h[i] - h[i - 1]) * (h[i] - h[i - 1]))//*/
/*
		cout << k << endl;
		cout << endl;//*/
	}
	
/*
	cout << endl;
	cout << status[0] << "  " << status[1] << endl;//*/
	cout << status[1] << endl;
	return 0;
} 

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

// bellman-ford ????????????????????????
public class Main {

    static int dist[][];
    static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int E = sc.nextInt();
        int s = sc.nextInt();

        Edge[] list = new Edge[E];

        for (int i = 0; i < E; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int f = sc.nextInt();
            list[i] = new Edge(a, b, f);
            // ????????°??????
            // list[i] = new Edge(b, a, f);
        }

        int[] d = new int[N];
        Arrays.fill(d, INF);
        d[s] = 0;

        for (int i = 0; i < E; i++) {
            for (int j = 0; j < E; j++) {
                Edge e = list[j];
                if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    if (i == E - 1) {
                        System.out.println("NEGATIVE CYCLE");
                        return;
                    }
                }
            }
        }

        for (int i = 0; i < N; i++) {
            System.out.println(d[i] == INF ? "INF" : d[i]);
        }
    }

    static class Edge implements Comparable<Edge> {
        public int from;
        public int to;
        public int cost;

        public Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }


        @Override
        public int compareTo(Edge o) {
            return this.cost - o.cost;
        }
    }

    public static boolean hasNegativeLoopWF(int[][] a) {
        for (int i = 0; i < a.length; i++) {
            if (a[i][i] < 0) {
                return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 37932
#include<cstdio>
using namespace std;
int sx,sy,tx,ty;
int main(){
  scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
  for(int i=sy;i<ty;i++)printf("U");
  for(int i=sx;i<tx;i++)printf("R");
  for(int i=ty;i>sy;i--)printf("D");
  for(int i=tx;i>sx;i--)printf("L");
  printf("L");
  for(int i=sy;i<ty+1;i++)printf("U");
  for(int i=sx;i<tx+1;i++)printf("R");
  printf("DR");
  for(int i=ty;i>sy-1;i--)printf("D");
  for(int i=tx+1;i>sx;i--)printf("L");
  printf("U");
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int N;cin >> N;int X;cin >> X;
    int ans = 1;
    int now = 0;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        now += b;
        if(now <= X){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
import static java.lang.System.in;
 
public class Main {
    static long mod = 1000000000+7;
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), h = sc.nextInt(), w = sc.nextInt();
        int ans = (n-h+1)*(n-w+1);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, M = map(int, input().split())
Ss = input()
Ts = input()

g = gcd(N, M)
ds, dt = N // g, M // g

if Ss[::ds] == Ts[::dt]:
    print(N * M // g)
else:
    print(-1)


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ll N; cin>>N;
    ll a[N+1];
    CINA(a,N+1);
    
    ll right[N+1];
    right[N] = 0;
    for(int i=N-1;i>=0;--i){
        right[i] = right[i+1]+a[i+1];
    }
    
    ll ans = 0;
    ll node = 1;
    REP(depth,N+1){
        if(node>=a[depth]){
            if(node==a[depth]&&depth<N){
                ans = -1; break;
            }
            ans += node;
            node = min( (ll)(node-a[depth])*2, (ll)right[depth]);
        }else{
            ans = -1;
            break;
        }
    }
    
    cout << ans << "\n";

}

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


int main() {

	int a[100];
	int size;
	int count = 0;

	cin >> size;

	for (int i = 0; i < size; i++) {
		cin >> a[i];
	}

	bool flg = true;
	int temp;
	do {
		flg = false;
		for (int i = size - 1; i >= 1; i--) {
			if (a[i] < a[i - 1]) {
				temp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = temp;
				count++;
				flg = true;
			}
		}

	} while (flg);

	for (int i = 0; i < size; i++) {
		printf("%d", a[i]);
		if (i + 1 != size)printf(" ");
	}
	printf("\n%d\n", count);




//	system("pause");
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int hen(char a) {
  if((int)a - 48 >= 0 && (int)a - 48 < 10) return (int)a - 48;
  if(a == 'a') return 10;
  else if(a == 'b') return 11;
  else if(a == 'c') return 12;
  else if(a == 'd') return 13;
  else if(a == 'e') return 14;
  else return 15;
}

int main() {
  string s;
  while(cin >> s) {
    if(s == "0") return 0;
    int r = hen(s[1]) * 16 + hen(s[2]);
    int g = hen(s[3]) * 16 + hen(s[4]);
    int b = hen(s[5]) * 16 + hen(s[6]);

    int ans = INT_MAX;
    string mans;
    if(r * r + g * g + b * b < ans) ans = r * r + g * g + b * b, mans = "black";
    if(r * r + g * g + (b - 255) * (b - 255) < ans) ans = r * r + g * g + (b - 255) * (b - 255), mans = "blue";
    if(r * r + (g - 255) * (g - 255) + b * b < ans) ans = r * r + (g - 255) * (g - 255) + b * b, mans = "lime";
    if(r * r + (g - 255) * (g - 255) + (b - 255) * (b - 255) < ans) ans = r * r + (g - 255) * (g - 255) + (b - 255) * (b - 255), mans = "aqua";
    if((r - 255) * (r - 255) + g * g + b * b < ans) ans = (r - 255) * (r - 255) + g * g + b * b, mans = "red";
    if((r - 255) * (r - 255) + g * g + (b - 255) * (b - 255) < ans) ans = (r - 255) * (r - 255) + g * g + (b - 255) * (b - 255), mans = "fuchsia";
    if((r - 255) * (r - 255) + (g - 255) * (g - 255) + b * b < ans) ans = (r - 255) * (r - 255) + (g - 255) * (g - 255) + b * b, mans = "yellow";
    if((r - 255) * (r - 255) + (g - 255) * (g - 255) + (b - 255) * (b - 255) < ans) ans = (r - 255) * (r - 255) + (g - 255) * (g - 255) + (b - 255) * (b - 255), mans = "white";

    cout << mans << endl;
  }
}

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main() {
	int x, a=1;
	std::cin >> x;
	for (int b = 1; b <= x; ++b) {
		for (int p = 2; p <= x; ++p) {
			if (pow(b, p) <= x&&a<=pow(b,p)) {
				a=pow(b,p);
			}
		}
	}
	std::cout << a << std::endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    vector<array<int, 2>> a(n);
    long long sum = 0;
    for (auto& it : a)
        cin >> it[0] >> it[1], sum += it[1];
    vector<long long> dp(sum + 1, 2e9);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = sum; j >= a[i][1]; j--) {
            dp[j] = min(dp[j], dp[j - a[i][1]] + a[i][0]);
        }
    }
    int idx = sum;
    while (dp[idx] > w)
        idx--;
    cout << idx;
    return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
using namespace std;
typedef long long ll;

int main()
{
	int n;
  	string p = "1";
	int x, y;
  	stack<int> a;
  	while(cin >> p){
      	if (p == "+"){
        	x = a.top();
          	a.pop();
          	y = a.top();
          	a.pop();
          	a.push(x+y);
             
        }
      	else if (p == "-"){
        	x = a.top();
          	a.pop();
          	y = a.top();
          	a.pop();
          	a.push(y-x);
        }
      	else if (p == "*"){
        	x = a.top();
          	a.pop();
          	y = a.top();
          	a.pop();
          	a.push(x*y);    
        }
      
      	else {
        n = stoi(p);
        a.push(n);
        }
      	
    }
  	cout << a.top() <<endl;
	return 0;
}


Measured memory_bytes: 3172
#include <cstdio>
#include <valarray>
#include <complex>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;

typedef complex<double> C;
typedef valarray<double> P;

#define EPS 1e-8

void assign(P &p, double x, double y, double z){
	p.resize(3);
	p[0] = x;
	p[1] = y;
	p[2] = z;
}

P cross(const P &a, const P &b){
	return a.cshift(1) * b.cshift(-1) - a.cshift(-1) * b.cshift(1);
}

P base(3);
P pts[5];

void rot(P &p, int i1, int i2, const C &r){
	C z(p[i1], p[i2]);
	z *= r;
	p[i1] = real(z);
	p[i2] = imag(z);
}

void corrot(int i1, int i2){
	C z(base[i1], base[i2]);
	if(abs(z) < EPS){
		return;
	}
	C r = polar(1.0, -arg(z));
	rot(base, i1, i2, r);
	for(int i = 0; i < 5; ++i){
		rot(pts[i], i1, i2, r);
	}
}

double dot(const C &a, const C &b){
	return real(a) * real(b) + imag(a) * imag(b);
}

double cross(const C &a, const C &b){
	return real(a) * imag(b) - imag(a) * real(b);
}

double distance_ls_p(const C &a, const C &b, const C &c){
	if(dot(b - a, c - a) <= 0.0) return abs(c - a);
	if(dot(a - b, c - b) <= 0.0) return abs(c - b);
	return abs(cross(b - a, c - a)) / abs(b - a);
}

bool contains(const vector<C> &plg, const C &pt){
	int cnt = 0;
	double y = imag(pt);

	for(size_t i = 1; i < plg.size(); ++i){
		size_t j = i - 1;

		if(distance_ls_p(plg[i], plg[j], pt) < EPS){
			return true;
		}

		double dyi = imag(plg[i]) - y;
		double dyj = y - imag(plg[j]);
		double tx = (dyi * real(plg[j]) + dyj * real(plg[i])) / (dyi + dyj);

		if(imag(plg[i]) >= y && imag(plg[j]) < y){
			if( tx < real(pt) ) ++cnt;
		}
		else if(imag(plg[i]) < y && imag(plg[j]) >= y){
			if( tx < real(pt) ) ++cnt;
		}
	}
	
	return (cnt % 2 != 0);
}

bool solve(){
	double x, y, z;
	for(int i = 0; i < 5; ++i){
		if(scanf("%lf%lf%lf", &x, &y, &z) == EOF){
			return 0;
		}
		assign(pts[i], x, y, z);
	}

	base = cross(pts[2] - pts[3], pts[3] - pts[4]);

	if(base.max() < EPS && base.min() > -EPS){
		return true;
	}

	corrot(2, 0);
	corrot(2, 1);

	double sz = pts[2][2];
	for(int i = 0; i < 5; ++i){
		pts[i][2] -= sz;
	}

	if(	(pts[0][2] > EPS && pts[1][2] > EPS) ||
		(pts[0][2] < -EPS && pts[1][2] < -EPS)
	){
		return true;
	}

	P v = pts[1] - pts[0];
	if(abs(v[2]) > EPS){
		double t = -pts[0][2] / v[2];
		P u = pts[0] + t * v;
		vector<C> tri;
		for(int i = 2; i < 5; ++i){
			tri.push_back(C(pts[i][0], pts[i][1]));
		}
		tri.push_back(tri[0]);
		
		if(contains(tri, C(u[0], u[1]))){
			return false;
		}
	}
	
	return true;
}

int main(){
	puts(solve() ? "HIT" : "MISS");
}

Measured memory_bytes: 1272
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main(void) {

  int N , M , C;
  scanf("%d %d %d",&N,&M,&C);
  int B[M];
  for (int i = 0 ; i<M;i++)
  scanf("%d",&B[i]);

  int count = 0;
  int A[M];
  int sum = 0;
  while(N--)
  {
     for (int i = 0;i<M;i++)
     {
        scanf("%d",&A[i]);
        sum+=A[i]*B[i];
     }

      sum+=C;
      if (sum>0)count++;
      sum=0;
  }

   printf("%d",count);

	return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1<<50LL
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

template <class T>
class EdgeBase
{
public:
    int to;
    T cost;
    EdgeBase(){};
    EdgeBase(int to0, T cost0){to = to0; cost = cost0;}
};
typedef EdgeBase<long long> Edge;
 
template<class T>
void dijkstra(const vector<vector<EdgeBase<T> > >& edges, int start, vector<T>& dist)
{
    const T Inf = numeric_limits<T>::max();
    const T EPS = static_cast<T>(1.0e-10);
 
    dist.assign(edges.size(), Inf);
    dist[start] = 0;
    priority_queue<pair<T,int>, vector<pair<T,int> >, greater<pair<T,int> > > q;
    q.push(make_pair(0, start));
 
    while(!q.empty()){
        pair<T, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first - EPS)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            EdgeBase<T> e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to] - EPS){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  s--;t--;
  vector<vector<Edge>> edgeA(n),edgeB(n);
  
  REP(_,m){
    ll u,v,yen,snuk;
    cin >> u >> v >> yen >> snuk;
    u--;v--;
    edgeA[u].push_back(Edge(v,yen));
    edgeA[v].push_back(Edge(u,yen));
    edgeB[u].push_back(Edge(v,snuk));
    edgeB[v].push_back(Edge(u,snuk));
  }
  
  vector<ll> dista,distb;
  
  dijkstra(edgeA,s,dista);
  dijkstra(edgeB,t,distb);
  // sからAでいける　ｔまでBでいける
  
  vector<ll> cost(n);
  REP(i,n){
    cost[i] = dista[i] + distb[i];
  }
  
//  REP(i,n) cout << cost[i] << endl;

  RREP(i,n-1){
    cost[i] = min(cost[i],cost[i+1]);
  }
  
  REP(i,n)
    cout << 1000000000000000 - cost[i] << endl;
  
  return 0;
}


Measured memory_bytes: 19332
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair { 
    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); 
        return hash1 ^ hash2; 
    } 
}; 

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    ll n, ans=0;
    
    cin >> n;
    
    for(int K=1; K<=n; K++){
		if(K%3!=0 && K%5!=0) ans += K;
	}
	
	cout << ans << "\n";
}


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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}


Measured memory_bytes: 3528
var line;
var moji;
var result = Infinity;

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line',function(x){
    line = x;
});

rl.on('close',function(){
    
    moji=line.split("");
    for (var i=0;i<moji.length-2;i++){
        tmp = Number(moji[i]+moji[i+1]+moji[i+2]);
        tmp = Math.abs(tmp - 753);
        if(result>tmp){result = tmp;}
    }
    //dfs(0,[]);
    console.log(result);
});

Measured memory_bytes: 7756
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int main()
{
	bool flag = false;
	int a, b; cin >> a >> b;
	for(int i = 1; i <= 3; i++){
		if((a * b * i) & 1) flag = true;
	}
	flag ? puts("Yes") : puts("No");
	return 0;
}

Measured memory_bytes: 764
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    string s;cin >> s;
    if(s.back()=='s') s+="es";
    else s+="s";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL p,q,r;
    cin>>p>>q>>r;
    PUTS(min(p+q, min(q+r, p+r)));
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	sum := make([]int, n+1)
	for i := 0; i < n; i++ {
		sum[i+1] = sum[i]+a[i]
	}

	cnt := make(map[int]int, n)

	ans := 0
	for i := 0; i < len(sum); i++ {
		ans += cnt[sum[i]]
		cnt[sum[i]]++
	}

	fmt.Fprintln(wr, ans)
}


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

typedef long long ll;

char s;

void answer(){
	cin >> s ;
	if(isupper(s)){
		cout << "A";
		}
	else{cout << "a";}
}

int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	answer(); 
return 0 ;
}


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

int main(){
    ll N,P;
    cin >> N >> P;
    string S;
    cin >> S;
    vector<ll> pr(N+1,0);
    ll ans = 0;
    if(10 % P == 0){
        for(int i=N-1;i>=0;i--){
            if((S[i] - '0') % P == 0){
                ans += i+1;
            }
        }
        cout << ans <<endl;
        return 0;
    }
    ll ten = 1;
    for(int i=N-1;i>=0;i--){
        ll a = (S[i] - '0');//*ten;
        a %= P;
        a *= ten;
        a %= P;
        ten *= 10;
        ten %= P;
        pr[i] = (a+pr[i+1]) % P; 
    }
    /*rep(i,N){
        cout << pr[i] << endl;
    }*/
    vector<ll> cnt(P,0);
    cnt[0]++;
    rep(i,N){
        //cout << pr[i] << endl;
        //int c = S[i] - '0';
        ans += cnt[pr[i]];
        cnt[pr[i]]++;
    }


    cout << ans << endl;
}


Measured memory_bytes: 2180
#include <stdio.h>

int main(void)
{
    long long int ans = 0, max = 0;
    int n;

    scanf("%d", &n);
    long long int h[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &h[i]);
        if (i != 0)
            if (h[i] <= h[i - 1])
                max++;
            else
            {
                if (max > ans)
                    ans = max;
                max = 0;
            }
    }
    if (ans < max)
        ans = max;

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 896
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a) memset((a),0,sizeof(a))
#define MCLR(a) memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int N;
    int zero = 0, two = 0;
    cin >> N;
    REP(i, N){
        int a;
        cin >> a;
        if(a%4==0){
            two++;
        }else if(a%2==1){
            zero++;
        }
    }

    if(zero <= two || (N % 2 == 1 && N / 2 == two)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100

int n, M[N][N];
int color[N], d[N], f[N], t;
int nt[N];

int nxt(int u){
	for (int v = nt[u]; v < n; ++v){
		nt[u] = v + 1;
		if (M[u][v]) return v;
	}
	return -1;
}

void dfs_visit(int idx){
	for (int i = 0; i < n; ++i) nt[i] = 0;

	stack<int> s; s.push(idx);
	color[idx] = GRAY;
	d[idx] = ++t;

	while (!s.empty()) {
		int u = s.top();
		int v = nxt(u);
		if (-1 != v){
			if (WHITE == color[v]){
				color[v] = GRAY;
				d[v] = ++t;
				s.push(v);
			}
		}
		else{
			s.pop();
			color[u] = BLACK;
			f[u] = ++t;
		}
	}
}

void dfs(){
	for (int i = 0; i < n; ++i)	color[i] = WHITE;

	t = 0;
	for (int i = 0; i < n; ++i){
		if (color[i] == WHITE) dfs_visit(i);
	}

	for (int i = 0; i < n; ++i)
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;

}


int main(){
	cin >> n;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j) M[i][j] = 0;
	}

	for (int i = 0; i < n; ++i){
		int u, d, v; cin >> u >> d;
		for (int j = 0; j < d; ++j)
		{
			cin >> v;
			M[u - 1][v - 1] = 1;
		}
	}

	dfs();
	return 0;
}

Measured memory_bytes: 3096
def solve(N, M):
    # 1 2
    # 3 4

    # 1 2
    # 3 4
    #
    # (0)    (1)
    # 1 2    1 2 3
    # 3 4    4 5 6
    # 5 6    7 8 9
    def cut(n):
        if n == 1:
            return 1
        elif n == 2:
            return 0
        return n - 2

    return cut(N) * cut(M)

N, M = [int(x) for x in input().split()]
print(solve(N, M))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 11;
const int mod = 1e9 + 7;
int f[N][N], n, q, a[N];
inline int A(int x, int y){
    return x + y - (x + y >= mod ? mod : 0);
}
inline int M(int x, int y){
    return 1LL * x * y % mod;
}
int main(){
    cin>>n>>q;
    for(int i = 1;i <= n; i++)cin>>a[i];
    for(int i = 1;i <= n; i++){
        for(int j = 1;j <= n; j++)f[i][j] = a[i] < a[j];
    }
    int inv2 = (mod + 1) / 2, mi = 1;
    for(int i = 1;i <= q; i++){
        mi = (mi << 1) % mod;
        int x, y;
        cin>>x>>y;
        f[x][y] = f[y][x] = M(inv2, A(f[x][y], f[y][x]));
        for(int j = 1;j <= n; j++){
            if(j == x || j == y)continue;
            f[x][j] = f[y][j] = M(inv2, A(f[x][j], f[y][j]));
            f[j][x] = f[j][y] = M(inv2, A(f[j][x], f[j][y]));
        }
    }
    int ans = 0;
    for(int i = 1;i <= n; i++){
        for(int j = i - 1;j >= 1; j--)ans = A(ans, f[i][j]);
    }
    ans = M(ans, mi);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  rep(i, n) ans += a[i] - 1;
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0]<<endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int i;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    double sum = 0;
    for(int x : a){
        sum += x;
    }
    sum = sum/(4*m);
    int ans = 0;
    for(i = 0; i < n; i++){
        if(a.at(i) >= sum){
            ans++;
        }
    }
    if(ans >= m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <iomanip>

int64_t cross(int64_t v1x, int64_t v1y, int64_t v2x, int64_t v2y) {
    return v1x * v2y - v2x * v1y;
}

int main() {
    int64_t q;

    std::cin >> q;
    
    for (auto i = 0; i < q; ++i) {
        int64_t x0, y0, x1, y1, x2, y2, x3, y3;
        std::cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

        auto v1x = x1 - x0;
        auto v1y = y1 - y0;
        auto v2x = x3 - x2;
        auto v2y = y3 - y2;

        bool ans;
        // 線分が同一直線上に存在する場合
        if (cross(v1x, v1y, x2-x0, y2-y0) == 0 && cross(v1x, v1y, x3-x0, y3-y0) == 0) {
            auto f0 = (v1x * (x2-x0) + v1y * (y2-y0)) * (v1x * (x3-x0) + v1y * (y3-y0));
            auto f1 = (v1x * (x2-x1) + v1y * (y2-y1)) * (v1x * (x3-x1) + v1y * (y3-y1));
            auto f2 = (v2x * (x0-x2) + v2y * (y0-y2)) * (v2x * (x1-x2) + v2y * (y1-y2));
            auto f3 = (v2x * (x0-x3) + v2y * (y0-y3)) * (v2x * (x1-x3) + v2y * (y1-y3));

            ans = (f0 <= 0) || (f1 <= 0) || (f2 <= 0) || (f3 <= 0);
        } else {
            auto c0 = cross(v1x, v1y, x2-x0, y2-y0);
            auto c1 = cross(v1x, v1y, x3-x0, y3-y0);
            auto c2 = cross(v2x, v2y, x0-x2, y0-y2);
            auto c3 = cross(v2x, v2y, x1-x2, y1-y2);

            ans = c0 * c1 <= 0 && c2 * c3 <= 0;
        }

        std::cout << ( ans ? 1 : 0 ) << std::endl;
    }
    return 0;
}



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

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector <int> > vvi;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);


typedef pair<int,bool> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1,x2;
    cin >> x1 >> x2;
    cout << abs(x1-x2) << endl;
    return 0;
}



Measured memory_bytes: 3172
/***************************************************
 * Problem Name : D - Face Produces Unhappiness.cpp
 * Problem Link :
 * Contest Name :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2019-09-07
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<ll,ll>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int n, k;
    string str;
    cin >> n >> k;
    cin >> str;
    int cnt = 0;

    for (int i = 1; i < n; i++) {
        if (str[i] == str[i - 1]) cnt++;
    }

    cout << min (n - 1, cnt + 2 * k) << "\n";
    return 0;
}


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

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

using namespace std;

signed main()
{
    int N, A, B;
    string s;

    cin >> N >> A >> B;
    cin >> s;
    int count = 0;
    int count_kaigai = 0;
    rep(i, N)
    {
        // cout << s[i] << count << endl;
        if (s[i] == 'a')
        {
            if (count < A + B)
            {
                cout << "Yes" << endl;
                count++;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        if (s[i] == 'b')
        {
            if (count < A + B)
            {
                if (count_kaigai < B)
                {
                    cout << "Yes" << endl;
                    count++;
                    count_kaigai++;
                }
                else
                {
                    cout << "No" << endl;
                }
            }
            else
            {
                cout << "No" << endl;
            }
        }
        if (s[i] == 'c')
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,r;
    cin >>n  >> r;
    if(n>=10){
        cout << r << endl;
    }
    else{
        cout << r+100*(10-n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			if (s.Contains("7")) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


Measured memory_bytes: 25792
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort(reverse = True)
check = a_list[:m]
frag = True
for a in check:
  if a < sum(a_list)/(4*m):
    frag = False
if frag:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 3060
n, c = [int(i) for i in input().split(" ")]
d = [0 for i in range(0, c + 1)]
a = [0 for i in range(0, n + 1)]

for i in range(1, c + 1):
    d[i] = [0] + [int(i) for i in input().split(" ")]

for i in range(1, n + 1):
    a[i] = [0] + [int(i) for i in input().split(" ")]
    
m = [[] for i in range(0, 3)]

for i in range(1, n + 1):
    for j in range(1, n + 1):
        m[(i + j) % 3].append(a[i][j])

d_min = 1000*500*500

def s(p):
    ca = [True] * (c + 1)
    c_min = 0
    global d_min
    d_min_t_sum = 0
    for mod in p:
        d_min_t = 1000*500*500
        for ci in range(1, c + 1):
            if ca[ci]:
                d_sum = sum([d[mi][ci] for mi in m[mod]])
                #print(d_sum)
                if d_sum < d_min_t:
                    d_min_t = d_sum
                    c_min = ci
        ca[c_min] = False
        d_min_t_sum += d_min_t
    if d_min_t_sum < d_min:
        d_min = d_min_t_sum
        
s([0, 1, 2])
s([0, 2, 1])
s([1, 0, 2])
s([1, 2, 0])
s([2, 1, 0])
s([2, 0, 1])

print(d_min)

Measured memory_bytes: 128332
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		// 配列を準備
		// int[] array = new int[N];
		// 最初からリスト
		List<Integer> list = new ArrayList<>();
		// for文でN回繰り返し
		for (int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		Collections.reverse(list);
		// 大きい方から小さい方に？ 小さい方から大きい方に？⇒後で。

		// for(int i = 0; i < list.size();i++) {
		// 配列に対する操作であって、Collectionsに合わせたループがある
		boolean flag = true;
		int AliceMaxCount = 0;
		int BobMaxCount = 0;
		Iterator<Integer> i = list.iterator();
		while (i.hasNext()) {
			if (flag) {
				// true なので Alice
				// 該当カードを取得する
				AliceMaxCount += i.next();
				//
				flag = false;
			} else {
				// Bob
				BobMaxCount += i.next();
				flag = true;
			}
		}
		System.out.println(AliceMaxCount - BobMaxCount);
		sc.close();
	}
}

Measured memory_bytes: 21844