akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60;


int main(){	
	int N,M;
	cin >> N >> M;
	vector<int> L(M);
	vector<int> R(M);
	for(int i = 0; i < M; i++){
		cin >> L[i];
		cin >> R[i];
	}
	int LL = 0;
	int RR = 1000000;
	for(int i = 0; i < M; i++){
		LL = max(L[i],LL);
		RR = min(R[i],RR);
	}
	cout << max(0, RR-LL+1) << endl;

}

Measured memory_bytes: 1024
def gcd(c,d):
  if d==0:
    return c
  else:
    t=c%d
    return gcd(d,t)

a,b,c,d=map(int,input().split())
m=c*d//gcd(c,d)
a-=1
l=a-a//c-a//d+a//m
r=b-b//c-b//d+b//m
print(r-l)

Measured memory_bytes: 3060
a=[]
q=int(input())

def pushback(a,x):
    a.append(x)
    return a

def randomaccess(a,p):
    print(a[p])

def popback(a):
    a.pop(len(a)-1)
    return a

for i in range(q):
    query=list(map(int,input().split()))
    if query[0]==0:
        a=pushback(a,query[1])
    elif query[0]==1:
        randomaccess(a,query[1])
    else:
        a=popback(a)
    



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    ll tmp = sum;
    for (int i = 0; i < n; i+=2) {
        tmp -= a[i]; 
    }
    
    vector<ll> ans(n);
    ans[0] = sum - (2*tmp);

    for (int i = 1; i < n; ++i){
        ans[i] = 2 * a[i-1] - ans[i-1];
    }
    
    for (auto& p : ans) {
        cout << p << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

/*  ll t=1;
    while(t<n) t*=2;
木の最底辺の大きさを決める*/ 
ll seg[2*MAX_N-1];
void segmake(ll n, ll a[n] ,ll t){
    rep(i,0,t) seg[t-1+i]=i<n?a[i]:a[n-1];
    while(t/=2) rep(i,0,t) seg[t+i-1]=gcd(seg[2*(t+i)],seg[2*(t+i)-1]); 
}

ll seggcd(ll from, ll to, ll a, ll l, ll r){
    if(l>=from && r<=to) return seg[a];
    if( to  < (l+r)/2+1 ) return seggcd(from,to,2*a+1,l,(l+r)/2);
    if( from  > (l+r)/2 ) return seggcd(from,to,2*a+2,(l+r)/2+1,r);
    return gcd( seggcd(from,to,2*a+2,(l+r)/2+1,r) , seggcd(from,to,2*a+1,l,(l+r)/2) ) ;
}

void segupdate(ll a, ll b, ll t){
    ll c=t-1+a;
    seg[c]=b;
    while(c>0){
        c--; c/=2;
        seg[c]=gcd(seg[2*(c+1)],seg[2*(c+1)-1]);
    }
}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }

    ll t=1;
    while(t<n) t*=2;
    segmake(n,a,t);
    // rep(i,0,2*t-1){
    //     printf("%lld ",seg[i]);
    // }

    ans=seggcd(1,n-1,0,0,t-1);
    // printf("%lld ",ans);
    ans=max2( ans , seggcd(0,n-2,0,0,t-1) );
    // printf("%lld ",ans);

    rep(i,1,n-1){
        ans = max2( ans , gcd( seggcd(0,i-1,0,0,t-1) , seggcd(i+1,n-1,0,0,t-1) ) );
    // printf("%lld ",ans);
    // if(i==3){
    //     printf("%lld %lld ", seggcd(0,i-1,0,0,n-1) , seggcd(i+1,n-1,0,0,n-1) );
    // }
    }
    // printf("%lld ", gcd( gcd(a[0],a[1]) , gcd(a[1],a[2]) ) );
    // printf("%lld ",gcd(46189,74613));

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


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
};

ll n;
vector<ll> adj[N];
ll fact[N];
ll ifact[N];
ll sz[N];
ll dp[N];

void dfs(ll curr, ll prev1 = -1) {
  sz[curr] = 1;

  ll num = 1;
  ll den = 1;
  for (ll &x : adj[curr]) {
    if (x != prev1) {
      dfs(x, curr);
      den = den * ifact[sz[x]] % mod;
      sz[curr] += sz[x];
      num = num * dp[x] % mod;
    }
  }
  dp[curr] = num * den % mod;
  dp[curr] = dp[curr] * fact[sz[curr] - 1] % mod;
}

