akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 2020;

int n, x, a[N], c[N];

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

    cin >> n >> x;
    forn(i,n) cin >> a[i], c[i] = a[i];

    ll res = 8e18;
    forn(spells,n) {
        ll cand = (ll)x * spells;
        forn(i,n) cand += c[i];
        res = min(res, cand);

        int j = (2*n-spells-1) % n;
        forn(i,n) {
            c[i] = min(c[i], a[j]);
            j = (j+1)%n;
        }
    }
    cout << res << endl;

    return 0;
}


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

using namespace std;

using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<ll> va{0};
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    va.push_back(va.back() + a);
  }

  ll sum = va.back();
  ll ans = -1;
  for (int i = 0; i < n - 1; ++i) {
    ll snk = va[i + 1];
    ll ari = sum - snk;
    ll diff = abs(snk - ari);
    if (ans < 0 || ans > diff) {
      ans = diff;
    }
  }

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

Measured memory_bytes: 5344
s=input()
t=input()
ls=len(s)
lt=len(t)

y=0
for i in list(reversed(range(ls-lt+1))):
    L=[]
    for j in range(lt):
        L.append((s[i+j]==t[j] or s[i+j]=='?'))
    if all(L):
        s=list(s)
        s[i:i+lt]=list(t)
        s="".join(s)
        s=s.replace('?','a')
        print(s)
        y=1
        break
if y==0:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
if __name__ == "__main__":
    n, m = map(int, input().split())

    l = [2] * n + [1] * m

    ans = 0
    for i in range(len(l)):
        for j in range(len(l)):
            if i != j and i < j and (l[i] + l[j]) % 2 == 0:
                ans += 1

    print(ans)


Measured memory_bytes: 2940
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return [int(i) for i in input().rstrip()]
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    k = II()
    ans = 0
    lis = []
    i = 0
    tmp = 1
    while len(s) > i + 1:
        if s[i] == s[i + 1]:
            tmp += 1
        else:
            lis.append((s[i], tmp))
            tmp = 1
        i += 1
    lis.append((s[i], tmp))
    if lis[0][0] == lis[-1][0]:
        if len(lis) == 1:
            ans += k * lis[0][1] // 2
            print(ans)
            return
        ans -= (lis[0][1] // 2 + lis[-1][1] // 2) * (k - 1)
        ans += (lis[0][1] + lis[-1][1]) // 2 * (k - 1)
    for _, b in lis:
        ans += b // 2 * k
    print(ans)
    return

#B
def B():
    n = II()
    s = SR(n)
    edg = [[] for i in range(n)]
    check = [0] * n
    for i in range(n):
        for k in range(n):
            if i == k:
                continue
            if s[i][k]:
                edg[i].append(k)
                edg[k].append(i)
            else:
                s[i][k] = inf
    for i in range(n):
        q = deque([i])
        if check[i] == 0:
            check[i] += 1
        while q:
            p = q.pop()
            for k in edg[p]:
                if check[k]:
                    if (check[k] ^ check[p]) & 1:
                        continue
                    print(-1)
                    return
                else:
                    check[k] = check[p] + 1
                    q.appendleft(k)

    for x in range(n):
        for i in range(n):
            for k in range(n):
                s[i][k] = min(s[i][k], s[i][x] + s[x][k])
    ans = 0
    for i in range(n):
        for k in range(n):
            if s[i][k] == inf:
                continue
            ans = max(s[i][k], ans)
    print(ans+1)
# C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 58588
package main

import (
	"fmt"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)

	d = d*2 + 1
	if n%d == 0 {
		fmt.Println(n / d)
	} else {
		fmt.Println(n/d + 1)
	}
}


Measured memory_bytes: 512
n,m = map(int,input().split())
ab_list = [list(map(int,input().split())) 
           for nesya in range(m)]
city_list = [0]*n
for hoge in ab_list:
  a = hoge[0]
  b = hoge[1]
  city_list[a-1] += 1
  city_list[b-1] += 1
