akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m,q;
  cin>>n>>m>>q;
  int mp[n][n]={};
  int s[n][n]={};
  rep(i,m){
    int l,r;
    cin>>l>>r;
    mp[l-1][r-1]++;
  }
 
  rep(i,n){
    rep(j,n){
      // cout<<mp[i][j]<<" ";
    }
    //cout<<endl;
  }
  s[0][0]=mp[0][0];
  //cout<<mp[0][0]<<" "<<s[0][0]<<endl;
  repi(i,1,n){
    s[i][0]=s[i-1][0]+mp[i][0];
    s[0][i]=s[0][i-1]+mp[0][i];
  }
  repi(i,1,n){
    repi(j,1,n){
      s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+mp[i][j];
    }
  }
  rep(i,n){
    rep(j,n){
      // cout<<s[i][j]<<" ";
    }
    //cout<<endl;
  }
  rep(i,q){
    int x,y;
    cin>>x>>y;
    x--;y--;
    if(x==0){
      cout<<s[y][y]<<endl;
    }else{
      cout<<s[y][y]-s[y][x-1]-s[x-1][y]+s[x-1][x-1]<<endl;
    }
  }
      
    

  return 0;
}


Measured memory_bytes: 4864
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
const int N=100005;
queue<int> q;
int f[N];
int main()
{
	memset(f,127,sizeof(f));
	int n;
	scanf("%d",&n);
	for (int u=1;u<=9;u++)	f[u%n]=min(f[u%n],u);
	for (int u=0;u<=9;u++) if (f[u]<=u)	q.push(u);
	while (!q.empty())
	{
		int x=q.front();q.pop();
		for (int u=0;u<=9;u++)
		{
			int y=(x*10+u)%n;
			if (f[y]>f[x]+u)	{f[y]=f[x]+u;q.push(y);}
		}
	}
	printf("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		int minv = 0;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int input = Integer.parseInt(br.readLine());
			if (i == 0) {
				minv = input;
				continue;
			}
			maxv = maxv < (input - minv) ? (input - minv) : maxv;
			minv = minv > input ? input : minv;
		}
		System.out.println(maxv);
	}
}

