akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s;
    cin >> s;

    int ans = 0;
    rep (i, s.size() / 2)
    {
        if (s[i] != s[s.size() - 1 - i])
        {
            ++ans;
        }
    }

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



Measured memory_bytes: 256
inf = float('inf')

n, w = map(int, input().split())
e = tuple(map(int, input().split()) for _ in range(n))
wt, vt = zip(*e)
sv = sum(vt)

dp = tuple([inf] * (sv + 1) for _ in range(n + 1))
dp[0][0] = 0

for i in range(n):
    dp[i + 1][:vt[i]] = dp[i][:vt[i]]
    for j in range(vt[i], sv + 1):
        dp[i + 1][j] = min(dp[i][j], dp[i][j - vt[i]] + wt[i])

res = -1
for j in range(sv, -1, -1):
    if dp[n][j] <= w:
        res = j
        break
print(res)


Measured memory_bytes: 307264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n);
  map<i64, i64> mp;
  for (i64 x : a) mp[x]++;
  if (mp.size() > 3) { cout << "No\n"; return 0; }
  if (mp.size() == 1) {
    if (mp[0] > 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
  }
  if (mp.size() == 3) {
    vector<i64> b;
    for (auto p : mp) {
      b.push_back(p.first);
    }
    if ((b[0] ^ b[1]) == b[2] 
        && mp[b[0]] == mp[b[1]] && mp[b[1]] == mp[b[2]])
      cout << "Yes\n";
    else
      cout << "No\n";
    return 0;
  }
  if (mp.size() == 2) {
    i64 i = 0, j = 0;
    for (auto p : mp) {
      i64 x, c;
      tie(x, c) = p;
      if (x == 0) i = c;
      else j = c;
    }
    if (2 * i == j) cout << "Yes\n";
    else cout << "No\n";
  }
  return 0;
}


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

using namespace std;

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

  vector<int> white(int(n + 1), 0);
  vector<int> black(int(n + 1), 0);

  int white_num = 0;
  int black_num = 0;


  for (int i = 0; i < n; i++) {
    white[i] = white_num;
    black[i] = black_num;

    if (s[i] == '.') {
      white_num += 1;
    } else {
      black_num += 1;
    }
  }

  white[n] = white_num;
  black[n] = black_num;

  int diff_min = 2 * 10e5 + 1;

  for (int i = 0; i < (n+1); i++) {
    int diff = 0;
    diff += black[i];
    diff += (white_num - white[i]);

    if (diff < diff_min) {
      diff_min = diff;
    }
  }

  cout << diff_min << endl;

  return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
