akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main() {
    long long N, Z, W; cin >> N >> Z >> W;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<vector<long long> > dp(N+1, vector<long long>(2));
    for (int i = N-1; i >= 0; --i) {
        // 先手番
        dp[i][0] = -INF; // 初期化
        long long Y = (i ? a[i-1] : W);
        chmax(dp[i][0], abs(Y - a[N-1]));
        for (int j = i+1; j < N; ++j) chmax(dp[i][0], dp[j][1]);

        // 後手番
        dp[i][1] = INF; // 初期化
        long long X = (i ? a[i-1] : Z);
        chmin(dp[i][1], abs(X - a[N-1]));
        for (int j = i+1; j < N; ++j) chmin(dp[i][1], dp[j][0]);

        //cout << i << ": " << dp[i][0] << ", " << dp[i][1] << endl;
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
  int sosuu[10001];
  int i,j,k,l,n,sum,flag;
  k=2;
  sosuu[0]=2;
  sosuu[1]=3;
  for(i=5;i<=120000;i+=2){
    flag=0;
    for(j=3;j<i;j+=2){
      if(i%j==0){
	flag=1;
	break;
      }
    }
    if(flag==0){
      sosuu[k]=i;
      k++;
    }
    if(k==10000){
      break;
    }
  }
  while(scanf("%d",&n)!=EOF){
    sum=0;
    if(n==0){
      break;
    }
    for(l=0;l<n;l++){
      sum+=sosuu[l];
    }
    printf("%d\n",sum);
  }
  return 0;

}

Measured memory_bytes: 1724
#include <vector>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
bool is_prime(int n, int k = 3)
{
    if(n < k * k) { return true; }
     
    if(n % k == 0) { return false; }
     
    return is_prime(n, k + 2);
}
 
int main()
{
    vector<int> prime = {2};
     
    for(int i = 3; i < 101300; i += 2)
    {
        if(is_prime(i))
        {
            prime.push_back(i);
        }
    }
     
    int n, m;
     
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &m);
         
        if(n == -1 && m == -1) { break; }
         
        int ptr = distance(prime.begin(), lower_bound(prime.begin(), prime.end(), n + 1));
         
        vector<int> c; int r = min(22, m) - 1;
        
        for(int i = ptr + r; i >= ptr; i--)
        {
            for(int j = ptr + r; j >= i; j--)
            {
                c.push_back(prime[i] + prime[j]);
            }
        }
        
        sort(c.begin(), c.end());
         
        printf("%d\n", c[m - 1]);
    }
     
    return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
#include<set>
// #include <stdio.h>
using namespace std;
 
#define int long long int
#define ld long double
#define mod 1000000007 
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define forn(i,s, e) for (int i = s; i <= e; i++)
#define fornd(i,s, e) for (int i = s ; i >= e; i--)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define print(x) for(auto el: x) cout<<el<<" ";cout<<"\n"
#define PSET(x,y) fixed<<setprecision(y)<<x
// #define bits(x) __builtin_popcount(x)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
// void fileio()
// {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }
template <typename T> 
void swap(T& a, T& b){
    T temp = a;
    a = b;
    b = temp;
}
const int N = 1000005; 

void solve(){
    int n;
    cin>>n;
    int inf = 1e18;
    int ifni = -1*inf;

    int** a = new int*[n];
    forn(i,0,n-1){
        a[i] = new int[n];
        forn(j,0,n-1)
            cin>>a[i][j];
    }

    int* dp = new int[(1<<n)]();
    dp[0] = 0;

    for(int mask = 0; mask < (1<<n); mask++){
        for(int i=0;i<n; i++){
            if(!(mask&(1<<i)) ){
                int temp = 0;
                for(int j=0;j<n;j++){
                    if(mask&(1<<j))
                        temp+= a[i][j];
                }
                // cout<<temp<<" ";
                dp[mask|(1<<i)] = dp[mask] + temp;
            }
        }
    }

    for(int mask1= 0; mask1 <(1<<n); mask1++){

        int temp = mask1^((1<<n)-1);
        for(int mask2= temp ; mask2 ; mask2 = (mask2-1)&temp ){
            if((mask2&mask1) == 0){
                dp[mask2|mask1] = max(dp[mask2|mask1] ,dp[mask1]+dp[mask2]);
            }
        }
    }
    // forn(i,0,(1<<n)-1){
    //     cout<<i<<" "<<dp[i]<<endl;
    // }
    // print(dp);
    cout<<dp[(1<<n)-1]<<endl;

}
 