ll ans[N];

void dfs2(ll curr, ll prev1 = -1, ll sz1 = -1, ll val1 = 1) {

  if (prev1 != -1) {
    ans[curr] = dp[curr] * ifact[sz[curr] - 1] % mod;
    ans[curr] = ans[curr] * fact[n - 1] % mod;
    ans[curr] = ans[curr] * ifact[sz1] % mod;
    ans[curr] = ans[curr] * val1 % mod;
  } else
    ans[curr] = dp[curr];

  ll prod = ans[curr];

  ll og = prod;
  for (ll &x : adj[curr]) {
    if (x != prev1) {

      prod = prod * power(dp[x], mod - 2, mod) % mod;
      prod = prod * fact[sz[x]] % mod;
      prod = prod * ifact[n - 1] % mod;
      prod = prod * fact[n - 1 - sz[x]] % mod;

      dfs2(x, curr, n - sz[x], prod);

      prod = og;
    }
  }
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  fact[0] = ifact[0] = 1;
  for (ll i = 1; i < N; i++) {
    fact[i] = i * fact[i - 1] % mod;
    ifact[i] = power(fact[i], mod - 2, mod);
  }

  cin >> n;
  for (ll i = 1; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  dfs(1);
  dfs2(1);

  for (ll i = 1; i <= n; i++)
    cout << ans[i] << en;

  return 0;
}

Measured memory_bytes: 22640
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n>>k>>m)
    {
        vi a;
        map<int,int>mp;
        rep(i,m)
        {
            cin>>x;
            mp[x]++;
        }
        Rep(i,n)
        {
            y=k-(m-mp[i]);
            if(y>0) cout<<"Yes"<<en;
            else cout<<"No"<<en;
        }

    }
}




Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,A,B,C,D;
	cin >> N >> A >> B >> C >> D;
	B -= A;
	FOR(i,0,N){
		ll lower = 0,upper = 0;
		upper += i*(-C);
		lower += i*(-D);
		upper += (N-1-i)*D;
		lower += (N-1-i)*C;
		if(lower <= B && B <= upper){
			YES(1);
			return 0;
		}
	}
	YES(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int memo[12001][8];
int b_pow(int a,int b){
	if(memo[a][b]) return memo[a][b];
	else if( b == 0 ) return 1;
	else if( b == 1 ) return a;
	else return memo[a][b] = b_pow(a,b/2) * b_pow(a,(b+1)/2);
}
int ans , A;

int dfs(int p , int q , int k , int product , int current){
	// productがoverflowした。(produt <= 0)　
	if( product <= 0 || product > A || p*current > k*q ) return 0 ; 
	if( p == 0 ) return 1;
	if( current*product > A || k == 0 || p == 0) return 0;
	
	int ans = 0;
	// {1/current}を何回使うかを決める
	for(int i = 0 ; i <= k ; i++){
		if(p*current >= i*q) {
			int bunsi = p * current - i * q;
			int bunbo = q * current;
			if(bunsi != 0){
				int g = __gcd(bunsi,bunbo);
				bunsi /= g , bunbo /= g;
			}
			ans += dfs(bunsi , bunbo , k - i , product * b_pow(current,i) ,  current + 1);
		}else{
			break;
		}
	}	
	return ans;
}

int main(){
	int a,b,c,d;
	while(cin >> a >> b >> c >> d , a || b || c || d){	
		A = c;
		cout << dfs(a,b,d,1,1) << endl;
	}		
}

Measured memory_bytes: 1512
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll N, M; cin >> N >> M;
	ll T = 1900 * M + (N - M) * 100;
	ll P = 1;
	rep(i, 0, M) {
		P *= 2;
	}
	cout << T * P << endl;

	return 0;
}

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

int main(void) {
    ll L[100];
    L[0] = 2;
    L[1] = 1;
    int N;
    cin >> N;
    for (int i=2; i<=N; i++) L[i] = L[i-2] + L[i-1];
    cout << L[N] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	double a=0;
	vector<double> b;
	b.push_back(0);
	double N,K;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		double p;
		cin>>p;
		b.push_back(b[i]+p);
	}
	for(int i=0;i<=N-K;i++)
	{
		double v;
		double d=b[i+K]-b[i];
		v=(d+K)/2;
		if(v>=a)a=v;
	}
	printf("%.8f\n",a);
	return 0;
}

