akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

long long bino(long long k){
    if(k == 0) return 0;
    return (k-1)*k/2;
}

int main(){
    int n; cin >> n;
    vector<int> num(n);
    vector<int> data(n);
    rep(i, n){
        cin >> data.at(i);
        num.at(data.at(i) - 1)++;
    }
    long long sum = 0;
    rep(i, n){
        sum += bino(num.at(i));
    }
    rep(i, n){
        long long tmp = sum;
        tmp = tmp - bino(num.at(data.at(i) - 1)) + bino(num.at(data.at(i) - 1) - 1);
        cout << tmp << endl;
    }
}

Measured memory_bytes: 4096
from math import floor
N = int(input())

cnt = N #1円ずつ下ろせばN回で済むため
for i in range(N+1):
    tmp_cnt = 0
    s = 1
    while i >= s:
        tmp_cnt += (i // s) % 6
        s *= 6
    j = N-i
    k = 1
    while j >= k:
        tmp_cnt += (j // k) % 9
        k *= 9
    
    if tmp_cnt < cnt:
#         print(tmp_cnt,i,j)
        cnt = tmp_cnt
        
print(cnt)

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

public class Main {	
	private static void solve(){
		//Implement solution here.
		long a = nl();
		long b = nl();
		long c = nl();
		if((c - a - b) * (c - a - b) > 4 * a * b && c - a - b > 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    int n;
    cin>>n;
    vector<ll> a(n+1);
  
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;
    return 0;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m,i,x,y,ans=1;
  cin >> n >> m;
  vector<int> box(n+5,1);
  vector<bool> can(n+5,false);
  can.at(1)=true;
  for (i=0;i<m;i++){
    cin >> x >> y;
    box.at(x)--;
    box.at(y)++;
    if (can.at(x)){
      if (!can.at(y)){
        can.at(y)=true;
        ans++;
      }
      if (box.at(x)==0){
        can.at(x)=false;
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
// ABC.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)

int main()
{
	int k,l = 0;
	cin >> k;
	string s;
	
		cin >> s;
	
	if (s.size() <= k) {
		l += 1;
	}
	else  {
		s.erase(s.begin()+k, s.begin()+s.size());
		s = s + "...";
	}
	cout << s << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		PrimeNumberGenerator pg = new PrimeNumberGenerator();
		int a[] = new int[n];

		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		int mod = 1_000_000_007;
//		int currentGCD = a[0];
//		int currentLCM = a[0];
//		for(int i = 1; i < n; i++){
////			currentGCD = gcd(a[i], currentGCD);
//			currentLCM = (int)lcmMod(currentLCM, a[i], mod);
//
//			System.out.println("gcd "+currentGCD+" lcm "+currentLCM);
//		}
		int factor[] = new int[1000000];
		for(int i = 0; i < n; i++){
			int num = a[i];

			int div = 2;
			while(num > 1){
				if(pg.isPrime(num)){
					factor[num] = Math.max(factor[num], 1);
					break;
				}

				int count = 0;
				while(num % div == 0){
					num /= div;
					count++;
				}

				factor[div] = Math.max(factor[div], count);
//				System.out.println(div +" appear "+count);
				div++;
			}
		}

		long commonVal = 1;

		for(int i = 2; i < factor.length; i++){
			commonVal *= repeatablePow(i, factor[i], mod);
			commonVal %= mod;
		}

//		System.out.println(commonVal);
		long result = 0;

		for(int i = 0; i < n; i++){
			result += commonVal*repeatablePow(a[i], mod - 2, mod)%mod;
			result %= mod;
//			System.out.println(result);
		}

		System.out.println(result);

	}

	static long repeatablePow(int x, int n, int mod){
		if(n == 0){
			return 1;
		}
		long result = repeatablePow((int)((long)x*x%mod), n/2, mod);
		if(n % 2 == 1){
			result = result*x%mod;
		}
		return result;
	}

	static long lcmMod(int a, int b, int gcd, int mod){
    	return (long)a*((long)b*repeatablePow(gcd, mod - 2, mod)%mod)%mod;
    }

    static long lcmMod(int a, int b, int mod){
    	int g = gcd(a, b);

    	return lcmMod(a,b,g,mod);
    }

	static int gcd(int a, int b){
        int tmp;

        while (a % b != 0)
        {
            tmp = b;
            b = a % b;
            a = tmp;
        }
        return b;
    }
}

class PrimeNumberGenerator {
    private boolean[] isPrime= new boolean[1000001];

    public PrimeNumberGenerator() {
        Arrays.fill(isPrime, true);

        isPrime[0] = false;
        isPrime[1] = false;
        isPrime[2] = true;

        int limit = (int)Math.sqrt(isPrime.length);
        for(int i = 3; i <= limit; i+=2){
            if(isPrime[i] == false){
                continue;
            }

            for(int j = i * 2; j <= isPrime.length - 1; j += i){
                isPrime[j] = false;
            }
        }
    }

    public boolean isPrime(int index){
        if(index % 2 == 0 && index != 2){
            return false;
        }
        return isPrime[index];
    }
}


Measured memory_bytes: 44704
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//
ll dp[2][20000];

int main() {
  ll x, y;
  string s;
  cin >> s >> x >> y;
  ll c = 0;
  std::vector<int> v;
  REP(i, s.size()) {
    if (s[i] == 'T') {
      v.pb(c);
      c = 0;
    } else {
      c++;
    }
  }
  v.pb(c);
  dp[0][8003] = 1; // y
  ll m = 1;
  FOR(i, 0, v.size()) {
    if (i % 2 == 0) {
      continue;
    }
    ll mod = i % 4 == 1 ? 0 : 1;
    REP(j, 17000) {
      if (!dp[mod][j])
        continue;
      dp[1 - mod][j + v[i]] = 1;
      dp[1 - mod][j - v[i]] = 1;
    }
    //  cout << "hoge" << endl;
    memset(dp[mod], 0, sizeof(dp[mod]));
    m = mod;
  }
  if (!(dp[1 ^ m][y + 8003])) {
    // cout << "a" << endl;
    cout << "No" << endl;
    return 0;
  }
  m = 0;
  fill_all(dp, (ll)0);
  dp[1][8003] = 1; // y
  FOR(i, 0, v.size()) {
    if (i == 0) {
      continue;
    }
    if (i % 2 == 1) {
      continue;
    }
    ll mod = i % 4 == 0 ? 0 : 1;

    REP(j, 17000) {
      if (!dp[mod][j])
        continue;
      dp[1 ^ mod][j + v[i]] = 1;
      dp[1 ^ mod][j - v[i]] = 1;
    }
    memset(dp[mod], 0, sizeof(dp[mod]));
    m = mod;
  }
  if (!(dp[1 ^ m][x - v[0] + 8003])) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int ans;
	string s;
	cin >> s;
	s.resize(15,'o');
	for (int i = 0; i < 15; ++i){
		if (s[i]=='o') ans++;
	}


	if (ans>=8) cout << "YES" <<endl;
	else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)


int main()
{	
	string s;
	string a = "CODEFESTIVAL2016";
	int cnt = 0;
	
	cin>>s;
	int i=0;
	while(s[i] != '\0'){
		if(a[i]!= s[i])
			cnt++;
		i++;
	}
	cout<<cnt<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <cfloat>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

using P = pair<double, int>;

int main() {
	for (int n; (n = in());) {
		P m {DBL_MAX, 0};
		while (n--) {
			int p {in()}, h {in()};
			m = min(m, {abs(22 - in() * 10000. / h / h), p});
		}
		outl(m.second);
	}
}


Measured memory_bytes: 2632
N, M = [int(i) for i in input().split()]
a = [int(input()) for _ in range(M)]
divisor = 10**9 + 7

fl = [True] * N

for i in range(M):
    fl[a[i]] = False

dp = [0] * (N+1)
dp[0] = 1

for i in range(1, N+1):
    if i > 0 and fl[i-1]:
        dp[i] += dp[i-1] % divisor
    if i > 1 and fl[i-2]:
        dp[i] += dp[i-2] % divisor
    
print(dp[N]%divisor)

Measured memory_bytes: 9608
n = gets.to_i / 2
v = gets.split.map(&:to_i)

h1 = Hash.new(0)
n.times{|i| h1[v[2 * i]] += 1}
h1 = h1.sort{|a,b| -a[1] <=> -b[1]} + [[-1, 0]]

h2 = Hash.new(0)
n.times{|i| h2[v[2 * i + 1]] += 1}
h2 = h2.sort{|a,b| -a[1] <=> -b[1]} + [[-1, 0]]

if h1[0][0] == h2[0][0]
    puts 2 * n - [h1[0][1] + h2[1][1], h1[1][1] + h2[0][1]].max
else
    puts 2 * n - h1[0][1] - h2[0][1]
end

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


int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end());

  cout << abs(a[0] - a[n-1]) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

vector<string> stage;
ll H, W;

ll foo[25][25];

void solve() {
  cin >> H >> W;
  rep (h, H) {
    string s;
    cin >> s;
    stage.push_back(s);
  }

  ll bar_c = 0;

  rep (h, H) rep (w, W) {
    if (stage[h][w] == '#') continue;
    rep (i, 25) rep (j, 25) foo[i][j] = -1;
    queue<pair<pair<ll, ll>, ll>> q;
    q.push(make_pair(make_pair(h, w), 0));
    foo[h][w] = 0;
    ll foo_c = -1;

    while (q.size()) {
      auto tmp = q.front();
      q.pop();
      ll tmp_h = tmp.first.first;
      ll tmp_w = tmp.first.second;
      ll tmp_c = tmp.second;
      if (tmp_c > foo_c) { foo_c = tmp_c; }
      if (tmp_h > 0 and stage[tmp_h-1][tmp_w] == '.' and foo[tmp_h-1][tmp_w] == -1) { foo[tmp_h-1][tmp_w] = tmp_c+1; q.push(make_pair(make_pair(tmp_h-1, tmp_w), tmp_c+1)); }
      if (tmp_h < H-1 and stage[tmp_h+1][tmp_w] == '.' and foo[tmp_h+1][tmp_w] == -1) { foo[tmp_h+1][tmp_w] = tmp_c+1; q.push(make_pair(make_pair(tmp_h+1, tmp_w), tmp_c+1)); }
      if (tmp_w > 0 and stage[tmp_h][tmp_w-1] == '.' and foo[tmp_h][tmp_w-1] == -1) { foo[tmp_h][tmp_w-1] = tmp_c+1; q.push(make_pair(make_pair(tmp_h, tmp_w-1), tmp_c+1)); }
      if (tmp_w < W-1 and stage[tmp_h][tmp_w+1] == '.' and foo[tmp_h][tmp_w+1] == -1) { foo[tmp_h][tmp_w+1] = tmp_c+1; q.push(make_pair(make_pair(tmp_h, tmp_w+1), tmp_c+1)); }
    }

    bar_c = max(bar_c, foo_c);
  }

  cout << bar_c << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
// 2020-08-16 01:05:12
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

bool visited[5050];
const ll inf = 1e18;
void answer() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
    p[i]--;
  }
  vector<ll> c(n);
  rep(i, n) cin >> c[i];
  ll ans = -inf;
  rep(s, n) if(!visited[s]) {
    vector<int> d;
    {
      int cur = s;
      do {
        d.push_back(cur);
        visited[cur] = true;
        cur = p[cur];
      } while(cur != s);
    }
    int sz = d.size();
    vector<vector<ll> > score(sz, vector<ll>(sz+1, 0));
    rep(i, sz) REPC(j, 1, sz) {
      score[i][j] += score[i][j-1] + c[d[(i+j)%sz]];
      if(j <= k) chmax(ans, score[i][j]);
    }
    ll base = score[0][sz];
    if(sz < k && base > 0) {
      ll x = k / sz, r = k % sz;
      if(r == 0) x--, r = sz;
      rep(i, sz) REPC(rr, 1, r) chmax(ans, base * x + score[i][rr]);
    }
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m>>k;

	if(m>=k){
        cout<<"delicious"<<endl;
	}
	else if(m<k)
    {
        if(k-m<=n) cout<<"safe"<<endl;
        else cout<<"dangerous"<<endl;
    }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vs a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    bool ans = false;
    rep(i, n-m+1) {
        rep(j, n-m+1) {
            bool flag = true;
            rep(k, m) {
                if (b[k] != a[i+k].substr(j, m)) flag = false;
            }
            if (flag) ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final char BOMB = '#';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			char[][] s = new char[h][];
			IntStream.range(0, h).forEach(i -> s[i] = scanner.next().toCharArray());
			IntStream.range(0, h).forEach(i -> IntStream.range(0, w).forEach(j -> calcCount(i, j, h, w, s)));
			IntStream.range(0, h).forEach(i -> System.out.println(s[i]));
		}
	}

	private static void calcCount(int i, int j, int h, int w, char[][] s) {
		if (BOMB != s[i][j]) {
			int count = 0;
			if (i > 0) {
				if (j > 0) {
					count += (BOMB == s[i - 1][j - 1]) ? 1 : 0;
				}
				count += (BOMB == s[i - 1][j]) ? 1 : 0;
				if (j < w - 1) {
					count += (BOMB == s[i - 1][j + 1]) ? 1 : 0;
				}
			}
			if (j > 0) {
				count += (BOMB == s[i][j - 1]) ? 1 : 0;
			}
			if (j < w - 1) {
				count += (BOMB == s[i][j + 1]) ? 1 : 0;
			}
			if (i < h - 1) {
				if (j > 0) {
					count += (BOMB == s[i + 1][j - 1]) ? 1 : 0;
				}
				count += (BOMB == s[i + 1][j]) ? 1 : 0;
				if (j < w - 1) {
					count += (BOMB == s[i + 1][j + 1]) ? 1 : 0;
				}
			}
			s[i][j] = (char) ('0' + count);
		}
	}
}


Measured memory_bytes: 28372
#include <iostream>

int main(){
  int n,q,cnt=0,iS,iE,i,j,s[100000],t[50000],mid;
  /*iS:iStart;iE=iEnd*/
  std::cin >> n;
  for ( i = 0; i < n; ++i)std::cin >> s[i];
  std::cin >> q;
  for ( i = 0; i < q; ++i)std::cin >> t[i];

  for (j = 0; j < q; ++j) {
    iS=0;iE=n-1;
    while (iS<=iE) {
      mid=(iS+iE)/2;
      if (t[j]<s[mid])iE=mid-1;
      else if (t[j]>s[mid])iS=mid+1;
      else {
        ++cnt;
        iE=-1;
      }
    }
  }
  std::cout << cnt << '\n';
}



Measured memory_bytes: 3688
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int A, B;
    cin >> A >> B;
    cout << max(A+B, max(A-B, A*B)) << endl;
}


Measured memory_bytes: 3628
from itertools import accumulate
from collections import defaultdict


def main():
    n = int(input())
    prime_counter = defaultdict(int)  # key ^ value
    acc = tuple(accumulate(range(1, 42)))  # because 10^12 < 2^39

    def facs(n):
        yield 2
        for x in range(3, int(pow(n, 0.5)) + 1, 2):
            yield x

    for fac in facs(n):
        while n % fac == 0:
            n //= fac
            prime_counter[fac] += 1
            # ここで if fac * fac > n: braek を入れると，
            # 計算量の少ないケースでは早く，多いケースでは遅くなる。
    if n != 1:
        prime_counter[n] += 1

    ans = 0
    for c in prime_counter.values():
        for i, x in enumerate(acc):
            if c < x:
                tmp = i
                break
        ans += tmp
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[512][512];

int main() {
    scanf("%d", &n);
    int m = 1;
    while (m < n) {
        m *= 2;
    }
    int ind = 0;
    for (int x = 1; x < m; x *= 2) {
        ++ind;
        vector<int> le, ri;
        for (int i = 0; i < m; i += x * 2) {
            forn(j, x) {
                le.pb(i + j);
                ri.pb(i + x + j);
            }
        }
        for (int l : le) {
            for (int r : ri) {
                a[l][r] = a[r][l] = ind;
            }
        }
    }
    forn(i, n - 1) {
        for (int j = i + 1; j < n; ++j) {
            printf("%d ", a[i][j]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int n;
int k;
int w[100000];
int getN(int p)
{
	int j = 0;
	for(int i = 0;i < k;i++)
	{
		int m = 0;
		while(m+w[j] <= p)
		{
			m+=w[j];
			j++;
			if(j==n)	return n;
		}
		
	}
	return j;
}

int getP()
{
	int right = 100000*10000;
	int left = 0;
	int mid;
	while(left<right-1)
	{
		mid = (left+right)/2;
		int v = getN(mid);
		if (v==n)	right = mid;
		else left = mid;
		}	
	return right;
}

int main(){
	cin>>n>>k;
	for(int y = 0;y<n;y++)
	cin>>w[y];
	int ooo = getP();
	cout<<ooo<<endl;
}




Measured memory_bytes: 3504
#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 RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPS(i, n) for (int i = 1; i <= (n); i++)
#define RREPS(i, n) for (int i = (n); i > 0; i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main() {
  int ans = 700;
  string s;
  cin >> s;
  REP(i,3){
    if(s[i] == 'o') ans += 100;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())

# == 0
if ((a == 0) or (b == 0) or (a < 0 and b > 0)):
    print("Zero")
    exit(0)

# > 0
if (a > 0 and b > 0):
    print("Positive")
    exit(0)

if (b - a + 1) % 2 == 0:
    print("Positive")
    exit(0)

# < 0
print("Negative")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    int n,x,y,dis1,dis2;
    cin>>n>>x>>y;
    int a[n+1][n+1]={0};
    int ans[n+1]={0};
    int dis=y-x-1;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if((i<y)&&(j<y))
            {
                if(i<x&&j>x)
                {
                    if((j-i)>(y-i-dis+y-j))
                    {
                        a[i][j]=y-i-dis+y-j;
                        ans[y-i-dis+y-j]++;
                    }
                    else
                    {
                        a[i][j]=j-i;
                        ans[j-i]++;
                    }
                }
                else if(i>=x&&j>=x)
                {
                    if((j-i)>(i-x+y-j+1))
                    {
                        a[i][j]=i-x+y-j+1;
                        ans[i-x+y-j+1]++;
                    }
                    else
                    {
                        a[i][j]=j-i;
                        ans[j-i]++;
                    }
                }
                else
                {
                    a[i][j]=j-i;
                    ans[j-i]++;
                }
            }
            else if(i<=x&&j>=y)
            {
                a[i][j]=j-i-dis;
                ans[j-i-dis]++;
            }
            else if(i>=x&&j>=y)
            {
                if((j-i)>(i-x+j-y+1))
                {
                    a[i][j]=i-x+j-y+1;
                    ans[i-x+j-y+1]++;
                }
                else
                {
                    a[i][j]=j-i;
                    ans[j-i]++;
                }

            }
            else
            {
                a[i][j]=j-i;
                ans[j-i]++;
            }
        }
    }
    for(int i=1;i<n;i++)
        cout<<ans[i]<<'\n';


}


Measured memory_bytes: 15872
#include<cstdio>


int main(void)
{
	int d, n;

	while(scanf("%d%d", &d, &n)==2)
	{
		int ans=n;
		if(ans==100) ans=101;
		for(int i=0;i<d;i++)
		{
			ans*=100;
		}
		printf("%d\n", ans);
	}

	return 0;
}


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

namespace atcoder_cs
{
	class Program
	{
		static double CalcSunuke(long num)
		{
			long tmp = num;
			long sn = 0;

			while (tmp > 0)
			{
				sn += (tmp % 10);
				tmp /= 10;
			}
			
			return num / (double)sn;
		}

		static void PrintSunuke(long k)
		{
			int count = 0;
			for (int i = 1; i < 10; i++)
			{
				Console.WriteLine(i.ToString());
				++count;

				if (count >= k)
				{
					return;
				}
			}

			long baseNum = 9;
			long baseDigit = 10;
			long nextCandidate = 0;

			while (count < k)
			{
				long topNum = 1;
				long nowCandidate = topNum * baseDigit + baseNum;

				while (nowCandidate <= nextCandidate)
				{
					++topNum;
					nowCandidate = topNum * baseDigit + baseNum;
				}

				double sunuke = CalcSunuke(nowCandidate);
				while (count < k)
				{
					++topNum;
					nextCandidate = topNum * baseDigit + baseNum;
					double tmpSunuke = CalcSunuke(nextCandidate);

					if (sunuke < tmpSunuke)
					{
						Console.WriteLine(nowCandidate.ToString());
						nowCandidate = nextCandidate;
						sunuke = tmpSunuke;
						++count;
					}
					else
					{
						baseNum = baseNum * 10 + 9;
						baseDigit *= 10;
						break;
					}
				}

			}

		}

		static void Main(string[] args)
		{
			long k;
			string str = Console.ReadLine();
			k = long.Parse(str);

			PrintSunuke(k);

			return;
		}
	}
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
        String str[] = {"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"};
        for(int i=0;i<26;i++){if(s.equals(str[i])){System.out.println("a");break;}
                              else{if(i==25){System.out.println("A");}}
                             }
		
		
	}
}


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

int main(){
    int i,count=0;
    char a[6];
    
    scanf("%s",a);
    
    for(i=0;a[i]!='\0';i++){
        if(a[i]=='+'){
            count++;
        }
        else if(a[i]=='-'){
            count--;
        }
    }
    
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define INF 3333333333
#define uint unsigned int

int merge(uint S[], int left, int mid, int right) {
  int numComp = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  uint L[n1 + 1], R[n2 + 1];
  REP(i, n1) {
    L[i] = S[left + i];
  }
  REP(i, n2) {
    R[i] = S[mid + i];
  }
  L[n1] = INF;
  R[n2] = INF;

  int i = 0, j = 0;
  FOR(k, left, right) {
    if(L[i] <= R[j]) {
      S[k] = L[i];
      i += 1;
    } else {
      S[k] = R[j];
      j += 1;
    }
    numComp += 1;
  }
  return numComp;
}

int mergeSort(uint S[], int left, int right) {
  int numComp = 0, mid;
  if((left + 1) < right) {
    mid = (left + right) / 2;
    numComp += mergeSort(S, left, mid);
    numComp += mergeSort(S, mid, right);
    numComp += merge(S, left, mid, right);
  }
  return numComp;
}

int main(void) {
  int n;
  scanf("%d", &n);
  uint S[n];
  REP(i, n) {
    scanf("%d", &S[i]);
  }

  int numComp = mergeSort(S, 0, n);

  REP(i, n) {
    if(i != 0) {
      printf(" ");
    }
    printf("%d", S[i]);
  }
  printf("\n%d\n", numComp);

  return 0;
}

Measured memory_bytes: 6496
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvi = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,x;
    cin >> n >> x;
    vl city(n);
    rep(i,n) cin >> city[i];
    vl dif(n);
    rep(i,n){
        dif[i] = abs(x-city[i]);
    }
    int ans = dif[0];
    rep(i,n){
        ans = gcd(ans,dif[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <bitset>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <assert.h>
 
 
using namespace std;
 
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 2e18 + 7;
const int maxN = 2e6 + 5;
const ll MOD = 1e9 + 7;
 
int n, k, h[maxN], dp[maxN];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	REP(i, n) cin >> h[i];
	dp[0] = 0;
	RI(i, n - 1) {
		dp[i] = MOD;
		FORD(j, i - 1, max(i - k, 0)) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return(0);
}

Measured memory_bytes: 1008
#include <iostream>

using namespace std;

int main() {

    int a, b;
    cin >> a >> b;

    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    n = n%10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon" << endl;
    }else if(n==0||n==1||n==6||n==8){
        cout << "pon" << endl;
    }else if(n==3){
        cout << "bon" << endl;
    }
    return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<ll> a(N); for (int i = 0; i < N; i++) cin >> a[i];
    vector<ll> cum(N); cum[0] = a[0];
    for (int i = 1; i < N; i++) cum[i] = cum[i-1] + a[i];
    map<ll, int> pr;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            if (i == 0) pr[cum[j]]++;
            else pr[cum[j] - cum[i-1]]++;
        }
    }
    for (int i = 62; 0 <= i; i--) {
        map<ll, int> tmp;
        int t = 0;
        for (auto x : pr) {
            if (x.first>>i & 1) {
                t += x.second;
                tmp[x.first] = x.second;
            }
        }
        if (t >= K) pr = tmp;
    }
    ll ans = (ll)1<<60;
    ans -= 1;
    for (auto x : pr) {
        ans &= x.first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 38656
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;

const ll mod = 1e9+7;
ll dp[2005];

ll solve(ll n)
{
    if(n<3) return 0;
    if(dp[n]!=0) return dp[n];
    for(ll i=3;i<=(n-3);i++)
    {
        ll k = (solve(n-i)%mod + 1%mod)%mod;
        dp[n] = (dp[n]%mod + k%mod)%mod;
    }
    return dp[n];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  if(n<3) cout<<"0"<<endl;
  else  cout<<solve(n)+1<<endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

struct UnionFind {
#define MAX 200000
    int ElementCount[MAX],Adress[MAX];
    void Init() {rep(i,MAX) ElementCount[i] = 1, Adress[i] = i;}
    void unite(int a ,int b) {
        int a_root = find(a),b_root = find(b);
        if (a_root != b_root) {
            if (ElementCount[a_root] <= ElementCount[b_root]) {
                ElementCount[a_root] += ElementCount[b_root];
                Adress[b_root] = a_root;
            } else {
                ElementCount[b_root] += ElementCount[a_root];
                Adress[a_root] = b_root;
            }
        }
    }
    int find(int a) {
        if (a == Adress[a]) return Adress[a];
        else {
            Adress[a] = find(Adress[a]);
            return Adress[a];
        }
    }
    int size(int a) {
        int root = find(a);
        return ElementCount[root];
    }
    /*
     * ElementCount : 属するグループの要素数
     * Adress : rootの番号
     * unite : 併合
     * find : aのrootを返す
     * size : aのrootのElementCountを返す
     * */
};

int n,k,l,a,b;
map<pair<int,int>,int> m;
UnionFind douro,tetudou;

signed main() {
    douro.Init();
    tetudou.Init();
    cin >> n >> k >> l;
    rep(i,k) cin >> a >> b, a--, b--, douro.unite(a,b);
    rep(i,l) cin >> a >> b, a--, b--, tetudou.unite(a,b);
    rep(i,n) m[mp(douro.find(i), tetudou.find(i))]++;
    rep(i,n-1) cout << m[mp(douro.find(i), tetudou.find(i))] << " ";
    cout << m[mp(douro.find(n-1), tetudou.find(n-1))] << endl;
}






Measured memory_bytes: 18304
#include <stdio.h>
int main(void) {
  int kane,odama,kodama,amari;
  scanf("%d\n",&kane);
  odama = kane/500;
  amari = kane%500;
  kodama = amari/5;
  printf("%d\n",odama*1000+kodama*5);
  return 0;
}

Measured memory_bytes: 128
#

import sys
from math import ceil
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    ans=A[0]
    for i in range(1,1+ceil((N-2)/2)):
        ans+=2*A[i]
    if (N-2)%2==1:
        ans-=A[i]
    print(ans)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 91860
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int N,t=0;
	bool flag = true;
	cin >> N;
	vector<pair<long long int, long long int>>A(N);
	for (int i = 0; i < N; i++)cin >> A[i].second >> A[i].first;
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++)
	{
		if (t + A[i].second <= A[i].first)t += A[i].second;
		else {
			flag = false;
			break;
		}
	}
	if (flag)cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout << a[0] + a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,K = MI()
    for i in range(K):
        if i%2==0:
            if A&1:
                A-=1
            A>>=1
            B+=A
        else:
            if B&1:
                B-=1
            B>>=1
            A+=B
    print(A,B)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
const int mod = 1000000007;
const int N = 2e5+5, M = N;
//=========================================

int dp[10005][105][2]; // dp[pos][sum_of_digits][flag]
vector<int> num;
string a, b; 
int k;
 
int call(int pos, int digit_sum, int flag){
    // Check if the digit_sum is divisible by D
    if(pos == (int)num.size()){
        return (digit_sum == 0);
    }
	
  	// Return if already computed
    if(dp[pos][digit_sum][flag] != -1)
        return dp[pos][digit_sum][flag];
    
    int ans = 0;
  	// set the limit of max digit for pos
    int LMT = (flag ? num[pos] : 9);
	
  	// calculate the answer
    for(int dgt = 0; dgt <= LMT; ++dgt){
        ans += call(pos + 1, (digit_sum + dgt) % k, flag && (dgt == LMT));
        ans %= mod;
    }

    return dp[pos][digit_sum][flag] = ans;
}

int solve(string a){
    
    num.clear();
  	// set the limit of max digit at each position
    for(int i = 0; i < (int)a.size(); ++i)
        num.push_back(a[i] - '0');
    
    memset(dp, -1, sizeof(dp));
  	// invoke the call function with flag = 1
  	// because digit at first pos has limit of num[0]
    int res = call(0, 0, 1) - 1;
  	if(res < 0) res += mod;
    return res;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  	// Input the number as a string
    cin >> a;
  
  	// Input D
    cin >> k;
    
    int ans = solve(a);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 20944
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstdio>
#define EPS 1e-4
using namespace std;

struct P{
  double x,y,z;
};

int main(){
  int N,n;
  P tr;
  double x,y,z,QR,RP,PQ;
  scanf("%d",&N);
  while(N-- > 0){
  cin >> x >> y >> z;
  QR = x/y; RP = y/z; PQ = z/x;
  tr.x = x; tr.y = y; tr.z = z; 
  cin >> n;
    P p[n+1];
    for(int i=0;i<n;i++){
      cin >> x >> y >> z;
      p[i].x = x; p[i].y = y; p[i].z = z;
    }
  
    double qr,rp,pq;
    bool fin = false;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i == j)continue;
	for(int k=0;k<n;k++){
	  if(i == k || j==k)continue;
	  qr = sqrt(pow(p[j].x-p[k].x,2)+pow(p[j].y-p[k].y,2)+pow(p[j].z-p[k].z,2));
	  rp = sqrt(pow(p[k].x-p[i].x,2)+pow(p[k].y-p[i].y,2)+pow(p[k].z-p[i].z,2));
	  pq = sqrt(pow(p[i].x-p[j].x,2)+pow(p[i].y-p[j].y,2)+pow(p[i].z-p[j].z,2));

	  if( fabs(qr/rp-QR) < EPS && fabs(rp/pq-RP) < EPS && fabs(pq/qr-PQ) < EPS){
	    cout << i+1 << " " << j+1 << " " << k+1 << endl;
	    fin = true;
	    break;
	  }
	}
	if(fin)break;
      }
      if(fin)break;
    }

  }

  return 0;
}

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

using namespace std;

int main() {
    int bucket[28] = {0};

    string s, S;
    cin >> s;

    S += s[0];

    for(int i = 1; i < (int)s.size(); ++i) {
        if(s[i] == s[i-1])
            continue;
        S += s[i];
    }

    for(auto c: S) {
        bucket[c-'E'] += 1;
    }

    if((!bucket['E'-'E'] xor !bucket['W'-'E']) or (!bucket['N'-'E'] xor !bucket['S'-'E']))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e6+3);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}
	
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	init(1000002);
	int q; cin>>q;
	while(q--)
	{
		int x,d,n; cin>>x>>d>>n;
		if(d==0)
		{
			cout<<modpow(x,n)<<'\n';
		}
		else
		{
			int coeff = modpow(d,n);
			int a = mult(x,inv[d]);
			int r = a+n-1;
			if(r>=MOD)
			{
				cout<<0<<'\n';
			}
			else
			{
				coeff=mult(coeff,fact[r]);
				if(a>=1) coeff=mult(coeff,ifact[a-1]);
				cout<<coeff<<'\n';
			}
		}
	}
}


Measured memory_bytes: 16512
n = int(input())
w = input().split()
for i in range(len(w)):
    w[i]=int(w[i])
alist=[]
for j in range(n):
    a = sum(w[0:j+1])-sum(w[j+1:n])
    alist.append(abs(a))
print(min(alist))

Measured memory_bytes: 3060