akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=225;
char s[N][N];
int n,m,sum[N][N],f[2][N][N][N];
bool chk(int x1, int y1, int x2, int y2)
{
	int s=sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
	return !s||s==(x2-x1+1)*(y2-y1+1);
}
int getcol(int a, int i, int j, int x)
{
	int l=i,r=j-1,ans=0;
	while(l<=r)
	{
		int mid=l+r>>1;
		ans=max(ans,min(f[a][i][mid][x],f[a][mid+1][j][x]));
		f[a][i][mid][x]<f[a][mid+1][j][x] ? r=mid-1 : l=mid+1; 
	}
	return ans;
}
inline int G(int a, int i, int j, int x, int p)
{	return min(f[a][i][p][x],f[a][p+1][j][x]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;++j) sum[i][j]+=(s[i][j]=='.');
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	for(int i=1;i<=n;++i)
		for(int j=i;j<=n;++j)
			for(int l=1,r;l<=m;l=r)
			{
				r=l;
				while(chk(i,l,j,r)&&r<=m) ++r;
				for(int p=l;p<r;++p) f[0][i][j][p]=r-1;
				if(l==r) f[0][i][j][l]=l-1,++r;
			}
	for(int a=1;;++a)
	{
		if(f[~a&1][1][n][1]>=m)
		{
			printf("%d\n",a-1);
			return 0;
		}
		for(int x=1;x<=m;++x)
			for(int i=1;i<=n;++i)
				for(int j=i,p=i;j<=n;++j)
				{
					while(p+1<j&&G(~a&1,i,j,x,p)<=G(~a&1,i,j,x,p+1)) ++p;
					if(f[~a&1][i][j][x]==m) f[a&1][i][j][x]=m;
					else f[a&1][i][j][x]=max(f[~a&1][i][j][f[~a&1][i][j][x]+1],G(~a&1,i,j,x,p));
				}
	}
}


Measured memory_bytes: 75776
#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<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
  ll n,r; cin >> n >> r;
  if(n <=9) cout << r + 100*(10-n) << endl;
  else cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  vector<int> v(3, 0);
  REP(i, 3) v[s[i]-'a']++;
  if(v[0] == v[1] && v[1] == v[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b,c;
 	cin>>a>>b>>c;
 	if(c>=a&&c<=b)
 	cout<<"Yes";
 	else
 	cout<<"No";
 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int A, P; cin >> A >> P;
	P += A * 3;
	cout << P / 2 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long N,A,B,counter=0;
cin>>N>>A>>B;
long long a[100000];
for(int j=0; j<N;j++){
cin>>a[j];}
for(int j=0; j<N-1;j++){
if((a[j+1]-a[j])*A<=B){
counter+=A*(a[j+1]-a[j]);}
else
counter+=B;
}
cout<<counter<<endl;}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main(){
	int k, a, b;
	scanf("%d%d%d", &k, &a, &b);
	if (a % k == 0 || b / k > a / k)
		printf("OK\n");
	else
		printf("NG\n");
	return 0;
}


Measured memory_bytes: 3760
#include"bits/stdc++.h"
using namespace std;

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

    string s1 = s;
    reverse(s1.begin(),s1.end());

    if(s1==s)
    {
        int flag = 0;
        string d="";
        for(int i=0;i<(s.size()>>1);i++) d+=s[i];
        string d1 = d;
        reverse(d1.begin(),d1.end());

        if(d1==d) flag = 0;
        else flag = 1;

        string e="";

        for(int i=(s.size()>>1)+1;i<s.size();i++)
        {
            e+=s[i];
        }
        string e1 = e;
        reverse(e1.begin(),e1.end());

        if(e1==e) flag = 0;
        else flag = 1;

        if(!flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

    }
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    double r,i,j,n,x;
    cin>>r;
    r=(44.00*r)/7.00;
    std::cout << std::fixed;
    cout << std::setprecision(2) <<r  << '\n';
}


Measured memory_bytes: 3800
<?php
$nums = array_map('intval', explode(" ", trim(fgets(STDIN))));
$count = 0;
for ($i = $nums[0]; $i <= $nums[1]; $i++) {
    if ($nums[2] % $i === 0) {
        $count++;
    }
}
echo $count.PHP_EOL;
?>


Measured memory_bytes: 9220
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main::IO()
main= do
    _ <- readLn::IO Int
    a <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let elmnt = drop 1 $ zip (scanl (+) 0 (init a)) (scanr (+) 0 a)
    print $ minimum $ map (abs) $ map (\e -> (fst e - snd e)) elmnt 



Measured memory_bytes: 52092
h,w,k=map(int,input().split())
s=[]
for i in range(h):
  s.append(input())
ans=[]
for i in range(h):
  ans.append([])
  for j in range(w):
    ans[-1].append(0)
flag=0
current=1
for i in range(h):
  count=0
  for j in range(w):
    if s[i][j]=='#':
      count+=1
  if count==0:
    if flag==1:
      for j in range(w):
        ans[i][j]=ans[i-1][j]
  else:
    if count==1:
      for j in range(w):
        ans[i][j]=str(current)
      current+=1
      if flag==0:
        for i2 in range(i):
          for j in range(w):
            ans[i2][j]=ans[i][j]
        flag=1
    else:
      start=0
      count2=0
      for j in range(w):
        if s[i][j]=='#':
          count2+=1
          for j2 in range(start,j+1):
            ans[i][j2]=str(current)
          if count2==count:
            for j2 in range(j+1,w):
              ans[i][j2]=str(current)
          current+=1
          start=j+1
      if flag==0:
        for i2 in range(i):
          for j in range(w):
            ans[i2][j]=ans[i][j]
        flag=1
for i in range(h):
  print(' '.join(ans[i]))

Measured memory_bytes: 75680
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <iomanip>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N, K; cin >> N >> K;
VI x(N); rep(i, 0, N) cin >> x[i];

if (x[0] >= 0){
    cout << x[K-1] << "\n";
    return 0;
}

if (x[N-1] <= 0){
    cout << -1 * x[N - K] << "\n";
    return 0;
}

// 全探索，2^N.TLE．
//原点を含むろうそく K 本 で最短な位置を見つける．
int mini = INF;
rep(i, 0, N - K + 1){
    if (x[i + K - 1] < 0) continue;
    if (x[i] > 0) break;
    mini = min(mini, min(-1 * x[i], x[i + K - 1]) + x[i + K - 1] - x[i]);
}

cout << mini <<  "\n";

}