Measured memory_bytes: 2548
from math import gcd
import sys
n = int(input())
s=0
a = {197:10290813,198:10493367,199:10611772,200:10813692}
if n>=197:
    print(a[n])
    sys.exit(0)
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            s = s + gcd(gcd(i,j),k)
print(s)

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,n) FOR(i,0,n){ll buf; scanf("%lld",&buf); a.pb(buf); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


#define NOT 0
#define VIS 1
#define COMP 2

map<pll, ll> mp;
ll stt[MAX];
ll mini[MAX];
vector<pll> edge[MAX];
priority_queue<pll, vector<pll>, greater<pll>> pq;

void dijkstra(ll start) {
  pll mi;
  ll k;
  FOR(i, 1, n + 1) {
	stt[i] = NOT;
	mini[i] = INF;
  }
  mini[start] = 0;
  pq.push(make_pair(0, start));

  while (!pq.empty()) {
	mi = pq.top();
	pq.pop();
	m = mi.second;
	stt[m] = COMP;

	if (mini[m] < mi.first) continue;

	FOR(i, 0, edge[m].size()) {
	  k = edge[m][i].first;
	  if (stt[k] != COMP) {
		if (edge[m][i].second + mini[m] < mini[k]) {
		  mini[k] = edge[m][i].second + mini[m];
		  stt[k] = VIS;
		  pq.push(make_pair(mini[k], k));
		}
	  }
	}
  }
}

ll ch[MAX];
void check(ll start) {
  ll now;
  queue<ll> q;
  FOR(i, 1, n + 1) ch[i] = 0;
  q.push(start);

  while (!q.empty()) {
	now = q.front();
	q.pop();
	if (ch[now]) continue;
	FOR(i, 0, edge[now].size()) {
	  m = edge[now][i].F;
	  if (mini[now] + edge[now][i].S == mini[m]) {
		mp[pll(now, m)] = 0;
		mp[pll(m, now)] = 0;
	  }
	  q.push(m);
	}
	ch[now]++;
  }

}

int main(void) {
  ll a, b, c;
  cin >> n >> m;

  FOR(i, 0, m) {
	cin >> a >> b >> c;
	edge[a].push_back(make_pair(b, c));
	edge[b].push_back(make_pair(a, c));
	mp[pll(a, b)]++;
	mp[pll(b, a)]++;
  }

  FOR(i, 1, n + 1) {
	dijkstra(i);
	check(i);
  }
  for (auto it : mp) {
	if (it.second) ans++;
  }
  cout << ans / 2 << endl;

  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
int x[200005];
int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b; scanf("%d%d",&a,&b);
		if(a==1) x[b]|=2;
		if(a==n) x[b]|=1;
		if(b==1) x[a]|=2;
		if(b==n) x[a]|=1;
	}
	rep(i,n+1){
		if(x[i]==3) {puts("POSSIBLE"); return 0;}
	}
	puts("IMPOSSIBLE");
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		List<String> list = new ArrayList<String>();
		int anyCount = 0;
		
		for (int i = 0; i < N; i++) {
			int rate = sc.nextInt();
			String color = getColor(rate);
			if (color == "any") {
				anyCount++;
			} else {
				list.add(color);
			}
		}
		
		// listの重複を削除する
		Set<String> set = new HashSet<String>(list);
		List<String> list2 = new ArrayList<String>(set);
		
		// anyしかない場合は、最小値は1、最大値はanyの数
		// any以外の色が1つ以上ある場合は、
		// 最小値は、list2の要素数（anyがすべて、list2に含まれる色だった場合）
		// 最大値は、list2の要素数 + anyの数（anyがすべて異なる色だった場合）
		int min, max;
		if (list.size() == 0) {
			min = 1;
			max = anyCount;
		} else {
			min = list2.size();
			max = min + anyCount;
		}
		
		System.out.println(min + " " + max);
	}
	
	public static String getColor(int rate) {
		if (rate <= 399) {
			return "gray";
		} else if (rate >= 400 && rate <= 799) {
			return "brown";
		} else if (rate >= 800 && rate <= 1199) {
			return "green";
		} else if (rate >= 1200 && rate <= 1599) {
			return "sky";
		} else if (rate >= 1600 && rate <= 1999) {
			return "blue";
		} else if (rate >= 2000 && rate <= 2399) {
			return "yellow";
		} else if (rate >= 2400 && rate <= 2799) {
			return "orange";
		} else if (rate >= 2800 && rate <= 3199) {
			return "red";
		} else {
			return "any";
		}
	}	
}