Measured memory_bytes: 42460
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from collections import deque,defaultdict,Counter
def main():
    N,M = map(int,input().split())
    G = [[] for _ in range(N)]
    G_rev = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G_rev[b].append(a)
    
    s,g = None,None
    ans = INF
    q = deque([])
    for i in range(N):
        q.append(i)
        dist = [-1] * N
        dist[i] = 0
        while q:
            v = q.popleft()
            for e in G[v]:
                if i == e:
                    if ans > dist[v] + 1:
                        ans = dist[v] + 1
                        s,g = i,v
                elif dist[e] < 0:
                    dist[e] = dist[v] + 1
                    q.append(e)

    if ans == INF:
        print(-1)
    else:
        print(ans)
        q.append(s)
        dist = [-1] * N
        dist[s] = 0
        while q:
            v = q.popleft()
            for e in G[v]:
                if e == g:
                    dist[g] = dist[v] + 1
                    q.clear()
                    break
                elif dist[e] < 0:
                    dist[e] = dist[v] + 1
                    q.append(e)
        route = [g + 1]
        now = g
        while now != s:
            for e in G_rev[now]:
                if dist[e] == dist[now] - 1:
                    now = e
                    break
            route.append(now + 1)
        print('\n'.join(map(str,route)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll A,B;
  cin>>A>>B;
  
  cout<<lcm(A,B)<<endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

vector<int> bABa;
vector<int> AbaB;
vector<int> a;
vector<int> b;
vector<int> A;
vector<int> B;
ll n;

char chenge(char c){
	if(isupper(c))return tolower(c);
	else return toupper(c);
}

string rev(string str){
	string ret = "";
	REP(i, str.size()){
		ret += chenge(str[str.size() - i - 1]);
	}
	return ret;
}

void test() {
	int n;cin >> n;
	string a = "a";
	string b = "b";
	cout << a << endl << b << endl;
	REP(i, n){
		string A = rev(a);	
		string B = b;
		while(A.size() > 0 && B.size() > 0 && chenge(A.front()) == B.back()){
			A.erase(A.begin());
			B.pop_back();
		}
		a = b;
		b = B + A;
		int pla = 0;
		while(pla < b.size()-1-pla && b[pla] == chenge(b[b.size()-1-pla]))pla++;
		REP(j, b.size()){
			if(j == pla || j == b.size() - pla)cout << " ";
			cout << b[j];
		}
		cout << endl;
	}
}

vector<int> func(vector<int> p, vector<int> q){
	vector<int> ret(p.size());
	REP(i, p.size()){
		ret[i] = p[q[i]];
	}
	return ret;
}

vector<int> inverse(vector<int> v){
	vector<int> ret(v.size());
	REP(i, v.size()){
		ret[v[i]] = i;
	}
	return ret;
}

void out(vector<int> v){
	REP(i, v.size())cout << v[i] + 1 << " ";cout << endl;
}

vector<int> make_x(ll n, ll k){
	ll cou = k / 6;
	vector<int> ret(n);
	auto kake = bABa;
	REP(i, n)ret[i] = i;
	REP(i, 30){
		if(cou & (1 << i)){
			ret = func(ret, kake);
		}
		kake = func(kake, kake);
	}
	
	int tmp = k % 6;
	if(tmp <= 0)return ret;
	ret = func(ret, b);
	if(tmp <= 1)return ret;
	ret = func(ret, A);
	if(tmp <= 3)return ret;
	ret = func(ret, B);
	if(tmp <= 4)return ret;
	ret = func(ret, a);
	return ret;
}

vector<int> make_y(int k){
	int tmp = k % 6;
	switch(tmp){
		case 0:return func(b, A);
		case 1:return A;
		case 2:return B;
		case 3:return func(B, a);
		case 4:return a;
		case 5:return b;
	}
}

int main(){
	ll n, k;cin >> n >> k;
	a.resize(n);REP(i, n)cin >> a[i],a[i]--;
	b.resize(n);REP(i, n)cin >> b[i],b[i]--;
	
	if(k == 1){
		out(a);
		return 0;
	}
	if(k == 2){
		out(b);
		return 0;
	}
	k -= 3;

	A = inverse(a);
	B = inverse(b);
	bABa = func(func(func(b, A), B), a);	
	
	auto x = make_x(n, k);
	auto y = make_y(k);
	
	out(func(func(x, y), inverse(x)));
	
	return 0;
}


Measured memory_bytes: 5880
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

string solve(string* s, int* cnt) {
	while(cnt[0] == 0) {
		cnt[0] =cnt[1], s[0] =s[1];
		cnt[1] =cnt[2], s[1] =s[2];
		cnt[2] =0;
	}
	if(cnt[1]+cnt[2] == 0) {
		string ret;
		for(int i =0; i < cnt[0]; i++) ret +=s[0];
		return ret;
	}

	if(cnt[1] == 0) {
		cnt[1] =cnt[2], s[1] =s[2];
		cnt[2] =0;
	}
	if(cnt[2] == 0) {
		string s_nw[] ={"", "", ""};
		int cnt_nw[] ={0, 0, 0};
		s_nw[0] =s_nw[1] =s[0];
		while(cnt[1] >= cnt[0]) {
			cnt[1] -=cnt[0];
			s_nw[0] +=s[1];
			s_nw[1] +=s[1];
		}
		s_nw[1] +=s[1];
		cnt_nw[1] =cnt[1];
		cnt_nw[0] =cnt[0]-cnt[1];
		return solve(s_nw, cnt_nw);
	}

	string s_nw[] ={"", "", ""};
	int cnt_nw[] ={0, 0, 0};
	for(int i =0; i < 3; i++) s_nw[i] =s[0];
	while(cnt[2] >= cnt[0]) {
		cnt[2] -=cnt[0];
		for(int i =0; i < 3; i++) s_nw[i] +=s[2];
	}
	s_nw[2] +=s[2];
	cnt_nw[2] =cnt[2];
	cnt[0] -=cnt[2];
	while(cnt[1] >= cnt[0]) {
		cnt[1] -=cnt[0];
		s_nw[0] +=s[1];
		s_nw[1] +=s[1];
	}
	s_nw[1] +=s[1];
	cnt_nw[1] =cnt[1];
	cnt_nw[0] =cnt[0]-cnt[1];
	return solve(s_nw, cnt_nw);
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string s[] ={"a", "b", "c"};
	int cnt[3];
	for(int i =0; i < 3; i++) cin >> cnt[i];
	cout << solve(s, cnt) << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
import math
A,B,C,x,y=map(int,input().split())
price=5000*(10**6)
for c in range(1+max([2*x,2*y])):
    a=0
    b=0
    if x>c/2:
        a=math.ceil(x-(c/2))
    if y>c/2:
        b=math.ceil(y-(c/2))
    if A*a+B*b+C*c<price:
        price=A*a+B*b+C*c
print(price)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
    int S;
    cin >> S;
    int h, m, s;
    h = S / 3600;
    S  %= 3600;
    m = S / 60;
    S %= 60;
    s = S;

    cout << h << ':' << m << ':' << s << endl;

    return 0;
}


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

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

	int a[N];
	for(int& x : a) cin >> x;

	int ans = 1 << 29;
	for (int i = 0; i <= N - K; i++)
		ans = min(ans, a[i + K - 1] - a[i] + min(abs(a[i]), abs(a[i + K - 1])));

	cout << ans;
}


Measured memory_bytes: 640
IDENTIFICATION DIVISION.
 PROGRAM-ID. TEST090.

 DATA DIVISION.
 WORKING-STORAGE SECTION.

 01 INP     PIC X(3).
 01 C1.
  03 C11    PIC X(1).
  03 FILLER PIC X(2).
 01 C2.
  03 FILLER PIC X(1).
  03 C22    PIC X(1).
  03 FILLER PIC X(1).
 01 C3.
  03 FILLER PIC X(2).
  03 C33    PIC X(1).
 01 ANS.
  03 A1    PIC X(1).
  03 A2    PIC X(1).
  03 A3    PIC X(1).

 PROCEDURE DIVISION.

  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO C1.

  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO C2.

  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO C3.

  MOVE C11 TO A1.
  MOVE C22 TO A2.
  MOVE C33 TO A3.

 DISPLAY ANS.

 STOP RUN.

Measured memory_bytes: 384
// C++ implementation of the above approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function to return the maximized gcd 
// after removing a single element 
// from the given array 
int MaxGCD(int a[], int n) 
{ 

	// Prefix and Suffix arrays 
	int Prefix[n + 2]; 
	int Suffix[n + 2]; 

	// Single state dynamic programming relation 
	// for storing gcd of first i elements 
	// from the left in Prefix[i] 
	Prefix[1] = a[0]; 
	for (int i = 2; i <= n; i += 1) { 
		Prefix[i] = __gcd(Prefix[i - 1], a[i - 1]); 
	} 

	// Initializing Suffix array 
	Suffix[n] = a[n - 1]; 

	// Single state dynamic programming relation 
	// for storing gcd of all the elements having 
	// greater than or equal to i in Suffix[i] 
	for (int i = n - 1; i >= 1; i -= 1) { 
		Suffix[i] = __gcd(Suffix[i + 1], a[i - 1]); 
	} 

	// If first or last element of 
	// the array has to be removed 
	int ans = max(Suffix[2], Prefix[n - 1]); 

	// If any other element is replaced 
	for (int i = 2; i < n; i += 1) { 
		ans = max(ans, __gcd(Prefix[i - 1], Suffix[i + 1])); 
	} 

	// Return the maximized gcd 
	return ans; 
} 

// Driver code 
int main() 
{ 
	int n;
	cin>>n;
	int v[n];
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	cout << MaxGCD(v, n); 

	return 0; 
} 


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

int main()
{
  int64_t H, W;
  cin >> H >> W;
  int64_t ans = (H * W + 1) / 2;
  if (H == 1 || W == 1)
  {
    ans = 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//#define int long long
#include <bits/stdc++.h>
using namespace std;
int f(int a,int d){
    int i = 0,day = 1,c = 0;
    while (day <= d){
        if(i*a+1 == day){c++;i++;}
        day++;
    }
    return c;
}
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int a;
    rep(i,n){
        cin >> a;
        x += f(a,d);
        //cout << x << endl;
    }
    cout << x << endl;
}

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

int main() {
    string s; cin >> s;
    string s1;
    int a, z;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A') {
            a = i;
            break;
        }
    }

    reverse(s.begin(), s.end());
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'Z') {
            z = i;
            break;
        }
    }
   
  cout << s.size()-a-z << endl;
}

    


