akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define erep(i,n) for (int i = 0; i <= (n); ++i)
#define brep(i,n) for (int i = n; i >= 0; i--)
#define PI 3.14159265359
using namespace std;
using P = pair<int,int>;
using ll = long long;
using Graph = vector<vector<int> > ;
const int INF = 100005;
const int MAX_K = 55;
const int MAX_W = 200005; 

int dp[205][205];

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;
    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> ans(N);

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            ans[nv] = v;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    bool ok = true;
    rep(i,N){
        if(dist[i] == -1) ok = false;
    }

    if(ok){
        cout << "Yes" << endl;
        for(int i=1;i<N;i++){
            cout << ans[i]+1 << endl; 
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 10648
x1, y1, x2, y2 = map(int, input().split())

x3 = y1 - y2 + x2
y3 = x2 - x1 + y2

x4 = y1 - y2 + x1
y4 = x2 - x1 + y1

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);
//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		String S=sc.next();
		if(S.equals("SUN")) {
			p(7);
		}else if(S.equals("MON")) {
			p(6);
	}else if(S.equals("TUE")) {
		p(5);
	}else if(S.equals("WED")) {
		p(4);
	}else if(S.equals("THU")) {
		p(3);
	}else if(S.equals("FRI")) {
		p(2);
	}else if(S.equals("SAT")) {
		p(1);
	}
		}	
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,m,r;cin >> n >>m >>r;
    vl v(r);rep(i,r){cin >> v[i];v[i]--;}sort(all(v));
    vvl dist(n,vl(n,inf));
    rep(i,m){
        ll a,b,c;cin >>a >>b >>c;a--;b--;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    rep(i,n)dist[i][i]=0;
    rep(k,n)rep(i,n)rep(j,n)chmin(dist[i][j],dist[i][k]+dist[k][j]);
    ll ans=inf;
    do{
        ll tmp=0;
        rep(i,v.size()-1){
            tmp+=dist[v[i]][v[i+1]];
        }
        chmin(ans,tmp);
    }while(next_permutation(all(v)));
    cout <<ans <<endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val n = br.readLine().toInt()
    val node = mutableListOf<Triple<Int, Int, Int>>()
    node.add(Triple(0, 0, 0))
    for (i in 1..n) {
        val d = br.readLine().split(' ')
                .map { it.toInt() }
        node.add(Triple(d[0], d[1], d[2]))
    }
    println(if (judge(node, 1, node.size - 1)) "Yes" else "No"
    )
}

fun judge(node: List<Triple<Int, Int, Int>>, index: Int, limit: Int): Boolean {
    val current = node[index]
    val pre = node[index - 1]
    val step = current.first - pre.first
    val x = current.second - pre.second
    val y = current.third - pre.third
    val move = Math.abs(x) + Math.abs(y)
    if (move > step) {
        return false
    }
    return (move - step) % 2 == 0 && if (index < limit) judge(node, index + 1, limit) else true
}

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 63628
str = STDIN.read
count = {}
str.size.times do |i|
  c = str[i].downcase
  unless count.key?(c)
    count[c] = 0
  end
  count[c] += 1
end
("a".."z").each do |c|
  puts "#{c} : #{count[c] || 0}"
end

Measured memory_bytes: 8704
#include<iostream>
using namespace std;
int main(){
int n,m;
cin >>n>>m;
int a[100][100];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) cin>>a[i][j];
int b[100];
for(int i=0;i<m;i++) cin>>b[i];
int c[100] ={};
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) c[i] +=a[i][j] * b[j];
for(int i=0;i<n;i++) cout<<c[i]<<endl;
return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    int cnt=0;
    for(int i=0;i<3;++i)
    {
        if(s[i]=='R')
        {
            int ans=1;
            for(int j=i+1;j<3;++j)
            {
                if(s[j]=='R') 
                {
                    ans++;
                    continue;
                }
                break;
            }
            cnt=max(cnt,ans);
        }
    }
    cout<<cnt<<endl;
    return 0;   
}

Measured memory_bytes: 3564
def main():
    N = int(input())
    H = list(map(int, input().split(' ')))
    move_cnt = 0
    max_move_cnt = 0
    left_h = 0
    for h in H:
        if left_h >= h:
            move_cnt += 1
        else:
            if move_cnt > max_move_cnt:
                max_move_cnt = move_cnt
            move_cnt = 0
        left_h = h
    if move_cnt > max_move_cnt:
        max_move_cnt = move_cnt
    print(max_move_cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}


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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 200002
#define MOD 1000000007