for city in city_list:
  print(city)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
	
	int h1, m1, h2, m2, t1, t2, d, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	t1 = h1 * 60 + m1;
	t2 = h2 * 60 + m2;
	d = t2 - t1;
	cout << max(0, d - k) << "\n";
	return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    int n;
    cin>>n;
    int ar[3][n];
    for(int i=0;i<n;++i)
    cin>>ar[0][i]>>ar[1][i]>>ar[2][i];
    
    for(int i=1;i<n;++i)
    {
        ar[0][i]=ar[0][i]+max(ar[1][i-1],ar[2][i-1]);
        
        ar[1][i]=ar[1][i]+max(ar[0][i-1],ar[2][i-1]);
        
        ar[2][i]=ar[2][i]+max(ar[1][i-1],ar[0][i-1]);
        
    }
    cout<<max({ar[0][n-1],ar[1][n-1],ar[2][n-1]});
    
    
    
    
    
    
    
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // シミュレーション
        Scanner sc = new Scanner(System.in);

        List<Meal> meal = new ArrayList<>();
        int ans = 0;
        for (int i = 0; i < 5; i++) {
            int dish = sc.nextInt();
            if (dish % 10 == 0) {
                ans += dish;
            } else {
                meal.add(new Meal(dish));
            }
        }

        Collections.sort(meal);

        // 最後以外の要素は注文ルールに従って、端数を10の倍数に合わせて加算
        for (int i = 0; i < meal.size(); i++) {
            int duration = meal.get(i).time;
            if (i >= meal.size() - 1) {
                // 最後の注文だけそのままの値を追加
                ans += duration;
            } else {
                ans += duration;
                ans += 10 - (duration % 10); // キリの悪い待ち時間を足す
            }
        }

        System.out.println(ans);
    }

    static class Meal implements Comparable<Meal> {
        int time;

        public Meal(int t) {
            this.time = t;
        }

        @Override
        public int compareTo(Meal o) {
            return o.time % 10 - this.time % 10;
        }

        @Override
        public String toString() {
            return String.valueOf(this.time);
        }
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, k;
    cin >> n >> k;
    double p[n + 5], s[n + 5];
    s[0] = 0.0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        s[i + 1] = s[i] + (p[i] - 1) / 2 + 1;
    }

    double mx = 0;
    for (int i = 0; i <= n - k; i++) {
        mx = max(mx, s[i + k] - s[i]);
    }
    cout << setprecision(16) << mx << endl;

}


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

long long int dp[110][1<<16];

