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

void lcs(string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

int index = L[m][n]; 

char lcs[index+1]; 
lcs[index] = '\0';

int i = m, j = n; 
while (i > 0 && j > 0) 
{
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1];
		i--; j--; index--;
	} 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 
 
cout << lcs; 
} 

int main() 
{ 
string X,Y;
cin>>X>>Y;
int m = X.length(); 
int n = Y.length(); 
lcs(X, Y, m, n); 
return 0; 
} 


Measured memory_bytes: 35456
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Edge
{
public:
    int to, cost;
    Edge(){};
    Edge(int to0, int cost0){to = to0; cost = cost0;}
};

long long minSpanningTree(const vector<vector<Edge> >& edges)
{
    int n = edges.size();
    vector<bool> used(n, false);
    int usedNum = 0;
    vector<int> minCost(n, INT_MAX);
    priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
    q.push(make_pair(0, 0));

    long long ret = 0;
    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if(used[v])
            continue;
        ret += p.first;
        used[v] = true;
        if(++usedNum == n)
            return ret;
        for(unsigned i=0; i<edges[v].size(); ++i){
            Edge e = edges[v][i];
            if(!used[e.to] && e.cost < minCost[e.to]){
                minCost[e.to] = e.cost;
                q.push(make_pair(e.cost, e.to));
            }
        }
    }
    return -1;
}

int main()
{
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > v(2, vector<pair<int, int> >(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<2; ++j){
            cin >> v[j][i].first;
            v[j][i].second = i;
        }
    }

    vector<vector<Edge> > edges(n);
    for(int i=0; i<2; ++i){
        sort(v[i].begin(), v[i].end());
        for(int j=0; j<n-1; ++j){
            int a = v[i][j].second;
            int b = v[i][j+1].second;
            int c = v[i][j+1].first - v[i][j].first;
            edges[a].push_back(Edge(b, c));
            edges[b].push_back(Edge(a, c));
        }
    }
    cout << minSpanningTree(edges) << endl;

    return 0;
}


Measured memory_bytes: 13040
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  long long N, M, dum;
  cin >> N >> M;
  long long sum = 0;

  for(int i=0;i<M;i++){
    cin >> dum;
    sum += dum;
    if(sum>N){
      cout << -1;
      return 0;
    }
  }

  cout << N - sum;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vd x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  double xl = -1, xr = 1001;
  double ans = 1e9;
  rep(i, 100) {
    vd xn = {(2 * xl + xr) / 3, (xl + 2 * xr) / 3};
    vd r(2, 0);
    rep(k, 2) {
      double yl = -1, yr = 1001;
      rep(j, 100) {
        double yll = (2 * yl + yr) / 3;
        double yrr = (yl + 2 * yr) / 3;
        double dl = 0, dr = 0;
        rep(i, n) {
          dl = max(dl, sqrt(pow(xn[k] - x[i], 2) + pow(yll - y[i], 2)));
          dr = max(dr, sqrt(pow(xn[k] - x[i], 2) + pow(yrr - y[i], 2)));
        }
        if(dl > dr)
          yl = yll;
        else
          yr = yrr;
      }
      rep(i, n) r[k] =
          max(r[k], sqrt(pow(xn[k] - x[i], 2) + pow(yl - y[i], 2)));
    }
    if(r[0] > r[1])
      xl = xn[0];
    else
      xr = xn[1];
    ans = min(ans, min(r[0], r[1]));
  }
  printf("%.18f\n", ans);
}

Measured memory_bytes: 256
'use strict'