Measured memory_bytes: 21844
class NegativeWeightDirectedGraph():
    def __init__(self, V):
        self.V = V
        self.INF = 10**10
        self.G = [[self.INF]*V for _ in range(V)]
        for i in range(V):
            self.G[i][i] = 0

    def append(self, src, to, weight):
        self.G[src][to] = weight

    def warshallFloyd(self):
        for k in range(self.V):
            for i in range(self.V):
                for j in range(self.V):
                    if self.G[i][k] != self.INF and self.G[k][j] != self.INF:
                        w = self.G[i][k] + self.G[k][j]
                        self.G[i][j] = min(self.G[i][j], w)
        # check
        for i in range(V):
            if self.G[i][i] < 0:
                return None       
        return self.G

        
V,E = map(int, raw_input().split())
G = NegativeWeightDirectedGraph(V)
for i in range(E):
    s,t,d = map(int, raw_input().split())
    G.append(s,t,d)

ans = G.warshallFloyd()
if ans == None:
    print "NEGATIVE CYCLE"
else:
    for ds in ans:
        print " ".join(map(lambda d: str(d) if d != G.INF else "INF", ds))



Measured memory_bytes: 5324
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  while(cin>>s){
    vector<int> t;
    REP(i,9){
      char a=s[i]-'0';
      char b=s[i+1]-'0';
      int tmp=(a+b)%10;
      t.PB(tmp);
    }
    REP(j,9){
      vector<int> u;
      REP(i,t.size()-1){
        u.PB((t[i]+t[i+1])%10);
      }
      t=u;
    }
    cout<<t[0]<<endl;
  }
  return 0;
}




Measured memory_bytes: 3224
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=200005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n, k;
int main() {
    scanf("%d%d", &n, &k);
    ll ans = 0;
    for(int i = k; i <= n + 1; i++) {
        ans += 1ll * i * (n - i + 1) % mod + 1;
    }
    ans %= mod;
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
  int h,w;
  cin >> h >> w;
 
  int cnt[h][w];
  
  string s[h];
  for(int i = 0; i < h; i++){
    cin >> s[i];
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cnt[i][j] = 0;

      if(s[i][j]=='.'){
		if(i > 0){
		  if(j > 0){
            if(s[i-1][j-1]=='#'){cnt[i][j]++;}
          }
          if(s[i-1][j]=='#'){cnt[i][j]++;}
		  if(j < w - 1){
	        if(s[i-1][j+1]=='#'){cnt[i][j]++;}
          }
        }

		if(j > 0)
          if(s[i][j-1]=='#'){cnt[i][j]++;}

        if(j < w - 1)
          if(s[i][j+1]=='#'){cnt[i][j]++;}

		if(i < h - 1){
          if(j > 0)
            if(s[i+1][j-1]=='#'){cnt[i][j]++;}

          if(s[i+1][j]=='#'){cnt[i][j]++;}

          if(j < w - 1)
            if(s[i+1][j+1]=='#'){cnt[i][j]++;}
        }

        s[i][j] = '0' + cnt[i][j];
      }
    }
  }
  for(int i = 0; i < h; i++){
    cout << s[i] << endl;
  }
}


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

int main(int argc, char *argv[])
{
    char buf[512];
    int len;
    fgets(buf, sizeof(buf), stdin);
    len = strlen(buf);
    printf("%c%d%c\n", buf[0], len-3, buf[len-2]);
    return 0;
}

Measured memory_bytes: 128
import numpy as np
import itertools as it

N = int(input())
inputs=[list(map(int,input().split())) for i in range(N)]
inputs.sort(key=lambda x : x[1])

np_input = np.asarray(inputs)
np_input =np.hstack((np_input,list(it.accumulate(np_input[:,:1]))))

flg=False
for row in np_input:
    if row[1] < row[2]:
        flg=True
        break

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