int32_t main()
{
    // fileio();
    fast;
    // int t;
    // cin>>t;
    // for(int y=1;y<=t;y++)
    {
        // cout<<"Case #"<<y<<": ";
        solve();
    }
    return 0;
} 

Measured memory_bytes: 768
#include<stdio.h>
int main(){
  int count[4][3][10];
  int n,b,f,r,v,a=0;

  scanf("%d",&n);

  for(b=0;b<4;b++){
    for(f=0;f<3;f++){
      for(r=0;r<10;r++){
        count[b][f][r]=0;
      }
    }
  }

  for(a=0;a<n;a++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
   count[b-1][f-1][r-1] = count[b-1][f-1][r-1]+v;
  }

  for(b=0;b<4;b++){
    for(f=0;f<3;f++){
      for(r=0;r<10;r++){
        printf(" %d",count[b][f][r]);
      }
      printf("\n");
    }
    if(b!=3) printf("####################\n");
  }
  return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    
    int res = A[0];
    for (int i = 1; i < N; ++i) {
        res = __gcd(res, A[i]);
    }
    
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    map<string, string> whether;
    whether["Sunny"] = "Cloudy";
    whether["Cloudy"] = "Rainy";
    whether["Rainy"] = "Sunny";
    cin >> s;
    
    cout << whether[s] << endl;
}

Measured memory_bytes: 384
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = list(iss())
    B = list(iss())
    atob = {}
    btoa = {}
    for n in range(ord('a'), ord('z') + 1):
        atob[chr(n)] = 0
        btoa[chr(n)] = 0

    for ab in zip(A, B):
        a, b = ab
        if atob[a] == 0 and btoa[b] == 0:
            atob[a] = b
            btoa[b] = a
        elif atob[a] != b or btoa[b] != a:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()


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

int main(void){
  int D;cin>>D;
  if(D==22)cout<<"Christmas Eve Eve Eve"<<endl;
  if(D==23)cout<<"Christmas Eve Eve"<<endl;
  if(D==24)cout<<"Christmas Eve"<<endl;
  if(D==25)cout<<"Christmas"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

string S;
int kotae;
int f;
int main(){
  kotae = 0;
  cin >> S;
  REP(i,S.size()){
    for(int j=i;j<S.size();j++){
      f = 0;
      for(int k=i;k<=j;k++){
        if(S[k] != 'A' &&  S[k] != 'C' && S[k] != 'G' && S[k] != 'T') f = 1;
      }
      if(f==0) kotae = max(kotae,j-i+1);
    }
  }
  cout << kotae << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
		
		int A = scr.nextInt();
		int B = scr.nextInt();
		int H = scr.nextInt();
		int M = scr.nextInt();
		
		double H1 = (H*60+M)*0.5;
		double M1 = M*6;
		
		double KK;
		
		if(H1 < M1) {
			KK = M1-H1;
		}else {
			KK = H1-M1;
		}
		
		double Theta = Math.cos(Math.toRadians(KK));
		
		double ans = A*A+B*B-2*B*A*Theta;
		
		System.out.println(Math.sqrt(ans));
		
	}
}

Measured memory_bytes: 35844
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

int main()
{
    set<int> a,b,d;
    int c;
    int n;
    cin>>n;
    while(n--){
        cin>>c;
        a.insert(c);
    }
    cin>>n;
    while(n--){
        cin>>c;
        b.insert(c);
    }
    //set_union(it1,it2,it3,it4,it);
    set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(d,d.begin()));
    for(set<int>::iterator it=d.begin();it!=d.end();it++){
        cout<<*it<<"\n";
    }
}