const ll INF = ll(1e18);

inline int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

inline int sub(int a, int b) {
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

inline int mult(int a, int b) {
	return (1LL * a * b) % MOD;
}

inline int power(int a, ll b) {
	int r = 1;
	while(b) {
		if (b & 1) r = mult(r, a);
		a = mult(a, a);
		b >>= 1;
	}
	return r;
}

int n, m, S, T;
vector < pair<int, int> > g[MAXN];
priority_queue < pair<ll, int> > q;
ll d1[MAXN];
ll d2[MAXN];
int f1[MAXN];
int f2[MAXN];

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d%d", &n, &m);
	scanf("%d%d", &S, &T);
	--S, --T;

	for (int i = 0; i < m; ++i) {
		int v1, v2, cost;
		scanf("%d%d%d", &v1, &v2, &cost);
		--v1, --v2;
		g[v1].pb({v2, cost});
		g[v2].pb({v1, cost});
	}

	for (int i = 0; i < n; ++i)
		d1[i] = INF;
	d1[S] = 0;
	f1[S] = 1;
	q.push({0, S});
	while(!q.empty()) {
		ll dist = -q.top().f;
		int v = q.top().s;
		q.pop();
		if (d1[v] != dist) continue;
		for (const auto& t : g[v]) {
			int v2 = t.f;
			int cost = t.s;
			if (d1[v2] > d1[v] + cost) {
				d1[v2] = d1[v] + cost;
            f1[v2] = 0;
				q.push({-d1[v2], v2});
			}
			if (d1[v2] == d1[v] + cost) {
            f1[v2] = add(f1[v], f1[v2]);
			}
		}
	}

	for (int i = 0; i < n; ++i)
		d2[i] = INF;
	d2[T] = 0;
	f2[T] = 1;
	q.push({0, T});
	while(!q.empty()) {
		ll dist = -q.top().f;
		int v = q.top().s;
		q.pop();
		if (d2[v] != dist) continue;
		for (const auto& t : g[v]) {
			int v2 = t.f;
			int cost = t.s;
			if (d2[v2] > d2[v] + cost) {
				d2[v2] = d2[v] + cost;
            f2[v2] = 0;
				q.push({-d2[v2], v2});
			}
			if (d2[v2] == d2[v] + cost) {
            f2[v2] = add(f2[v2], f2[v]);
			}
		}
	}

	int ans = mult(f1[T], f2[S]);
	ll D = d1[T];
	for (int i = 0; i < n; ++i) {
		if (D == d1[i] + d2[i] && d1[i] == d2[i]) {
			ans = sub(ans, mult(mult(f1[i], f1[i]), mult(f2[i], f2[i])));
		}
		for (const auto& t : g[i]) {
			int v2 = t.f;
			int cost = t.s;
			if (D == d1[i] + d2[v2] + cost && (d1[i] + cost) * 2 > D && (d2[v2] + cost) * 2 > D) {
				ans = sub(ans, mult(mult(f1[i], f1[i]), mult(f2[v2], f2[v2])));
			}
		}
	}
	printf("%d\n", ans);
	      
	return 0;
}