Measured memory_bytes: 95324
#include "bits/stdc++.h"
#include "random"
#include <unistd.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int Uniform_Random(int a, int b){ // (a <= x <= b)

  random_device rd;
  mt19937 mt(rd());
  
  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
  
}
 
int main(){
  
  int n, k; cin >> n >> k;

  int ans = 1;
  
  while(n >= k){
    ans += 1;
    n/= k;
  }
  
  cout << ans << endl;

  return 0; 
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll K;
    cin >> K;
    string S;
    cin >> S;

    if(S.length()<=K) cout << S << endl;
    else cout << S.substr(0, K)+"..." << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll pre[n - 1];
    pre[n - 2] = a[n - 1];
    for (int i = n - 2, k = n - 3; i >= 0 && k >= 0; i--, k--)
    {
        pre[k] = (pre[k + 1]%mod + a[i]%mod)%mod;
    }
    ll prod = 0;
    for (int i = 0, j = 0; i < n - 1 && j < n; i++, j++)
    {
        prod += a[j] * pre[i];
        // if(prod<0) prod+=mod;
        prod %= mod;
    }
    cout << prod;
    return 0;
}

Measured memory_bytes: 5944
import java.util.*;

public class Main {
    public static void main (String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] x = new int[n], y = new int[n];
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            y[i] = x[i];
        }

        Arrays.sort(y);
        int a = y[n/2 - 1], b = y[n/2];
        for (int i = 0; i < x.length; i++) {
            if (x[i] < y[n/2]) {
                System.out.println(b);

            } else {
                System.out.println(a);
            }
        }
    }
}

Measured memory_bytes: 92416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i=0; i<N;i++){
    cin >> h.at(i);
  }
  
  vector<int> dp(N);
  
  dp.at(0)=0;
  dp.at(1)=abs(h.at(1)-h.at(0));
  
  for (int i=2; i<N; i++){
    dp.at(i)=dp.at(i-1)+abs(h.at(i)-h.at(i-1));
    for (int j=2;j<K+1;j++){
      if(i>=j){
        dp.at(i)=min(dp.at(i), dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
      }
    }
  }
  
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),x=sc.nextInt(),y=sc.nextInt();
		long res1=a*x+b*y,res2=Math.max(x, y)*c*2,res3=Long.MAX_VALUE;
		if(x>y) {
			res3=y*c*2+(x-y)*a;
		}else if(x<y) {
			res3=x*c*2+(y-x)*b;
		}
		System.out.println((long)Math.min(res1, Math.min(res2, res3)));
	}
}