ll N,Y;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> Y;
    
    rep(i,N+1) {
        rep(j,N+1-i) {
            ll k = N-i-j;
            ll sum = 10000*i+5000*j+1000*k;
            if (sum == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    
    cout << "-1" << " " << "-1" << " " << "-1" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>     
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {  
    ll n,k;                                                                                                                              
    cin >> n >> k;
    vector<pair<ll, ll> > p(n);
    REP(i,n) {    
        cin >> p[i].first;
        cin >> p[i].second;
    } 
    sort(p.begin(),p.end());
    ll count=0;   
    REP(i,n) {    
        if(k-count-p[i].second <= 0) {
            cout << p[i].first << endl;
            break;
        } else {  
            count += p[i].second;
        }
    } 
}  

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
  // 入力 N A B
  unsigned long n, a, b, ret, temp;
  scanf("%lu %lu %lu", &n, &a, &b);
  ret = 0;
  ret += n / (a + b) * a;
  if ((temp = n % (a + b)) > a) {
    ret += a;
  } else {
    ret += temp;
  }
  // 出力
  printf("%lu\n", ret);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	string n;
	cin>>n;

	if(n[0]=='7' || n[1]=='7' || n[2]=='7'){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
    return 0;
}


Measured memory_bytes: 3600
N=int(input())
A=list(map(int,input().split()))
B=[]
total=0
for i in range(N):
    B.append(A[i]-i-1)

B.sort()
#print(B)
if len(A)%2==1:
    for i in range(N):
        total+=abs(A[i]-(B[len(B)//2]+i+1))
        #print(B[len(B)//2+1],total)
else:
    for i in range(N):
        total+=abs(A[i]-(B[len(B)//2]+i+1))
print(total)


Measured memory_bytes: 99924
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[][] dp = new int[n][n];


		for(int j = n-1; j>=0; j--) {
			int i = n-1;
			if(s.charAt(i) == s.charAt(j)) dp[i][j] = 1;
			else dp[i][j] = 0;
		}

		for(int i=n-1; i>=0; i--) {
			int j = n-1;
			if(s.charAt(i) == s.charAt(j)) dp[i][j] = 1;
			else dp[i][j] = 0;
		}

		for(int i = n-2; i>=0; i--) {
			for(int j = n-2; j>=0; j--) {
				if(s.charAt(i) == s.charAt(j)) dp[i][j] = dp[i+1][j+1]+1;
				else dp[i][j] = 0;
			}
		}

		int len = 0;
		for(int i=0; i<n; i++) {
			for(int j = 0; j<n; j++) {
				if(i+dp[i][j] <= j) len = Math.max(len, dp[i][j]);
			}
		}
		System.out.println(len);
	}
}


Measured memory_bytes: 169116
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  int n=sz(s);
  int cnt = 0,win = 0,lose = 0;
  rep(i,n){
    if(s[i] == 'g'){
      if(cnt>0){
        win++;
        cnt--;
      }
      else cnt++;
    }else{
      if(cnt<=0){
        lose++;
        cnt++;
      }
      else cnt--;
    }
    //show(win);
  }
  cout<<win-lose<<endl;
  return 0;
}

Measured memory_bytes: 512
def main():
    n,a,b = map(int,input().split())
    if (b-a)%2 == 0:
        print((b-a)//2)
    else:
        if b-a > 1:
            ans = min(n-b,a-1)+1
            ans += (b-a-1)//2
        else:
            ans = min(n-a,b-1)

        print(ans)


main()


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

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

    printf("%lf\n", (double)hypot(x1-x2, y1-y2));

    return 0;
}



Measured memory_bytes: 2072
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    freq = [0] * (10**5)
    for a in A:
        freq[a] += 1
    ans = -1
    for i in range(len(freq)):
        if i == 0:
            l = 0
        else:
            l = freq[i-1]

        m = freq[i]

        if i == len(freq)-1:
            r = 0
        else:
            r = freq[i+1]
        ans = max(ans, l + m + r)
    print(ans)
main()



Measured memory_bytes: 78748
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val N,M,X,Y= sc.nextInt
  val f = (N:Int,X:Int)=>List.fill(N)(sc.nextInt):+X
  val ans = if(f(N,X).max < f(M,Y).min){"No War"}else{"War"}
  println(ans)
}



Measured memory_bytes: 27292
def main():
    S = input()

    ans = f(S)
    print(ans)


def f(S):
    stack = []
    ans = 0
    for c in S:
        if stack and stack[-1] != c:
            ans += 2
            stack.pop()
        else:
            stack.append(c)
    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
use std::cmp;

const EPS: f64 = 1e-9;

fn main () {
    let (n, k): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut x: Vec<f64> = vec![0.0; n];
    let mut y: Vec<f64> = vec![0.0; n];
    let mut c: Vec<f64> = vec![0.0; n];
    for i in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        x[i] = iter.next().unwrap().parse().unwrap();
        y[i] = iter.next().unwrap().parse().unwrap();
        c[i] = iter.next().unwrap().parse().unwrap();
    }

    let mut left: f64 = 0.0;
    let mut right: f64 = 200_000.0;
    while EPS < right - left {
        let t: f64 = (left + right) / 2.0;

        let count = |p: f64, q: f64| -> usize {
            let mut cnt: usize = 0;
            for i in 0..n {
                let r = t / c[i];
                if (p - x[i]).hypot(q - y[i]) <= r + EPS {
                    cnt += 1;
                }
            }
            cnt
        };

        let mut res: usize = 0;

        for i in 0..n {
            res = cmp::max(res, count(x[i], y[i]));
        }

        for i in 0..n {
            for j in (i + 1)..n {
                let r1 = t / c[i];
                let r2 = t / c[j];

                if (x[i] - x[j]).hypot(y[i] - y[j]) > r1 + r2 {
                    continue;
                }
                if (x[i] - x[j]).hypot(y[i] - y[j]) < (r1 - r2).abs() {
                    continue;
                }

                let a = 2.0 * (x[j] - x[i]);
                let b = 2.0 * (y[j] - y[i]);
                let c = {
                    x[i].powi(2) - x[j].powi(2) +
                    y[i].powi(2) - y[j].powi(2) +
                    r2.powi(2) - r1.powi(2)
                };    
                let d = (a * x[i] + b * y[i] + c).abs();
                let aa = a.powi(2);
                let bb = b.powi(2);
                let dd = d.powi(2);
                let rr1 = r1.powi(2);
    
                let p = (a * d - b * ((aa + bb) * rr1 - dd).sqrt()) / (aa + bb) + x[i];
                let q = (b * d + a * ((aa + bb) * rr1 - dd).sqrt()) / (aa + bb) + y[i];
                res = cmp::max(res, count(p, q));
    
                let p = (a * d + b * ((aa + bb) * rr1 - dd).sqrt()) / (aa + bb) + x[i];
                let q = (b * d - a * ((aa + bb) * rr1 - dd).sqrt()) / (aa + bb) + y[i];
                res = cmp::max(res, count(p, q));    
            }
        }

        if res < k {
            left = t;
        } else {
            right = t;
        }
    }
    println!("{:.10}", right);
}

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

bool is_prime[32769];
int prime[32769];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i < 32769; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j < 32769; j += i)is_prime[j] = false;
		}
	}
	int n;
	while (scanf("%d", &n), n) {
		int cnt = 0;
		for (int i = 0; prime[i] <= n / 2; i++) {
			if (is_prime[n - prime[i]])cnt++;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3152
h,w = map(int,input().split())
n = int(input())
ai = [int(i) for i in input().split()]

cij = [[0 for i in range(w)] for j in range(h)]

aij = []

for i in range(n):
    for j in range(ai[i]):
        aij.append(i+1)

for i in range(h):
    #print(i)
    if i % 2 == 0:
        for j in range(w):
            cij[i][j] = aij[i*w+j]
            #print(cij)
    else:
        for j in range(w):
            #print(cij[i][w-1-j],i*w+j)
            cij[i][w-1-j] = aij[i*w+j]

for i in range(h):
    print(*cij[i])



Measured memory_bytes: 42864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int x; cin >> x;
    cout << 10-(x/200) << endl;
}

Measured memory_bytes: 3584
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i, j;
	int H, W;
	int flag = 0;//#があればフラグ1
	char a[101][101];
	char h[101][101];
	char w[101][101];
	int h_flag[101] = {};
	int w_flag[101] = {};
	int sum_h = 0;
	int sum_w = 0;

	cin >> H >> W;
	for (i = 0; i < H; ++i) {
		for (j = 0; j < W; ++j) {
			cin >> a[i][j];
		}
	}

	for (i = 0; i < H; ++i) {//#があるか見る(Height)
		for (j = 0; j < W; ++j) {
			if (a[i][j] == '#') {
				flag = 1;
			}
		}
		if (flag == 1) {
			h_flag[i] = 1;
		}
		flag = 0;
	}

	for (i = 0; i < H; ++i) {//フラグたてて出力
		if (h_flag[i] == 1) {
			for (j = 0; j < W; ++j) {
				h[i][j] = a[i][j];

			}
			sum_h += h_flag[i];
		}

	}
	//cout <<"sum_h "<< sum_h << endl;//デバッグ

	for (j = 0; j < W; ++j) {//#があるか見る(Weight)
		for (i = 0; i <H; ++i) {
			if (h[i][j] == '#') {
				flag = 1;
			}

		}
		if (flag == 1) {
			w_flag[j] = 1;
		}
		flag = 0;
		sum_w += w_flag[j];
	}
	//cout << "sum_w " << sum_w << endl;//デバッグ

	for (j = 0; j < W; ++j) {//フラグたてて出力
		if (w_flag[j] == 1) {
			for (i = 0; i < H; ++i) {
				w[i][j] = h[i][j];
			}
		}
	}




	//cout << endl;//デバッグ

	for (i = 0; i < H; ++i) {

		for (j = 0; j < W; ++j) {
			if (h_flag[i] == 1 && w_flag[j] == 1) {
				cout << w[i][j];
			}

		}
		if (h_flag[i] == 1) {
			cout << endl;
		}

	}

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
#if false
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            int n = int.Parse(szLine);

            if( n <= 999)
            {
                Console.WriteLine("ABC");
            }
            else
            {
                Console.WriteLine("ABD");
            }
        }
#endif
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');

            int a = int.Parse(szArr[0]);
            int b = int.Parse(szArr[1]);

            int x = 0;
            int k = b - a - 1;// 級数の魔法計算よりk板目とk+1番目の比較だ

            x = k * (k + 1) / 2 - a;
            Console.WriteLine(x);
        }
    }
}