Measured memory_bytes: 31144
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A,B; cin >> A >> B;
  REP(i,1010){
    if(int(i * 0.08) == A && int(i * 0.1) ==B){
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 3572
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int main(){
    string S;
    cin >> S;

    int N = S.size();
    int ans = 999;
    for(int i=0;i<= N-3;++i){
        int num = (S[i] - '0')*100 + (S[i+1]-'0')*10+S[i+2] - '0';
        ans = min(ans, abs(num-753));
    }
    cout << ans << endl;
}

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

using namespace std;
int i, j, n, x, y;
int val[2010];

int minDist(int i, int j) {
    return min(j-i, i-x+y-j+1);
}

int main() {
    scanf(" %d %d %d", &n, &x, &y);
    for (i=1;i<=n;i++) {
        val[i] = 0;
    }
    for (i=1;i<=n;i++) {
        for (j=i+1;j<=n;j++){
            int tar = 0;
            if ((i <= x && j <= x) || (i >= y && j >= y)) tar = j - i;
            else if (i <= x && j > x && j < y) tar = minDist(x, j) + x - i;
            else if (i > x && i < y && j >= y) tar = minDist(i, y) + j - y;
            else if (i > x && i < y && j > x && j < y) tar = minDist(i, j);
            else if (i <= x && j >= y) tar = x - i + j - y + 1;
            val[tar]++;
        }
    }
    for (i=1;i<n;i++) {
        printf("%d\n", val[i]);
    }
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define el '\n'
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define pb() push_back()
#define MAX 10e+7
void solve()
{
int n;
cin>>n;
string s;
cin>>s;
int l=s.length();
if(l<=n)
 cout<<s;
else
{
    cout<<s.substr(0,n)<<"..."<<el;
}

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  h,w,dp[1003][1003],k,i,mod;
char a[1004][1004];
int main(){
	cin>>h>>w;
	mod=1e9+7;
	for(k=1;k<=h;k++)
	for(i=1;i<=w;i++)
	cin>>a[k][i];
	dp[0][1]=1;
	for(k=1;k<=h;k++){
		for(i=1;i<=w;i++){
			 if(a[k][i]=='.') dp[k][i]=dp[k][i-1]+dp[k-1][i];
			 //cout<<k<<" "<<i<<" "<<dp[k][i]<<endl;
			 dp[k][i]%=mod;
		}
	}
	cout<<dp[h][w];
}

Measured memory_bytes: 5120
import java.util.*;

public class Main{
    public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
		 double a = sc.nextDouble();
		 double b = sc.nextDouble();
		 double d = 0;
		 double r = 0;
		 double f = 0;
		 d = a / b;
		 r = a % b;
		 f = a / b;
		 System.out.printf((int)d + " " + (int)r + " " + "%.8f",f);
        
    }
}


Measured memory_bytes: 28144
#include <iostream>

using namespace std;

int main(){
    int H,W;

    
    int i=0;
    int j=0;
    int num=0;
    while(num<1000){
    
    cin>>H>>W;
    if(H!=0 && W!=0){    
        while(i<H){
        
            while(j<W){
                cout<<"#";
                j++;
            }
            cout<<endl;
         j=0;
            i++;
        
        }
        cout<<endl;
        i=0;
    }
    if(H==0 && W==0){
        break;
    }
    
    }
    
    
    
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define MOD 10000
#define INF 1000000007
using namespace std;
//
int N;
int sum;
int F(int u){
  while(u>0){
    sum+=u%10;
    u/=10;
  }
  return sum;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  if(N%F(N)==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

using ll = long long;
using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N;
vector<ll> A, B;

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

    cin >> N;
    A.resize(N);
    B.resize(N);

    REP(i, N) {
        cin >> A[i] >> B[i];
    }
    
    sort(ALL(A));
    sort(ALL(B));

    ll ans = 0;

    if (N%2) {
        ll min = A[N/2];
        ll max = B[N/2];
        ans = max - min + 1;
    } else {
        ll min = A[N/2-1] + A[N/2];
        ll max = B[N/2-1] + B[N/2];
        ans = max - min + 1;
        
    }

    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 6324
import Control.Applicative ((<$>))
import Control.Monad
import Control.Monad.RWS.Strict
import qualified Data.IntMap as IM
import qualified Data.Set as S
import Data.List (sortBy)

type Time = Int

type AdjG = IM.IntMap [Int]
type State = (Time, IM.IntMap Bool)
type Log = S.Set (Bool, Int, Time)

main :: IO ()
main = do
  n <- readLn
  adjG <- fmap IM.fromList $ replicateM n $ do
    (u:_:vs) <- map read . words <$> getLine :: IO [Int]
    return (u,vs)
  let res = S.toList $ snd $ evalRWS (dfs n) adjG (1, IM.fromList $ zip [1..n] $ repeat False)

  forM_ [1..n] $ \i -> do
    putStrLn $ unwords $ map show $ (i:) $ map (\(_,_,t) -> t) $ sortBy (\(a,_,_) (b,_,_) -> a `compare` b) $ filter (\(_,v,_) -> v == i) res

dfs :: Int -> RWS AdjG Log State ()
dfs n = forM_ [1..n] $ \v -> do
  fls <- snd <$> get
  when (not $ fls IM.! v) $ rec v

rec :: Int -> RWS AdjG Log State ()
rec v = do
  (t, fls) <- get

  when (not $ fls IM.! v) $ do
    us <- asks (IM.!v)
    tell $ S.singleton (False, v, t)
    put (t+1, IM.alter (fmap (const True)) v fls)
    mapM_ rec us
    (t, fls) <- get
    tell $ S.singleton (True, v, t)
    put (t+1, fls)
    return ()

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

const int mxN = 2e5+5, M = 1e9+7;
ll a[mxN];

ll mul(ll a, ll b) {
	return (a%M * b%M)%M;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	ll sum = a[n-1];
	for(int i = n-2; i >= 0; i--) {
		ans = (ans + mul(sum, a[i]))%M;
		sum = (sum + a[i])%M;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5204
#include <stdio.h>
int main(){
    int m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1){
            break;
        }
        if(m==-1||f==-1){
            puts("F");
        }
        else if(m+f>=80){
            puts("A");
        }
        else if(m+f>=65){
            puts("B");
        }
        else if(m+f>=50||r>=50){
            puts("C");
        }
        else if(m+f>=30){
            puts("D");
        }
        else{
            puts("F");
        }
    }
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <array>
using namespace std;

vector<long> v;

void func(long x, long n)
{
    if (x>n) return;
    v.push_back(x);
    func(x*10+3, n);
    func(x*10+5, n);
    func(x*10+7, n);
}

int main()
{
    long n; cin>>n;
    func(0, n);
    int res=0;
    for(int e: v) {
        array<int, 10> c={};
        for(; e>0; e/=10) c[e%10]++;
        if (c[3] && c[5] && c[7]) ++res;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cassert>
#include<algorithm>
using namespace std;
static const int MAX = 5000;
 
vector<int> G[MAX+1];
vector<int> ans;
bool V[MAX+1];
int W[MAX+1];
 
int N, M;
 
void dfs(int u){
  V[u] = true;
  for ( int i = 0; i < G[u].size(); i++ ){
    int v = G[u][i];
    if ( !V[v] ) dfs(v);
  }
  ans.push_back(u);
}
 
main(){
  cin >> N >> M;
  for ( int i = 1; i <= N; i++ ) {
    V[i] = false;
    W[i] = -1;
  }
 
  int s, t;
  for ( int i = 0; i < M; i++ ){
    cin >> s >> t;
    W[s] = t;
    G[t].push_back(s);
  }
 
  for ( int i = 1; i <= N; i++ ){
    if (!V[i]) dfs(i);
  }
 
  for ( int i = 0; i < N; i++ ) cout << ans[i] << endl;
  bool mul = false;
  for ( int i = 0; i < N-1; i++ ){
    int i1 = ans[i];
    int i2 = ans[i+1];
    if ( W[i1] == -1 ){
      mul = true; break;
    }
  }
 
  if ( mul ) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <unordered_map>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::unordered_map<uint64,uint32> map;
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map[sum] = 0;
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)!=map.end()) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map[sum] = i + 1;
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 11032
#include <bits/stdc++.h>
#define ri register int
using namespace std;
typedef double db;
typedef long double ld;
typedef long long ll;
typedef vector <int> poly;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef unsigned long long ulll;
typedef unsigned int uii;
typedef string strr;
#define fi first
#define se second
#define pb push_back
#define ppp pop_back
#define rez resize
const ll Inf = 1e18;
const int rlen = 1 << 20, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin)), ib == ob) ? -1 : *ib++)
inline int read() {
  static int ans, f;
  static char ch;
  ans = 0, ch = gc(), f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = gc();
  return f ? ans: -ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  top = 0, ch = gc();
  while (!isalpha(ch)) ch = gc();
  while (isalpha(ch)) s[++top] = ch, ch = gc();
  return top;
}
namespace modular {
  const int mod = 1e9 + 7;
  int ret;
  inline int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod; }
  inline void Dec(int &a, int b) { a = a < b? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) {
    for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
  }
  inline int Inv(int a) { return ksm(a, mod - 2); }
  inline int sqr(int a) { return (ll) a * a % mod; }
  inline int cub(int a) { return (ll) a * a % mod * a % mod; }
} using namespace modular;
template <typename T> inline void ckmax(T &a, T b) { a < b ? a = b : 0; }
template <typename T> inline void ckmin(T &a, T b) { a > b ? a = b : 0; }
template <typename T> inline T Abs(T a) { return a < 0 ? -a : a; }
template <typename T> inline T gcd(T a, T b) {
  T t;
  while (b) t = a, a = b, b = t - t / a * a;
  return a;
}
const int N = 1e6 + 5;
int n, q[N], hd, tl;
char s[N], t[N];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read();
  Read(s), Read(t);
  int pos = n, ans = 0, ss = 0, dt = 0;
  bool ff = 1;
  for (ri i = 1; i <= n; ++i) if (s[i] != t[i]) ff = 0;
  if (ff) return cout << 0, 0;
  int res = 0;
  hd = 1, tl = 0;
  for (ri pos = n, i = n; i; --i) {
    if (t[i] == t[i - 1]) continue;
    while (pos && (s[pos] != t[i] || pos > i)) --pos;
    if (!pos) return cout << -1, 0;
    while (hd <= tl && q[hd] - (tl - hd + 1) >= i) ++hd;
    if (pos ^ i) q[++tl] = pos;
    ckmax(res, tl - hd + 1);
  }
  cout << res + 1;
  return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main(){
  long long n,a,b,sasa;
  cin >> n >> a >> b;

  long long sa = abs(a-b);
  long long a1 = a - 1;
  long long b1 = b - 1;
  long long an = n - a;
  long long bn = n - b;

  long long yasumi1 = (a1 + b1) / 2 + 1;
  long long yasumin = (an + bn) / 2 + 1;
  long long yasumi = min(yasumi1,yasumin);

  if(sa % 2 == 0){
    sasa = sa / 2;
  }else{
    sasa = yasumi;
  }

  long long ans = min(yasumi,sasa);

  cout << ans;
}

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

using namespace std;

int main(){
  string O,E;
  cin >> O;
  cin >> E;
  int n=0;
  while (O[n]!=0 || E[n]!=0){
    if(O[n]==0) cout << E[n];
    else if (E[n]==0) cout << O[n];
    else cout << O[n] << E[n];
    n++;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

    int n;
    cin >> n;
    vector<int> vec;
    ll x = 0;
    ll y = 0;
    ll ans = INF;
    rep(i,n) {
        int a;
        cin >> a;
        vec.push_back(a);
        x += a;
    }
    rep(i,n){
        y += vec[i];
        if (i+1<n)ans = min(ans,abs(x-2*y));
        
    }
    cout << ans << endl;
        
}

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

entHai = []

def newHai(preHai, hai):
    global entHai
    if len(hai) == 1:
        entHai.append(preHai+hai)

    #print(hai)
    for h in hai:
        narr = [na for na in hai if na != h]
        #print("narr:",narr)
        narr = newHai(preHai + [h], narr)
        #print("narR:",narr)

newHai([], list(range(N)))

keiroSum = 0
for eh in entHai:
    #print(eh)
    for nn in range(1, N):
        xi, yi = xy[eh[nn-1]]
        xj, yj = xy[eh[nn]]
        keiroSum += pow((xi-xj)**2 + (yi-yj)**2, 0.5)

print(keiroSum/len(entHai))

Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n, m;
  cin >> n >> m;
  cout << n * m;

  return 0;
}

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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) throws IOException {
        int n = scanner.nextInt();
        long ans = 0;
        long k = scanner.nextLong();
        long[] count = new long[2001];
        long[] b = new long[n];
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            count[a[i] - 1]++;
            for (int j = a[i]; j <= 2000; j++) {
                b[i] += count[j];
            }
        }
        for (int i = 2000; i > 0; i--) {
            count[i - 1] += count[i];
        }
        for (int i = 0; i < n; i++) {
            ans = (ans + ((k * (k - 1) / 2) % mod * count[a[i]] % mod + b[i] * k % mod)) % mod;
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

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

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	long x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int ans = 1e8;
    for (int p = 0; p <= 100; p++) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt += (x[i] - p) * (x[i] - p);
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

static const int N = 100;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
int main(void){
	int n,p[N+1],m[N+1][N+1];
	cin>>n;

	loop(i,1,n+1){
		cin>>p[i-1]>>p[i];
	}

	loop(i,1,n+2)m[i][i] = 0;

	loop(l,2,n+1){
		loop(i,1,n-l+2){
			int j = i + l - 1;
			m[i][j] = (1<<21);
			loop(k,i,j){
				m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
			}
		}
	}
	cout << m[1][n] << endl;
}

Measured memory_bytes: 1200
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if abs(a[0]-a[2]) <=a[3] or (abs(a[0] -a[1]) <=a[3] and abs(a[1]-a[2]) <=a[3]):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long 
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<(int)s.size();i++)
	{
		if(s[i]==',')
		{
			s[i]=32;
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
from operator import itemgetter
sentence = list(input().split())
max_length = 0
max_sentence = ""
count = []
for i in range(len(sentence)) :
    if max_length < len(sentence[i]) :
        max_length = len(sentence[i])
        max_sentence = sentence[i]
    new_word = False
    for j in range(len(count)) :
        if count[j][0] == sentence[i] :
            new_word = True
            count[j][1] += 1
            break
    if new_word == False :
        count.append([sentence[i], 1])
count = sorted(count, key = itemgetter(1), reverse = True)
print(count[0][0], max_sentence)
    


Measured memory_bytes: 5652
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int d, n, ans;
	cin >> d >> n;
	
	if (n == 100) ans = pow(100, d) * (n + 1);
	else ans = pow(100, d) * n;

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

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int a,x;
	scanf("%d",&a);
	if(a==0)	x=0;
	else if(a==1)	x=1;
	else if(a==10)	x=1;
	else if(a==100)	x=1;
	else if(a==11)	x=2;
	else if(a==101)	x=2;
	else if(a==110)	x=2;
	else x=3;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;


public class Main {
	static Scanner sc = new Scanner(System.in);
	static final double EPS = 1e-8;
	public static void main(String[] args) {
		
		int[] hist = {0, 0, 0, 0};
		while (sc.hasNext()) {
			String[] ss = sc.next().split(",");
			if (ss[1].equals("A")) {
				hist[0]++;
			} else if (ss[1].equals("B")) {
				hist[1]++;
			} else if (ss[1].equals("AB")) {
				hist[2]++;
			} else if (ss[1].equals("O")) {
				hist[3]++;
			}
		}
		
		for (int i = 0; i < 4; i++) {
			System.out.println(hist[i]);
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main()
{
   int a,b,c1,c2,c3;
   scanf("%d %d",&a,&b);
    c1=a+b;
    c2=a-b;
    c3=a*b;

   if(c1>=c2 && c1>=c3){
   printf("%d",c1);}

   else if(c2>=c1 && c2>=c3){
   printf("%d",c2);}

   else {
    printf("%d",c3);}

   return 0;









}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, H, W; cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3684
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
    S = input()
    if(S == "AC"):
        AC+=1
    elif(S == "WA"):
        WA+=1
    elif(S == "TLE"):
        TLE+=1
    elif(S == "RE"):
        RE+=1


print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b)
{
	return a>b;
}
int main()
{
	int n, sum=0, s=0,  x=0, z=0;
	cin >> n;
	int a[n+1];
	if(n%2==0)
	{
		sum=n/2;
	}
	else
	{
		sum=(n/2)+1;
	}
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	sort(a+1, a+n+1, cmp);
	for(int i=1;i<=n;i+=2)
	{
		x+=a[i];
	}
	for(int i=2;i<=n;i+=2)
	{
		z+=a[i];
	}
	cout << x - z <<endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b,c ,k;
	cin >>a >>b >>c >>k;
	
	ll nc =c, nb =b;
	int ans =0;
	while(nb <= a ) { nb*=2; ans++;}
	while(nc <= nb) {nc*=2; ans++;}
	//dbg(ans, k);
	if(ans <= k) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3652
N ,M = map(int,input().split())
P_list = [0 for i in range(N+1)]
AC_count = 0
WA_count = 0

for i in range(M):
    box = input().split()
    if P_list[int(box[0])] != "AC":
        if box[1] == "AC":
            AC_count += 1
            WA_count += P_list[int(box[0])]
            P_list[int(box[0])] = "AC"
        elif box[1] == "WA":
            P_list[int(box[0])] += 1


print(AC_count,WA_count)


Measured memory_bytes: 3928
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, m, n) for(int i = m; i >= n; i--)

map<int, int> mp;

int main(){
	int n, num;
	while(cin >> n && n){
		mp.clear();
		rep(i, n){
			cin >> num;
			mp[num]++;
		}
		int cnt = 0;
		int id = 0;
		for(map<int, int>::iterator iter = mp.begin(); iter != mp.end(); iter++){
			if((*iter).second > cnt){
				cnt = (*iter).second;
				id = (*iter).first;
			}
		}
		if(cnt > n / 2){
			cout << id << endl;
		}else{
			cout << "NO COLOR" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	map<char,int> mp;
	mp['A'] = 1;mp['C'] = 1;mp['G'] = 1;mp['T'] = 1;
	int ans = -1000;
	for(int i=0;i<=s.size();i++)
	{
		for(int j=0;j<s.size();j++)
		{
			string H = s.substr(j,i);
			bool isok = true;
			for(int k=0;k<H.size();k++)
			{
				if(mp[H[k]] == 0)
					isok = false;
			}
			if(isok)
			{
				int sz = H.size();
				ans = max(ans,sz);
			}
		}
	}
	if(ans)
		cout<<ans<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long W = sc.nextInt();
    long[] w = new long[N];
    int[] v = new int[N];
    int vsum = 0;
    for (int i = 0; i < N; i++) {
      w[i] = sc.nextInt();
      v[i] = sc.nextInt();
      vsum += v[i];
    }
    long[][] dp = new long[N + 1][vsum + 1];
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= vsum; j++) {
        dp[i][j] = 11000000000000000L;
      }
    }

    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j <= vsum; j++) {
        dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
        if (j + v[i] <= vsum) 
          dp[i + 1][j + v[i]] = Math.min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
      }
    }

    long ans = 0;
    for (int i = vsum; i >= 0; i--) {
      if (dp[N][i] <= W) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}



Measured memory_bytes: 138936
// region
fun main(args: Array<String>) = abc155c()
// endregion

fun abc155c() {
    val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }

    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second
    val answer = map.filter { it.second == max }.map { it.first }.sorted()
        .joinToString(System.lineSeparator())

    println(answer)
}


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

using namespace std;

bool func(pair<long, long> &p1, pair<long, long> &p2) {
    return p1.first < p2.first;
}

void sortTwo(vector<long> &a, vector<long> &b) {
    long n = a.size();
    vector<pair<long, long> > p(n);
    for(long i=0; i<n; i++) {
        p[i] = make_pair(a[i], b[i]);
    }
    sort(p.begin(), p.end(), func);
    for(long i=0; i<n; i++) {
        a[i] = p[i].first;
        b[i] = p[i].second;
    }
}

int main() {
    long n, m, mon=0;
    cin >> n >> m;
    vector<long> a(n), b(n);
    for(int i=0; i<n; i++) {
        cin >> a[i] >> b[i];
    }
    sortTwo(a, b);
    long min_i = 0;
    while(m > 0) {
        if(m - b[min_i] > 0) {
            mon += b[min_i] * a[min_i];
        } else {
            mon += m * a[min_i];
        }
        m -= b[min_i];
        a[min_i] = LONG_MAX;
        min_i++;
    }
    cout << mon << endl;
}


Measured memory_bytes: 3328
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  N=II()
  l1=LI()
  l2=LI()
  l3=LI()

  l=[]
  for x in l1:
    l.append([x,3])

  for x in l2:
    l.append([x,2])

  for x in l3:
    l.append([x,1])

  l=sorted(l,key=lambda x:[x[0],x[1]])

  a=0
  b=c=N
  cnt=0
  for x in l:
    y=x[1]
    if y==3:
      a+=1
    elif y==1:
      c-=1
    else:
      cnt+=a*c
      b-=1

  return cnt

# main()
print(main())


Measured memory_bytes: 85756
n, m = map(int, input().split())
table = [[0, "None"] for i in range(n+10)]
for i in range(m):
    p, s = input().split()
    p = int(p)
    if table[p][1] == "None" or table[p][1] == "WA":
        if s == "WA":
            table[p][0] += 1
        table[p][1] = s
AC = 0
PEN = 0
for i in table:
    if i[1] == "AC":
        AC += 1
        PEN += i[0]
print(AC, PEN)


Measured memory_bytes: 18804
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<int> v;
    for(int i=1;i<n;i++)
    {
        v.push_back(a[i]-a[i-1]);
    }
    int x=k-a[n-1]+a[0];
    v.push_back(x);
    sort(v.begin(),v.end());
    int num=0;
    for(int i=0;i<v.size()-1;i++)
        num=num+v[i];
    cout<<num;
    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  for (int i = K; i < N; ++i) {
    std::cout << ((A[i] > A[i - K]) ? "Yes" : "No") << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
 
int main() {
  int n;
  cin>>n;
  bool ans=true;
  if(n%10!=7){
    n/=10;
  if(n%10!=7){
      n/=10;
  if(n%10!=7)
      ans=false;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

int main(void){
    long long L,R;
    cin>>L>>R;
    long long ans=2018;
    if(R-L>2021) cout<<0<<endl;
    else{
        for(long long i=L;i<=R;i++){
            for(long long j=i+1;j<=R;j++){
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;

    string s;
    int p;
    vector<pair<string,pair<int,int>>> list(N);
    for (int i = 0; i < N; i++){
        cin >> s;
        cin >> p;
        s = s;  
        list[i]=make_pair(s,make_pair(-p,i+1));
    }
    sort(list.begin(), list.end());
    for (int i = 0; i < N;i++)
        cout << list[i].second.second << endl;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int cnt = 0;
  rep(i,n-1){
    if(a.at(i) == a.at(i+1)){
      a.at(i+1) = 10001;
      cnt++;
    }
  }
  cout << cnt << endl;
      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

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

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {
 ios::sync_with_stdio(false);

ll x;
cin>>x;

ll k=lcm(x, 360);
cout<<k/x<<endl;



return 0;
}




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

void func140c() {
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n-1);
  for (int i = 0; i < n-1; i++) cin >> b[i];
  a[0] = b[0];
  ans += a[0];
  for (int i = 1; i <= n-2; i++) {
    a[i] = min(b[i], b[i-1]);
    ans += a[i];
  }
  a[n-1] = b[n-2];
  ans += a[n-1];
  cout << ans << "\n";
}

int main() {
  func140c();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

#define INF 1e9

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

typedef long long ll;

struct Node {
	int x, y, t, cost;
};
bool operator >(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

int main() {
	int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
	int N; cin >> N;
	bool wall[201][201] = {0};
	for (int i = 0; i < N; ++i) {
		int x, y; cin >> x >> y;
		wall[y+100][x+100] = true;
	}
	int W, H; cin >> W >> H;

	int ans = -1;
	priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push( (Node){sx, sy, 0, 0} );
	bool gone[6][201][201] = {0};
	while ( !Q.empty() ) {
		Node node = Q.top(); Q.pop();
		int x = node.x, y = node.y, t = node.t, cost = node.cost;

		int cmd = (int)abs(x * y * t) % 6;

		if (abs(x) > W || abs(y) > H) continue;

		if (gone[t%6][y+100][x+100]) continue;
		gone[t%6][y+100][x+100] = true;

		if (wall[y+100][x+100]) continue;

		if (x == gx && y == gy) {
			if (ans < 0 || cost < ans) ans = cost;
			continue;
		}
		for (int i = 0; i < 6; ++i) {
			int nx = x + dx[i];
			int ny = y + dy[(x+100)%2][i];
			int nc = i == cmd ? cost : cost+1;
			Q.push( (Node){nx, ny, (t+1)%6, nc} );
		}
		Q.push( (Node){x, y, (t+1)%6, cost+1} );
	}
	cout << ans << endl;
}

Measured memory_bytes: 2348
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 15:35:55 2020

@author: NEC-PCuser
"""

N = int(input())

print()
if (N % 2 == 1):
    print(0)
else:
    i = N
    ans = 0
    count = 0
    while(i >= 5):
        i = i // 5 
        count += 1
    for i in range (count, 0, -1):
        ans += (N // ((5 ** i) * 2))
    print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        String res = "No";
        if (n / 100 == 7)  res = "Yes";
        if ((n % 100) / 10 == 7) res = "Yes";
        if ((n % 100) % 10 == 7) res = "Yes";

        System.out.println(res);
    }
}

Measured memory_bytes: 35740