Measured memory_bytes: 22612
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                             in(T &p){cin>>p;}
template<class T1,class T2>inline void                   in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T>inline void                             ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
template<class T>inline void                             outs(T p){for_each(all(p),out<decltype(p[0])>);}
long H,W;
string S[26][26];
inline void solve(void){
  in(H,W);
  rep(i,H)rep(j,W)in(S[i][j]);
  rep(i,H)rep(j,W){
    if(S[i][j]=="snuke"){
      cout<<char('A'+j);
      cout<<i+1<<endl;
      return;
    }
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int ans = 0;
	int res = 0;

	for (int i = 0; i < k; i++) {
		if (a > 0) {
			res += 1;
			a--;
		}
		else if (b > 0) {
			b--;
		}
		else if (c > 0) {
			res -= 1;
			c--;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 3540
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayDeque<String> ans = new ArrayDeque<String>();

		int n = sc.nextInt();
		for(int i=0;i<n;i++){
			String s = sc.next();
			String t = sc.next();
			String u = "";
			int[] rst = new int[80];
			
			if(s.length()<t.length()){
				u = s;
				s = t;
				t = u;
			}
			
			int exit=0;
			int sub = s.length()-t.length();
			
			if(s.length()>80){
				exit=1;
			}else{
				for(int j=0;j<s.length();j++){
					int a = Integer.valueOf(s.substring(s.length()-1-j,s.length()-j));
					int b = 0;
					if(j<t.length()){
						b = Integer.valueOf(t.substring(t.length()-1-j,t.length()-j));
					} 
					int c = a+b+rst[j];
					if(j==79 && c>9){
						exit=1;
					}else{
						if(j!=79)rst[j+1] = c/10;
						rst[j] = c%10;
					}
				}
			}
			
			if(exit==1){
				ans.push("overflow");
			}else{
				String stn = "";
				for(int k=0;k<s.length();k++){
					stn += rst[k];
				}
				if(s.length()!=80 && rst[s.length()]!=0){
					stn += rst[s.length()];
				}
				StringBuffer sb = new StringBuffer(stn);
				ans.push(sb.reverse().toString());
			}
			
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			System.out.println(ans.pollLast());
		}
	}
}

Measured memory_bytes: 15460
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
vector<vector<int>> G;
vector<int> K;
int main() {
	int s = 0, e, t;
	vector<int> ans;
	string S;
	cin >> S;
	S.push_back('R');
	rep(i, 1, S.size()) {
		if (S[i - 1] == 'R' && S[i] == 'L')t = i;
		if (S[i - 1] == 'L' && S[i] == 'R') {
			e = i;
			//printf("s:%d e:%d t:%d\n", s, e, t);
			rep(i2, s, e) {
				if (i2 == t - 1) {
					ans.push_back((e - s + (t - s) % 2) / 2);
				}
				else if (i2 == t) {
					ans.push_back((e - s + ((t - s) % 2 == 0)) / 2);
				}
				else {
					ans.push_back(0);
				}
			}
			s = e;
		}
	}
	rep(i, 0, ans.size()) {
		printf(i == ans.size() - 1 ? "%d\n" : "%d ", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1144
//package compilers;

import java.util.Queue;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.*;

public class Main {
	private static Map<Integer,Boolean> map;
	private static List<Integer> ans;
	private static int max=0;
	private static int dp[];
    private static int dfs(int i, Set<Integer>[] arr, int ma) {
    	if(map.containsKey(i))
    		return dp[i];
    	map.put(i,true);
    	int maxi=0;
		for(int j: arr[i]) {
			//System.out.println(j);
			maxi=Math.max(dfs(j,arr,ma)+1,maxi);
			max=Math.max(maxi,max);
		}
		dp[i]=maxi;
		return dp[i];
    }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int m=in.nextInt();
		Set<Integer> []arr=new Set[n+1];
		int x,y;
		for(int i=1;i<=n;i++)
			arr[i]=new HashSet();
		//Map<Integer,Integer> ma=new HashMap();
		while(m>0) {
		       x=in.nextInt();
			   y=in.nextInt();
			   arr[x].add(y);
			   m--;
		}
		//Stack<Integer> s=new Stack();
		/*
		 * for(int i=1;i<=n;i++) { System.out.print(i + "-> "); for(int j:arr[i]) {
		 * System.out.print(j+ " "); } System.out.println(); }
		 */
		map=new HashMap();
		//s.push(1);
		 dp=new int[n+1];
		 ans=new ArrayList();
		  for(int i=1;i<=n;i++) {
			  dfs(i,arr,0);
		}
		  
		  Collections.reverse(ans);
		  
		  for(int i=1;i<ans.size();i++) {
			  for(int j=0;j<i;j++) {
				  if(arr[ans.get(j)].contains(ans.get(i)))
					  dp[i]=Math.max(dp[i],dp[j]+1);
			  }
		  }
		  
		/*
		 * int max=0;
		 * 
		 * for(int i=0;i<n;i++) { //System.out.print(dp[i] + " "); max=Math.max(max,
		 * dp[i]); }
		 */
		  System.out.println(max);
		
		
		
	}

}


Measured memory_bytes: 115504
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a,b;
  cin >> a >> b;
  if( a == 'H'){
    cout << b << endl;
  }else{
    if(b == 'H'){
      cout << 'D' << endl;
    }else{
      cout << 'H' << endl;
    }
  }
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}

	ll ans = 0;
	for(int get_num = min(k, n); get_num >= 0; --get_num)
	{
		for(int start = -get_num; start <= 0; ++start)
		{
			ll sum = 0;
			vector<int> may_erase;
			for(int i = 0; i < get_num; ++i)
			{
				int val = v[start + i < 0 ? start + i + n : start + i];
				sum += val;
				if (val < 0) may_erase.emplace_back(val);
			}

			sort(may_erase.begin(), may_erase.end());
			int erase_num = min((int)may_erase.size(), k - get_num);
			ll erase_sum = 0;
			for(int i = 0; i < erase_num; ++i)
			{
				erase_sum += may_erase[i];
			}
			// cout << get_num << " " << start << " : " << sum << " - " << -erase_sum << endl;
			ans = max(ans, sum - erase_sum);
		}
	}
	cout << ans;



}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3608
s = input()

s = list(s)
answer = True
for i in range(len(s)):
  if i%2 == 0:
    if(s[i] == "L"):
      answer = False
      break
  else:
    if(s[i] == "R"):
      answer = False

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

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

struct City {
    int cityNum;
    int prefNum;
    int year;
    string ID = "";
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int> V(N);
    cin >> V;

    constexpr int Max = 100001;
    vector<int> e1(Max), o1(Max);
    REP(i, N) {
        if (i % 2 == 0) {
            e1[V[i]]++;
        }
        else {
            o1[V[i]]++;
        }
    }

    auto EMaxIt = max_element(ALL(e1));
    auto OMaxIt = max_element(ALL(o1));
    int EMax = distance(e1.begin(), EMaxIt);
    int OMax = distance(o1.begin(), OMaxIt);

    if (EMax == OMax) {
        int EMax2 = 0, OMax2 = 0;
        REP(i, Max) {
            if (i != EMax) {
                if (EMax2 < e1[i]) {
                    EMax2 = e1[i];
                }
            }
            if (i != OMax) {
                if (OMax2 < o1[i]) {
                    OMax2 = o1[i];
                }
            }
        }

        int ans1 = N - EMax2 - *OMaxIt;
        int ans2 = N - *EMaxIt - OMax2;
        cout << min(ans1, ans2) << endl;
    }
    else {
        int ans = N - *EMaxIt - *OMaxIt;
        cout << ans << endl;
    }

    return 0;

}

Measured memory_bytes: 1408
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;


int main()
{
   ll a; double b;
   cin >> a >> b;

   ll d = round(b * 100);
   ll ans = a * d;

   ans /= 100;
   cout << ans;

   return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int n=0;
    cin>>n;

    if(n%2==0){
        cout<<n/2<<endl;
    }else{
        cout<<n/2+1<<endl;
    }


}

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

int main() {
    string s;cin>>s;
    int q;cin>>q;
    int flag=0;
    string fst,last;
    for(int i=0;i<q;i++){
        int t;cin>>t;
        if(t==1){
            if(flag==0) flag=1;
            else flag=0;
        }if(t==2){
            int f;cin>>f;
            if(f==1){
                if(flag==0){
                    string c;cin>>c;
                    fst+=c;
                }if(flag==1){
                    string c;cin>>c;
                    last+=c;
                }
            }if(f==2){
                if(flag==0){
                    string c;cin>>c;
                    last+=c;
                }if(flag==1){
                    string c;cin>>c;
                    fst+=c;
                }
            }
        }
    }
    if(flag==0){
        reverse(fst.begin(),fst.end());
        cout<<fst<<s<<last<<endl;
    }if(flag==1){
        reverse(last.begin(),last.end());
        reverse(s.begin(),s.end());
        cout<<last<<s<<fst<<endl;
    }
}

Measured memory_bytes: 1088
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

ruisekisa = [0]*(M-1)
for i in range(0,M-1,1):
    ruisekisa[i]=X[i+1]-X[i]

ruisekisa.sort()
print(sum(ruisekisa[0:max(M-N,0)]))#負方向のout index が変な挙動するのよ


Measured memory_bytes: 84672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////


signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	pair<int,int> p[n];
	for(int i=0;i<n;++i)
	{
		cin>>p[i].S>>p[i].F;
	}
	sort(p,p+n);
	int t=0;
	for(int i=0;i<n;++i)
	{
		t+=p[i].S;
		if(p[i].F<t)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 3456
import java.util.Scanner;


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

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());

		sc.close();

		if(A <= 9 && B <= 9) {
			System.out.println(A * B);
		}else {
			System.out.println(-1);
		}
		



	}
}