Measured memory_bytes: 11092
import sys 
sys.setrecursionlimit(4100000)

N = int(input())

def dfs(i,s):
    if len(s) == N:
        
        return print(s)
    
    for x in range(97,i + 1):
        t = s + chr(x)
        
        dfs(max(x + 1,i),t)
    
    
dfs(ord("a"),"")    

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;


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

	string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	vector<int> num;
	num.assign(26,0);

	char a,b,c,d;
	for(int i=0;i<4;i++){
		auto pos = abc.find(s[i]);
		num[pos] ++;
	}

	auto p2 = std::find(num.begin(),num.end(),2);
	auto p1 = std::find(num.begin(),num.end(),1);
	if(p2!=num.end() && p1==num.end()){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]

ans = 'Yes'

for line in lst:
    t, x, y = line
    c1 = t < x + y
    c2 = t % 2 == 0 and (x + y) % 2 != 0
    c3 = t % 2 != 0 and (x + y) % 2 == 0
    
    if c1 or c2 or c3:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 27380
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <numeric>

using namespace std;

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

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

	sort(h.begin(), h.end(), greater<int>());
	for (int i = 0; i < min(k, n); i++) {
		h[i] = 0;
	}

	long long ans = accumulate(h.begin(), h.end(), 0LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<string>
#include<iostream>
#include<algorithm>

void print(std::string str,int a,int b){
    std::cout<<str.substr(a,b-a+1)<<std::endl;
}

int main(void){
    std::string str,instruction;
    int a,b,q;
    std::cin>>str;
    std::cin>>q;
    while(q-->0){
        std::cin>>instruction>>a>>b;
        switch(instruction[2]){
            case 'i':
                print(str,a,b);
                break;
            case 'v':
                std::reverse(str.begin()+a,str.begin()+b+1);
                break;
            case 'p':
                std::string p;
                std::cin>>p;
                str.replace(a,b-a+1,p);
                break;
        }
    }
    

    return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
int n,num;
double ta,omo,bmi;
while(cin>>n){
	if(n==0){
		break;
	}
	double max=100000,sa;
	int best=1000000;
for(int k=0;k<n;k++){
	cin>>num>>ta>>omo;
	bmi=omo*10000/(ta*ta);
	if(bmi-22<0){
		sa=22-bmi;
	}
	else{
		sa=bmi-22;
	}
	if(sa<max||(sa==max&&num<best)){
		best=num;
		max=sa;
	}
}
cout<<best<<endl;
}
	return 0;
}

Measured memory_bytes: 1228
import sys
from collections import deque

N, K = map(int, sys.stdin.readline().strip().split())
tmp = list(map(int, sys.stdin.readline().strip().split()))

A = [a-1 for a in tmp]

visited = set()
loop = []

q = deque()
q.append(0)
start = float("inf")
end = float("inf")

count = 0
while q and count <= N:
    s_town = q.popleft()
    # ループを確認
    if s_town in visited:
        start = loop.index(s_town)
        end = len(loop)
        break
    visited.add(s_town)
    loop.append(s_town)
    n_town = A[s_town]
    q.append(n_town)
    count += 1

# print(start, end)
if start >= K:
    print(loop[K]+1)
else:
    res = K - start
    res %= (end - start)
    # print("res", res)
    print(loop[start + res]+1)

Measured memory_bytes: 147404
/*
 * ABC100_A.cpp
 *
 *  Created on: Jun 21, 2018
 *      Author: 13743
 */

#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if(a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int X;
  cin >> X;
  if (X<600) cout << 8 << endl;
  else if (X<800) cout << 7 << endl;
  else if (X<1000) cout << 6 << endl;
  else if (X<1200) cout << 5 << endl;
  else if (X<1400) cout << 4 << endl;
  else if (X<1600) cout << 3 << endl;
  else if (X<1800) cout << 2 << endl;
  else cout << 1 << endl;
  return 0;
}

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