Measured memory_bytes: 16368
/*
 * atcoder/dp_3rd/k.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100100;
ll N, K, min_ = 100100;
vector<ll> A;

// dp[0][i] := 先手が残りiで必勝か
bool dp[MAX] = {0};

void input() {
  cin >> N >> K;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
    chmin(min_, a);
  }
}

void solve() {
  for (int n=0; n<=K; n++) {
    for (auto &&a: A) {
      if (n+a<=K) dp[n+a] |= !dp[n];
    }
  }

  if (dp[K]) cout << "First" << endl;
  else cout << "Second" << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		int count = 0;
		String l = "";
		String r = "";
		if(s.length() % 2 == 0) {
			l = s.substring(0, s.length()/2);
			r = s.substring(s.length()/2, s.length());// eraser
		}else {
			l = s.substring(0, s.length()/2);
			r = s.substring(s.length()/2+1, s.length()); // dream

		}
		StringBuffer sb = new StringBuffer(r);
		r = sb.reverse().toString();
		for(int i = 0; i < l.length(); i++) {
			if(l.charAt(i) != r.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 23380
N = int(input())
lis = []
for i in range(N):
    lis.append(tuple(map(int, input().split())))
if N == 1:
    print(1)
    exit()

dic = {}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        val = (lis[i][0]-lis[j][0], lis[i][1]-lis[j][1])
        if val in dic:
            dic[val] += 1
        else:
            dic[val] = 1
#print(dic)
print(N-max(dic.values()))


Measured memory_bytes: 80032
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int H, W,N = 0;
	cin >> H >> W;
	vector<string> v(H);
	for (int i = 0; i < H; i++) {
		cin >> v[i];
	}
	for (string i : v) { for (char j : i) { if (j == '#')N++; } }
	queue<pair<pair<int,int>,int>> q;
	q.push({ {0,0},1 });
	while (!q.empty()) {
		pair<pair<int, int>, int> pos = q.front(); q.pop();
		if (pos == make_pair(make_pair(H - 1, W - 1),N)) {
			cout << "Possible" << endl;
			return 0;
		}
		if (pos.first.second != W - 1)
			if (v[pos.first.first][pos.first.second + 1] == '#')
				q.push({ {pos.first.first,pos.first.second + 1},pos.second+1 });
		if (pos.first.first != H - 1)
			if (v[pos.first.first + 1][pos.first.second] == '#')
				q.push({ {pos.first.first + 1,pos.first.second},pos.second+1 });
	}
	cout << "Impossible" << endl;
	return 0;
}


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

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; }
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

string S;
int Q;

// *********************************************************


int main(){

    cin >> S;
    cin >> Q;

    deque<char> deq;
    for(auto tmp: S){
        deq.emplace_back(tmp);
    }

    int q,f;
    char c;
    bool flag=true;
    for(int i=0; i<Q; ++i){
        cin >> q;
        if(q==1){
            flag = !flag;
        }else{
            cin >> f >> c;
            if(flag){//反転偶数回なのでそのまま演算
                if(f==1){
                    deq.push_front(c);
                }else{
                    deq.push_back(c);
                }
            }else{//反転奇数回なので逆に演算
                if(f==1){
                    deq.push_back(c);
                }else{
                    deq.push_front(c);
                }
            }

        }

    }
    if(!flag){
        reverse(deq.begin(), deq.end());
    }
    string ans;
    for(auto tmp : deq) ans.push_back(tmp);
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 1412
#include<stdio.h>
int main()
{
    int k, a, b, check;
    scanf("%d%d%d", &k, &a, &b);
    if(a-b<k){
        for(int i=a; i<=b; i++){
            if(i%k==0){
                printf("OK\n");
                return 0;
            }
        }
        printf("NG\n");
    }
    else{
        printf("OK\n");
    }
    return 0;
}

Measured memory_bytes: 1608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int A[N], B[N];
  FOR(i,0,N) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B, B + N);
  map<int, bool> MAP;
  FOR(i,0,N) MAP[B[i]] = i & 1;
  int ans = 0;
  FOR(i,0,N) {
    if(MAP[A[i]] != (i & 1)) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
using namespace std;
int a[11];
int a1[11];
int pn=0;
int Flag;
void dfs(int i)
{
    if(Flag==1)
        return;

    if(a[i]>a[a1[pn]])
    {
        a1[++pn]=i;
        for(int m=i+1;m<=10;m++)
        {
            dfs(m);
        }
    }
    else
        return;
    int flag=0;
    for(int m=i+1;m<=10;m++)
    {
        if(a[m]>a[i])
            flag=1;
    }
    int flag2;
    if(flag==0||i==10)
    {
        int a2[11];
        int pm=0;
        for(int n=1;n<=10;n++)
        {
            flag2=0;
            for(int m=1;m<=pn;m++)
            {
                if(n==a1[m])
                   flag2=1;
            }
            if(!flag2)
            {
               a2[++pm]=n;
            }
        }
        int flag3=0;
        for(int m=1;m<pm;m++)
        {
            if(a[a2[m]]>a[a2[m+1]])
                flag3=1;
        }
        if(flag3==0)
        {
            Flag=1;
            return;
        }
        else
        {
            pn--;
            return;
        }
    }

}
int main()
{
    int n;
    
    scanf("%d",&n);
    getchar();
    a[0]=-1;
    a1[0]=0;
    for(int i=1;i<=n;i++)
    {
        Flag=0;
        pn=0;
        for(int j=1;j<=10;j++)
        {
            scanf("%d ",&a[j]);
        }
        dfs(1);
        if(Flag==0)
        {
            printf("NO\n");
        }
        else
            printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 3084
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

# def seive():
#     prime=[1 for i in range(10**6+1)]
#     prime[0]=0
#     prime[1]=0
#     for i in range(10**6+1):
#         if(prime[i]):
#             for j in range(2*i,10**6+1,i):
#                 prime[j]=0


n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=0
    ans=ans+1
  elif a[i-1]<a[i] and temp==2:
    temp=0
    ans=ans+1
print(ans)

Measured memory_bytes: 16304
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成


    ans=10**18
    for i in range(1, N):
        ans = min(abs(B[i]-(zenbu-B[i])),ans)
    print(ans)

resolve()

Measured memory_bytes: 93416
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, t; cin >> n >> t;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];

    vector<ll> r(n);
    iota(ALL_OF(r), 0LL);
    sort(ALL_OF(r), [&](ll i, ll j) {
        return a[i] < a[j];
    });
    
    vector<vector<ll>> dp(n+1, vector<ll>(t, 0));
    REP(_i, n) { ll i = r[_i];
        REP(w, t) {
            if (0 <= w - a[i]) {
                // 食べるかもしれない
                dp[_i+1][w] = max(dp[_i][w], dp[_i][w - a[i]] + b[i]);
            } else {
                // 食べ(られ)ない
                dp[_i+1][w] = dp[_i][w];
            }
        }
    }
    
    ll ans = 0;
    REP(_i, n) { ll i = r[_i];
        chmax(ans, b[i] + *max_element(ALL_OF(dp[_i])));
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 70784
<?php

$n = trim(fgets(STDIN));
$f = floor($n/4);

$ans = "No";
for($i=0; $i<$f; $i++){
  $l = $n-$i*4;
  if ($l%7==0 || $l%4==0) {
    $ans = "Yes";
    break;
  }
}

echo $ans;

?>

Measured memory_bytes: 4604
N, M, K = map(int, input().split())
friend = [[] for _ in range(N+1)]
block = [[] for _ in range(N+1)]

for i in range(M):
  A,B = map(int, input().split())
  friend[A].append(B)
  friend[B].append(A)

for i in range(K):
  C,D = map(int, input().split())
  block[C].append(D)
  block[D].append(C)
#print(friend)
#print(block)

#import queue
grouping = [False]*(N+1)
#print(grouping)
grouping[0] = True
group = [0]*(N+1)
g_num = 0
g_cnt = []
for i in range(1,N+1):
  cnt = 0
  if grouping[i] == True:
    continue 
  group[i] = g_num
  grouping[i] = True
  #q = queue.Queue()
  #q.put(i)
  stack = [i]
  #while not q.empty():
  while len(stack)>0:
    #print('v:',visited)
    #p = q.get()
    p = stack.pop()
    for f in friend[p]:
      #print(p,f)
      if grouping[f]==False:
        #q.put(f)
        stack.append(f)
        group[f]=g_num
        grouping[f] =True
        cnt += 1
  g_num += 1
  g_cnt.append(cnt)
  #print('g:',grouping)
ans = []
for i in range(1,N+1):
  c = g_cnt[group[i]]-len(friend[i])
  for b in block[i]:
    if group[b]==group[i]:
      c -= 1
  ans.append(c)
print(*ans)


Measured memory_bytes: 49328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll LIM = 1e8;

int dfs(int N, int x, bool u7, bool u5, bool u3) {
    int ct = 0;
    if ( x <= N && u7 && u5 && u3 ) ct++;
    if ( x < LIM ) {
        ct += dfs(N, 10*x+7, true, u5, u3);
        ct += dfs(N, 10*x+5, u7, true, u3);
        ct += dfs(N, 10*x+3, u7, u5, true);
    }
    return ct;
}

int main() {
    int N;
    cin >> N;
    
    ll ans = dfs(N, 0, false, false, false);
    cout << ans << '\n';
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int main(){
    int n, t;
    scanf("%d%d", &n, &t);
    ll ans = 0, last = 0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d", &x);
        if(last >= x) ans += (x+t)-last;
        else ans += t;
        last = x+t;
    }   
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[100005];
ll sum[200005];

int main(void){
	scanf("%d",&n);
	ll all=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		all+=a[i];
	}
	for(int i=0;i<n*2;i++){
		sum[i+2]+=sum[i];
		sum[i+2]+=a[i%n];
		//printf("%lld\n",sum[i]);
	}
	for(int i=0;i<=n*2;i++){
		//printf("%lld\n",sum[i]);
	}
	all/=2LL;
	for(int i=0;i<n;i++){
		ll val=sum[i+((n+1)/2)*2]-sum[i];
		printf("%lld%c",(val-all)*2LL,i+1==n?'\n':' ');
	}
	return 0;
}


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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  
  long long ans=1;
  ans*=count(s.begin(),s.end(),'R');
  ans*=count(s.begin(),s.end(),'G');
  ans*=count(s.begin(),s.end(),'B');
  
  for (int i=1; i<=(n-1)/2; i++){
    for (int j=0; j<=n-i*2-1; j++){
      if (s[j]!=s[j+i] && s[j+i]!=s[j+2*i] && s[j+2*i]!=s[j]){
        ans-=1;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(void) {
	int D; cin >> D;

	if (D == 25) {
		cout << "Christmas" << endl;
	}
	else if (D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else { cout << "Christmas Eve Eve Eve" << endl; }
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int a=sc.nextInt();
    if(x<a){
      System.out.println(0);
    }if(x>=a){
      System.out.println(10);
    }
  }
}


Measured memory_bytes: 21844
#include <stdio.h>

void compare_profit(int r[], int n) {
  int max = r[1] - r[0];
  int min_r = r[0];

  for (int i = 1; i <= n - 1; i++) {
    if (r[i] - min_r > max) {
      max = r[i] - min_r;
    }
    if (min_r > r[i]) {
      min_r = r[i];
    }
  }
  printf("%d\n", max);
}

int main() {
  int n;
  scanf("%d", &n);
  int r[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &r[i]);
  }
  compare_profit(r, n);

  return 0;
}



Measured memory_bytes: 2584
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll n,k;
    cin>>n>>k;
    ll ans;
    ans = min(n%k,abs((n%k)-k));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<string>

#define maxn 1000005
#define INF 0x3f3f3f3f

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int N=128,C=62,n;
vector<string>S;

inline bool cmp(string x,string y)
{return x.size()<y.size();}
inline char id(int x)
{
	if(x<26)return x+65;
	if(x<52)return x+71;
	return x-4;
}
inline int query(string x)
{
	cout<<"? "<<x<<endl;
	return getint();
}
inline bool check(string x)
{return query(x)+x.size()==n;}

int main()
{
	for(int i=0;i<C;i++)
	{
		string x(N,id(i));
		int tmp=N-query(x);
		n+=tmp;if(tmp)S.push_back(string(tmp,id(i)));
	}
	while(S.size()>1)
	{
		sort(S.begin(),S.end(),cmp);
		string a=S[0],b=S[1],res;
		S.erase(S.begin()),S.erase(S.begin());
		while(a.size()&&b.size())
			if(check(res+a[0]+b))res+=a[0],a.erase(a.begin());
			else res+=b[0],b.erase(b.begin());
		res+=a,res+=b;
		S.push_back(res);
	}
	cout<<"! "<<S[0]<<endl;
}

Measured memory_bytes: 3800
import sys

def h1(key):
    return key % M

def h2(key):
    return 1 + key % (M - 1)

def H(key, i):
    return (h1(key) + i * h2(key)) % M

def my_insert(dic, key):
    i = 0

    while 1:
        j = H(key, i)
        if dic[j] is None:
            dic[j] = key
            return j
        else:
            i += 1

def my_search(dic, key):
    i = 0

    while 1:
        j = H(key, i)
        if dic[j] == key:
            return True
        elif dic[j] is None or i >= M:
            return False
        else:
            i += 1

def str2int(s):
    res = s

    res = res.replace("A", "1")
    res = res.replace("C", "2")
    res = res.replace("G", "3")
    res = res.replace("T", "4")

    return int(res)

M = 1000003
dic = [None] * M

n = int(sys.stdin.readline())

for k in range(n):
    cmd, s = sys.stdin.readline().split()

    if cmd == "insert":
        my_insert(dic, str2int(s))
    else:
        print("yes" if my_search(dic, str2int(s)) else "no")

Measured memory_bytes: 34044
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e18+1;


/*
市松始点のバリエーション
(0,0) ~ (0,2K-1)
 ~          ~
(2K-1,0) ~ (2K-1,2K-1)

黒ならxだけに+Kして
2Kで剰余を取る

すると同時にいくつの(0~2K-1)内N個の点を白に染められるか

結局、正方形内に入れられる点の最大値となるのではないか


(u,v)を始点にしたとき、
白マス...((x-u)/K + (y-v)/K) % 2 == 0
黒    ...((x-u)/K + (y-v)/K) % 2 == 1

xi,yiが白であることを可能にする始点
u = (xi/K + 0...K-1) % K
v = (xi/K + 0...K-1) % K と

u = (xi/K + 0...K-1) % K+K
v = (xi/K + 0...K-1) % K+K
*/
char rev(char a) {
    if (a == 'W') return 'B';
    return 'W';
}