function main(input) {
  const inputList = input.split('\n');
  const n = Number(inputList[0].split(' ')[0])
  const m = Number(inputList[0].split(' ')[1])
  const heightList = inputList[1].split(' ').map(height => Number(height))
  const routeList = inputList.slice(2)

  let list = new Array(n)
  for (let i=0; i<n; i++) {
    list[i] = new Array()
  }
  for (let i=0; i<m; i++) {
    const tmp = routeList[i].split(' ')
    const a = Number(tmp[0]) - 1
    const b = Number(tmp[1]) - 1
    list[a].push(b)
    list[b].push(a)
  }

  let count = 0
  for (let i=0; i<list.length; i++) {
    let tmp = 1
    for (let j=0; j<list[i].length; j++) {
      if (heightList[i] <= heightList[list[i][j]]) {
        tmp = 0
        break
      }
    }
    count += tmp
  }

  console.log(count)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 76384
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}void _p() {cout << "]\n";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=========================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;



string fx(int r){
        if (!r) return string();
        return fx((r-1)/26)+char('a'+((r-1)%26));
}




void sol()
{   
    cin>>n;

    cout<< fx(n) <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3648
const MOD: u64 = 998244353;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let a_sum = a.iter().sum::<usize>();
    let mut dp = vec![0; a_sum + 1];
    dp[0] = 1;
    for i in 0..n {
        let a = a[i];
        for i in (0..(a_sum - a + 1)).rev() {
            dp[i + a] += dp[i];
            dp[i + a] %= MOD;
            dp[i] *= 2;
            dp[i] %= MOD;
        }
    }
    let mut dp2 = vec![0; a_sum + 1];
    dp2[0] = 1;
    for i in 0..n {
        let a = a[i];
        for i in (0..(a_sum - a + 1)).rev() {
            dp2[i + a] += dp2[i];
            dp2[i + a] %= MOD;
        }
    }

    let mut half = 0;
    for i in ((a_sum + 1) / 2)..(a_sum + 1) {
        half += dp[i];
        half %= MOD;
    }

    let all = mod_pow(3, n);
    if a_sum % 2 == 0 {
        let ans = (all + MOD - (half * 3) % MOD) % MOD;
        println!("{}", (ans + dp2[a_sum / 2] * 3) % MOD);
    } else {
        println!("{}", (all + MOD - (half * 3) % MOD) % MOD);
    }
}

fn mod_pow(mut x: u64, mut e: usize) -> u64 {
    let mut result = 1;
    while e > 0 {
        if e & 1 == 1 {
            result = (result * x) % MOD;
        }
        e >>= 1;
        x = (x * x) % MOD;
    }
    result
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    bool p = S[0] == 'R';
    bool q = S[1] == 'R';
    bool r = S[2] == 'R';
    if (p && q && r) {
        cout << 3 << endl;
    } else if ((p && q) || (q && r)) {
        cout << 2 << endl;
    } else if (p || q || r) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
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);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> &a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
template<class T>void prArr(T a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

struct dat{
  int idx,to, pre;
  
  dat(int idx=-1, int to=-1,int pre = -1):idx(idx),to(to), pre(pre){}
};

void print(int head, int tail, vector<dat> A,vector<int> num){
  vector<int>ans;
  for(int i = head; ; i = A[i].to){
    //pr(i, A[i].pre, A[i].to, A[i].idx, head,tail);
    ans.push_back(num[A[i].idx]);
    if(i == tail) break;;
  }
  cout<<ans<<endl;
  
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, Q;
  cin >>n>> Q;
  vector<dat> A(n);
  for(int i=0;i<n;i++){
    A[i].idx = i;
    A[i].to = (i+1)%n;
    A[i].pre = (i-1 + n) % n;
  }
  int head = 0, tail = n-1;
  
  vector<int> num(n);
  vector<int> Idx(n);
  cin>>num;
  for(int i=0;i<n;i++) Idx[num[i]-1] = i;

  auto query=[&](int x){

    if(x == tail){
      int nhead = x;
      int ntail = A[x].pre;
      A[x].to = head;
      A[head].pre = x;
      head = nhead;
      tail = ntail;
      return;
    };

    if(x == head){
      int nhead = A[x].to;
      int ntail = x;
      A[tail].to = x;
      A[x].pre = tail;
      head = nhead;
      tail = ntail;
      return;
    }

    int nhead = A[x].to;
    int ntail = A[x].pre;
    A[x].to = head;
    A[head].pre = x;

    A[tail].to = x;
    A[x].pre = tail;
    head = nhead;
    tail = ntail;
  };

  
  while(Q--){
    int q;
    cin>>q;
    query(Idx[q-1]);
    // print(head, tail, A,num);
  }

  print(head, tail, A, num);
  
  
  return 0;
}



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

typedef pair<int,int> ii;
typedef long long ll;

#define SQR(x) ((x)*(x))
vector<int>nodes[100010];
int colour[100010];
int pre[100010];
void dfs(int x){
    for(auto y:nodes[x]){
        if(pre[y]!=0)continue;
        pre[y]=x;
        dfs(y);
    }
}
void dfs2(int x){
    for(auto y:nodes[x]){
        if(colour[y]!=0)continue;
        colour[y]=colour[x];
        dfs2(y);
    }
}

int main() {
    //freopen("hi.txt","r",stdin);
    int n;
    scanf("%d",&n);
    int a,b;
    for(int i=0;i<n-1;i++){
        scanf("%d%d",&a,&b);
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }
    pre[1]=-1;
    dfs(1);
    vector<int>v;
    int cur=n;
    while(cur!=-1){
        v.push_back(cur);
        cur=pre[cur];
    }
    for(int i=0;i<v.size()/2;i++){
        colour[v[i]]=2;
    }
    for(int i=v.size()/2;i<v.size();i++){
        colour[v[i]]=1;
    }
    for(auto i:v){
        dfs2(i);
    }
    int counter=0;
    for(int i=1;i<=n;i++){
        counter+=colour[i]==1;
    }
    if(counter>n/2){
        printf("Fennec");
    }
    else{
        printf("Snuke");
    }
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

// int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;



int main() {

  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  // vector<vector<int>> A(K);
  vector<bool> su(N, false);
  REP(i, K){
    cin >> d[i];
    REP(j, d[i]){
      int a;
      cin >> a; a--;
      // A[j].push_back(a);
      su[a] = true;
    }
  }
  int count = 0;
  REP(i, N){
    if(su[i]==false){
      count++;
    }
  }

  cout << count << endl;


}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3632
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
      Scanner sc = new Scanner(System.in);
      int x,y;
      x = 1;
      y = 1;
      while(x != 0){
    	x = sc.nextInt();
    	if(x!=0){
    		System.out.println("Case "+y+": "+x);
    	}
    	y = y+1;
      }
	}

}

Measured memory_bytes: 44600
#include <iostream>

using namespace std;

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

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

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for (int i = 2; i < n; ++i) {
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
    }

    std::cout << dp[n - 1];

    return 0;
}