int		main(void)
{
	int		x, a, b, tmp;
	cin >> x >> a >> b;
	x -= a;
	for (int i = 0; 0 <= x; i++)
	{
		tmp = x;
		x -= b;
	}
	cout << tmp << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n, x, c = 0;
	while (scanf("%d %d", &n, &x) && (n != 0 || x != 0)) {
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) c++;
				}
			}
		}
		printf("%d\n", c);
		c = 0;
	}
	return 0;
}




Measured memory_bytes: 2740
int main()
{
  long n;
  scanf("%ld", &n);
  long a[n];
  long i;
  long sum = 0;
  for (i = 0; i < n; i++)
  {
    scanf("%ld", &a[i]);
    if (i >= 1)
    {
      if (a[i] < a[i - 1])
      {
        sum += a[i - 1] - a[i];
        a[i] = a[i - 1];
      }
    }
  }
  printf("%ld", sum);
}

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

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

    vector<int> t(k);
    for(int i = 0; i < k; i++)  cin >> t[i];
    sort(t.begin(), t.end());

    for(int i = 0; i < 1<<k; i++){
        int d = 0;
        vector<int> res;
        for(int j = 0; j < k; j++){
            if(i & 1<<j){
                d |= 1<<t[j];
                res.push_back(t[j]);
            }
        }
        cout << d << ":";
        for(int j : res)    cout << " " << j;
        cout << endl;
    }

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)1e5) + 5;
const long long int M = ((long long int)1e3) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