Measured memory_bytes: 23764
import sys
input = sys.stdin.readline

def main():
    N, M, C = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    A = [[int(x) for x in input().split()] for _ in range(N)]

    ans = 0
    for a in A:
        tmp = 0
        for i in range(M):
           tmp += a[i] * B[i]

        if tmp + C > 0:
            ans += 1

    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

int main() {
	int a, b, c;
	cin >> a >> b >> c; if (a == b && b == c) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    unsigned long long ans = 0;
    int n;
    long long a[51];
    cin >> n;
    long long sum = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
    }
    long long need = sum - n * n;
    while(need > 0){
        long long delta = 0;
        for(int i = 1; i <= n; i++){
            long long need_for = (a[i] + need) / (n + 1);
            if((a[i] + need) % (n + 1) != 0){
                need_for++;
            }
            a[i] -= (n + 1) * need_for;
            delta += need_for;
        }
        for(int i = 1; i <= n; i++){
            a[i] += delta;
        }
        ans += delta;
        need -= delta;
        delta = 0;
    }
    long long border = n - 1;
    while(true){
        bool check = true;
        for(int i = 1; i <= n; i++){
            if(a[i] > border){
                check = false;
                long long need_for = (a[i] - border) / n;
                if((a[i] - border) % n != 0){
                    need_for++;
                }
                ans += need_for;
                a[i] -= (n + 1) * need_for;
                border -= need_for;
            }
        }
        if(check == true){
            break;
        }
    }
    /*cout << "border " << border << endl;
    for(int i = 1; i <= n; i++){
        cout << a[i] << endl;
    }*/
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

	int n, s[100],tmp,j,S=0,MAX[100],ans=0;

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> s[i];

	}

	for (j = 0; j < n; j++) {

		for (int i = 0; i < n; i++) {

			if (s[j] < s[i]) {

				tmp = s[i];
				s[i] = s[j];
				s[j] = tmp;

			}
		}
	}

	for (int i = 0; i < n; i++) {

		S = S + s[i];

	}

	if (S % 10 != 0)
		cout << S << endl;

	else if (S % 10 == 0) {

		for (int i = 0; i < n; i++) {

			if (s[i] != 10) {

				MAX[i] = S - s[i];

				if (MAX[i] % 10 != 0) {
					ans = MAX[i];
					break;
				}
			}
		}

		cout << ans << endl;

	}
}

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