Measured memory_bytes: 1024
/*
for (int i = 0; i < N; ++i){}

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

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	int A[2];
	cin >> A[0] >> A[1] >> A[2];
 
	// 解法
	int arr[] = {0, 1, 2};
	int ans = 300;
	
	do {
		
		int tmp = 0
				  + abs(A[arr[1]]-A[arr[0]]) 
				  + abs(A[arr[2]]-A[arr[1]]);
		
		if (ans>tmp) ans = tmp;
		// for(int i = 0; i < 3; i++) {
		// 	cout << A[arr[i]];
		// 	if(i + 1 == 3) cout << endl;
		// 	else cout << ' ';
		// }
		// cout << tmp << endl;
	} while(next_permutation(arr, arr + 3));
	printf("%d\n", ans);

}
 


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = []
for i in range(M):
  b, c = map(int, input().split())
  B.append([c, b])
B.sort(reverse=True)
i = 0
f = 0
for j in range(M):
  while B[j][1]:
    if A[i] < B[j][0]:
      A[i] = B[j][0]
      B[j][1] -= 1
      i += 1
      if i >= N:
        f = 1
        break
    else:
      f = 1
      break
  if f == 1:
    break
print(sum(A))

Measured memory_bytes: 94956
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

// Train A departs at station i at sum(j=0..i-1,tj+u{j+1})
// Train B arrives at station i at D-sum(j=0..i-1,tj+v{j+1})
// If track i is one way then D-sum(j=0..i-1,tj+v{j+1})<=sum(j=0..i-1,tj+u{j+1}) || D-sum(j=0..i-1,tj+v{j+1})-ti>=sum(j=0..i-1,tj+u{j+1})+ti
// In other words: -sum(j=0..i-1,2*tj)<=sum(j=0..i-1,u{j+1}+v{j+1})-D<=-sum(j=0..i,2*tj)

int ntrack,T;
int t[MAXN];
bool onedir[MAXN];
ll tsum[MAXN+1];

int L[MAXN],R[MAXN],ncond;
int x[2*MAXN],nx;
ll dpL[MAXN],dpR[MAXN];

int sval[4*MAXN];

void spush(int x) { if(sval[x]!=-1) sval[2*x+1]=sval[2*x+2]=sval[x],sval[x]=-1; }
void sset(int x,int l,int r,int L,int R,int VAL) {
	//printf("sset(%d,%d..%d,%d..%d,%d)\n",x,l,r,L,R,VAL);
	if(L<=l&&r<=R) { sval[x]=VAL; return; }
	spush(x);
	int m=l+(r-l)/2;
	if(L<=m) sset(2*x+1,l,m,L,R,VAL);
	if(m+1<=R) sset(2*x+2,m+1,r,L,R,VAL);
}
int sget(int x,int l,int r,int IDX) {
	//printf("sget(%d,%d..%d,%d)\n",x,l,r,IDX);
	if(sval[x]!=-1||l==r) return sval[x];
	spush(x);
	int m=l+(r-l)/2;
	return IDX<=m?sget(2*x+1,l,m,IDX):sget(2*x+2,m+1,r,IDX);
}

void run() {
	scanf("%d%d",&ntrack,&T);
	REP(i,ntrack) { int tmp; scanf("%d%d",&t[i],&tmp); onedir[i]=tmp==1; }
	REP(i,ntrack) if(onedir[i]&&2*t[i]>T) { printf("-1\n"); return; }
	tsum[0]=0; REP(i,ntrack) tsum[i+1]=tsum[i]+t[i];
	ncond=0;
	REP(i,ntrack) if(onedir[i]) { L[ncond]=-2*tsum[i]%T; R[ncond]=-2*tsum[i+1]%T;  if(L[ncond]<0) L[ncond]+=T; if(R[ncond]<0) R[ncond]+=T; ++ncond; }
	nx=0; REP(i,ncond) x[nx++]=L[i],x[nx++]=R[i]; sort(x,x+nx); nx=unique(x,x+nx)-x; REP(i,ncond) L[i]=lower_bound(x,x+nx,L[i])-x,R[i]=lower_bound(x,x+nx,R[i])-x;

	memset(sval,-1,sizeof(sval));
	for(int i=ncond-1;i>=0;--i) {
		int lj=sget(0,0,nx-1,L[i]);
		dpL[i]=lj==-1?0:(x[L[lj]]-x[L[i]]+T)%T+dpL[lj];
		int rj=sget(0,0,nx-1,R[i]);
		dpR[i]=rj==-1?0:(x[L[rj]]-x[R[i]]+T)%T+dpL[rj];
		//printf("%d: %d..%d (%d..%d) -> %d,%d -> %lld,%lld\n",i,L[i],R[i],x[L[i]],x[R[i]],lj,rj,dpL[i],dpR[i]);
		if(L[i]<=R[i]) {
			if(L[i]>=1) sset(0,0,nx-1,0,L[i]-1,i);
			if(nx-R[i]>=2) sset(0,0,nx-1,R[i]+1,nx-1,i);
		} else {
			if(L[i]-R[i]>=2) sset(0,0,nx-1,R[i]+1,L[i]-1,i);
		}
	}
	ll ret=LLONG_MAX;
	REP(i,nx) {
		int j=sget(0,0,nx-1,i);
		ll cur=j==-1?0:(x[L[j]]-x[i]+T)%T+dpL[j];
		//printf("%d (%d) -> %d -> %lld\n",i,x[i],j,cur);
		if(cur<ret) ret=cur;
	}
	ret+=2*tsum[ntrack];
	printf("%lld\n",ret);
}

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


Measured memory_bytes: 6144
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int n,k;
  cin>>n>>k;
  int cnt=0;
  while(n>=1){
    //scout<<n<<endl;
    cnt++;
    n=n/k;
  }
  cout<<cnt<<endl;
}

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

using namespace std;


int N, M, Q;
vector<int> A;
vector<int> a, b, c, d;

int ans = 0;


void dfs(int n) {

    if (n == N) {
        int sum = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }

    for (int i = min(A[n], M); i <= M; i++) {
        A[n + 1] = i;
        dfs(n + 1);
    }

}


void solve() {
    cin >> N >> M >> Q;
    A.resize(N + 1);
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);

    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    A[0] = 1;
    dfs(0);

    cout << ans << endl;    
}


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

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<4;i++)
	{
		cout<<s[i];
	}
	cout<<" ";
	for(int j=4;j<12;j++)
	{
		cout<<s[j];
	}
	cout<<"\n";
}

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

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


#define rep(a,n) for(int a = 0;a < n;a++)


int main(void)
{
	ll n;
	cin >> n;
	vector<ll> cs(n+1);
	vector<ll> m(n+1,0);
	rep(i, n)
	{
		cin >> cs[i];
		m[cs[i]]++;
	}
	if (cs[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	if (m[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	ll rest = n;
	ll sum = 1;
	ll prev = 1;
	const ll mod = 998244353;
	rep(i, n + 1) {
		if (rest <= 0) break;
		ll c = m[i];
		if (c == 0 && rest > 0) {
			cout << 0 << endl;
			return 0;
		}
		rep(j, c) {
			sum *= prev;
			sum %= mod;
		}
		prev = c % mod;
		rest -= c;
	}
	cout << (sum%mod) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){ 
 int N; 
 long long int p = 1; 
 int i; 
 scanf("%d",&N);
 for(i=1;i<=N;i++){ 
  p *= i; 
  p = p % 1000000007; 
 } 
 printf("%lld",p); 
 return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if (N*A <= B) {
    int x;
    x = N*A;
    cout << x << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0,k;
	int a[1000001];
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=n;i>n-k;i--)
		sum+=a[i];
	cout<<sum<<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,a) FOR(i,0,a)

const int SLEN=1e5;

char S[SLEN+1];

int main(){
    scanf("%s",S);
    int len=strlen(S);
    int l=-1,r=-1;
    REP(i,len-1){
        if (S[i]==S[i+1]){
            l=i+1;
            r=i+2;
        }
    }
    REP(i,len-2){
        if (S[i]==S[i+2]){
            l=i+1;
            r=i+3;
        }
    }
    printf("%d %d\n",l,r);
    return 0;
}

Measured memory_bytes: 384
$\=8e18;<>=~$";@x=sort{$a-$b}<>;until(@x<$'){map{@p=sort{$a-$b}map/ /*$',@x[0..--$_];$\-=$-=$\+($p[-$']-pop@p)*($x[$_]-"@x")until@p<$'}$'..@x;shift@x}print

Measured memory_bytes: 512
base = input()
a = int(base)

for i in range(1,a+1):

    if i%3 == 0:
            print(" %d"%i,end = "")
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()



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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[] a = new int[1000001];
        for (int i = 0; i < n; i++) {
            int b = in.ni();
            a[b]++;
        }
        int ans = n;
        boolean[] flag = new boolean[1000001];
        Arrays.fill(flag,true);
        for (int i = 1; i <= 1000000; i++) {
            if(a[i]==1){
                for (int j = 2; j*i <= 1000000; j++) {
                    if(a[j*i]>0&&flag[j*i]){
                        flag[j*i]= false;
                        ans -= a[j*i];
                    }
                }
            }else if(a[i]>1){
                for (int j = 1; j*i <= 1000000; j++) {
                    if(a[j*i]>0&&flag[j*i]){
                        flag[j*i]= false;
                        ans -= a[j*i];
                    }
                }
            }
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 57556
import numpy as np

n = int(input())
arr = np.array([int(input()) for _ in range(n)])

a_max = arr.max()

idx = np.where(arr == a_max)[0]

if len(idx) > 1:
    for i in range(n):
        print(a_max)

    exit()

not_arr = arr[arr != a_max]

b_max = not_arr.max()

t = idx[0]
for i in range(n):
    if i == t:
        print(b_max)
    else:
        print(a_max)



Measured memory_bytes: 21844
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int> ,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

bool check(long long int a)
{
    for(int i=2;i<=sqrt(a);i++)
    {
        if(a%i == 0)
            return 0;
    }
    return 1;
}
void go()
{
    long long int n;
    cin>>n;
    long long int i=2;
    vector<long long int> f;
    long long int prev=n;
    if(n == 1)
    {
        cout<<0;
        return;
    }
    if(check(n))
    {
        cout<<1;
        return;
    }
    while(n>1)
    {
        if(prev!= n && check(n))
        {
            f.push_back(1);
            break;
        }
        else if((n%i == 0) && check(i))
        {
            //cout<<i<<endl;
            prev=n;
            long long int cnt=0;
            while(n%i == 0)
                cnt++,n/=i;
            f.push_back(cnt);
        }
        i++;
    }
    long long int ans=0;
    for(int i=0;i<f.size();i++)
    {
        //cout<<f[i]<<endl;
        long long int z=1;
        long long int c=2;
        while(z <= f[i])
            z+=c,c++,ans++;
    }
    cout<<ans;
}
int main()
{
    //FIO;
    //int t;
    //cin>>t;
    //while(t--)
        go();
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong() - 1;
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		sc.close();
		long cMulti = B / C - A / C;
		long dMulti = B / D - A / D;
		long cd = C * D / gcd(C, D);
		long cdMulti = B / cd - A / cd;
		System.out.println(B - A - (cMulti + dMulti - cdMulti));
	}

	private static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 21332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0100
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                Dictionary<int,int> sales  = new Dictionary<int, int>(4001);

                int n = RInt();
                if (n == 0) break;

                for (int i = 0 ; i < n ; i++)
                {
                    int[] items = RIntAr();
                    if (!sales.ContainsKey(items[0])) sales.Add(items[0], 0);
                    sales[items[0]] += items[1] * items[2];
                }

                if (sales.All(x => x.Value < 1000000)) Console.WriteLine("NA");
                else foreach (var item in sales.Where(x => x.Value >= 1000000)) Console.WriteLine(item.Key);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16908
from itertools import accumulate
from bisect import *

N, M,K=map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))


cum_A = list(accumulate([0] + A))
cum_B = list(accumulate([0] + B))

start = bisect(cum_A, K) - 1       # K を超えない最大のcum_Aの要素を導くindex = 和がK以下になるようなAの要素の個数
res = [start]
k = 0

for i in reversed(range(start+1)):
    while cum_A[i] + cum_B[k] <= K:
        if k == M:
            res.append(i + k)
            break
        k += 1
    res.append(i + k-1)


print(max(res))


'''

3 3 3
1 1 1
10 2 3

'''


Measured memory_bytes: 132780
import numpy as np

N, M = map(int, input().split())
arr = []
for i in range(N):
    a, b = map(int, input().split())
    arr.append([a,b])

vec = np.array(arr)
sort = vec[np.argsort(vec[:, 0])]

amnt = 0
num = 0
for i in range(len(sort)):
    if num + sort[i][1] >= M:
        x = M - num
        amnt += sort[i][0] * x
        break
    else:
        amnt += sort[i][0] * sort[i][1]
        num += sort[i][1]
print(amnt)


Measured memory_bytes: 32484
using System;
using System.Linq;

namespace ALDS1_9B{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var H = sr.Next<int>();
            var A = new[]{0}.Concat(sr.Next<int>(H)).ToArray();

            Action<int> maxHeapify = null;
            maxHeapify = i =>{
                var l = 2 * i;
                var r = l + 1;

                var maxi = i;
                if(l <= H && A[l] > A[maxi]) maxi = l;
                if(r <= H && A[r] > A[maxi]) maxi = r;
                if(maxi == i) return;

                var tmp = A[i];
                A[i] = A[maxi];
                A[maxi] = tmp;

                maxHeapify(maxi);
            };

            for(var i = H / 2; i >= 1; i--) maxHeapify(i);
            Console.WriteLine(" " + string.Join(" ", A.Skip(1).Select(x => x.ToString()).ToArray()));
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 72676
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, C, l[100009], c[100009], w[100009], p[100009];
int main() {
	cin >> N >> M >> C;
	for (int i = 0; i < C; i++) cin >> l[i];
	for (int i = 0; i < N; i++) cin >> c[i] >> w[i], p[i] = i, c[i]--;
	sort(p, p + N, [](int i, int j) { return w[i] > w[j]; });
	int sum = 0, cnt = 0;
	for (int i = 0; i < N; i++) {
		if (l[c[p[i]]] > 0) {
			l[c[p[i]]]--;
			sum += w[p[i]];
			cnt++;
		}
		if (cnt == M) break;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4492
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
   int y;
  if(a>b)
  {y=((a-b)%2);
      if(y==0)
      { int z=((a-b)/2);
          cout<<(b+z);
      }
      else{
        cout<<"IMPOSSIBLE";
      }
  }
  if(b>a)
  {
      y=((b-a)%2);
      if(y==0)
      { int z=((b-a)/2);
          cout<<(a+z);
      }
      else{
        cout<<"IMPOSSIBLE";
      }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s[n];
    for (int i=0; i<n; i++) cin >> s[i];
    int m;
    cin >> m;
    string t[m];
    for (int i=0; i<m; i++) cin >> t[i];
    map<string, int> blue;
    for (int i=0; i<n; i++) {
        blue[s[i]]++;
    }
    map<string, int> red;
    for (int i=0; i<m; i++) {
        red[t[i]]++;
    }
    int max_point = 0;
    for (auto itr = blue.begin(); itr != blue.end(); ++itr) {
        int tmp_point = itr->second - red[itr->first];
        if (max_point < tmp_point) max_point = tmp_point;
    }

    cout << max_point << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split(" "))
dif = 0
plus = 0

gcd = c
t = d
while t:
    gcd, t = t, gcd % t

lcm = c * d // gcd
e = b + 1 - a

dif += b // c - (a - 1) // c
dif += b // d - (a - 1) // d
plus += b // lcm - (a -1) // lcm

print(e - dif + plus)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    vector<long long> A(N),B(N);
    vector<pair<long long,long long>> P(N);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
        P[i] = make_pair(B[i],A[i]);
    }
    sort(P.begin(),P.end());
    
    long long Time = 0;
    bool flag = true;
    for(int i = 0; i < N; i++){
        Time += P[i].second;
        if(P[i].first < Time){
            flag = false;
            cout << "No" << endl;
            break;
        }
        //cout << Time << endl;
        //Time += A[i];
    }
    if(flag == true) cout << "Yes" << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define tag "spoj"
#define maxn 10007
#define oo 2000000007
#define meset(a,x) memset(a,x,sizeof(a))
#define loop(x) for(int LoOpEr=x;LoOpEr-->0;)
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int main()
{
    #ifdef dmdd
    freopen(tag".inp","r",stdin); freopen(tag".out","w",stdout);
    #endif // dmdd
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin>>n;
    vector<int> a(n+1),b(n+1);

    long long s[2]={0,0};
    for(int i=1;i<=n;i++)
        cin>>a[i],s[i%2]+=2*a[i];

    b[1]=(s[1]-s[0])/2;

    cout<<b[1];
    for(int i=2;i<=n;i++) cout<<' '<<(b[i]=2*a[i-1]-b[i-1]);
    return 0;
}


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

int nums[102];

int main() {
  int x, n;
  cin >> x >> n;
  for (int i = 0; i < n; ++i) {
    int y;
    cin >> y;
    nums[y] = 1;
  }

  if (nums[x] == 0) {
    cout << x << endl;
    return 0;
  }

  int i = 0;
  while (true) {
    ++i;
    if (nums[x - i] == 0) {
      cout << x - i << endl;
      break;
    } else if (nums[x + i] == 0) {
      cout << x + i << endl;
      break;
    }
  }
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>

#define ll long long
using namespace std;

int main() {
    ll n, s;
    cin >> n >> s;
    if (n < s)cout << -1 << endl;
    else if (n == s)cout << s + 1 << endl;
    else {
        bool found = false;
        for (ll i = 2; i * i <= n; i++) {
            ll sum = 0;
            ll x = n;
            while (x > 0) {
                sum += x % i;
                x /= i;
            }
            if (sum == s) {
                found = true;
                cout << i << endl;
                break;
            }
        }

        if (!found) {
            for (ll i = sqrt(n - 1); i >= 1; i--) {
                if ((n - s) % i == 0) {
                    ll p = (n - s) / i + 1;
                    ll sum = 0;
                    ll x = n;
                    while (x > 0) {
                        sum += x % p;
                        x /= p;
                    }
                    if (sum == s) {
                        found = true;
                        cout << p << endl;
                        break;
                    }
                }
            }
        }

        if (!found) cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n<3) printf("0\n");
	else printf("%d\n",n/3);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 1000000000

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

template<class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int N, M;
int a[1100];
int b[1100];
int c[1100][20];

int main () {
  cin >> N >> M;
  Rep(i, M) {
    cin >> a[i] >> b[i];
    Rep(j, b[i]) {
      cin >> c[i][j];
    }
  }

  vector<int> dp(5000, INF);
  dp[0] = 0; 

  Rep(i, M) {
    int curr = 0;
    Rep(j, b[i]) {
      curr |= 1 << (c[i][j] - 1);
    }

    Rep(bits, 1 << N) {
      chmin(dp[bits | curr], dp[bits] + a[i]);
    }
  }

  cout << ((dp[(1 << N) - 1] == INF) ? -1 : dp[(1 << N) - 1]) << "\n";
}

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

int main() {
  int S,h,m,s,A,B;

  std::cin >> S;

  A = S % 3600;
  B = A % 60;

  h = (S - A) / 3600;
  m = (A - B) / 60;
  s = B;

  std::cout << h << ":" << m << ":" << s << '\n';
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<P> A(N);
    vector<ll> B(N);
    vector<ll> C(N);

    REP(i, N){
        cin >> A[i].first >> A[i].second;
        B[i] = A[i].first - A[i].second;
        C[i] = A[i].first + A[i].second;
    }

    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    cout << max(B[N-1]-B[0], C[N-1]-C[0]) << endl; 
    
    return 0;
}

Measured memory_bytes: 9532
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B, K; cin >> A >> B >> K;
    vector<int> cnt;
    for (int i = 1; i <= 100; ++i) if (A % i == 0 && B % i == 0) cnt.push_back(i);
    printf("%d\n", cnt[cnt.size() - K]);
}


Measured memory_bytes: 3696
n, m = list(map(int, input().split()))

redball = [0]*n
redball[0] = 1
ball_cnt = [1]*n

for _ in range(m):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1

    if ball_cnt[x] == 1 and redball[x]:
        redball[x] = 0
        redball[y] = 1

    if ball_cnt[x] > 1 and redball[x]:
        redball[y] = 1

    ball_cnt[x] -= 1
    ball_cnt[y] += 1

print(redball.count(1))


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

int main(){
    string s;
    ll q;
    cin >> s >> q;
    ll nrev = 0;
    ll fro=500000, bck=500001;
    char ans[1000010];
    fro -= s.size()/2;
    bck += (s.size()+1)/2;
    rep(i, fro+1, bck) ans[i] = s[i-fro-1];
    rep(i, 0, q){
        int t;
        cin >> t;
        if(t == 1){
            nrev++;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(nrev%2 == 0){
                if(f == 1){
                    ans[fro] = c;
                    fro--;
                }else{
                    ans[bck] = c;
                    bck++;
                }
            }else{
                if(f == 1){
                    ans[bck] = c;
                    bck++;
                }else{
                    ans[fro] = c;
                    fro--;
                }
            }
        }
    }
    
    if(nrev % 2 == 0){
        rep(i, fro+1, bck){
            cout << ans[i];
        }
    }else{
        for(ll i = bck-1; i > fro; i--){
            cout << ans[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N * 3; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::sort(std::begin(A), std::end(A),
              [](const auto& a, const auto& b) {
                  return a > b;
              });

    int64_t sum = 0;
    for (int64_t i = 0; i < N; ++i) {
        sum += A[i*2+1];
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 6256