int n,m;
int dp[N];
vector<int> v[N];
int ans;

int f (int x)
{
	if (dp[x] != -1)
		return dp[x];
	int t1 = 0;
	if (v[x].size() == 0)
		return 0;
	for (auto i : v[x])
		t1 = max(t1,f(i));
	return dp[x] = t1 + 1;
}

int main ()
{
	fast;
	//freop;
	cin >> n >> m;
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= m; i++)
	{
		int a,b;
		cin >> a >> b;
		v[a].pb(b);
	}
	int a = 0;
	for (int i = 1; i <= n; i++)
		a = max(a,f(i));
	cout << a << "\n";
}


Measured memory_bytes: 8192
input_lines = str(input())
input_lines2 = str(input())

oCount = len(input_lines)
eCount = len(input_lines2)

o = list(input_lines)
e = list(input_lines2)

answer = ""

if oCount - eCount == 1:
    for i in range(oCount-1):
        answer = answer + o[i] + e[i]
    answer = answer + o[oCount-1]
else:
    for i in range(oCount):
        answer = answer + o[i] + e[i]

print(answer)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int A = 0;
		int B = 0;
		long num = 0;

		for (int i = -120; i < 120; i++) {
			for (int j = -120; j < 120; j++) {
				num = i*i*i*i*i - j*j*j*j*j;

				if (num == X) {
					A = i;
					B = j;
					break;
				}
			}
			if (num == X) break;
		}

		System.out.println(A + " " + B);
	}

}

Measured memory_bytes: 38708
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define int long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 998244353;

template<class T> class segtree {
	int n;
	vector<T> data;
	T id;
	function<T(T, T)> operation;
	function<T(T, T)> update;
public:
	segtree(size_t _n, T _id, function<T(T, T)> _operation, function<T(T, T)> _update)
		:id(_id), operation(_operation), update(_update) {
		n = 1;
		while (n < _n + 2) {
			n *= 2;
		}
		data = vector<T>(2 * n, id);
	}
	void change(int i, T x) {
		i += n;
		data[i] = update(data[i], x);
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};

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

	int n;
	cin >> n;
	vector<int> x(n), d(n), y(n);
	vector<P> p(n);
	rep(i, n) {
		cin >> x[i] >> d[i];
		y[i] = x[i] + d[i];
		p[i].first = x[i];
		p[i].second = y[i];
	}
	sort(all(p));
	rep(i, n) {
		x[i] = p[i].first;
		y[i] = p[i].second;
	}
	p.pb(P(INF, INF));
	vector<int> use(n);
	for (int i = 0; i < n; i++) {
		int g = lower_bound(all(x), y[i]) - x.begin();
		use[i] = g - 1;
	}
	segtree<int> seg(n + 2, 0, [](int a, int b) {return max(a, b); }, [](int a, int b) {return b; });
	rep(i, n) seg.change(i, use[i]);
	for (int i = n - 1; i >= 0; i--) {
		int maxv = seg.get(i, seg[i] + 1);
		seg.change(i, maxv);
	}
	vector<int> dp(n + 1);
	dp[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		dp[i] = dp[i + 1] + dp[seg[i] + 1];
		if (dp[i] > mod) dp[i] -= mod;
	}
	cout << dp[0] << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int n = 100 * a + 10 * b + c;
  if (n % 4 == 0)cout << "YES" << endl;
  else cout << "NO" <<  endl;
}

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

void solve() 
{
    bool flag=0;
    string s;cin>>s;
    int q;cin>>q;
    REP(i,q){
        int t;cin>>t;
        if(t==1){
            flag=!flag;
        }else if(t==2){
            int f;char c;cin>>f>>c;f--;
            bool ff=f;
            if(flag)ff=!ff;
            if(!ff){
                s.insert(s.begin(),c);
            }else{
                s.push_back(c);
            }

        }
    }
    if(flag){
        for(int i=s.size()-1;i>=0;i--)cout<<s[i];cout<<endl;
    }else{
        cout<<s<<endl;
    }
}

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