Measured memory_bytes: 640
x, k, d  = map(int, input().split())

a = (x+ d*k)//(2*d)
b = a+1

if abs(x+d*k-2*d*a) < abs(x+d*k-2*d*b):
    best = a
else:
    best = b

if 0 <= best <= k:
    print(abs(x+d*k-2*d*best))
elif best < 0:
    print(abs(x+d*k))
else:
    print(abs(x-d*k))


Measured memory_bytes: 9180
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int f(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}

signed main() {
  cout << fixed << setprecision(15);
  int n,m;
  cin >> n >> m;
  Vi a(n);
  int sum=0;
  rep(i,0,n){
    cin >> a[i];
    sum += a[i];
  }
  if(sum == m) {cout<<n<<endl;return 0;}
  if(sum < m) {cout<<n-1<<endl;return 0;}
  
  sort(ALL(a));
  int now=0,ct=0;
  while(now<=m){
    now+=a[ct];
    ct++;
  }
  cout << ct-1 << endl;
  return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define MAX_N 100010

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  int n, m, ans = 0;
  int p[MAX_N], x[MAX_N], y[MAX_N];
  bool vis[MAX_N];
  map<int, vi> graph; graph.clear();
  scanf("%d %d", &n, &m);
  //CAREFUL 1-indexed!!!!!
  for(int i = 1; i <= n; ++i) {scanf("%d", &p[i]);}
  for(int i = 1; i <= m; ++i) {
    scanf("%d %d", &x[i], &y[i]);
    graph[x[i]].pb(y[i]);
    graph[y[i]].pb(x[i]);
  }
  //bfs
  for(int i = 1; i <= n; ++i) {
    queue<int> qi;
    vector<int> pos;
    map<int, bool> val;
    pos.clear();
    val.clear();
    while(!qi.empty()) qi.pop();
    if(!vis[i]) {
      qi.push(i);
      //check equal to i or not????
      while(!qi.empty()) {

        int qf = qi.front();
        //cout << qf << "->" << p[qf] << endl;
        qi.pop();
        vis[qf] = true;
        pos.pb(qf);
        val[p[qf]] = true;
        int sz = graph[qf].size();
        for(int j = 0; j < sz; ++j) {
          //cout << qf << "tambahin : ";
          if(!vis[graph[qf][j]]) {
            qi.push(graph[qf][j]);
            //cout << graph[qf][j];
          }
          //cout << endl;
        }
      }
    }
    //sort(pos.begin(), pos.end());
    int sz = pos.size();
    for(int j = 0; j < sz; ++j) {
      if(val[pos[j]]) ++ans;
      val[pos[j]] = false;
    }
  }
  /*
  for(int i = 1; i <= n; ++i) {
    if(p[i] == i) ++ans;
  }
  */
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 17528
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int c = sc.nextInt();
    c=c*10+sc.nextInt();
    c=c*10+sc.nextInt();

    if(c%4==0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;

int main(){
	int n,taro=0,hanako=0;
	bool flag;
	string str1,str2;
	cin >> n;
	while(n--){
		flag=true;
		cin >> str1 >> str2;
			if(str1 > str2)taro+=3;
			else if(str1 < str2) hanako+=3;
			else{
				taro++;
				hanako++;
			}
	}
	cout << taro << " " << hanako <<endl;
	return 0;
}

Measured memory_bytes: 1208
from itertools import accumulate

import sys

input=sys.stdin.readline

N,C=map(int,input().split())
X=[0 for i in range(0,N)]
V=[0 for i in range(0,N)]
for i in range(0,N):
    X[i],V[i]=map(int,input().split())

acu=list(accumulate(V))
if N>=2:
    data=[0 for i in range(0,N)]
    data[N-1]=acu[N-2]-2*X[N-1]
    for i in range(1,N):
        data[N-1-i]=min(data[N-i],acu[N-2-i]-2*X[N-1-i])

    data2=[0 for i in range(0,N)]
    data2[N-1]=acu[N-2]-X[N-1]
    for i in range(1,N):
        data2[N-1-i]=min(data2[N-i],acu[N-2-i]-X[N-1-i])
    ans=[0 for i in range(0,N-1)]
    for i in range(0,N-1):
        ans[i]=min(data[i+1]-acu[i]+X[i]+2*C,data2[i+1]-acu[i]+2*X[i]+C)
    test1=max(acu[i]-X[i] for i in range(0,N))
    k=sum(V)
    test2=max(k-acu[i]-(C-X[i+1]) for i in range(0,N-1))
    test2=max(test2,k-(C-X[0]))
    test3=k-min(ans)
    print(max(0,test1,test2,test3))
else:
    print(max(0,V[0]-min(C-X[0],X[0])))

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll k, a, b;
/******* define variable end *******/
int solve() {
	cin >> k >> a >> b;
	for(ll i = a; i <= b; i++){
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
 int H,N,i,total=0;
 int tmp;
 scanf("%d %d",&H,&N);

  for(i=0;i<N;i++)
  {
    scanf("%d ",&tmp);
    H -= tmp;
      if(H <=0) 
      {
        printf("Yes\n"); 
        return 0;
      }
  }
  
  printf("No\n");
  
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int n;
	cin >> n;
	vector<pair<pair<string,int>,int>> v(n);
	cu(i,0,n){
		cin >> v[i].F.F >> v[i].F.S;
		v[i].F.S = MOD - v[i].F.S;
		v[i].S = i + 1;
	}
	sort(all(v));
	cu(i,0,n){
		cout << v[i].S << '\n';
	}
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
    try(Scanner sc = new Scanner(System.in)){
            for(int i = 1;;i++) {
                int x = sc.nextInt();
                if(x == 0) {
                        break;
                        }
                System.out.printf("Case %d: %d\n",i, x);
                    }
            }
                    }
                }


Measured memory_bytes: 65920
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=a; i<b; i++)
typedef long long ll;

#define N 123
int f[N][10];
int p[N][11];
int main(){
  int n; scanf("%d", &n);
  REP(i, n) REP(j, 10) scanf("%d", f[i]+j);
  REP(i, n) REP(j, 11) scanf("%d", p[i]+j);
  int ans=INT_MIN;
  FOR(i, 1, 1024){
    int sm=0;
    REP(j, n){
      int cnt=0;
      REP(k, 10) if((i&(1<<k))&&f[j][k]) cnt++;
      sm+=p[j][cnt];
    }
    ans=max(ans, sm);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,L;
#define Maxn 3005
#define pi acos(-1)
double T[Maxn];
double x,y;
inline void add(double rad,int cnt){
	x+=cos(rad)*cnt;
    y+=sin(rad)*cnt;
}
int main(){
	scanf("%d%d",&n,&L);
	for(register int i=0;i<n;++i){
		scanf("%lf",&T[i]);
		T[i]=T[i]/L*2*pi;
	}
    for(register int i=0;i<n;++i)
        for(register int j=i+1;j<n;++j){
        	double m1=(T[i]+T[j])/2;
		    double m2=m1+pi;
		    add(m1,i+n-j-1);
			add(m2,j-i-1);
		}
	double all=1.0*n*(n-1)*(n-2)/6;
	x/=all;y/=all;
	printf("%.11lf\n %.11lf\n",x,y);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 
int a[200010],b[200010],c[200010];
int main()
{
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=b[i-1]^a[i];
	for(i=n;i>0;i--)c[i]=c[i+1]^a[i];
	for(i=1;i<=n;i++)printf("%d ",b[i-1]^c[i+1]);
	return 0;
}

Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
int N;
int a[2000000];
vector<int> lungs;
int main() {
    cin >> N;
    for(int i = 0; i < (1 << N); i++) {
        cin >> a[i];
        bool childdie = false;
        for(int j = 0; j < N; j++) {
            if(!((1 << j) & i)) continue;
            int child = (i & (~(1 << j)));
            if(a[i] == 0) {
                if(a[child] == 1) {
                    cout << -1 << endl;
                    return 0;
                }
            } else {
                if(a[child] == 1) {
                    childdie = true;
                }
            }
        }
        if(a[i] == 1 && !childdie) {
            lungs.push_back(i);
        }
    }
    if(lungs.empty()) {
        cout << -1 << endl;
        return 0;
    }
    cout << lungs.size() << endl;
}


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

using namespace std;


int main() {
	int n, s1 = 0, s2 = 0, min;
	cin >> n;
	vector<int> w(n, 0);

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

	min = s2;
	for (int i = 1; i < n; i++) {
		s1 += w[i - 1];
		s2 -= w[i - 1];
		if (abs(s1 - s2) < min) {
			min = abs(s1 - s2);
		}
	}

	cout << min << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll inf = numeric_limits<ll>::max()/3;

int main(void){
  int n;
  vector< int > num;
  cin >> n;
  num.resize(n);
  for(int i = 0;i < n;++i){
    cin >> num[i];
  }
  sort(num.begin(),num.end(),greater<int>());
  int a = 0, b= 0;
  for(int i = 0;i < n;++i){
    if(i % 2 == 0)
      a += num[i];
    else
      b += num[i];
  }
  cout << a - b << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let asum = a.iter().fold(0, |sum, &ai| sum + ai);
    let isum = (1..n + 1).fold(0, |sum, ai| sum + ai);
    if asum % isum != 0 {
        println!("NO");
        return;
    }
    let sum = asum / isum;
    for i in 0..a.len() {
        let ai: i64 = a[i] as i64 - a[(i + 1) % n] as i64 + sum as i64;
        if ai < 0 || (ai % n as i64) != 0 {
            println!("NO");
            return;
        }
    }
    println!("YES");
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main(){

  int N, num, ans = 0;

  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> num;
    while(num % 2 == 0 && num != 0){
      num = num / 2;
      ans++;
    }
  }

  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int X = in.nextInt();
            String ans = "NO";
            if (X == 7 || X == 5 || X == 3) {
                ans = "YES";
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

data=[list(map(int,input().split())) for _ in range(N)]
hmax=max(data,key= lambda x:x[2])[2]

def check(x,y,h):
    flag=True
    for d in data:
        flag&=(d[2]==max(h-abs(d[0]-x)-abs(d[1]-y),0))
        if not flag:
            break
    return flag

for cx in range(101):
    for cy in range(101):
        for ch in range(hmax,hmax+202):
            if check(cx,cy,ch):
                print(cx,cy,ch)

Measured memory_bytes: 3064
#include <cstdio>
#include <array>
#include <utility>

template <unsigned int N> struct shuumai{
    unsigned int minPrime[N + 1];
    unsigned int Primes[N + 1];
    unsigned int size_;

    constexpr shuumai(void): minPrime(), Primes(), size_(0U){
        minPrime[0] = 1; minPrime[1] = 1;
        for(int even = 2, odd = 3; odd <= N; even += 2, odd += 2){
            minPrime[even] = 2;
            minPrime[odd] = odd;
        }
        if(!(N & 1)) minPrime[N] = 2;
        Primes[size_++] = 2;

        for(int x = 3; x <= N; x += 2){
            if(minPrime[x] == x) Primes[size_++] = x;
            for(int y = 0; y < size_ and Primes[y] <= minPrime[x] and x * Primes[y] <= N; ++y)
                    minPrime[x * Primes[y]] = Primes[y];
        }
    }
    // 範囲for文用の begin() と end()
    const unsigned int *begin(void) const noexcept{ return Primes; }
    const unsigned int *end(void) const noexcept{ return Primes + size_;}
    const unsigned int size(void) const {return this.size_;}
};

using uint = unsigned int;
constexpr uint N = 1e6;
constexpr uint mod = 1e9 + 7;
constexpr uint M = mod - 2;
constexpr shuumai<N> P;
std::array<uint, N + 1> Count;

// a^nを返す関数
const uint power(uint a, uint n)noexcept{
    unsigned long long res = 1, waiting = a;
    while(n){ 
        if(n & 1) { res *= waiting; res %= mod; }
        waiting *= waiting; waiting %= mod; 
        n >>= 1;
    }
    return res;
}

uint fastRead(void) {
	char c;
	while(true){
        c = getchar();
        if('0' <= c) break;
	}
    uint res = c - '0';
	while(true){
		c = getchar();
        if(c < '0') break;
		res = (res << 3) + (res << 1) + (c - '0');
	}
    return res;
}


int main(void){
    uint n = fastRead();
    uint inv_sum = 0;
    for(uint _ = 0; _ < n; ++_){
        uint a = fastRead();
        inv_sum += power(a, M); if(inv_sum >= mod) inv_sum -= mod;
        while(a - 1U){
            uint fac = P.minPrime[a];
            uint cnt = 1; a /= fac;
            while(a % fac == 0) a /= fac, cnt++;
            if(Count[fac] < cnt) Count[fac] = cnt; 
        }
    }

    unsigned long long int lcm = 1;
    for(unsigned int x : P) if(Count[x]) (lcm *= power(x, Count[x])) %= mod;
    unsigned int res = lcm * inv_sum % mod;
    
    printf("%u\n", res);
    return 0;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <string>
#include <utility>
#include <map>
#include <vector>
#include <iostream>
using namespace std;

const int alph = 26;
int main() {
    string s, t; cin >> s >> t;
    if(s.length() > t.length()) swap(s, t);
    for(int len=s.length(); len>=1; len--) {
        vector<int> vec(alph);
        for(int i=0; i<len-1; i++) {
            vec[ s[i] - 'a' ]++;
        }

        map< vector<int>, int > mp;
        for(int i=len-1; i<(int)s.length(); i++) {
            vec[ s[i] - 'a' ]++;
            mp[vec]++;
            vec[ s[i-len+1] - 'a' ]--;
        }

        vec = vector<int>(alph);
        for(int i=0; i<len-1; i++) {
            vec[ t[i] - 'a' ]++;
        }
        for(int i=len-1; i<(int)t.length(); i++) {
            vec[ t[i] - 'a' ]++;
            if(mp.count(vec)) {
                cout << len << endl;
                return 0;
            }
            vec[ t[i-len+1] - 'a' ]--;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      ll d=y-(10000*i+5000*j);
      if(d>=0&&d%1000==0&&i+j+d/1000==n){
	cout<<i<<' '<<j<<' '<<d/1000<<endl;
	return(0);
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
  return(0);
}


Measured memory_bytes: 256
n=int(input())
count=0
bx=0
xa=0
ba=0
for i in range(n):
    s=input()
    for j in range(0,len(s)-1):
        if s[j:j+2]=='AB':
            count=count+1
    if s[0]=='B' and s[len(s)-1]=='A':
        ba=ba+1
    if s[0]=='B' and not s[len(s)-1]=='A':
        bx=bx+1
    if not s[0]=='B' and s[len(s)-1]=='A':
        xa=xa+1
if bx==0 and xa==0:
    if ba>=2:
        count=count+ba-1
else:
    count=count+ba+min(xa,bx)
print(count)


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

int main()
{
	long long int X;
	scanf("%lld", &X);

	long long int val = 100;
	int ans = 0;
	while (val < X) {
		val = val + val / 100;
		ans++;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
const int N=1007,dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
int n,m,ans,qs,qe,d[N][N],qx[N*N],qy[N*N];
char mp[N][N];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%s",mp[i]+1);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	if(mp[i][j]=='.')d[i][j]=1e9;
	else d[i][j]=0,qx[qe]=i,qy[qe++]=j;
	while(qs<qe)
	{
		int x=qx[qs],y=qy[qs++];
		for(int i=0;i<4;i++)
		{
			int u=x+dx[i],v=y+dy[i];
			if(u<1||u>n||v<1||v>m||d[u][v]<=d[x][y]+1)continue;
			d[u][v]=d[x][y]+1,ans=max(ans,d[u][v]);
			qx[qe]=u,qy[qe++]=v;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 13056
#include <stdio.h>
#include <math.h>

int is_prime1(int);
int is_prime2(int);

int prime[168];

int main()
{
	int input, input_cnt, prime_cnt, cnt;
	int output[30];
	
	/*Make prime table*/
	prime[0] = 2;
	prime_cnt = 1;
	for(cnt = 3; cnt < 1000; cnt += 2)
	{
		if(is_prime1(cnt))
		{
			prime[prime_cnt] = cnt;
			prime_cnt++;
		}
	}
	
	/*Get, calculate input then save in output[]*/
	input_cnt = 0;
	while(scanf("%d", &input) != EOF)
	{
		prime_cnt = 0;
		if(input >= 2)
		{
			prime_cnt++;
		}
		for(cnt = 3; cnt <= input; cnt += 2)
		{
			if(is_prime2(cnt))
			{
				prime_cnt++;
			}
		}
		output[input_cnt] = prime_cnt;
		input_cnt++;
	}
	
	/*print output[]*/
	for(cnt = 0; cnt < input_cnt; cnt++)
	{
		printf("%d\n", output[cnt]);
	}
	
    return 0;
}

/*Test prime directly*/
int is_prime1(int prime1_input)
{
	int prime1_cnt;
	
	if(prime1_input == 1)
	{
		return 0;
	}
	else if(prime1_input == 2 || prime1_input == 3 || prime1_input == 5 || prime1_input == 7)
	{
		return 1;
	}
	else if((prime1_input % 2) == 0)
	{
		return 0;
	}

	for(prime1_cnt = 3 ; prime1_cnt <= (sqrt(prime1_input)); prime1_cnt += 2)
	{
		if(prime1_input % prime1_cnt == 0)
		{
			return 0;
		}
	}
	
	return 1;
}

/*Test prime with prime table*/
int is_prime2(int prime2_input)
{
	int prime2_cnt = 0;
	for( ;prime2_cnt <168; prime2_cnt++)
	{
		if(prime[prime2_cnt] > sqrt(prime2_input))
		{
			break;
		}
		if(prime2_input % prime[prime2_cnt] == 0)
		{
			return 0;
		}
	}
	return 1;
}

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

const int N_MAX = 40;
int ps[N_MAX + 1];
int ts[N_MAX + 1];
int c[N_MAX+1][4];

int main() {
    int n;
    while (cin >> n, n) {
        for (int i = 1; i <= n; i++) {
            cin >> ps[i] >> ts[i];
        }
        if (ps[1] > ts[1]) {
            cout << "NG " << 1 << endl;
            continue;
        }
        for (int i = 1; i <= n; i++) {
            fill_n(c[i], 4, INT_MAX);
        }
        c[0][0] = 0;
        c[1][1] = ps[1];
        int kth = -1;
        for (int i = 1; i < n; i++) {
            int dp = abs(ps[i+1] - ps[i]);
            int dt = ts[i+1] - ts[i];
            bool capture = false;
            for (int j = 1; j < 4; j++) {
                if (c[i][j] == INT_MAX) {
                    continue;
                }
                if (j < 3 && dp * (j + 1) <= dt) {
                    c[i+1][j+1] = min(c[i+1][j+1], c[i][j] + dp);
                    capture = true;
                }
                if (ps[i] * (j + 1) + ps[i+1] <= dt) {
                    c[i+1][1] = min(c[i+1][1], c[i][j] + ps[i] + ps[i+1]);
                    capture = true;
                }
            }
            if (!capture) {
                kth = i + 1;
                break;
            }
        }
        if (kth < 0) {
            int d_min = min(c[n][1], min(c[n][2], c[n][3])) + ps[n];
            cout << "OK " << d_min << endl;
        } else {
            cout << "NG " << kth << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
int n;
cin>>n;
vector<int> m(n);
int ans =0;
for(int i=0;i<n;i++){
int l;
cin>>l;
ans+=l;
m[i]=l;
}
sort(m.begin(),m.end());
int j=0;

while(ans%10==0){
if(m[j]%10==0)j++;
else{
    ans-=m[j];
    break;
}

if(j==n){
    ans=0;
    break;
}


}

cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

int main()
{
    Phuong_; /// <3
    double n;
    cin >> n;
    cout << setprecision(10) << n*6.283185307;
    return 0;
}



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

const int N = 1e5 + 5;

int h[N];
int dp[N];

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

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

const int mod = 2019;

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

  int n = (int)s.size();
  reverse(s.begin(),s.end());

  map<int,int> mp;
  mp[0] = 1;
  int m = s[0] - '0';
  int ten = 10;
  mp[m]++;
  for (int i = 1; i < n; i++) {
    m = m + (s[i] - '0') * ten;
    ten *= 10;
    m %= mod;
    ten %= mod;
    mp[m]++;
  }
  ll ans = 0;
  for (auto it : mp) {
    ans += it.second * (it.second - 1) / 2;
  }
  cout << ans << '\n';
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll H, N;
ll dp[1005][20005];

void solve() {
    cin >> H >> N;
    rep(i, 1005)rep(j, 20005) dp[i][j] = INF;
    vector<ll> a(N), b(N);
    rep(i, N) cin >> a[i] >> b[i];
    dp[0][0] = 0;
    rep(i, N){
        Rep1(j, 0, 20005){
            if(j - a[i] < 0){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-a[i]]+b[i]);
            }
        }
    }

    ll res = INF;
    Rep(i, H, 20005){
        res = min(res, dp[N][i]);
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 161408
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    s = read()
    lost = s.count('x')
    print("YES" if lost < 8 else "NO")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")


def read():
    return input()


def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)


def read_int():
    return int(read())


def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29548
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;
#define dbg(x) cout << #x << " has a value of: " << x << "\n";
#define usize(x) (int)(x.size())
#define plist(x)                       \
    for (int i = 0; i < usize(x); i++) \
        cout << "eleman " << i << " = " << x[i] << "\n";
#define foreach(x) for (auto item : x)
#define fill(s, x)              \
    for (int i = 0; i < x; i++) \
        cin >> s[i];
#define in(veriler, a) (veriler.find(a) != veriler.end())
#define btw(x, y, z) x >= y&& x <= z;
std::ostream& operator<<(std::ostream& os, pair<int,int> p) {
    os << p.first << ", " << p.second;
    return os;
}
#ifdef ONLINE_JUDGE
#define fio ios_base::sync_with_stdio(false);cin.tie(null);
#else
#define fio //a
#endif
int main(){
	lli n;
	cin>>n;
	if(n%2){
		cout<<n/2;
		
	}
	else cout<<n/2-1;
}


Measured memory_bytes: 256
#define MAX 200100;
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int k, n;
    int tmp;
    cin >> n >> k;

    vector<int> memo(n);
    for (int i = 0; i < n; ++i)
    {
        memo[i]=0;
    }

    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &tmp);
        memo[tmp]++;
    }

    sort(memo.begin(),memo.end(),greater<int>());

    int res=0;
    for (int i = 0; i < k; ++i)
    {
        res+=memo[i];
    }

    cout<<n-res<<endl;
}

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

main(){
  char s[27];
  int len,ans=0;

  cin >> s;
  len=std::strlen(s);
  
  for(int i=0;i<len-1;i++){
    for(int j=i+1;j<=len;j++){
      if(s[i]==s[j]){
	ans=1;
	break;
      }
    }
    if(ans==1)break;
  }
  
  if(ans==0){
    cout << "yes\n";
  }else{
    cout << "no\n";
  }
  return 0;
}


Measured memory_bytes: 256