int main() {
    int N,K; cin >> N >> K;
    vector<int> x(N), y(N);
    vector<vector<int> > B(K, vector<int>(K, 0));
    vector<vector<int> > W(K, vector<int>(K, 0));
    vector<vector<int> > SB(K+1, vector<int>(K+1, 0));
    vector<vector<int> > SW(K+1, vector<int>(K+1, 0));
    int black = 0, white = 0;
    for (int i = 0; i < N; i++) {
        char tmp;
        cin >> x[i] >> y[i] >> tmp;
        int tx = x[i] % (2*K),ty = y[i] % (2*K);
        if (tx >= K && ty >= K) {tx -= K; ty -= K;}
        if (tx >= K) {
            tx -= K; tmp = rev(tmp);
        }
        if (ty >= K) {
            ty -= K; tmp = rev(tmp);
        }
        if (tmp == 'B') {
            black++;
            B[tx][ty]++;
        } else {
            white++;
            W[tx][ty]++;
        }
    }
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; ++j) {
            SW[i+1][j+1] = SW[i][j+1] + SW[i+1][j] - SW[i][j] + W[i][j];
            SB[i+1][j+1] = SB[i][j+1] + SB[i+1][j] - SB[i][j] + B[i][j];
        }
    }

    int res = -1;
    
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            int w = SW[K][K]-SW[i][K]-SW[K][j]+2*SW[i][j];
            int b = SB[K][K]-SB[i][K]-SB[K][j]+2*SB[i][j];
            chmax(res, w+black-b);
            chmax(res, b+white-w);
        }
    }

    cout << res << endl;




}