Measured memory_bytes: 912
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<ll>> dp(n+1,vector<ll>(13,0));

    dp[0][0] = 1;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 13; j++){
            if(s[i] == '?'){
                for(int k = 0; k < 10; k++){
                    dp[i+1][(j*10+k)%13] += dp[i][j];
                    dp[i+1][(j*10+k)%13] %= mod;
                }
            }
            else {
                dp[i+1][(j*10+s[i]-'0')%13] = dp[i][j];
                dp[i+1][(j*10+s[i]-'0')%13] %= mod;
            }
        }
    }
    cout << dp[n][5] << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll h,w; cin>>h>>w;
  if(h%3==0||w%3==0)res2=0;
  else res2=min(h,w);
  for(i=1;i<=w-1;i++){
    buf=max({h*i,(w-i)*(h/2),(w-i)*(h-h/2)});
    buf-=min({h*i,(w-i)*(h/2),(w-i)*(h-h/2)});
    chmin(res2,buf);
  }
  swap(h,w);
  for(i=1;i<=w-1;i++){
    buf=max({h*i,(w-i)*(h/2),(w-i)*(h-h/2)});
    buf-=min({h*i,(w-i)*(h/2),(w-i)*(h-h/2)});
    chmin(res2,buf);
  }

  cout<<res2<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

vector<int> getDegs(int h,int m,int s){
  vector<int> res({h,m,s});
  res[1] = (res[1] - res[0] + 60)%60;
  res[2] = (res[2] - res[0] + 60)%60;
  res[0] = 0;
  return res;
}


int toSec(int h,int m,int s){return s + 60*m + 60*60*(h/5);}
int toSec(vector<int> a){return toSec(a[0],a[1],a[2]);}
bool can(int hh,int mm,int ss){
  return hh%5 == mm/12;
}

vector<vector<int> > calcSameTimes(vector<int> a){
  vector<vector<int> > res; 
  for(int h=0;h<60;h++)
    for(int m=0;m<60;m++)
      for(int s=0;s<60;s++){
        if(!can(h,m,s))continue;
        if(a == getDegs(h,m,s)) res.push_back(vector<int>({h,m,s}));
      }
  return res;
}

vector<vector<int> > calcSameTimes(int h,int m,int s){
  vector<int> a = {h,m,s}; sort(a.begin(),a.end());
  vector<vector<int> > res; 
  do{
    vector<vector<int> > tmp = calcSameTimes(getDegs(a[0],a[1],a[2]));
    for(vector<int> t:tmp) res.push_back(t);
  } while(next_permutation(a.begin(),a.end()));
  sort(res.begin(),res.end());
  res.erase(unique(res.begin(),res.end()),res.end());
  return res;
}

int n;
vector<vector<vector<int> > > times;
vector<int> calcTime(int h,int m,int s){
  vector<int> res;
  int mx = -1;
  for(int i=0;i<n;i++){
    vector<int> tmp;
    int mn = INF;
    for(vector<int> t:times[i]){
      int a = toSec(h,m,s);
      int b = toSec(t[0],t[1],t[2]);
      if(b < a || mn <= b - a) continue;
      mn = b - a;
      tmp = t;
      break;
    }
    if(mn == INF) return vector<int>();
    if(mx < mn) mx = mn, res = tmp;
  }
  return res;
}

signed main(){
  while(1){
    cin>>n;
    if(!n) break;
    times.clear();
    times.resize(n);
    for(int i=0;i<n;i++){
      int h,m,s;
      cin>>h>>m>>s;
      times[i] = calcSameTimes(h,m,s);
    }

    /*  for(int i=0;i<n;i++){
        cout<<"begin"<<i<<" size="<<times[i].size()<<endl;
        for(int j=0;j<times[i].size();j++)
        cout<<times[i][j][0]<<" "<<times[i][j][1]<<" "<<times[i][j][2]<<endl;
        }
    */
    vector<int> from,to;
    int mn = INF;
    for(int h=0;h<60;h++)
      for(int m=0;m<60;m++)
        for(int s=0;s<60;s++){
          if(!can(h,m,s))continue;
          vector<int> a = {h,m,s};
          vector<int> b = calcTime(h,m,s);
          if(b.empty()) continue;
          int as = toSec(h,m,s);
          int bs = toSec(b[0],b[1],b[2]);
          assert(bs >= as);
          if(mn > bs - as) mn = bs - as, from = a, to = b;
        }
  
    printf("%02lld:%02lld:%02lld ",from[0]/5,from[1],from[2]);
    printf("%02lld:%02lld:%02lld\n",to[0]/5,to[1],to[2]);
  }
  return 0;
}

Measured memory_bytes: 3292
# -*- coding: utf-8 -*-
w = list(str(input()))
n = len(w)
alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

if n % 2 != 0:
    print("No")
else:
    ans = "Yes"
    for i in alph:
        if w.count(i) % 2 != 0:
            ans = "No"
    print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<set>

using namespace std;

int main() {

	int n;
	cin >> n;
	set<int> dis;
	int a;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		dis.insert(a);
	}

	cout << abs(*dis.begin() - *dis.rbegin()) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using LL = long long int;