int main(int argc, char *argv[]){
  int n;
  while(cin >> n, n){
    int m, l[n], t[n];
    memset(t, 0, sizeof(t));
    for (int i = 0; i < n; i++) {
      cin >> m >> l[i];
      int s, e;
      for (int j = 0; j < m; j++) {
        cin >> s >> e;
        for (int k = s - 6; k < e - 6; k++)
          t[i] |= 1<<k;
      }
    }
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j < (1<<16); j++) {
        dp[i][j] = -1;
      }      
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < (1<<16); j++) {
        if(dp[i][j] < 0)continue;
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        if((t[i]&j) > 0)continue;
        dp[i + 1][j | t[i]] = max(dp[i + 1][j | t[i]],
                                  dp[i][j] + l[i]);
      }
    }
    long long int ans = 0;
    for (int i = 0; i < (1<<16); i++) {
      ans = max(ans, dp[n][i]);
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 54404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 1e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;

ll a[MAXN];
vector<int>vec[MAXN];
vector<int>zone[MAXN];
bool vis[MAXN];
int cnt = 0;
map<ll,int>mp;
set<ll>se;

void dfs(int u) {
    vis[u] = true;
    zone[cnt].push_back(a[u]);
    for(int i=0; i<vec[u].size(); i++) {
        int v = vec[u][i];
        if(!vis[v]) dfs(v);
    }
}

bool cmp(vector<int>x,vector<int>y) {
    return x.size() > y.size();
}

int main()
{
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    while(m--) {
        int u,v;
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    for(int i=0; i<n; i++) {
        if(vis[i]) continue;
        dfs(i);
        sort(zone[cnt].begin(),zone[cnt].end());
        cnt++;
    }
    if(cnt == 1) {
        puts("0");
        return 0;
    }
    sort(zone,zone+cnt,cmp);
    for(int i=0; i<=1; i++) {
        for(int j=1; j<zone[i].size(); j++) {
            ll num = zone[i][j];
            se.insert(num);
            mp[num]++;
        }
    }
    ll ans = zone[0][0] + zone[1][0];
    for(int i=2; i<cnt; i++) {
        if(se.size() == 0) {
            puts("Impossible");
            return 0;
        }
        auto x = *se.begin();
        ans += x + zone[i][0];
        mp[x]--;
        if(mp[x] == 0) se.erase(x);
        for(int j=1; j<zone[i].size(); j++) {
            ll num = zone[i][j];
            se.insert(num);
            mp[num]++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    deque<char> dq;

    for (int i=0; i<s.size(); i++) dq.push_back(s[i]);

    for (int i=0; i<q; i++) {
        int t;
        cin >> t;

        if (t == 1) {
            rev = !rev;
        }
        else {
            int f;
            char c;
            cin >> f >> c;

            if (f == 1) {
                if (!rev) dq.push_front(c);
                else dq.push_back(c);
            }
            else {
                if (!rev) dq.push_back(c);
                else dq.push_front(c);
            }
        }
    }
    
    if (!rev) {
        for (int i=0; i<dq.size(); i++) {
            cout << dq.at(i);
        }
        cout << endl;
    }
    else {
        for (int i=0; i<dq.size(); i++) {
            cout << dq.at(dq.size()-i-1);
        }
        cout << endl;
    }
    
    return 0;
}


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

int main() {
    int N, M;

    cin >> N;
    cin >> M;

    vector<int> A(N);
    
    // for(auto& a:A){
    //     a=1;
    // }

    // for(auto a:A){
    //     cout << a << " ";
    // }
    // cout << endl;


    int b, e;
    int maxb = 1;
    int mine = N; 
    for(int i=0; i<M; ++i) {
        cin >> b;
        cin >> e;

        if(b!=1 && b > maxb) {
            for(int j=0; j<b-1; ++j) {
                A[j] = 1;
            }
            maxb=b;
        }
        if(e!=N && e < mine) {
            for(int k=e; k<N; ++k) {
                A[k] = 1;
            }
            mine=e;
        }

        // for(auto a:A){
        //     cout << a << " ";
        // }
        // cout << endl;

    }
    int sum=0;
    for(auto a:A){
        sum = sum + a;
    }
    cout << N - sum << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll n,a,b;

    Scll3(n,a,b);

    if( a > b ){
        printf ("%d\n", 0);
        return 0;
    }

    if( n == 1 ){
        if( a == b ){
            printf ("%d\n", 1);
            return 0;
        }else{
            printf ("%d\n", 0);
            return 0;
        }
    }

    n -= 2;

    ll ans = n*b - n*a + 1;
    printf ("%llu\n", ans);

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int c = 4;
		int d = 7;
		int flag = 0;
		int cut = 0;
		for(int i=0;i<=25;i++){
			for(int j=0;j<=14;j++){
				cut = c*i + d*j;
				if(cut == 0)cut = 4;
				if(n%cut==0){flag=1;break;}
				if(cut>100){break;}
			}
			if(flag==1)break;
		}
		// 文字列の入力
		//String s = sc.next();
		// 出力
		if(flag==1)System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 21972
#define _USE_NATH_DEFINES
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;


// 各桁の和を計算する関数
int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) { // n が0になるまで
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int N,A,B;
	cin >> N >> A >> B;
	int total = 0;
	for (int i = 1; i <= N; ++i) {
		int sum = findSumOfDigits(i);
		if (sum >= A && sum <= B) {
			total += i;
		}
	}
	cout << total << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,k,s;
  cin>>n>>k>>s;
  rep(i,k) {
    cout << s << " ";
  }
  rep(i,n-k) {
    if(s==1e9)
      cout << s-1 << " ";
    else
      cout << s+1 << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

int n,a[10005];

int main() {
  cin >> n;
  rep(i,n)
  cin >> a[i];
  int ans=0;
  for(int i=1;i<n;i++){
     if(a[i]==a[i-1]){
      ans++; a[i]=-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
       var n = int.Parse(Console.ReadLine());
       var list = new List<int>();
       for(var i = 0;i < n;i++){
           list.Add(int.Parse(Console.ReadLine()));
       }
       var ans = list.Sum();
       if(list.Count(x => x % 10 == 0) == n){
           ans = 0;
       }else{
           if(ans % 10 == 0){
               ans -= list.Where(x => x % 10 != 0).Min();
           } 
       }
       Console.WriteLine(ans);
       
    }
}


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

ll GCD(ll a,ll b){
    if(a*b==0)return a+b;
    if(a>b){
        return GCD(b,a);
    }
    else{
    ll r=b%a;
    while(r!=0){
        b=a;
        a=r;
        r=b%a;
    }
    return a;
    }
}

int main(){
    ll n;cin>>n;
    ll a[100010];
    rep(i,0,n)cin>>a[i];
    ll l[100010],r[100010];
    l[0]=0,r[n-1]=0;
    rep(i,1,n){
        l[i]=GCD(l[i-1],a[i-1]);
    }
    for(int i=n-2;i>=0;i--){
        r[i]=GCD(r[i+1],a[i+1]);
    }
    ll MX=-1;
    rep(i,0,n){
        MX=max(MX,GCD(l[i],r[i]));
    }
    cout<<MX<<endl;
    
}







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

int main() {
    
    int N;
    cin >> N;
    
    vector<int> V(N), C(N);
    for (int i=0; i<N; i++) {
        cin >> V[i];
    }
    for (int i=0; i<N; i++) {
        cin >> C[i];
    }
    
    
    int ans = 0;
    for (int i=0; i<N; i++) {
        if (V[i] - C[i] >= 0)
            ans += V[i] - C[i];
    }
    
    cout << ans << endl;
    
    
}

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

int main(void){
    int N, ans = 0;
    long long total = 0, tmp = 0;
    std::cin >> N;
    std::vector<long long> A(N);
    for (int i = 0; i < N; ++i){
        std::cin >> A[i];
        total += A[i];
    }
    for (int i = 0; i < N; ++i){
        tmp += A[i];
        if (tmp >= total / 2){
            ans = std::min(2 * tmp - total, total - 2 * (tmp - A[i]));
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
void call(int n);
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		a[i] = tmp;
	}
	for(int i = n - 1; i > 0; i--){
		cout << a[i] << " ";
	}
	cout << a[0] << '\n';
}



Measured memory_bytes: 3080
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> cs(n);
    vector<int> ts(n);

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

    int min = 1001;
    for(int i = 0; i < n; i++) {
        if (ts[i] <= t && cs[i] < min) min = cs[i];
    }

    if (min == 1001) {
        cout << "TLE" << endl;
    } else {
        cout << min << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  int count = 0;
  for(int i = 1;i<n;++i){
    for(char c = 'a';c <= 'z';++c){
      bool left = false;
      bool right = false;
      for(int j = 0;j<i;++j){
        if(s[j] == c){
          left = true;
        }
      }
      for(int j = i;j<n;++j){
        if(s[j] == c){
          right = true;
        }
      }
      if(left && right){
        ++count;
      }
    }
    ans = max(ans,count);
    count = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

ll x,y;
cin >> x >> y;
fr(i,0,x+1)
{
	l = x-i;
	r = i;
	if(2*l + 4*r == y){
		cout << "Yes";
		return 0 ;
	}
}
cout << "No";

 eNd();
  return 0;
 
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const int MAX_N = 3000 + 2;
ll a[MAX_N];
ll dp[MAX_N][MAX_N];

ll rec(int start, int end) {
  if(dp[start][end] != -1) return dp[start][end];
  
  ll tmp1, tmp2;
  tmp1 = tmp2 = 0;
  if(start <= end - 1) tmp1 = -1 * rec(start, end - 1) + a[end];
  if(start + 1 <= end) tmp2 = -1 * rec(start + 1, end) + a[start];
  return dp[start][end] = max(tmp1, tmp2);
}

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

  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> a[i];

  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= N; i++) dp[i][i] = a[i];

  rec(1, N);
  cout << dp[1][N] << endl;
  
  return 0;
}


Measured memory_bytes: 73676
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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


int main() {

	string A, B, C;
	cin >> A >> B >> C;

	if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) { cout << "YES"; }
	else { cout << "NO"; }
	
	system("PAUSE");
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

bool ok = false;

void f(vector<char> a, int ind, char c)
{
	if (ok) return;
	if (ind >= len(a)) return;
	a[ind] = c;
	ll res = (a[0] - '0');
	for (int i = 0; i < a.size(); ++i)
	{
		if (a[i] == '-')
		{
			res -= (a[i + 1] - '0');
		}
		else if (a[i] == '+')
		{
			res += (a[i + 1] - '0');
		}
	}
	if (res == 7)
	{
		for (int i = 0; i < len(a); ++i)
		{
			cout << a[i];
		}
		cout << "=7";
		ok = true;
		return;
	}

	f(a, ind + 2, '+');
	f(a, ind + 2, '-');
	
}

void solve()
{	
	string s; cin >> s;
	int n = s.length();
	vector<char> a(2 * n - 1);
	int cnt = 0;
	for (int i = 0; i < 2 * n - 1; ++i)
	{
		if (i & 1) a[i] = '-';
		else 
		{
			a[i] = s[cnt];
			cnt++;
		}
	}
	debug() << imie(a);
	f(a, 1, '-');
	f(a, 1, '+');
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3540
n, p = map(int, input().split())

res = []
for i in range(2, int(pow(p, 0.5)) + 1):
    if p % i == 0:
        ex = 0
        while p % i == 0:
            ex += 1
            p //= i
        res.append([i, ex])
if p != 1:
    res.append([p, 1])

ans = 1
for p in res:
    k = p[1]
    while k:
        if k < n:
            k = 0
        else:
            ans *= p[0]
            k -= n
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (b >= c) {
        printf("delicious\n");
    }else if (c - b < a + 1) {
        printf("safe\n");
    }else{
        printf("dangerous\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
k,a,b=map(int,input().split())
if k==1:
    print(2)
    exit()
if b-a<=2:
    print(k+1)
    exit()
if k<=a:
    print(k+1)
    exit()
k-=a-1
ans=a
t=k//2
ans+=(b-a)*t
k-=t*2
ans+=k
print(ans)

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

struct UF {
    int n;
    vector<int> par;
    UF(int n) : n(n) {
        for(int i = 0; i < n; i++) par.push_back(i);
    }
    int find(int a){
        if(a != par[a]) par[a] = find(par[a]);
        return par[a];
    }
    void join(int a, int b){
        par[find(a)] = find(b);
    }
};

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<string> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	UF uf(2*n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i][j] == '1'){
				uf.join(i, j+n);
				uf.join(i+n, j);
			}
		}
	}
	vector<vector<int> > dist(n, vector<int>(n, 100000));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i][j] == '1') dist[i][j] = 1;
		}
	}
	for(int q = 0; q < 3; q++)
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
			}
		}
	}
	int maxd = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i != j) maxd = max(maxd, dist[i][j]);
		}
	}
	for(int i = 0; i < n; i++){
		if(uf.find(i) == uf.find(i+n)){
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << maxd + 1 << '\n';
	return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var w, a, b int
	fmt.Scan(&w, &a, &b)
	var g int
	if a <= b && b <= a+w {
		g = 0
	} else if a+w < b {
		g = b - (a+w)
	} else {
		g = a - (b+w)
	}
	fmt.Println(g)
}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
double rs[10];

int main() {
  while (scanf("%d", &n) > 0) {
    set<vector<int> > visit;
    REP(i, n) { scanf("%lf", &rs[i]); }
    sort(rs, rs + n);
    double ans = 0.0;
    do {
      for (int last = 3; last <= n; last++) {
        {
          vector<int> target;
          REP(i, last) { target.push_back(rs[i]); }
          if (visit.count(target)) { continue; }
          REP(iter, 2) {
            REP(i, last) {
              visit.insert(target);
              rotate(target.begin(), target.begin() + 1, target.end());
            }
            reverse(target.begin(), target.end());
          }
        }
        double left = 0.0;
        double right = PI;
        REP(iter, 100) {
          double mid = (left + right) / 2.0;
          double lans = rs[0] * rs[1] * sin(mid) / 2.0;
          double sum = mid;
          for (int i = 1; i < last; i++) {
            double v = rs[0] * rs[1] / rs[i] / rs[(i + 1) % last] * cos(mid);
            if (v > 1) { v = 1; }
            if (v < -1) { v = -1; }
            double theta = acos(v);
            sum += theta;
            lans += rs[i] * rs[(i + 1) % last] * sin(theta) / 2.0;
          }
          if (sum > 2 * PI) {
            right = mid;
          } else {
            left = mid;
          }
          if (fabs(sum - 2 * PI) < EPS) { ans = max(ans, lans); }
        }
      }
    } while (next_permutation(rs, rs + n));
    printf("%.8f\n", ans);
  }
}

Measured memory_bytes: 8084
#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#define PI 3.14159265358979323846264338327950L
#define ll long long
using namespace std;


int main()
{
    int n;
    cin >> n;
    vector<int> c(n);
    vector<int> dp(n, 1e9+5);
    dp[0] = 0;
    for(int x = 0; x<n; x++){
        cin >> c[x];
    }
    for(int i=0; i<n; i++){
        for(int j : {i+1, i+2}){
            if(j < n){
                dp[j] = min(dp[j] , dp[i] + abs(c[i] - c[j]));
            }
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

ll Amat[101][101];
ll Bmat[101][101];
ll Cmat[101][101];


int main() {
    int N, M, L;
    cin >> N >> M >> L;
    rep(i, N)rep(j, M)cin >> Amat[i][j];
    rep(i, M)rep(j, L)cin >> Bmat[i][j];

    int NMmin = min(N, M);
    int NMmax = max(N, M);

    rep(i, N)rep(j, L)rep(k, M)Cmat[i][j] += Amat[i][k] * Bmat[k][j];

    rep(i, N) {
        rep(j, L) {
            if(j!=L-1)cout << Cmat[i][j] << ' ';
            else cout << Cmat[i][j];
        }
        cout << endl;
    }

}



Measured memory_bytes: 3372
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

template<typename T>
struct Segment_Tree {
	typedef function<T(T, T)> F;

	ll n;
	F f;//モノイドとしての演算(最小値、和　など)
	T unit;//単位元

	ll size;
	vector<T> seg;

	Segment_Tree(ll n0, F f0, T unit0) {
		n = n0;
		f = f0;
		unit = unit0;

		size = 1;
		while (size < n) {
			size *= 2;
		}
		seg.assign(2 * size, unit);
	}


	void update(ll k, T x) {//k番目の要素をxに更新
		k += size - 1;
		seg[k] = x;
		while (k > 1) {
			k /= 2;
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}



	T query_prep(ll a, ll b, ll k, ll l, ll r) {//[a,b)とkに対応する区間[l,r)の共通部分でクエリ
		if (b <= l || a >= r) { return unit; }
		if (a <= l && r <= b) { return seg[k]; }

		T v1 = query_prep(a, b, 2 * k, l, (l + r) / 2);
		T v2 = query_prep(a, b, 2 * k + 1, (l + r) / 2, r);
		return f(v1, v2);

	}

	T query(ll a, ll b) {
		return query_prep(a, b, 1, 1, size + 1);
	}

};



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

	string ans = "Yes";

	if (S.size() % 2 == 1) { ans = "No"; }

	rep(i, S.size()) {
		if (i % 2 == 0 && S[i] != 'h') { ans = "No"; }
		if (i % 2 == 1 && S[i] != 'i') { ans = "No"; }
	}

	cout << ans;
	

	system("PAUSE");

}





Measured memory_bytes: 504
(N,M) = list(map(int,input().split()))
xlis = list(map(int,input().split()))
if N >= M:
    print("0")
else:
    xlis.sort()
    dist_lis = []
    for i in range(1,len(xlis)):
        dist_lis.append(xlis[i] - xlis[i-1])
    dist_lis.sort()

    for i in range(N-1):
        dist_lis.pop(-1)
    print(sum(dist_lis))

Measured memory_bytes: 13968
n=int(input())
s=input().rstrip()
r=s.count("R")
g=s.count("G")
b=s.count("B")
count=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if j+j-i<n:
            if s[i]!=s[j] and s[i]!=s[j+j-i] and s[j]!=s[j+j-i]:
                count+=1
print(r*g*b-count)

Measured memory_bytes: 67944
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int M, D;
    cin >> M >> D;

    int ans = 0;

    for (int m = 1; m <= M; ++m) {
        for (int d = 1; d <= D; ++d) {
            int d1 = d % 10;
            int d10 = d / 10;

            if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var p1=new Complex(s[0],s[1]);
		var p2=new Complex(s[2],s[3]);
		var p3=Complex.FromPolarCoordinates(1,(PI/180)*270)*(p1-p2)+p2;
		var p4=Complex.FromPolarCoordinates(1,(PI/180)*90)*(p2-p1)+p1;
		Console.WriteLine("{0:f0} {1:f0} {2:f0} {3:f0}",p3.Real,p3.Imaginary,p4.Real,p4.Imaginary);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 11220
### subroutines

def upper_bound(arr, key, i0 = 0, i1 = arr.length)
  lb = i0 - 1
  ub = i1

  while lb + 1 < ub
    m = (lb + ub) / 2
    if arr[m] > key
      ub = m
    else
      lb = m
    end
  end
  ub
end

### main

loop do
  n, s = gets.split.map(&:to_i)
  break if (n | s) == 0

  rs = n.times.map{gets.to_i}.sort

  count = 0

  for i in (0...(n - 1))
    rem = s - rs[i]
    if rem < rs[i + 1]
      count += n - 1 - i
    else
      j = upper_bound(rs, rem, i + 1, n)
      count += n - j
    end
  end

  puts count
end

Measured memory_bytes: 6400
#include <stdio.h>

int main(){
  
  int i,n;
  long max,min,sum=0;
  scanf("%d",&n);
  int a[n];

  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
  max = a[1];
  for(i=1;i<=n;i++){
    if(max<a[i]) max=a[i];
  }
  min = a[1];
  for(i=1;i<=n;i++){
    if(min>a[i]) min=a[i];
  }
  printf("%ld %ld %ld\n",min,max,sum);

  return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, T, A, I;
double M;

int main(void){
	//IO("test.in", "test.out");
	M = DBL_MAX;
	scanf("%d%d%d", &N, &T, &A);
	for(int i = 1; i <= N; i++){
		double e;
		scanf("%lf", &e);
		e = abs(A - (T - e * 0.006));
		if(e < M) M = e, I = i;
	}
	printf("%d\n", I);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int a,b;
 cin>>a>>b;
 if (a%2==0 or b%2==0){
 cout<<"Even";
 system("pause");
 return 0;}
 cout<<"Odd";
 system("pause");
 return 0;
}        

Measured memory_bytes: 504
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f3f3f3f3f;
int main()
{
    ll x,d,k;
    cin>>x>>k>>d;
    ll dis=abs(x);
    ll ans=x;
    if(dis>=d){
        ll res=dis/d;
        if(res>=k)ans=dis-d*k;
        else {
            k-=res;
            dis=dis-res*d;
            ll ans1,ans2;
            ans1=dis;//ans1=min(ans,dis);
            ans2=d-dis;//min(ans,d-dis);
            if(k&1)ans=ans2;
            else ans=ans1;
        }
    }
    else {
        if(k&1)ans=d-dis;// ans=min(ans,dis);
        else ans=dis;//ans=min(ans,d-dis);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3188
def SumOfDegit(x):
  sum = 0
  while x > 0:
    sum += x % 10
    x //= 10
  return sum

n = int(input())
degits_sum = []
for a in range(1,n):
  degits_sum.append(SumOfDegit(a) + SumOfDegit(n-a))
print(min(degits_sum))

Measured memory_bytes: 3864
A = input()

import string
p = {}
for x in string.ascii_lowercase: p[x] = len(A)
tb = [(0, 0, 0)] * len(A)
tb.append((1, 0, 0))
tb.append((0, 0, 0))

for i, x in reversed(list(enumerate(A))):
    p[x] = i
    tb[i] = min([(tb[p[c]+1][0] + 1, c, p[c]+1) for c in string.ascii_lowercase])

i = 0
ans = []
while i < len(A):
    ans.append(tb[i][1])
    i = tb[i][2]

print("".join(ans))


Measured memory_bytes: 52948
n,X = map(int,input().split())
x = list(map(int,input().split()))

dist = [0] * n
for i in range(n):
    dist[i] = abs(X-x[i])
def gcd(a,b):
    if a%b == 0:return b
    return gcd(b,a%b)
if n == 1:
    print(dist[0])
    exit(0)
    
g = gcd(dist[0],dist[1])
for i in range(n):
    if i == 0:continue
    g = gcd(g,dist[i])
    
print(g)

Measured memory_bytes: 14224
import sys

N, Y = map(int, input().split())

for m in range(N+1):
  g = (Y//1000 - N - 9*m) / 4
  s = N - m - g
  if g >= 0 and s >= 0 and g == int(g):
    print(m, int(g), int(s))
    sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX
#define MAX 10000
#define NIL -1

using namespace std;
using LL=long long;

struct Node { int parent,left,right;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
    if(u==NIL) return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}

int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].left!=NIL)
        h1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL)
        h2=setHeight(T[u].right)+1;
    return H[u]=(h1>h2?h1:h2);
}

int getSibling(int u){
    if(T[u].parent==NIL) return NIL;
    if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
        return T[T[u].parent].left;
    if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
        return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(T[u].left!=NIL) deg++;
    if(T[u].right!=NIL) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    if(T[u].parent==NIL){
        printf("root\n");
    }
    else if(T[u].left==NIL&&T[u].right==NIL){
        printf("leaf\n");
    }
    else{
        printf("internal node\n");
    }
}

int main(){
    int v,l,r,root=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) T[i].parent=NIL;
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].left=l;
        T[v].right=r;
        if(l!=NIL) T[l].parent=v;
        if(r!=NIL) T[r].parent=v;
    }
    for(int i=0;i<n;i++) if(T[i].parent==NIL) root=i;
    setDepth(root,0);
    setHeight(root);
    for(int i=0;i<n;i++) print(i);
    return 0;
}



Measured memory_bytes: 3220
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, n, x, a) for (int i = (x), a = 0; a < (n);  \
                              i = (i + 1) % (n), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


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

    cout << N * N * N;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
l=0
w=0
c=0
for i in range(n-1,0,-1):
    if a[i]==a[i-1] and l==0:
        l=a[i]
        a[i]=0
        a[i-1]=0
    elif a[i]==a[i-1] and w==0:
        w=a[i]
        print(l*w)
        break
if w==0:
    print(0)

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    if(c=='+'){
        cout << a+b << endl;
    }else{
        cout << a-b << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll cnt[33][MAX];

int main(void) {
  ll i, j, k, l;
  
  ll N;
  cin >> N;
  ll C;
  cin >> C;
  
  for(i=0; i<N; i++) {
    ll s, t, c;
    cin >> s >> t >> c;
    t++; c--;
    cnt[c][s]++;
    cnt[c][t]--;
  }
  
  for(i=0; i<C; i++) {
    for(j=1; j<MAX; j++) cnt[i][j]+=cnt[i][j-1];
    for(j=1; j<MAX; j++) if(cnt[i][j]>=2) cnt[i][j]=1;
  }
  
  ll ans=0;
  for(j=1; j<MAX; j++) {
    ll t=0;
    for(i=0; i<C; i++) t+=cnt[i][j];
    chmax(ans, t);
  }
  
  pt(ans);
  
}




Measured memory_bytes: 24832