Measured memory_bytes: 16768
#include <stdio.h>
 int main(void)
{
	int i;
	int a[26] = {0};
	char x[1201];
	
	while ( scanf("%s", x) != EOF){
		for (i=0; x[i]!='\0'; i++) {
			if ('a'<=x[i] && x[i]<='z') {
				a[x[i]-'a']++;  
				}
				if ('A'<=x[i] && x[i]<='Z') {
					a[x[i]-'A']++; 
				}
			}
		}
    
    for(i=0; i<26; i++){
        printf("%c : %d\n", i+'a', a[i]);  
    }
    
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> t(n);
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> t[i] >> a[i];
	}
	
	long long aoki = a[0];
	long long takahashi = t[0];
	for(int i = 1; i < n; i++)
	{
		if(a[i] != t[i])
		{
			if(aoki > a[i])
			{
				if(aoki % a[i] != 0)
				{
					aoki = ((aoki / a[i]) + 1) * a[i];
				}
			}
			else
			{
				aoki = a[i];
			}
			
			if(takahashi > t[i])
			{
				if(takahashi % t[i] != 0)
				{
					takahashi = ((takahashi / t[i]) + 1) * t[i];
				}
			}
			else
			{
				takahashi = t[i];
			}
			
			if(takahashi / t[i] > aoki / a[i])
			{
				aoki = (takahashi / t[i]) * a[i];
			}
			else if(takahashi / t[i] < aoki / a[i])
			{
				takahashi = (aoki / a[i]) * t[i];
			}
		}
		else
		{
			takahashi = takahashi > aoki ? takahashi : aoki;
			aoki = takahashi;
		}
		
	
	}
	
	cout << aoki + takahashi << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a,b,h,m = map(int ,input().split())