int main(){
    LL n;
    vector<LL> a;
    map<LL,LL> b;
    cin >> n;
    for(LL i = 0;i < n;i++){
        LL buf;
        cin >> buf;
        a.push_back(buf);
        b[buf]++;
    }
    LL counter = 0;
    for(LL i = 1;i <= n;i++){
        counter += (b[i] * (b[i] - 1))/2;

    }
    for(LL k = 0;k < n;k++){
        cout << counter  + 1 - b[a[k]] << endl;
    }
    return 0;
}


Measured memory_bytes: 17284
#include<cstdio>
using namespace std;

int boll[15];
int dig[2];

bool dfs(int d)
{
    if(d==10) return true;
    int tmp;
    for(int i=0; i<2; ++i)
    {
        if(boll[d]>dig[i])
        {
            tmp = dig[i];
            dig[i] = boll[d];
            if(dfs(d+1)) return true;
            dig[i] = tmp;
        }
    }
    return false;
}

void solve()
{
    dig[0] = dig[1] = -1;
    bool ans = dfs(0);
    printf("%s\n", ans?"YES":"NO");
}

int main()
{
    int n;
    scanf("%d\n", &n);
    while(n--)
    {
        for(int i=0; i<10; ++i) scanf("%d", &boll[i]);
        solve();
    }
    return 0;
}

Measured memory_bytes: 2544
# 写経
# https://atcoder.jp/contests/dp/submissions/6401166
# 私が再帰関数でTLEした計算方法だが、
# 3重ループを使うと、間に合うらしい

def main():
    from collections import Counter

    def tami(i, j, k):
        if i is 0 and j is 0 and k is 0:
            return

        res = N
        if i > 0:
            res += dp[i - 1][j][k] * i
        if j > 0:
            res += dp[i + 1][j - 1][k] * j
        if k > 0:
            res += dp[i][j + 1][k - 1] * k
        res *= divTable[i + j + k]

        dp[i][j][k] = res
        return

    N = int(input())
    a = list(map(int, input().split()))

    c = Counter(a)
    one = c[1]
    two = c[2]
    three = c[3]

    dp = tuple(tuple([0.0] * (N + 1) for _ in range(N + 1)) for _ in range(N + 1))

    divTable = [1]
    for i in range(1, N * 3 + 1):
        divTable.append(1.0 / i)

    for k in range(N + 1):
        for j in range(N - k + 1):
            for i in range(N - k - j + 1):
                tami(i, j, k)

    print(dp[one][two][three])


if __name__ == '__main__':
    main()


Measured memory_bytes: 254856
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node {
int value;
struct node* next;
struct node* prev;
} node_t;

int n, num = 0;
node_t* head = NULL;
node_t* last = NULL;

node_t* current = NULL;

node_t* searchList(int);
node_t* createNode(int);
void insertToList(node_t*);
void deleteNode(node_t*);
void printList();

int main() {
	scanf("%d", &n);

	char tempCmd[15];
	int tempValue;
	for (int i = 0; i < n; i++) {
		scanf("%s", tempCmd);
		if (strcmp(tempCmd, "insert") == 0) {
			scanf("%d", &tempValue);
			node_t* insert = createNode(tempValue);
			insertToList(insert);
			num++;
			if (num == 1) last = insert;
		}
		else {
			node_t* delNode = NULL;
			if (strcmp(tempCmd, "delete") == 0) {
				scanf("%d", &tempValue);
				delNode = searchList(tempValue);
			}
			else if (strcmp(tempCmd, "deleteFirst") == 0) {
				delNode = head;
			}
			else {
				delNode = last;
			}

			if (delNode == last && delNode != head) last = last->prev;
			if(delNode == head) head = head->next;
			if(delNode != NULL) deleteNode(delNode);
			num--;
		}
	}
	printList();
	return 0;
}

node_t* searchList(int key) {
	current = head;
	while (current != NULL && current->value != key) {
		current = current->next;
	}
	return current;
}

node_t* createNode(int key) {
	node_t* newNode = (node_t*)malloc(sizeof(node_t));
	newNode->value = key;
	newNode->next = newNode->prev = NULL;
	return newNode;
}

void insertToList(node_t * newNode) {
	newNode->next = head;
	if (head != NULL) head->prev = newNode;
	head = newNode;
	newNode->prev = NULL;
}

void deleteNode(node_t * node) {
	if (node->prev != NULL) node->prev->next = node->next;
	if (node->next != NULL) node->next->prev = node->prev;
}

