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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
// const int mx = 1e7 + 5;
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mx = 1e5 + 5;
ll freq[mx] = {};

/********************************************************************/
int main() {
	FAST();
	ll x, y;
	cin >> x >> y;
	if (y >= 2 * x && (y - 2 * x) % 2 == 0 && 4 * x >= y && (4 * x - y) % 2 == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int64,int64>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=2e5+5;
int n,top,l;
int64 C;
int64 h[maxn];
pii st[maxn];
int64 f[maxn];
void Input()
{
    cin >> n >> C;
    FOR(i,1,n)
        cin >> h[i];
}
long double Intersection(pii A, pii B)
{
    return 1.0*(B.se-A.se)/(A.fi-B.fi);
}
bool Bad(pii A, pii B, pii C)
{
    return Intersection(A,C)>=Intersection(B,C);
}
void AddLine(pii L)
{
    while (top>1&&Bad(st[top-1],st[top],L)) --top;
    st[++top]=L;
}
int64 GetCost(pii A, int64 x)
{
    return A.fi*x+A.se;
}
int64 GetRes(int64 x)
{
    if (l>top) l=top;
    while (l<top&&GetCost(st[l],x)>GetCost(st[l+1],x)) ++l;
//    int64 res=1e18;
//    FOR(i,1,top) res=min(res,GetCost(st[i],x));
//    return res;
    return GetCost(st[l],x);
}
void Solve()
{
    AddLine(mp(-h[1]*2,h[1]*h[1]+C));
    l=1;
    FOR(i,2,n) {
        f[i]=GetRes(h[i])+h[i]*h[i];
        AddLine(mp(-h[i]*2,f[i]+h[i]*h[i]+C));
    }
    cout << f[n];
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 6528
M = 10**9 + 7
N, A, AB, ABC = 1, 0, 0, 0
idx = {'A': 1, 'B': 2, 'C': 3}
for c in input():
    if c == '?':
        N, A, AB, ABC = (N*3)%M, (A*3+N)%M, (AB*3+A)%M, (ABC*3+AB)%M
    elif c == 'A':
        A = (A+N)%M
    elif c == 'B':
        AB = (AB+A)%M
    else:
        ABC = (ABC+AB)%M
print(ABC)

Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int k = in.nextInt();
            if (b - a < k * 2) {
                for (int i = a; i <= b; i++) {
                    out.println(i);
                }
            } else {
                for (int i = a; i < a + k; i++) {
                    out.println(i);
                }
                for (int i = b - k + 1; i <= b; i++) {
                    out.println(i);
                }
            }
        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    unsigned long long a;
    //double b;
    string b;
    cin >> a >> b;
    char b1=b[0]-'0';
    char b2=b[2]-'0';
    char b3=b[3]-'0';
    //int b2=(int)round(b*10)%10;
    //int b3=(int)round(b*100)%10;
    unsigned long long a2 = a/10;
    unsigned long long a3 = a/100;
    unsigned long long c=a*(b1*100+b2*10+b3)/100;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3612
N, K = map(int, input().split())
A = list(map(int, input().split()))

rireki = [-1 for i in range(N)]
rireki[0] = 0
ima = 0
kuri = 0
start = 0
end = 0
for i in range(K):
  saki = A[ima]
  if rireki[saki - 1] == -1:
    rireki[saki - 1] = i + 1
    ima = saki - 1
  else:
    ima = saki - 1
    kuri = 1
    start = rireki[saki - 1]
    end = i + 1
    break
    
if kuri == 1:
  KK = (K - start) % (end - start)
  for i in range(KK):
    saki = A[ima]
    ima = saki - 1

print(ima+1)

Measured memory_bytes: 32384
import bisect

n = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        k = bisect.bisect_left(L[j+1:], L[i]+L[j])
        count += k

print(count)


Measured memory_bytes: 52272
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
std::set<int> st;
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;


int main(){

    long long sum,sum1;
	sum=0;
	sum1=0;
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	long long max;
	int max1;
	max=0;
	max1=0;
	int min;
	int min1;
	min=INF;
	min1=INF;

	int work1,work2,work3,work4;
	work1=0;
	work2=0;
	work3=0;
	work4=0;
		
	long long N,M,K;
	string s;
    
	//std::cin >> N;
    //std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
	//std::vector<long long> v(N);
	//std::vector<long long> w(N);
    std::cin >> s;
    
    
    // 配列入力
    /*
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	*/
	/*
	for(long long i=0; i<N; i++){
		std::cin >> w[i];
	}
	*/
    
	//通常
	/*
    for(long long i=0; i<N; i++){
		
	}
	*/
	

	//文字列入力
	
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]=='x'){
			cnt++;
		}
		else{
			cnt1++;
		}
	}
	

	
	
	//ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    //std::sort(w.begin(),w.end());//昇順ソート
    //std::sort(w.begin(),w.end(),std::greater<long long>());//降順ソート
    /*
    
    //S.substr(i, 5);
    //S.size();
    
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
		if(st.find(v[i])==st.end()){
			st.insert(v[i]);
		}
		else{
			st.erase(v[i]);
		}
	}
	*/


	/*
	int a[4];
	int value;
	value=0;
	
	a[0] = (value % 10); 
	value /= 10;// 1桁目を取り出す
	a[1] = (value % 10); 
	value /= 10;// 2桁目を取り出す
	a[2] = (value % 10); 
	value /= 10;// 3桁目を取り出す
	a[3] = (value % 10); 
	value /= 10;// 4桁目を取り出す
    work1=a[0]+10*a[1];
    work2=a[2]+10*a[3];
    */
	
	
    if(15-s.length()+cnt1>=8){
    	//printf("%d",YES);
    	//printf("%lld",N);
    	puts("YES");
    	//printf("%d",st.size());
    	//文字列の出力
    	//std::cout << s << std::endl;
    	//printf("%.12f\n",ret);
    	//cout << sum << endl;
	}
	else{
		puts("NO");
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	public static int findLCS(String s0, String s1) {
		int[][] arr = new int[s1.length()+1][s0.length()+1]; 
		for(int i = 1; i <= s1.length(); i++) {
			for(int j = 1; j <= s0.length(); j++) {
				if(s0.charAt(j-1) != s1.charAt(i-1))
					arr[i][j] = Math.max(arr[i-1][j], arr[i][j-1]);
				else
					arr[i][j] = 1 + arr[i-1][j-1]; 
			}
		}
		return arr[s1.length()][s0.length()]; 
		
	}
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in); 
		int q = in.nextInt(); 
		
		for(int i = 0; i < q; i++) {
			System.out.println(findLCS(in.next(), in.next())); 
		}
	}

	

}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int h, w, sh, sw;

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &w);

  scanf("%d %d", &sh, &sw);

  printf("%d\n", (h - sh) * (w - sw));

  return 0;
}