deg = 2*math.pi*abs((h+m/60)/12-m/60)
if deg > math.pi:
    deg = 2*math.pi-deg
c = abs((a**2+b**2-2*a*b*math.cos(deg))**0.5)
print(c)

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

int main() {
    char c[202020];
    scanf("%s", c);
    int sz = strlen(c);
    int sum = 0;
    int i;
    for (i = 0; i < sz; ++i) sum += (c[i] - '0');
    if (sum % 9) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 1848
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    S = lr()
    T = lr()
    U = lr()
    V = lr()
    # d = [[-1]*N for i in range(N)]
    # def flip():
    #     for i in range(N):
    #         for j in range(i):
    #             d[i][j], d[j][i] = d[j][i], d[i][j]
    a = [[0]*N for i in range(N)]
    for k in range(64):
        val = [[bool(U[i]&(1<<k)), bool(V[i]&(1<<k))] for i in range(N)]
        d = [[-1]*N for i in range(N)]
        # for b in range(2):
        for i in range(N):
            x = val[i][0]
            if S[i] != x:
                for j in range(N):
                    if d[i][j] != x and d[i][j] != -1:
                        print(-1)
                        return
                    d[i][j] = x
        for j in range(N):
            x = val[j][1]
            if T[j] != x:
                for i in range(N):
                    if d[i][j] != x and d[i][j] != -1:
                        print(-1)
                        return
                    d[i][j] = x
            # flip()
        for _ in range(2):
            # for b in range(2):
            for i in range(N):
                x = val[i][0]
                if S[i] == x:
                    p = []
                    ok = False
                    for j in range(N):
                        if d[i][j] == -1:
                            p.append(j)
                        if d[i][j] == x:
                            ok = True
                    if ok:
                        continue
                    if len(p) == 0:
                        print(-1)
                        return
                    if len(p) == 1:
                        d[i][p[0]] = x
            for j in range(N):
                x = val[j][1]
                if T[j] == x:
                    p = []
                    ok = False
                    for i in range(N):
                        if d[i][j] == -1:
                            p.append(i)
                        if d[i][j] == x:
                            ok = True
                    if ok:
                        continue
                    if len(p) == 0:
                        print(-1)
                        return
                    if len(p) == 1:
                        d[p[0]][j] = x
                # flip()
        ni = []
        nj = []
        for i in range(N):
            filled = True
            for j in range(N):
                if d[i][j] == -1:
                    filled = False
                    break
            if not filled:
                ni.append(i)
        for j in range(N):
            filled = True
            for i in range(N):
                if d[i][j] == -1:
                    filled = False
                    break
            if not filled:
                nj.append(j)
        for i, ii in enumerate(ni):
            for j, jj in enumerate(nj):
                d[ii][jj] = (i+j)%2
        for i in range(N):
            for j in range(N):
                a[i][j] |= d[i][j]<<k
    for i in range(N):
        print(*a[i], sep=' ')
resolve()

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

using P = pair<int,int>;

struct RUQ{
	int n,seg,init,now;
	vector<P> dat;
	RUQ(int n,int init) : n(n),init(init),seg(1),now(0){
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = 0;i < seg * 2 - 1;i++) dat[i] = P(-1,init);
	}
	void update(int a,int b,int x,int tim,int k = 0,int l = 0,int r = -1){
		if(r == -1) r = seg;
		if(r <= a || b <= l) return;
		if(a <= l && r <= b){
			dat[k] = P(tim,x);
			return;
		}
		update(a,b,x,tim,k * 2 + 1,l,(l + r) / 2);
		update(a,b,x,tim,k * 2 + 2,(l + r) / 2,r);
	}
	void update(int a,int b,int x){
		update(a,b,x,now++);
	}
	P get(int i){
		i += seg - 1;
		P ret = dat[i];
		while(i){
			i = (i - 1) / 2;
			ret = max(ret,dat[i]);
		}
		return ret;
	}
};