int main(){
	for(;;){
		int n;
		cin>>n;
		if(!n)break;
		bool ok=false;
		for(int k,i=n; i--;){
			cin>>k;
			ok|=k>1;
			if(!k)n--;
		}
		if(ok)cout<<n+1<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
 int n;
 cin >> n;
int a[2][n];
 for(int i=0;i<2;i++){
     for(int j=0;j<n;j++){
         cin >> a[i][j];
     }
 }
 int che=0,chea=0,ans=0;
 for(int i=0;i<n;i++){
      che+=a[0][i];
      chea = 0;
     for(int j=i;j<n;j++){
      chea+=a[1][j];   
     }
     ans = max(ans,che+chea);
 }
 cout << ans << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
const int LIM = 3e5+3;
int cost[LIM+3], d[LIM+3];
ll INF = 1e18;
ll Ans = 0;
ll MOD = 1e9+7;
ll dp[LIM+3][13];
int rem[LIM+3][9];
int solve(int i , int j)
{
  if(j == 0)return 0;
  if(i == 0 && j)return j;
  if(i == 0)return 10;
  int &ret = rem[i][j];
  if(ret != -1)return ret;
  ret = j * 10 * solve(i-1,1);
  ret %= 13;
  return ret;
}
int main(){
    memset(rem, -1, sizeof rem);
    //cout << solve(8, 3) << endl;
    //cout << 300000000%13 << endl;
    string s;cin >> s;
    reverse(s.begin(),s.end());
    memset(rem, -1, sizeof rem);
    for(int i = 0 ;i<=9;i++)rem[0][i] = i;
    dp[0][0] = 1;
    for(int i = 0;i<s.size();i++)
    {
      if(s[i] == '?')
      {
        for(int j = 0;j<=9;j++)
          for(int r = 0;r<13;r++)
          {
            int req = r - solve(i,j) + 13;
            req %= 13;
            dp[i+1][r] += dp[i][req];
            dp[i+1][r] %= MOD;
          }
      }
      else
      {
        int j = s[i]-'0';
       for(int r = 0;r<13;r++)
          {
            int req = r - solve(i,j) + 13;
            req %= 13;
            dp[i+1][r] += dp[i][req];
            dp[i+1][r] %= MOD;
          } 
      }
    }
    cout << dp[s.size()][5] << endl;
}

Measured memory_bytes: 23040