void printList() {
	node_t* current = head;
	if (current == NULL) return;
	printf("%d", current->value);
	current = current->next;
	while (current != NULL) {
		printf(" %d", current->value);
		current = current->next;
	}
	printf("\n");
}


Measured memory_bytes: 36120
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>
#include <cstdio>

using namespace std;

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

int N;
int A[200000];

int main() {
    scanf("%d", &N);
    rep(i, N) scanf("%d", &A[i]);
    int max0 = 0, max1 = 0;
    int max0cnt = 0;
    rep(i, N) {
        if (A[i] > max0) {
            max1 = max0;
            max0 = A[i];
            max0cnt = 1;
        } else if (A[i] == max0) {
            max0cnt ++;
        } else if (A[i] > max1) {
            max1 = A[i];
        }
    }
    rep(i, N) {
        if (A[i] == max0) {
            cout << (max0cnt > 1 ? max0 : max1) << endl;
        } else {
            cout << max0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
from collections import defaultdict

N = int(input())
A = [0] + [int(i) for i in input().split()]

cnt = defaultdict(int)
cnt[0] += 1

ret = 0
for i in range(1, N + 1) :
    A[i] += A[i-1]
    ret += cnt[A[i]]
    cnt[A[i]] += 1
    
print(ret)

Measured memory_bytes: 112976
a, b = map(int, input().split())
if 0 <= a <= 10 ** 9 and 0 <= b <= 10 ** 9 and a != b:
    if 0 == (abs(a - b)) % 2:
        if a < b:
            k = (b - a) / 2 + a
            print(int(k))
        else:
            k = (a - b) / 2 + b
            print(int(k))
    else:
        print('IMPOSSIBLE')
else:
    print('Invalid value')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> B(N-1);
  rep(i, N-1)
    cin >> B[i];
  ll ans = 0;
  rep(i, N) {
    if(i == 0)
      ans += B[i];
    else if(i == N-1)
      ans += B[i-1];
    else
      ans += min(B[i], B[i-1]);
  }
  cout << ans << endl;
  return 0;
}



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

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

    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double res = h*w/2;
    int resflg;

    if(x*2 == w && y*2 == h) resflg = 1;
    else resflg = 0;

    printf("%.10f%s%d\n", res, " ", resflg);

}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int n = readln.chomp.to!int;
  char[][] field = new char[][](4, n + 2);
  foreach (ref line; field)
  {
    line[] = '*';
  }
  int[char] cnt;
  foreach (i, c; readln.chomp)
  {
    field[1][i + 1] = c;
    cnt[c]++;
  }
  foreach (i, c; readln.chomp)
  {
    field[2][i + 1] = c;
    cnt[c]++;
  }

  bool[char] done;
  long sum = 1;
  enum MOD = 1_000_000_007L;
  bool x;
  int ofs;
  if (field[1][1] == field[2][1]) {
    sum *= 3;
    x = true;
    ofs = 2;
  } else {
    sum *= 6;
    x = false;
    ofs = 3;
  }
  for (int c = ofs; c <= n;)
  {
    long t;
    bool nx = field[1][c] == field[2][c];
    final switch (x << 1 | nx) {
      case 0:
        sum *= 3;
        break;
      case 1:
        sum *= 1;
        break;
      case 2:
        sum *= 2;
        break;
      case 3:
        sum *= 2;
        break;
    }
    if (nx) {
      ++c;
    } else {
      c += 2;
    }
    x = nx;
    sum %= MOD;
  }
  sum.writeln;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define pb  push_back
#define mp make_pair
#define ll long long
#define pr pair<int, int> 
#define vpr vector<pr> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define all(n) n.begin(),n.end()
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define Test printf("Case %d: ",tc++);
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
const int mod = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	ll n,m;
	cin>>n>>m;
	ll sum =0;
	for(ll i=0;i<m;i++){
		int x;
		cin>>x;
		sum+=x;
	}
	cout<<max(n-sum,-1LL)<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

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

using namespace std;

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

  string s;
  cin >> s;

  const size_t n = s.size();
  for (int i = n - 2; i > 0; --i) {
    const auto len = i + 1;
    if (len % 2 == 1)
      continue;
    const auto mid = len / 2;
    bool found = true;
    for (int j = 0; j < mid; ++j) {
      if (s[j] != s[mid + j]) {
        found = false;
        break;
      }
    }
    if (found) {
      cout << len << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
  int n,i=0;
  string s;
  cin >> n >> s;
  for (i=0;i<s.size();i++) s[i]=(s[i]-'A'+n)%26+'A';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s, t;
    cin >> s >> t;
    sort(ALL(s));
    sort(RALL(t));

    ATYN(s < t)

    return 0;
}

Measured memory_bytes: 256