signed main(){
	int n,q;
	cin >> n >> q;
	RUQ ruq(n,(1ll << 31) - 1);
	for(int i = 0;i < q;i++){
		int t;
		cin >> t;
		if(!t){
			int a,b,x;
			cin >> a >> b >> x;
			ruq.update(a,b + 1,x);
		}
		else{
			int x;
			cin >> x;
			cout << ruq.get(x).second << endl;
		}
	}
}


Measured memory_bytes: 4960
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
////@formatter:on
//endregion


int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    make(int, n);
    int cnt = 1, ans = 0;
    while(n > 0){
        ans += cnt;
        cnt *= 2;
        n /= 2;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <vector>
#include <cstdlib>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 200000+5
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
    f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
string s;
int q;
bool flag=0;
char pre[DMAX],suf[DMAX];
int pcnt,scnt;
int main(){
    cin>>s;
    read(q);
    int ope,f;
    char c;
    while(q--){
        read(ope);
        if(ope==1){
            flag^=1;
        }
        if(ope==2){
            read(f);
            cin>>c;
            if(f==1){
                if(!flag){
                    pre[++pcnt]=c;
                }
                else{
                    suf[++scnt]=c;
                }
            }
            if(f==2){
                if(!flag){
                    suf[++scnt]=c;
                }
                else{
                    pre[++pcnt]=c;
                }
            }
        }
    }
    if(flag){
        for(int i=scnt;i>=1;i--){
            printf("%c", suf[i]);
        }
        for(int i=s.size()-1;i>=0;i--){
            cout<<s[i];
        }
        for(int i=1;i<=pcnt;i++){
            printf("%c", pre[i]);
        }
        printf("\n");
    }
    else{
        for(int i=pcnt;i>=1;i--){
            printf("%c", pre[i]);
        }
        cout<<s;
        for(int i=1;i<=scnt;i++){
            printf("%c", suf[i]);
        }
        printf("\n");
    }
    
    return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  int n = s.size();

  int ans = 0;
  for(int i=0; i<n; i++) {
    if(s[i]!=t[i]) ans++;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3916
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define mod 2019

int main(void)
{
	int l, r;
	scanf("%d %d", &l, &r);

	int ans, r_rm, l_rm;
	r_rm = r % mod;
	l_rm = l % mod;
	ans = 2020;
	if (r - l >= 2019 || r_rm - l_rm < 0)	ans = 0;
	else {
		int i, j;
		for (i = l_rm ; i < r_rm; i++)
		{
			for (j = l_rm + 1; j <= r_rm; j++) {
				ans = min(ans, (i * j) % mod);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
a = list()
tmp = [0, 0]

for _ in range(N):
    ai = int(input())
    a.append(ai)
    if ai > tmp[1]:
        tmp[1] = ai
    elif ai > tmp[0]:
        tmp[0] = ai

m = tmp[1]

for ai in a:
    ans = m
    if ai == m:
        ans = tmp[0]
    print(ans)

Measured memory_bytes: 68696
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>M>>H;
    rep(i,10){
        H = H*N;
        H -= M;
        cout << H << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int S=200005,M=1e9+7;
int n,x,y,c,w,m[S],f,s,d,i;
vector<int> G[S];
long long fc[S]={1},iv[S],k,b,a=1;
int main(){
	cin>>n>>x>>y;
	fill(m,m+n,M);
	for(i=0;i<n;i++){
		cin>>c>>w;
		G[--c].push_back(w);
		m[c]=min(m[c],w);
		if(c!=f){
			if(w<m[f]){
				s=f;f=c;
			}else if(w<m[s])s=c;
		}
		fc[i+1]=fc[i]*(i+1)%M;
	}
	for(iv[n]=1,k=M-2,b=fc[n];k;k/=2,(b*=b)%=M)if(k&1)(iv[n]*=b)%=M;
	for(i=n;i>0;i--)iv[i-1]=iv[i]*i%M;
	for(i=0;i<n;i++)if(y-m[f]>=m[i]){
		w=max(y-m[f==i?s:f],x-m[i]);c=0;
		for(int t:G[i])if(t<=w)c++;
		d+=c;
		a=a*fc[d]%M*iv[d-c]%M*iv[c]%M;
	}
	cout<<a;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

int main(){
    int n;
    cin >> n;
    vi p(n), q(n);
    rep(i,n) cin >> p.at(i);
    rep(i,n) cin >> q.at(i);

    vi r(n);
    rep(i,n) r.at(i) = i + 1;
    int P, Q;
    int cnt = 0;
    do {
        cnt++;
        rep(i,n){
            if (p.at(i) != r.at(i)) break;
            if (i == n-1) P = cnt;
        }
        rep(i,n){
            if (q.at(i) != r.at(i)) break;
            if (i == n-1) Q = cnt;
        }
    } while(next_permutation(r.begin(),r.end()));
    int ans = abs(P-Q);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int count = 0;
    int n, d;
    in2(n, d)
    while(n--)
    {
        double x, y;
        in2(x, y)
        if(pow(x*x+y*y, 0.5) <= (double)d) count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 4284