Measured memory_bytes: 256
def func(start, end, leng):
    for i in range(leng):
        if S[start+i] != S[end-i]:
            return False
    else:
        return True

S = input()
N = len(S)
M = len(S)//2

if func(0, N-1, N) and func(0, M-1, M) and func(M+1, N-1, M):
    print("Yes")
else:
    print("No")


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

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int[] b=new int[3];

		for(int i=0; i<3; i++) {
			b[i]=sc.nextInt();
		}
		int wa=0;

		Arrays.sort(b);
		for(int i=0; i<2; i++) {
			wa+=Math.abs(b[i+1]-b[i]);
		}
		System.out.println(wa);
	}
}

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

using namespace std;


#define MAXN 100001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    ans += r-l+1;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	
	int s = a*c;
	
	if(s <= b) cout << c << endl;
	else if(a <= b) cout << b / a << endl;
	else cout << "0" << endl;
	
	return 0;
}
		
		

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> A;
  REP(i, N) { A.push_back(i); }
  vector<vector<bool>> graph(N, vector<bool>(N, false));
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a][b] = true;
    graph[b][a] = true;
  }

  int ans = 0;
  do {
    if(A[0] != 0) break;
    bool ok = true;
    REP(i, N - 1) {
      if(!graph[A[i]][A[i + 1]]) {
        ok = false;
        break;
      }
    }
    if(ok) { ans++; }
  } while(next_permutation(all(A)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
li=list(map(int,input().split()))
li.sort(reverse = True)
al = 0
bo = 0
for i in range(0, n, 2):
    al += li[i]
    if (n % 2 == 1 and i == n - 1):
        break
    bo += li[i + 1]
print(al-bo)
    


Measured memory_bytes: 3060
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
$v2 = explode(" ", $stdin[0]);

#dream dreamer erase eraser

#var_dump($v2);

$ans = ($v2[1] + $v2[2]) - $v2[0];

if($ans < 0){
  $ans = 0;
}

echo $ans . PHP_EOL;

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int n;
vector<vector<pair<int,int>>> to(100010); //辺のindex,行き先のペア
vector<int> bfs(){
    vector<int> ans(n-1);
    queue<pair<int,int>> q; //toのindex,親のカラー
    q.emplace(0,0);

    auto update = [&](int i, int j, int& c){ //辺のindex, 行き先, x:色（1以上)
        if(ans[i]!=0) return;
        ans[i] = c;
        q.emplace(j,c);
        c++;
    };
    while(!q.empty()){
        auto now = q.front(); q.pop();
        int color=1;
        for(auto&& edge: to[now.first]){
            if(color==now.second) color++;
            //cout << edge.first << " " << edge.second << " " << color << endl;
            update(edge.first, edge.second, color);
        }
    }
    return ans;
}
int main(){
    cin >> n;
    vector<pair<int,int>> g(n-1);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[i].first = a;
        g[i].second = b;
    }
    
    int ct = 0;
    for (auto&& x:g){
        to[x.first].emplace_back(ct, x.second);
        to[x.second].emplace_back(ct, x.first);
        ct++;
    }
    int k=0;
    rep(i,n){
        if(to[i].size()>k) k=to[i].size();
    }
    auto ans = bfs();  
    cout << k << endl; 
    rep(i,n-1){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
using namespace rel_ops;
struct rat{
	int a,b;
	rat(int a,int b) :a(a),b(b){}
};
inline int gcd(int x,int y){
	if(y==0) return abs(x);
	return gcd(y,x%y);
}
inline rat normz(rat x){
	int g=gcd(x.a,x.b);
	// if(x.b<0) x.a*=-1,x.b*=-1;
	return rat(x.a/g,x.b/g);
}
inline rat operator+(const rat& x,const rat& y){
	return normz(rat(x.a*y.b+x.b*y.a,x.b*y.b));
}
inline rat operator-(const rat& x,const rat& y){
	return normz(rat(x.a*y.b-x.b*y.a,x.b*y.b));
}
inline bool operator<(const rat& x,const rat& y){
	return x.a*y.b<x.b*y.a;
}
inline bool operator==(const rat& x,const rat& y){
	return x.a*y.b==x.b*y.a;
}

typedef vector<int> Vi;
int main(){
	while(true){
		int N,t[50],c[50];
		cin>>N;
		if(N==0) break;
		rep(i,N) cin>>t[i]>>c[i];
		map<rat,Vi> mp;	//pos->id
		Vi fst;
		rep(i,N) fst.pb(i);
		mp[rat(0,1)]=fst;
		int tm=0;
		while(true){
			map<rat,Vi> nmp;
			int T=1e9;
			for(auto it:mp){
				bool slow=1;
				rat r=it.fs;
				Vi vc=it.sc;
				if(r==rat(0,1)||r==rat(1,1)) slow=0;
				if(slow){
					int mx=0;
					for(int v:vc) chmax(mx,t[v]);
					rat s(1,1);
					if(r < rat(1,1)) s=rat(1,1)-r;
					else s=rat(2,1)-r;
					chmin(T,s.a*mx/s.b);
				}else{
					for(int v:vc){
						rat s(1,1);
						if(r < rat(1,1)) s=rat(1,1)-r;
						else s=rat(2,1)-r;
						chmin(T,s.a*t[v]/s.b);
					}
				}
			}
			rat mn(2,1);
			for(auto it=mp.rbegin();it!=mp.rend();it++){
				bool slow=1;
				rat r=it->fs;
				Vi vc=it->sc;
				if(r==rat(0,1)||r==rat(1,1)) slow=0;
				if(slow){
					int mxt=0;
					for(int v:vc) chmax(mxt,t[v]);
					rat nr=min(r+rat(T,mxt),mn);
					chmin(mn,nr);
					nmp[nr].insert(nmp[nr].end(),vc.begin(),vc.end());
				}else{
					for(int v:vc){
						rat nr=min(r+rat(T,t[v]),mn);
						nmp[nr].pb(v);
					}
				}
			}
			for(int v:nmp[rat(2,1)]){
				c[v]--;
				if(c[v]) nmp[rat(0,1)].pb(v);
			}
			nmp.erase(rat(2,1));
			mp=nmp;
			tm+=T;
			if(mp.empty()){
				cout<<tm<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1240
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int32_t N;
	cin >> N;

	int32_t res = 0;
	for (int32_t i = 1; i <= N; i++) {
		string s = std::to_string(i);
		if (s.size() % 2 == 1)
			res++;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	rep(i,h) cin >> v[i];
	int cnt = 0;
	rep(i,h) rep(j,w) if (v[i][j] == '#') cnt++;
	if (cnt == h + w - 1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <complex>
#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
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

mat a(700,vec(700,0));
vec color(700,0);
bool inte = false;
void dfs(ll to, ll c, P &p){
    //cout<<to<<' '<<c<<' '<<inte<<endl;
    color[to] = c;
    ++(c == 1 ? p.fi : p.se);
    rep(i,N){
        if(inte)  return;
        if(a[to][i] == 0){
            if(color[i] == 0) {
                dfs(i, -c, p);
            }else if(color[i] == c){
                inte = true;
                //p.fi = -1;
            }
            if(inte)  return;
        }
    }
}


int main(){
    cin>>N>>M;
    rep(i,M){
        cin>>A>>B;
        --A; --B;
        a[B][A] = 1;
        a[A][B] = 1;
    }
    rep(i,N) a[i][i] = 1;
    vp ans(0);
    rep(i,N){
        if(color[i] == 0){
            P p = mp(0,0);
            dfs(i, 1, p);
            if(inte) {
                cout<<-1<<endl;
                return 0;
            }else{
                ans.push_back(p);
            }
        }
    }
    mat dp(ans.size() + 1,vec(701,0));
    dp[0][0] = 1;
    reps(i,1,ans.size() + 1){
        P p = ans[i - 1];
        rep(j,701){
            if(p.fi <= j){
                if(dp[i-1][j-p.fi] == 1){
                    dp[i][j] = 1;
                }
            }
            if(p.se <= j){
                if(dp[i-1][j-p.se] == 1){
                    dp[i][j] = 1;
                }
            }
        }
    }
    ll cen= 0;
    rep(i,701){
        if(dp[ans.size()][i] == 1 && abs(i*2-N) < abs(cen*2-N)){
            cen = i;
        }
    }
    ll out = 0;
    if(cen > 0) (out+=cen * (cen - 1) / 2)%=MOD;
    if(N-cen > 0) (out+=(N - cen) * (N - cen - 1) / 2)%=MOD;
    cout<<out<<endl;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define N 500005
char s[N];
int n, Pi1[N], Pi2[N];
void kmp(int* Pi) {
    int j = Pi[0] = -1;
    for (int i = 0; i < n; i++) {
        while (~j && s[j] != s[i]) j = Pi[j];
        Pi[i + 1] = ++j;
    }
}
bool check(int a, int b) { return a % (a - b) || !b; }
int main() {
    scanf("%s", s);
    n = strlen(s);
    kmp(Pi1);
    if (check(n, Pi1[n])) return printf("1\n1\n"), 0;
    if (n - Pi1[n] == 1) return printf("%d\n1\n", n), 0;
    reverse(s, s + n);
    kmp(Pi2);
    int ans = 0;
    for (int i = 1; i < n; i++)
        if (check(i, Pi1[i]) && check(n - i, Pi2[n - i])) ans++;
    printf("%d\n%d\n", 2, ans);
    return 0;
}

Measured memory_bytes: 4608
const num_chars: [char; 9] = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
const num_stick: [usize; 9] = [2, 5, 5, 4, 5, 6, 3, 7, 6];

fn func(input_str: &str) -> String {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut a_s: Vec<usize> = iter.take(m).map(|x| x.parse().unwrap()).collect();
    a_s.sort();
    a_s.reverse();
    let a_s = a_s;

    let mut dp = vec![std::isize::MIN; n + 1];
    dp[0] = 0;
    for i in 1..(n + 1) {
        for &a in &a_s[..] {
            let ns = num_stick[a - 1];
            if i >= ns {
                dp[i] = std::cmp::max(dp[i], dp[i - ns] + 1);
            }
        }
    }

    let mut ans = Vec::new();
    let mut r_stick = n;
    while r_stick > 0 {
        for &a in &a_s[..] {
            if r_stick >= num_stick[a - 1] && dp[r_stick] - 1 == dp[r_stick - num_stick[a - 1]] {
                ans.push(num_chars[a - 1]);
                r_stick -= num_stick[a - 1];
                break;
            }
        }
    }
    ans.into_iter().collect()
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  if(a!=0){
    cout<<b/x-(a-1)/x<<endl;
  }
  else{
    cout<<b/x+1<<endl;
  }
}

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


int main(){

  int n;
  cin >> n;
  vector<ll> a(n);

  REP(i,n) cin >> a[i];

  sort(ALL(a));
  bool flg = true;

  REP(i,n-1){
    if(a[i] == a[i+1]){
      flg = false;
      break;

    }
  }
  if(flg) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 4732
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CHAndV {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w, k; cin >> h >> w >> k;
      vector<vector<bool>> mat(h, vector<bool>(w));
      rep(i, h) {
        rep(j, w) {
          char c; cin >> c;
          mat[i][j] = (c == '#');
        }
      }

      int ret = 0;
      int t = (1<<(h+w));
      rep(s, t) {
        int cnt = 0;
        rep(i, h) {
          rep(j, w) {
            if (mat[i][j] && !(s&(1<<i)) && !(s&(1<<(j+h)))) {
              cnt++;
            }
          }
        }
        if (cnt == k) {
          ret++;
        }
      }
      cout << ret << endl;

    }
};

signed main() {
  CHAndV solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string a;
    while(cin>>a){
    int q=0,w=0,e=0;
    for(int i=0;i<3;i++)
    {
        if(a[i]=='a')q=1;
        if(a[i]=='b')w=1;
        if(a[i]=='c')e=1;
    }
    if(q&&w&&e)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;}
    return 0;
}


Measured memory_bytes: 256
//2019.5.20 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN {
    int n,k;
    db ans;
    inline void MAIN(){
        n=read(),k=read();
        for(res i=k;i<=n;i++)ans+=1.0/n;
        res t=1;
        while(k>1){
            res tmp;
            if(k&1)tmp=k/2+1;
            else tmp=k>>1;
            if(n>=tmp)ans+=(min(k,n+1)-tmp)*(1.0/n)/pow(2,t);
            k=tmp,t++;
        }
        printf("%.10lf\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    double[] X, Y;
    void Solve()
    {
        int N = cin.Nextint;
        X = new double[N];
        Y = new double[N];
        for (int i = 0; i < N; i++)
        {
            X[i] = cin.Nextdouble;
            Y[i] = cin.Nextdouble;
        }

        var dp = new double[N, N];
        for (int j = 0; j < N; j++)
        {
            for (int i = 0; i < j; i++)
            {
                if (i == 0 && j == 1)
                {
                    dp[0, 1] = dist(0, 1);
                }
                else if (i < j - 1)
                {
                    dp[i, j] = dp[i, j - 1] + dist(j - 1, j);
                }
                else
                {
                    dp[i, j] = double.MaxValue;
                    for (int k = 0; k < i; k++)
                    {
                        dp[i, j] = Math.Min(dp[i, j], dp[k, i] + dist(k, j));
                    }
                }
            }
        }
        var ans = double.MaxValue;
        for (int k = 0; k < N - 1; k++)
        {
            ans = Math.Min(ans, dp[k, N - 1] + dist(k, N - 1));
        }
        Console.WriteLine(ans.ToString("F7"));


    }
    double dist(int s, int t)
    {
        return Math.Sqrt(Math.Pow(X[s] - X[t], 2) + Math.Pow(Y[s] - Y[t], 2));
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 17312
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;


int main() {
	int n;
	cin >> n;
	int c = 0;
	for (int i = 0; i < 4; i++) {
		if (n % 10 == 2)
			c++;
		n = n / 10;
	}
	cout << c << endl;
}

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

#define endl "\n"
#define INF 9e18
#define int long long
#define uint unsigned long long
#define MOD (int) (1e9 + 7)
#define deb(x) cout << #x << " => " << x << "\n"
#define deba(x) cout << #x << "\n"; for (auto a : x) cout << a << " "; cout << "\n";
#define debm(x) cout << #x << "\n"; for (auto a : x) {for(auto b : a) cout << b << " "; cout << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m;
    while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    } return res;
}

int merge(vector<int> &a, int low, int mid, int high) {
    vector<int> temp;
    int i = low, j = mid + 1;
    int count = 0;
    while (i <= mid and j <= high) {
        if (a[i] <= a[j]) {
            temp.push_back(a[i]);
            i++;
        } else {
            temp.push_back(a[j]);
            j++;
            count += mid - i + 1;
        }
    }
    while (i <= mid) {
        temp.push_back(a[i]);
        i++;
    }
    while (j <= high) {
        temp.push_back(a[j]);
        j++;
    }
    for (int i = 0, j = low; j <= high; j++, i++) {
        a[j] = temp[i];
    }
    return count;
}

int mergeSort(vector<int> &arr, int low, int high) {
    int count = 0;
    if (low < high) {
        int mid = (low + high) / 2;
        count += mergeSort(arr, low, mid);
        count += mergeSort(arr, mid + 1, high);
        count += merge(arr, low, mid, high);
    }
    return count;
}

int32_t main() {
    fastio;
    // int t; cin >> t;
    // while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        int count = mergeSort(arr, 0, arr.size() - 1);
        vector<int> b = arr;
        for (auto a : arr) {
            b.push_back(a);
        }
        int mergeCount = merge(b, 0, n - 1, 2 * n - 1);
        int modInv = (MOD + 1) / 2;
        int res = ((k * count) % MOD + (((k * (k - 1)) % MOD) * ((mergeCount * modInv) % MOD)) % MOD) % MOD;
        cout << res << endl;
    // }
    return 0;
}

Measured memory_bytes: 384
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(int(s[K-1]))

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

int main(){
 int i,slen;
 char str[1001],b;
 scanf("%s",str);
 slen=strlen(str);
 for(i=0;i<slen;i++){
  if(isalpha(str[i])){
    b=(int)str[i]-(int)'A'-3;
    b=(b>-1?b:26+b)+'A';
    printf("%c",b);
  }else{
   printf("%c",str[i]);
  }
 }
 printf("\n");
 return 0;
}

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


int main() {
    int N;
    cin >> N;
    int p;
    cin >> p;
    int minValue = p;
    int ans = 1;
    for(int i=1;i<N;i++){
        cin>>p;
        if(minValue>p){
            ans++;
            minValue = p;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    int N=S.size();
        int ans=0;
        for(int i=0;i<N/2;i++){
            if(S[i]!=S[N-i-1]){
                ans++;
            }
        }
        cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def bubble_sort(A):
    swap_count = 0
    for i in range(len(A)):
        for x in range(len(A)-1, i, -1):
            if A[x] < A[x-1]:
                swap_count += 1
                A[x], A[x-1] = A[x-1], A[x]

    return swap_count

n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

swap_count = bubble_sort(A)
s_list = list(map(str, A))
print(' '.join(s_list))
print(swap_count)



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

int main() {
	// your code goes here
	
	char a[3] = {};
	char b[3] = {};
	
	cin >> a;
	cin >> b;
	
	for(int i = 0;i < 3;i++){
		
		if(a[i] != b[ 2 - i ]){
			
			cout << "NO" << endl;
			
			return 0;
			
		}
		
	}
	
	cout << "YES" << endl;
	
	return 0;
}

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

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 400200;
char s[N], t[N];
int main() {
  int q; scanf(" %s", s);
  scanf("%d", &q);
  int c = 0, n1 = strlen(s), n2 = 0;
  while (q--) {
    int e; scanf("%d", &e);
    if (e == 1) c ^= 1;
    else {
      int f; char ch; scanf("%d %c", &f, &ch);
      if (f == 1) {
        if (c == 0) t[n2++] = ch;
        else s[n1++] = ch;
      } else {
        if (c == 0) s[n1++] = ch;
        else t[n2++] = ch;
      }
    } 
  }
  if (c == 0) {
    for (int i = n2 - 1; i >= 0; --i) putchar(t[i]);
    rep(i, n1) putchar(s[i]);
  } else {
    for (int i = n1 - 1; i >= 0; --i) putchar(s[i]);
    rep(i, n2) putchar(t[i]);
  }
  puts("");
  return 0;
}



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

int main() {

  auto isP = [&](string str) {
    bool ans = true;
    int size = str.size();
    rep(i, size/2) {
      if (str[i] != str[size-1-i]) {
        ans = false;
        break;
      }
    }
    return ans;
  };

  string S, l, r;
  cin >> S;
  int size = S.size();
  l = S.substr(0, (size-1)/2);
  r = S.substr(((size+3)/2)-1, size);

  string ans = "No";
  if (isP(S) && isP(l) && isP(r)) ans = "Yes";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K , x , A = 0;
  cin >> N >> K;
 for (int i = 0; i < N ; i++ ) {
   cin >> x;
   if (2 * x < K){
     A+=2 * x;
   }
   else if (x > K) {
     A+=(x-K) * 2;
   }
   else {
     A+=(K - x) * 2;
 }     
 }
cout << A;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#include <string> 
using namespace std;
const int N = 1000000;
int n, a[N];
void heapify(int i){
	int l = 2 * i + 1, r = l + 1;
	int pv = i;
	if(l < n && a[l] > a[pv]) pv = l;
	if(r < n && a[r] > a[pv]) pv = r;
	if(i != pv){
		swap(a[i], a[pv]);
		heapify(pv);
	}
}
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = n / 2 - 1; i >= 0; i--){
		heapify(i);
	}
	for(int i = 0; i < n; i++) cout << " " << a[i];
	cout << endl;
}
int main(void){
	solve();
	return 0;
}



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

int main(){
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> v(100001);
    for(unsigned long i = 0, a, b; i < N; ++i){
        cin >> a >> b;
        v[a] += b;
    }
    partial_sum(v.begin(), v.end(), v.begin());
    cout << lower_bound(v.cbegin(), v.cend(), K) - v.cbegin() << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=a;i>b;i--)
#define mkp(a,b) make_pair(a,b)
#define all(v) v.begin(),v.end()
#define max3(a,b,c) max(a,(max(b,c))
#define min3(a,b,c) min(a,(min(b,c))
#define read(a) cin>>a
#define readt(a,b) read(a),read(b)
#define mod 1000000007
using namespace std;
bool compare(pair<int,int>& p1,pair<int,int>& p2)
{
    return p1.second<p2.second;
}
int main()
{
    fastio
    ll n;
    read(n);
    vector<ll> v(n),sum(n);
    
    ll cs=0;
    rep(i,0,n)
    {
        cin>>v[i];
    }
    repv(i,n-1,-1)
    {
        cs=(cs+v[i])%mod;
        sum[i]=cs;
    }
    ll ans=0;
    rep(i,0,n-1)
    {
        ll ft=v[i],st=sum[i+1];
        ans=(ans%mod+((ft)%mod*(st)%mod)%mod)%mod;
    }
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 6356
package main
import "fmt"
const mod = int(1e9 + 7)
func main() {
    var N int
    fmt.Scanf("%d", &N)
    var dp [1000100][2][2]int
    dp[0][0][0] = 1
    for i := 0; i < N; i++ {
        for j := 0; j < 2; j++ {
            for k := 0; k < 2; k++ {
                for d := 0; d < 10; d++ {
                    if d == 0 {
                        dp[i+1][1][k] += dp[i][j][k]
                        dp[i+1][1][k] %= mod
                        continue
                    }
                    if d == 9 {
                        dp[i+1][j][1] += dp[i][j][k]
                        dp[i+1][j][1] %= mod
                        continue
                    }
                    dp[i+1][j][k] += dp[i][j][k]
                    dp[i+1][j][k] %= mod
                }
            }
        }
    }
    fmt.Println(dp[N][1][1])
}

Measured memory_bytes: 34168
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, mod = mi()
S = list(map(int, list(input())))
ans = 0

if 10 % mod != 0:
    mod_list = [0]
    ten = 1
    for num in S[::-1]:
        yo = (num * ten + mod_list[-1]) % mod
        mod_list.append(yo)
        ten = (ten * 10) % mod

    cnt = [0]*mod
    for yo in mod_list:
        cnt[yo] += 1

    for i in range(mod):
        ans += cnt[i] * (cnt[i]-1) // 2

else:
    for i, num in enumerate(S):
        if num % mod == 0:
            ans += i+1

print(ans)

Measured memory_bytes: 14468
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[110]={0},b[110]={0};
  cin >> n;
  for(int i=1; i<=n; i++) {
    cin >> a[i];
    a[i]+=a[i-1];
  }
  for(int i=1; i<=n; i++) {
    int c;
    cin >> c;
    b[i]=max(b[i-1],a[i])+c;
  }
  cout << b[n] << endl;
}


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

int main(){
    int k,s;
    int ans=0;

    cin >> k >> s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z = s - x - y;
            if((0 <= z)&&(z <= k))    ans++;
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int64_t A, B, C, K;
    std::cin >> A >> B >> C >> K;

    C = K - A - B;
    if (C < 0) C = 0;
    if (A > K) A = K;

    std::cout << A - C << '\n';

    return 0;
}

Measured memory_bytes: 3636
import heapq
def dijkstra_heap(s):
    d = [float("inf")] * n
    used = [True] * n
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v],e[1]))
    return d
_,*a = [list(map(int,t.split())) for t in open(0)]
n = 10
edge = [[] for _ in range(n)]
for i in range(n):
    for j in range(n):
        edge[i].append((a[i][j],j))
c = [dijkstra_heap(i)[1] for i in range(n)]+[0]
print(sum(c[j] for i in a[n:] for j in i))

Measured memory_bytes: 41564
<?php
fscanf(STDIN, '%s', $input);
$nums = str_split($input);
$len = count($nums);
$ans = $input;
$memo = [];
if ($len <= 1) {
    echo $ans."\n";
    exit;
} else {
    for ($idx=0; $idx < (1 << ($len-1)); $idx++) {
        $nums = str_split($input);
        for ($plus=0; $plus < $len; $plus++) { 
            if($idx >> $plus & 1){
                $nums[$plus] .= '+';
                $str = implode($nums);
                if (!in_array($str, $memo)) {
                    $ans += eval("return $str;");
                    $memo[] = $str;
                }
            }
        }
    }
}
echo $ans."\n";

Measured memory_bytes: 4984
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    while (scanner.hasNext()) {
      int n = scanner.nextInt();
      if (n == 0) {
        break;
      }
      List<String> ts = new ArrayList<String>();
      for (int ii = 0; ii < n; ii++) {
        String t = scanner.next();
        int w = scanner.nextInt();
        int l = scanner.nextInt();
        int d = scanner.nextInt();
        String wp = "0000" + (w * 3 + d);
        wp = wp.substring(wp.length() - 5);
        String idx = "00" + (n - ii);
        idx = idx.substring(idx.length() - 3);
        ts.add(wp + "," + idx + "," + t);
      }
      Collections.sort(ts);
      Collections.reverse(ts);
      for (String el : ts) {
        String[] works = el.split(",");
        int wp = Integer.parseInt(works[0]);
        out += works[2] + "," + wp + "\n";
      }
      out += "\n";
    }
    System.out.print(out.substring(0, out.length() - 1));
  }
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll n;
  cin>>n;
  V<TP<str,ll,ll>> v(n);
  FOR(i,0,n){
    cin>>get<0>(v[i])>>get<1>(v[i]);
    get<2>(v[i])=i+1;
  }
  FOR(i,0,n){
    get<1>(v[i])*=-1;
  }
  SORT(v);
  FOR(i,0,n){
    co(get<2>(v[i]));
  }
}
    

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))

    scarf_0 = 0
    for a in A[1:]:
        scarf_0 ^= a
    
    scarf_all = scarf_0 ^ A[0]
    
    ans = [scarf_all^a for a in A]
    
    print(*ans, sep=" ")

if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  if (h < 2 * b || w < 2 * a) {
    cout << "-1" << '\n';
    return 0;
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << (i < b && j < a || i >= b && j >= a);
    }
    cout << '\n';
  }
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(N + 1);
  int P;
  string S;
  int ac = 0, wa = 0;
  while (cin >> P >> S) {
    if (S == "AC") {
      if (V.at(P) != -1) ac++, wa += V.at(P), V.at(P) = -1;
      else continue;
    } else {
      if (V.at(P) != -1) V.at(P)++;
      else continue; 
    }
  }
  cout << ac << " " << wa << "\n";
}

Measured memory_bytes: 640
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(input().split())
    return li

# --------------------------------------------

dp = None

def main():
    N = int(input())
    K = int(input())


    minimum_value = 10**9
    for seq in itertools.product("01", repeat=N):
        value = 1
        for binary in seq:
            if binary == "0":
                value *= 2
            else:
                value += K
        minimum_value = min(value, minimum_value)

    print(minimum_value)

main()


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


int gcd(int x, int y){
  if(y>x){
    int t=y;
    y=x;
    x=t;
  }
  while(y){
    int t=x%y;
    x=y;
    y=t;
  }
  return x;
}

int main(){
  int K; cin >> K;
  long long result=0;
  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      int g=gcd(i,j);
      for(int k=1; k<=K; k++){
        result+=gcd(g,k);
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 3636
using System;

namespace A___K_City
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var m = int.Parse (input[1]);
            Console.WriteLine ((n - 1) * (m - 1));
        }
    }
}

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

int main(){
    ll N, K;
    cin >> N >> K;
    ll m = N / K;
    ll ans = N - m * K;
    if (ans * 2 > K){
        ans = K - ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;

int main() {
  int d,n;
  cin >> d >> n;
  int m=pow(100,d);
  if(n<100) cout << pow(100,d) * n << endl;
  else cout << m* 101 << endl;
}




Measured memory_bytes: 256