// 境界，出力文字列 チェック



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			int tmp = sc.nextInt();
			input[i] = tmp;
		}
		int index = 1;
		int res = 0;
		while (index != 2) {
			if (input[index] == 0) {
				System.out.println(-1);
				System.exit(0);
			}
			int tmp = input[index];
			input[index] = 0;
			index = tmp;
			res++;
		}
		System.out.println(res);

	}
}


Measured memory_bytes: 59640
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    ll sum=0;
    for(int i=1;i<=n;++i){
        if(i%3>0 && i%5>0)sum+=i;
    }
    cout << sum ENDL;
    
    return 0;
}

Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc071/tasks/abc071_b
"use strict";
function Main(input) {
  const S = input.trim().split("\n")[0];
  const alphabet = "abcdefghijklmnopqrstuvwxyz".split("");

  let exist = false;
  for (let i = 0; i < alphabet.length; i++) {
    if (!S.includes(alphabet[i])) {
      console.log(alphabet[i]);
      exist = true;
      return;
    }
  }

  if (!exist) {
    console.log("None");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29700
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int A, B;
    cin >> A >> B;

    if (A <= 5) cout << 0 << endl;
    else if (A <= 12) cout << B/2 << endl;
    else cout << B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout<<fixed<<setprecision(9);
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  double ans= (double)w*h/2;
  int num = 0;
  if(w==x*2 && h==y*2){
    num=1;
  }else{
    num=0;
  }
  cout<<ans<<" "<<num<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int main() {
  int H, W; cin >> H >> W;

  vector<vector<int>> dp(H + 1, vector<int>(W + 1));
  dp[0][1] = 1;

  for (int i = 1; i <= H; i++)
  {
    for (int j = 1; j <= W; j++)
    {
      char c; cin >> c;
      if (c == '#') continue;
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
    }
  }

  cout << dp[H][W] << endl;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);
int lastZ(char* s, int len);

int main(void) {
	int i, len, cnt = 0, max = 0, z = 0;
	char S[200001];

	s_cin(S);
	len = strlen(S);

	for (i = len - 1; i >= 0; i--)
		if (S[i] == 'Z') break;
	z = i;
	if (!z) { i_cout(0); return 0; }

	for (i = 0; i < z; i++)
		if (S[i] == 'A') break;
	if (i == z) { i_cout(0); return 0; }
	i_cout(z - i+1);
	return 0;
}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 384
//48
#include<iostream>
#include<string>

using namespace std;

int main(){
  int n;
  cin>>n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
      int cn=0;
      char c=s[i];
      for(;s[i]!='0';i++,cn++) ;
      if(c!='0'){
	string bc[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	cout<<bc[c-'0'][(cn-1)%bc[c-'0'].size()];
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Dinic:
    def __init__(self, n):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.level = None
        self.it = None
    
    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.graph[fr].append(forward)
        self.graph[to].append(backward)
    
    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.graph[v1].append(edge1)
        self.graph[v2].append(edge2)
    
    def bfs(self, s, t):
        self.level = level = [-1] * self.n
        deq = deque([s])
        level[s] = 0
        G = self.graph
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] == -1:
                    level[w] = lv
                    deq.append(w)
        return level[t] != -1
    
    def dfs(self, v, t, f):
        if v == t:
            return f
        for e in self.it[v]:
            w, cap, rev = e
            if cap and self.level[v] < self.level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0
    
    def flow(self, s, t):
        flow = 0
        INF = 10 ** 18
        while self.bfs(s, t):
            *self.it, = map(iter, self.graph)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow


def solve():
    H, W = map(int, rl().split())
    INF = 10 ** 18
    s = H + W
    t = s + 1
    dinic = Dinic(t + 1)
    for i in range(H):
        line = input()
        for j in range(W):
            if line[j] == 'o':
                dinic.add_multi_edge(i, H + j, 1, 1)
            elif line[j] == 'S':
                dinic.add_edge(s, i, INF)
                dinic.add_edge(s, H + j, INF)
            elif line[j] == 'T':
                dinic.add_edge(i, t, INF)
                dinic.add_edge(H + j, t, INF)
    
    ans = dinic.flow(s, t)
    print(ans if ans < INF else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 45916
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int N;
    cin>>N;
    vector<int> v,c;

    for(int i = 0;i < N;i++) {
        int t;
        cin>>t;
        v.push_back(t);
    }

    for(int i = 0;i < N;i++) {
        int t;
        cin>>t;
        c.push_back(t);
    }

    int sum = 0;
    for(int i = 0;i < N;i++) {
        sum += (v[i]-c[i] > 0 ? v[i]-c[i] : 0);
    }

    cout<<sum<<endl;

    return 0;
}




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

int main()
{
    vector<int> x(3);
    cin >> x.at(0) >> x.at(1) >> x.at(2);

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

    int answer = -1;
    for (int i = x.at(2); i <= 100; i++)
    {
        if ((3 * i) % 2 == (x.at(0) + x.at(1) + x.at(2)) % 2)
        {
            answer = (3 * i - (x.at(0) + x.at(1) + x.at(2))) / 2;
            break;
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
import collections, sys

h, w = map(int, input().split())
count = 0
a = []
a.append("." * (w + 2))
for i in range(h):
    temp = input()
    a.append("." + temp + ".")
    count += temp.count("#")
a.append("." * (w + 2))
if count != h + w - 1:
    print("Impossible")
else:
    queue = collections.deque([[1, 1]])
    d = [[1, 0], [0, 1]]
    while queue:
        test = queue.popleft()
        for i in d:
            x = test[0] + i[0]
            y = test[1] + i[1]
            if (x, y) == (w, h):
                print("Possible")
                sys.exit()
            else:
                if a[y][x] == "#":
                    queue.append([x, y])
    else:
        print("Impossible")

Measured memory_bytes: 9488
s=input()
li=[]
for i in s:
  li.append(int(i))

for i in range(2**3):
  op=[]
  ans=li[0]
  for j in range(3):
    if((i>>j)&1):
      op.append("+")
      ans+=li[j+1]
    else:
      op.append("-")
      ans-=li[j+1]
  if ans==7:
    op.append("=7")
    break
for (x,y) in zip(li,op):
  print(str(x)+y,end="")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n;
long long sum,sum_fu;
struct longs{long long num,jue;};
longs a[100000+10];
bool zero=0;
bool comp(longs x,longs y)
{
    return x.jue>y.jue;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i].num;
        if(a[i].num>=0) a[i].jue=a[i].num;
        else    a[i].jue=-a[i].num;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i].num==0)
        {
            zero=1;
            break;
        }
        if(a[i].num<0)  sum_fu++;
    }
    sort(a,a+n,comp);
    for(int i=0;i<n;i++)    sum+=a[i].jue;
    if(zero==0&&sum_fu%2!=0)    sum-=2*a[n-1].jue;
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int x;
    cin >> x;
    int principal = 100, time = 0;
    while(principal < x){
        principal += principal/100;
        time++;
    }
    cout << time << endl;
}

Measured memory_bytes: 3660
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ans := make([]int, 10000+1)
	for x := 1; x <= 100; x++ {
		for y := 1; y <= 100; y++ {
			for z := 1; z <= 100; z++ {
				a := x*x + y*y + z*z + x*y + y*z + z*x
				if a > 10000 {
					continue
				}
				ans[a]++
			}
		}
	}

	for i := 1; i <= N; i++ {
		fmt.Println(ans[i])
	}
}


Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int dp2[MAX][2], ar[2][MAX], dp1[MAX], nextPos[2][MAX], S[MAX], n, A[2];

int P1(int id);

int P2(int id, int last){
  if(id == n) return 1;
  if(dp2[id][last] != -1) return dp2[id][last];
  int ret = 0;
  if(nextPos[last][id-1] == id) return dp2[id][last] = P1(id);
  if(ar[last^1][id] >= nextPos[last][id-1]){
    ret += P2(nextPos[last][id-1], last^1);
    ret %= MOD;
  }
  return dp2[id][last] = ret;
}

int P1(int id){
  if(id == n) return 1;
  if(dp1[id] != -1) return dp1[id];
  int ret = 0;
  ret = P2(id+1, 0) + P2(id+1, 1);
  ret %= MOD;
  return dp1[id] = ret;
}

 main() {
    cin >> n >> A[0] >> A[1];
    REP(i, n) cin >> S[i];
    ar[0][n] = ar[1][n] = n;
    for(int i=n-1;i>=0;i--){
      REP(j, 2){
        nextPos[j][i] = lower_bound(S, S+n, S[i]+A[j]) - S;
        ar[j][i] = i+1;
        if(nextPos[j][i] == i+1) ar[j][i] = ar[j][i+1];
      }
    }
    memset(dp1, -1, sizeof dp1);
    memset(dp2, -1, sizeof dp2);
    cout << P1(0);
    return 0;
}

Measured memory_bytes: 12800
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3612
#include<iostream>

using namespace std;
void call(int n){
  for(int i=1;i<=n;i++){
    if(i%3==0){
      cout<<" "<<i;
      continue;
    }
    if(i%10==3){
      cout<<" "<<i;
      continue;
    }
    for(int x=i/10;x>0;x/=10){
      if(x%10==3){
        cout<<" "<<i;
        break;
      }
    }
  }
  cout<<endl;
}

int main(void){
  int n;
  cin>>n;
  call(n);
  return 0;
}



Measured memory_bytes: 3064
import random, math
from copy import deepcopy as dc
from bisect import bisect_left, bisect_right



# Function to call the actual solution
def solution(li):
	ma = {}
	for i in li:
		ma[i] = ma.get(i, 0) + 1
	s = 0
	for i in ma:
		if i != ma[i]:
			if ma[i] > i:
				s += ma[i] - i
			else:
				s += ma[i]
	return s


# Function to take input
def input_test():
	# for _ in range(int(input())):
		n = int(input())
		# a, b = map(int, input().strip().split(" "))
		# a, b, c = map(int, input().strip().split(" "))
		li = list(map(int, input().strip().split(" ")))
		out = solution(li)
		print(out)

# Function to check test my code
def test():
	pass


input_test()
# test()

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

int main(void) {
	int N;
	bool ans = false;;
	scanf("%d", &N);
	for (int i = 1; i <= 9; i++) {
		if (N % i != 0) {
			continue;
		}
		int A = N / i;
		if (1 <= A && A <= 9) {
			ans = true;
			break;
		}
	}
	printf(ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int> memo;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		memo[s]++;
	}
	int maxv=0;
	for(map<string,int>::iterator it=memo.begin();it!=memo.end();it++){
		int v=it->second;
		if(v>maxv) maxv=v;
	}
	for(map<string,int>::iterator it=memo.begin();it!=memo.end();it++){
		if(it->second==maxv){
			cout<<it->first<<endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 25216
#include <iostream>
int main(){
std::string S;
std::cin>>S;
int N=S.size();
for(int i=0;i<(N-1)/2;i++){
if(S[i]!=S[N-1-i]||S[i]!=S[(N-3)/2-i]){
std::cout<<"No";
return 0;
}
}
std::cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> x(n),l(n);
  rep(i,n){
    cin >> x[i] >> l[i];
  }
  vector<pair<int,int>> p(n);
  rep(i,n){
    p[i] = make_pair(x[i]-l[i],x[i]+l[i]);
  }
  sort(p.begin(), p.end());
  int cnt = 0;
  int back = -1e+9-10;
  rep(i,n){
    int f = p[i].first;
    int b = p[i].second;
    if(back<=f){
      back = b;
    }
    else{
      back = min(back,b);
      cnt++;
    }
  }

  cout << n-cnt << "\n";
  
  return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3

import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


x = int(input())

if x == 2:
    print(2)
    exit()
if x % 2 == 0:
    x += 1

while 1:
    if is_prime(x):
        print(x)
        exit()
    else:
        x += 2


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(long long (i)=0;(i)<(n);(i)++)
#define ll long long
#define pr_qu priority_queue
#define vec(name,size,common) vector<ll> (name)((size),(common))
 
 
 
 
 
int main(){

int a,b,c;
cin>>a>>b;
  c = a+b;
if(c>=24){
  c = (a+b) -24;
}
  cout<<c;
}

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

int main(){
    int N;
    cin >> N;
    long long A, ans;
    double dans;
    dans=1.0;
    ans =1;
    bool flag1, flag2;
    flag1=false;
    flag2=false;
    for(int i=0; i<N; i++){
        cin >> A;
        dans *= (double) A;
        ans *= (long long) A;
        if( dans > 1e18 || ans > (long long) 1e18 ){
            flag1=true;
        }
        if(flag1 && A==0){
            flag2 = true;
        }
    }

    if(flag2){
        cout << 0 << endl;
    }else if(flag1){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
const Int MOD=1e9+9; //<- alert!!!
typedef vector<Int> arr;
typedef vector<arr> mat;
inline arr mul(const mat &a,arr &b,Int mod){
  arr res(b.size(),0);
  for(int i=0;i<(int)b.size();i++)
    for(int j=0;j<(int)a[i].size();j++)
      (res[i]+=a[i][j]*b[j])%=mod;
  return res;
}
inline mat mul(const mat &a,const mat &b,Int mod){
  mat res(a.size(),arr(b[0].size(),0));
  for(int i=0;i<(int)a.size();i++)
    for(int j=0;j<(int)b[0].size();j++)
      for(int k=0;k<(int)b.size();k++)
	(res[i][j]+=a[i][k]*b[k][j])%=mod;
  return res;
}
mat mat_pow(mat a,Int n,Int mod){
  mat res(a);
  for(int i=0;i<(int)a.size();i++)
    for(int j=0;j<(int)a[i].size();j++)
      res[i][j]=(i==j);
  while(n){
    if(n&1) res=mul(a,res,mod);
    a=mul(a,a,mod);
    n>>=1;
  }
  return res;
}
//END CUT HERE
mat base;
mat memo[100];
void init(mat a,Int mod){
  base=mat(a);
  for(int i=0;i<(int)base.size();i++)
    for(int j=0;j<(int)base.size();j++)
      base[i][j]=i==j;
  memo[0]=a;
  for(int k=1;k<70;k++)
    memo[k]=mul(memo[k-1],memo[k-1],mod);
}
inline mat mat_pow2(Int n,Int mod){
  mat res(base);
  int k=0;
  while(n){
    if(n&1) res=mul(memo[k],res,mod);
    n>>=1;
    k++;
  }
  return res;
}

typedef pair<Int,Int> P;
signed main(){
  Int w,h,n,cnt=0;
  while(cin>>w>>h>>n,w||h||n){
    Int x[n],y[n];
    for(Int i=0;i<n;i++) cin>>x[i]>>y[i];
    P p[n];
    for(Int i=0;i<n;i++) p[i]=P(y[i],x[i]);
    sort(p,p+n);
    for(Int i=0;i<n;i++) x[i]=p[i].second,y[i]=p[i].first;
    arr a(w,0);
    a[0]=1;
    mat b(w,arr(w,0));
    for(Int i=0;i<w;i++){
      for(Int j=0;j<w;j++) b[i][j]=0;
      b[i][i]=1;
      if(i-1>=0) b[i][i-1]=1;
      if(i+1<w)  b[i][i+1]=1;
    }
    init(b,MOD);
    Int d=1;
    for(Int k=0;k<n;k++){
      if(y[k]==d) continue;
      a=mul(mat_pow2(y[k]-d-1,MOD),a,MOD);
      Int j=k;
      mat c=b;
      while(j<n&&y[k]==y[j]){
	for(Int i=0;i<w;i++) c[x[j]-1][i]=0;
	j++;
      }
      a=mul(c,a,MOD);
      d=y[k];
    }
    a=mul(mat_pow2(h-d,MOD),a,MOD);
    cout<<"Case "<<++cnt<<": "<<a[w-1]<<endl;
  }
  return 0;
}

/*
  verified on 2018/01/17
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2397
*/



Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  while(true)
  {
    cin >> a >> b;
    if(a==0&&b==0) return 0;
    int k = a;
    while(k--)
    {
      int r = b;
      while(r--)
      {
        if((k+r)%2==((a+b)%2)) cout << "#";
        else cout << ".";
      }
      cout << "\n";
    }
    cout << "\n";
  }
}


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

int main() {
  int M, D, sum = 0;
  cin >> M >> D;
  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= D; j++) {
      if (j % 10 < 2 || j / 10 < 2) {
        continue;
      }
      else if ((j % 10) * (j / 10) == i) {
        sum ++;
      }
    }
  }
  cout << sum << endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[1111][1<<12];

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

	REP(i, 1111)REP(j, (1<<12))dp[i][j] = INF;
	dp[0][0] = 0;

	ll n, m;cin >> n >> m;
	vector<ll> v(m);
	vector<ll> g(m);

	REP(i, m){
		ll b;cin >> v[i] >> b;
		REP(j, b){
			ll tmp;cin >> tmp;
			g[i] |= (1 << (tmp - 1));
		}
	}

	REP(i, m){
		REP(j, (1<<12))if(dp[i][j] != INF){
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			dp[i+1][j | g[i]] = min(dp[i+1][j | g[i]], dp[i][j] + v[i]);
		}
	}

	if(dp[m][(1 << n) - 1] != INF)cout << dp[m][(1 << n) - 1] << endl;
	else cout << -1 << endl;

	return 0;
}


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

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

inline int Sieve_of_Eratothenes(const int n) {

	std::vector<bool> flg(n + 1, true);
	for (int i = 2; i*i <= n; i++) {
		if (flg[i]) {
			for (int j = i + i; j <= n; j += i) {
				flg[j] = false;
			}
		}
	}

	return(std::count(flg.begin(), flg.end(), true) - 2);

}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int a = 0;
	std::vector<int> A;
	while (std::cin >> a) {
		A.push_back(a);
	}

	std::for_each(A.begin(), A.end(),
		[](int i) {std::cout << Sieve_of_Eratothenes(i) << std::endl; });
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int x; cin>>x;
    if(x==3||x==5||x==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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


int main() {
  int H,W;
  cin>>H>>W;
  int N;
  cin>>N;
  int A[N];
  for (int i = 0 ; i < N;i++) cin>>A[i];

  std::vector<int> As;
  As.resize(N);
  As[0] = A[0];
  for (int i = 1 ; i < N;i++) {
    As[i] = As[i-1] + A[i];
  }

  int C[H][W];
  for (int i = 0; i < H;i++) {
    for (int j = 0; j<W;j++) C[i][j] = 0;
  }

  int ci;
  int cj;
  for (int i = 0; i < H;i++) {
    for (int j = 0; j<W;j++) {
      if (i%2 == 0) {
        ci = i;
        cj = j;
      } else {
        ci = i;
        cj = W-j-1;
      }
      int color = std::upper_bound(As.begin(),As.end(),ci*W+cj) - As.begin() + 1;
      // cout<<i<<" "<<j<<" "<<color<<endl;
      C[i][j] = color;
    }
  }

  for (int i = 0; i < H;i++) {
    for (int j = 0; j<W;j++) cout<<C[i][j]<<" ";
    cout<<endl;
  }


  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n; cin >> n;
	vector<int> u(26, IINF);
	rep(i, n){
		string s; cin >> s;
		vector<int> t(26, 0);
		rep(j, s.size()) t[s[j]-'a']++;
		rep(j, 26) u[j] = min(u[j], t[j]);
	}
	
	rep(i, 26) rep(j, u[i]) printf("%c", 'a'+i);
	cout << endl;
	
	return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 605;

int n, p, q, col[N][N], ans[N][N];
vector <pii> trs;
bool vis[N][N];

inline void DFS(int x, int y) {
  for (auto e : trs) {
    int p = x + e.X, q = y + e.Y;
    if (p >= 0 && p < n << 1 && q >= 0 && q < n << 1) {
      if (!~col[p][q] && !vis[p][q]) {
        col[p][q] = !col[x][y], DFS(p, q);
      }
    }
  }
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), Read(p), Read(q);
  trs.clear();
  for (int i = 0; i * i <= p; ++i) {
    int x = p - i * i, y = sqrt(x);
    if (y * y == x) {
      trs.pb(mp(i, y));
      trs.pb(mp(-i, y));
      trs.pb(mp(i, -y));
      trs.pb(mp(-i, -y));
    }
  }
  memset(col, -1, sizeof col);
  for (int i = 0; i < n << 1; ++i) {
    for (int j = 0; j < n << 1; ++j) {
      if (!~col[i][j]) {
        col[i][j] = 0, DFS(i, j);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n << 1; ++i) {
    for (int j = 0; j < n << 1; ++j) {
      if (!col[i][j]) {
        ++cnt;
      }
    }
  }
  if (cnt << 1 < n * n) {
    for (int i = 0; i < n << 1; ++i) {
      for (int j = 0; j < n << 1; ++j) {
        col[i][j] = !col[i][j];
      }
    }
  }
  for (int i = 0; i < n << 1; ++i) {
    for (int j = 0; j < n << 1; ++j) {
      if (col[i][j]) {
        vis[i][j] = true;
      }
    }
  }
  trs.clear();
  for (int i = 0; i * i <= q; ++i) {
    int x = q - i * i, y = sqrt(x);
    if (y * y == x) {
      trs.pb(mp(i, y));
      trs.pb(mp(-i, y));
      trs.pb(mp(i, -y));
      trs.pb(mp(-i, -y));
    }
  }
  memset(col, -1, sizeof col);
  for (int i = 0; i < n << 1; ++i) {
    for (int j = 0; j < n << 1; ++j) {
      if (!~col[i][j] && !vis[i][j]) {
        col[i][j] = 0, DFS(i, j);
      }
    }
  }
  cnt = 0;
  for (int i = 0; i < n << 1; ++i) {
    for (int j = 0; j < n << 1; ++j) {
      if (!col[i][j] && !vis[i][j]) {
        ++cnt;
      }
    }
  }
  if (cnt < n * n) {
    for (int i = 0; i < n << 1; ++i) {
      for (int j = 0; j < n << 1; ++j) {
        col[i][j] = !col[i][j];
      }
    }
  }
  int lim = n * n;
  for (int i = 0; i < n << 1; ++i) {
    for (int j = 0; j < n << 1; ++j) {
      if (!col[i][j] && !vis[i][j]) {
        printf("%d %d\n", i, j);
        --lim;
        if (!lim) {
          return 0;
        }
      }
    }
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 19584
import java.util.Scanner;
import java.lang.Math;
import java.text.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double r = Double.parseDouble(scan.next());
		System.out.println(String.format("%6f",r*r*Math.PI)+" "+String.format("%6f",2*r*Math.PI));
		scan.close();
	}

}

Measured memory_bytes: 17208
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,c,d; cin >> a >> b >> c >> d;
    OUT(min(a,b) + min(c,d));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
bool prime(int p) {
	for (int i = 2;i <= sqrt(p);i++) {
		if (p%i == 0)return false;
	}
	return true;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int main() {
	int k, t, a[100];
	cin >> k >> t;
	rep(i, t) cin >> a[i];
	sort(a, a + t);
	cout << max(0, a[t - 1] - 1 - (k - a[t - 1])) << endl;
	return 0;
}


Measured memory_bytes: 256
solver::(Int,Int,Int)->(Int,Int)->Int
solver (a,b,c) (x,y) = if (a+b) <= 2*c
                      then (a*x) + (b*y)
                      else if (x > y) && (a > 2*c) then 2*c*x
                      else if (x < y) && (b > 2*c) then 2*c*y
                      else (min x y)*(2*c) + (if x > y then (x-y)*a else (y-x)*b  )

main::IO()
main=do
  d<-getLine
  let a:b:c:x:y:[]=map read (words d)
  print (solver (a,b,c) (x,y))

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    ll n;
    cin >> n;
    n--;
    ll ans = (n + n*n) / 2ll;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char x, y;

    scanf("%c %c", &x, &y);
    getchar();

    if(x == y){
        printf("=\n");
    }
    else if(x < y){
        printf("<\n");
    }
    else{
        printf(">\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define N 1000

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b && b==c) cout<<"No"<<endl;
    else if (a!=b && b!=c && c!=a) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    lenS = len(S)
    for i in range(1, lenS//2):
        if S[:(lenS - 2 * i) // 2] == S[(lenS - 2 * i)// 2: lenS - 2 * i]:
            print(lenS - 2 * i)
            break

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include<cstdio>
int main(){
    int n,t,ci,ti,cmin=1e9;
    scanf("%d%d",&n,&t);
    for(int i=0;i<n;i++){
        scanf("%d%d",&ci,&ti);
        if(ti<=t&&ci<cmin)cmin=ci;
    }
    if(cmin==1e9)printf("TLE");
    else printf("%d",cmin);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
full = sum(v*(v-1)//2 for v in ctr.values())

ans = []
for a in A:
    ans.append(full - ctr[a] + 1)
print(*ans, sep='\n')

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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  
  for(int i=0; i<N; i++) cin >> a[i];
  sort(a.begin(),a.end());
  int ans = a.at(N-1)-a.at(0);
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<pair<int, int> > a(n);
	int x;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		a[i] = {x, i + 1};
	}

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

	vector<pair<int, int> > assoc;
	int med = a[n / 2].first;
	for (int i = 0; i < n / 2; ++i) {
		pair<int, int> p = {a[i].second, med};
		assoc.push_back(p);
	}

	med = a[n / 2 - 1].first;
	for (int i = n / 2; i < n; ++i) {
		pair<int, int> p = {a[i].second, med};
		assoc.push_back(p);
	}

	sort(assoc.begin(), assoc.end());
	for (int i = 0; i < n; ++i) {
		cout << assoc[i].second << "\n";
	}

	return 0;

}

Measured memory_bytes: 5488
object Main {
  def main(args: Array[String]): Unit = {
    val factors      = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    var tree_heights = Vector[Int]()

    for(i <- 0 until factors(0)) {
      tree_heights = scala.io.StdIn.readInt +: tree_heights
    }

    val sorted_tree_heights = tree_heights.sorted

    var min_diff = 1000000000
    for(i <- 0 until (factors(0) - factors(1) + 1)) {
      val diff = sorted_tree_heights(i + factors(1) - 1) - sorted_tree_heights(i)
      if (diff < min_diff) min_diff = diff
    }
    println(min_diff)
  }
}

Measured memory_bytes: 46972
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
7
994 518 941 851 647 2 581
)");
#define cin input
#endif

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

	int a;
	int sum = 0;
	REP(i,n)
	{
		cin >> a;
		sum += a-1;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

void solve() {
  int N; cin >> N;
  vector<tuple<int, int, int>> train(N-1);
  rep(i,N-1) {
    int c, s, f; cin >> c >> s >> f;
    train[i] = make_tuple(c, s, f);
  }

  rep(i,N) {
    int ans = 0;

    for (int j=i; j<N-1; ++j) {
      int C, S, F;
      tie(C, S, F) = train[j];
      ans = max(S, ((ans-1)/F+1)*F) + C;
    }

    cout << ans << endl;
  }
  return;
}

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


Measured memory_bytes: 256