akhauriyash/Code-Regression huggingface dataset:
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){

  string S;
  cin >> S;
  int year = (S[0] - '0')*1000 + (S[1] - '0')*100 + (S[2] - '0')*10 + (S[3] - '0');
  int month = (S[5]- '0')*10 + (S[6]-'0');
  int day = (S[8] - '0')*10 + (S[9]-'0');

  if(year == 2019){
    if(month == 4 ){
          cout << "Heisei" << endl;

    }else if(month < 4){
          cout << "Heisei" << endl;
    }else{
          cout << "TBD" << endl;
    }
  }else if(year < 2019){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int l = 0;
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			l += Math.min(2 * x, 2 * (K - x));
		}
		sc.close();
		System.out.println(l);
	}
}


Measured memory_bytes: 22740
#include<stdio.h>

int main() {
	int n,i;

	scanf("%d ", &n);

	long long a[10001], min, max, sum = 0;
	scanf("%lld", &a[0]);
	min = a[0];
	max = a[0];
	sum += a[0];

	for (i = 1; i < n;i++) {
		scanf("%lld", &a[i]);
		if (min > a[i])min = a[i];
		else if (max < a[i])max = a[i];

		sum += a[i];
	}
	
	printf("%lld %lld %lld\n",min,max,sum);
	
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if (b == 1) b = 14;
  if (a == 1) a = 14;
  if (a > b) cout << "Alice\n";
  else if (b > a) cout << "Bob\n";
  else cout << "Draw\n";
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<sstream>
#include<vector>
using namespace std;
typedef long long LL;
#define inf 0x3f3f3f3f
const int M = 500005;
int main()
{
    int n,i,j,m,a,b,flag=0;
    cin>>i;
    cin>>a>>b;
    for(int j=a;j<=b;j++)
    {
        if(j%i==0)flag=1;
    }
   if(flag)cout<<"OK";
   else cout<<"NG";
    

    //system("pause");
    return 0;
}

Measured memory_bytes: 3636
import sys

def dp(costs):
    table = [0]
    for i in range(1, len(costs)):
        if i == 1:
            table.append(table[0] + abs(costs[0] - costs[1]))
            continue
        one_step = table[i-1] + abs(costs[i-1] - costs[i])
        two_step = table[i-2] + abs(costs[i-2] - costs[i])
        table.append(min([one_step, two_step]))
    return table[-1]
        
def main():
    for index, line in enumerate(sys.stdin):
        if index == 0:
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14068
#include "vector"
#include "set"
#include "map"
#include "unordered_set"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define MAX_SIZE 1000000000

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { bool first = true; for (const auto& j: v) { if (!first) { os << " "; } first = false; os <<j; } os << "\n"; return os; }
template<typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& elem : v) { is >> elem; } return is; }


void solve() {
    int n;
    cin >> n;
    unordered_set<string> x;

    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        x.insert(s);
    }

    cout << x.size();
}


int main() {
    //ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    if (0) {
        int tests;
        cin >> tests;
        for (int t = 1; t <= tests; t++) {
            //cout << "Case #" << t << ": ";
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 17704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
int a[MAXN],n,cnt,x,y;
char sb[MAXN],hb[MAXN];
string s;
queue<int> q;
int read(){
    int f=1,x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int main(){
    cin>>s;
    for(int i=1;i<=s.length();i++) hb[i]=s[i-1];
    for(int i=1,j=1;i<=s.length();i++,j++){
        sb[j]=hb[i];
        if(i==1) continue;
        if(sb[j]+sb[j-1]-'0'-'0'==1){
            j-=2;
            cnt+=2;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

int mod_pow(int a, int b) {
    if (!b) return 1;
    if (b % 2) return a * mod_pow(a, b - 1) % MOD;
    int q = mod_pow(a, b / 2);
    return q * q % MOD;
}

int fact(int n) {
    int res = 1;
    for (int i = 2; i <= n; i++) {
        res = res * i % MOD;
    }
    return res;
}

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    int d = 0;
    for (int i = 1, ost = 0; i <= n; i++) {
        for (int j = 1; j <= m; j++, ost++) {
            d = (d + ost * i) % MOD;
            d = (d - (n * m - ost - 1) * i + MOD) % MOD;
        }
    }
    for (int j = 1, ost = 0; j <= m; j++) {
        for (int i = 1; i <= n; i++, ost++) {
            d = (d + ost * j) % MOD;
            d = (d - (n * m - ost - 1) * j + MOD) % MOD;
        }
    }

    int c = (fact(n * m - 2) * mod_pow(fact(k - 2), MOD - 2) % MOD) * mod_pow(fact(n * m - k), MOD - 2) % MOD;
    cout << c * d % MOD;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int main(){
	char str[200010];
	scanf("%s", str);
	int left, right;
	int i=0;
	while(i<200001){
		if(str[i] == 'A'){
			left = i;
			break;
		}
		i++;
		//printf("%d\n", i);
	}
	i = strlen(str);
	//printf("%d\n", i);
	while(i>0){
		if(str[i] == 'Z'){
			right = i;
			break;
		}
		i--;
		//printf("%d\n", i);
	}
	printf("%d\n", right-left+1);

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(v.begin(),v.end());
    cout << v[1]-v[0] + v[2]-v[1] << endl;
    

    return 0;

}


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

int main()
{
    int x, y;
    std::cin >> x >> y;

    std::vector<std::vector<int>> groups = {
        { 1, 3, 5, 7, 8, 10, 12 },
        { 4, 6, 9, 11 },
        { 2 },
    };

    for (auto arr : groups) {
        int same_flag = 0;
        for (auto elem : arr) {
            if (elem == x || elem == y) {
                same_flag++;
            }
        }
        if (same_flag == 2) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;
                                                          
template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int INF32 = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);          
    int n;
    cin >> n;
    vector<int> h(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    vector<int> dp(n + 4, INF32);
    dp[1] = 0;
    for (int i = 2; i <= n; i++) { 
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n];
    return false;                                                       
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cassert>

using namespace std;

int main(int argc, char* argv[]) {
    int N;
    std::cin >> N;

    auto v1 = new int[N/2];
    auto v2 = new int[N/2];
    for (int i = 0; i < N / 2; i++) {
        std::cin >> v1[i];
        std::cin >> v2[i];
    }

    auto bucket1 = new int[100002];
    auto bucket2 = new int[100002];
    for (int i = 0; i < 100002; i++) {
        bucket1[i] = 0;
        bucket2[i] = 0;
    }

    for (int i = 0; i < N / 2; i++) {
        bucket1[v1[i]]++;
        bucket2[v2[i]]++;
    }

    int max1 = 0;
    int submax1 = 0;
    int max2 = 0;
    int submax2 = 0;
    int index1 = 0;
    int index2 = 0;
    for (int i = 1; i < 100001; i++) {
        if (max1 < bucket1[i]) {
            submax1 = max1;
            max1 = bucket1[i];
            index1 = i;
        } else if (submax1 < bucket1[i]) {
            submax1 = bucket1[i];
        }

        if (max2 < bucket2[i]) {
            submax2 = max2;
            max2 = bucket2[i];
            index2 = i;
        } else if (submax2 < bucket2[i]) {
            submax2 = bucket2[i];
        }
    }
    int cnt = 0;
    if (index1 == index2) {
        int sum1, sum2, v;
        if (max1 > max2) {
            v = max1 + submax2;
        } else if (max1 < max2) {
            v = submax1 + max2;
        } else /* (max1 == max2) */ {
            sum1 = max1 + submax2;
            sum2 = submax1 + max2;
            v = std::max(sum1, sum2);
        }
        cnt = N - v;
    } else {
        cnt = N - max1 - max2;
    }

    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1408
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
d = defaultdict(int)
for i in a:
    d[i-1] += 1
    d[i] += 1
    d[i+1] += 1
res = 0
for key in list(d):
    res = max(res, d[key])
print(res)

Measured memory_bytes: 21768
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int N;
   cin >> N;
   int K;
   cin >> K;
   string S;
   cin >> S;

   for (int i = 0; i < N; i++) {
      if (i != K - 1) cout << S[i];
      else if (S[i] == 'A') cout << 'a';
      else if (S[i] == 'B') cout << 'b';
      else if (S[i] == 'C') cout << 'c';
   }
   cout << endl;
   return 0;
}


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

int main()
{
    string s,t;
    int check[11],i,j,fin=1,a,b;
    cin >>s >>t;
    /*
    for(i=0;i<(t.size());i++)check[i]=0;

    for(i=0;i<(t.size()-1);i++)
    {
        for(j=0;j<(s.size());j++)
        {
            if(t[i]==s[j])check[i]=1;
        }

    }
    */
    for(i=0;i<(t.size()-1);i++)
    {
        if(s[i]!=t[i])fin=0;
    }

    //a=t.size();
    //b=s.size();
    if(((t.size())==(s.size())+1)&&(fin==1))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
//Nは桁数が大きい場合があるので文字列として受け取る
string N;
vector<int> n; //Nの各桁の数字を格納するベクター
long long dp[200][2][10];
int main(void)
{
    cin >> N;
    int K;
    cin >> K;

    //ベクターnを構成
    for (auto a : N)
    {
        n.push_back(a - '0');
    }
    int l = N.size(); //nの長さ
    dp[0][0][0] = 1;
    if (l == 1)
    {
        if (K >= 2)
        {
            cout << 0 << endl;
        }
        else if (K == 1)
        {
            cout << n[0] << endl;
        }
        else
        {
            cout << 0 << endl;
        }
        return 0;
    }
    for (int i = 0; i < l; i++)
    {
        for (int smaller = 0; smaller < 2; smaller++)
        {
            for (int j = 0; j <= K; j++)
            {
                for (int x = 0; x <= (smaller ? 9 : n[i]); x++)
                {
                    if (x == 0)
                    {
                        dp[i + 1][smaller || x < n[i]][j] += dp[i][smaller][j];
                    }
                    else
                    {
                        if (j + 1 <= K)
                            dp[i + 1][smaller || x < n[i]][j + 1] += dp[i][smaller][j];
                    }

                    //dp[i + 1][smaller || x < n[i]][j || x == 3] += dp[i][smaller][j];
                }
            }
        }
    }
    cout << dp[l][0][K] + dp[l][1][K] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin>>n;
	vector<int>v;
	
	for(int i=0;i<n;++i)
	{
		cin>>x;
		v.push_back(x);
	}
	int j=1,c=0;
	for(int i=0;i<n;++i){
		if(v[i]==j)
		{
			++j;
			++c;
		}
	}
	if(c==0)
	cout<<-1<<endl;
	else cout<<n-c<<endl;
	
	return 0;
	
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
char C[500005]={'\0'};
char t[100005]={'\0'};
int main()
{
	int fx=1,locz=200001,locy,n,i,lC;//fx方向 偶数反，奇数正;
	scanf("%s%d",t,&n);
	lC=strlen(t);locy=locz+lC-1;
	for(i=0;i<lC;i++)
		C[i+locz]=t[i];
	int t,tt,zy;char c;
	for(i=0;i<n;i++)
	{
		scanf("%d",&t);
		if(t==1)fx++;
		else
		{
			scanf("%d %c",&tt,&c);
			zy=tt+fx;
			if(zy%2)//jia you
				C[++locy]=c,lC++;
			else
				C[--locz]=c,lC++;
		}
	}
	if(fx%2)
		for(i=locz;i<=locy;i++)
			printf("%c",C[i]);
	else
		for(i=locy;i>=locz;i--)
			printf("%c",C[i]);
	return 0;
}

Measured memory_bytes: 896
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
#=True

inf=float('inf')
n=I()
s=[[inf]*n for _ in range(n)]
g=[[] for i in range(n)]
for r in range(n):
    ri=list(input())
    for c in range(n):
        if ri[c]=='1':
            s[r][c]=1
            g[r].append(c)  

def wf(d):
    n=len(d)
    for k in range(n):#       // 経由する頂点
        for i in range(n):#    // 始点
            for j in range(n):#  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

d=wf(s)
diam=-1
bg=0
ed=n-1
for r in range(n):
    for i,dist in enumerate(d[r]):
        if i==r:
            continue
        if diam<dist:
            diam=dist
            bg=r
            ed=i

v=[-1]*(n)

def bfs(x):
    p=deque()
    p.append(x)
    v[x]=0
    while p:
        c=p.popleft()
        for i in g[c]:
            if v[i]==-1:
                p.append(i)
                v[i]=v[c]+1
    return

bfs(bg)

for i in range(n):
    for nb in g[i]:
        if abs(v[nb]-v[i])!=1:
            print(-1)
            exit()
            #show(i,nb,v[i],v[nb])

print(diam+1)
exit()
'''
show(s)
show(wf(s))
show(diam,bg,ed)
show(v)
'''

Measured memory_bytes: 56924
fun main(args: Array<String>) {
    val n = readInteger()
    val ps = readIntegerArray()
    var min = 2 * 100000 + 1
    var ans = 0
    for (p in ps) {
        if (p <= min) {
            ans++
        }

        min = Math.min(min, p)
    }

    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerArray() = readStringList().map(String::toInt).toIntArray()
fun readLongArray() = readStringList().map(String::toLong).toLongArray()


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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

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

    p.push_back(0);

    ll i=0,ans=0;
    while(i!=n){
        if(i+1==p[i]){
            swap(p[i],p[i+1]);
            ans++;
        }
        i++;
    }

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

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int a[n];

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

    long long sum = 0, mid = a[n/2];

    for(int i = 0; i < n; ++i) sum += abs(a[i] - mid);
    cout << sum;
}


Measured memory_bytes: 1024
from collections import OrderedDict

N = int(input())

city = set()

rest = OrderedDict()

for i in range(N):
    sp = input().split()

    if sp[0] in city:
        rest[sp[0]].append([int(sp[1]), i])
    else:
        city.add(sp[0])
        rest[sp[0]] =[[int(sp[1]), i]]

index = sorted(rest)

for i in index:
    for r in sorted(rest[i], reverse=True):
        print(r[1]+1)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int k; cin>>k;
    string s; cin>>s;
    if (s.length() <= k) {
        cout << s << '\n';
        return 0;
    }
    string ans = s.substr(0,k)+"...";
    cout << ans << '\n';
    return 0;
}

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

int main() {
    //
    long long cnt = 0;
    string str;
    char tmpStr;
    cin >> str;

    tmpStr = str.at(0);
    for (int i = 1; i < str.size(); i++) {
        if (tmpStr == str.at(i)) continue;

        tmpStr = str.at(i);
        cnt++;
    }

    cout << cnt;
    //
}


Measured memory_bytes: 3728
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
 
t = 0
for i in B:
  t = t + i
  
y = []
for x in range(len(A)-1):
  if A[x] + 1 == A[x+1]:
    y.append(A[x]-1)
  else:
    pass
for k in y:
  t = t + C[k]
print(t)

Measured memory_bytes: 3064
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
  for(int times; scanf("%d", &times), times != 0;) {
    int[] prev, curr = new int[](times);
    int counter = 0;
    int[int] set;
    
    foreach(i; 0..times) {
      scanf(i == times - 1 ? "%d\n" : "%d ", &curr[i]);
      set[curr[i]] = 0;
    }
    
    while(true) {
      foreach(ref i; set) i = 0;
      for(int i = 0; i < times; i++) set[curr[i]]++;
      prev = curr.dup;
      for(int i = 0; i < times; i++) curr[i] = set[curr[i]];
      if (prev != curr) {
        counter++;
        continue;
      }
      else break;
    }
    writeln(counter, "\n", curr.map!(to!string).join(" "));
  }
}

Measured memory_bytes: 1240
import java.io.*;

public class Main {
	public static void main(String args[]) throws IOException{
		String str;
		int i,d;
		int total = 0;
		int x;
		
		BufferedReader input =
				new BufferedReader(new InputStreamReader(System.in));
		while((str = input.readLine()) != null){
			d = Integer.parseInt(str);
			x = 0; //図形に書き出すと四角形は600/d - 1個
			for(i = 0; i < 600/d; i++){
				total += x * x * d;
				x += d;
			}
			System.out.println(total);
			//x = 0;
			total = 0;
		}
	}
}

Measured memory_bytes: 16864
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

struct LowestCommonAncestor {
    const vector<vector<int>> &g;
    int h;
    vector<vector<int>> par;    // par[k][v] := 2^k-th parent of v
    vector<int> dep, ord;
    LowestCommonAncestor(const vector<vector<int>> &g, int r = 0)
        : g(g), dep(g.size()), ord(g.size()) { build(r); }
    void build(int r) {
        int V = g.size(), id = 0;
        h = 1; while ((1 << h) < V) ++h;        // 32 - __builtin_clz(V)
        par.assign(h, vector<int>(V, -1));
        dfs(r, -1, 0, id);
        for (int k = 0; k + 1 < h; ++k) for (int v = 0; v < V; ++v) {
            if (par[k][v] != -1) par[k + 1][v] = par[k][par[k][v]];
        }
    }
    void dfs(int u, int p, int d, int &id) {
        par[0][u] = p;
        dep[u] = d;
        ord[u] = id++;
        for (auto v: g[u]) if (v != p) dfs(v, u, d + 1, id);
    }
    int get(int u, int v) {
        if (dep[u] > dep[v]) swap(u, v);
        for (int k = 0; k < h; ++k) {
            if ((dep[v] - dep[u]) >> k & 1) v = par[k][v];
        }
        if (u == v) return u;
        for (int k = h - 1; k >= 0; --k) {
            if (par[k][u] != par[k][v]) u = par[k][u], v = par[k][v];
        }
        return par[0][u];
    }
    int ancestor(int u, int k) {
        for (int i = h - 1; i >= 0; i--) if (k >> i & 1) u = par[i][u];
        return u;
    }
    int dist(int u, int v) { return dep[u] + dep[v] - dep[get(u, v)] * 2; }
};

int main() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        while (k--) {
            int c; cin >> c;
            g[i].emplace_back(c);
            g[c].emplace_back(i);
        }
    }
    LowestCommonAncestor lca(g);
    int q; cin >> q;
    while (q--) {
        int u, v; cin >> u >> v;
        cout << lca.get(u, v) << endl;
    }
    return 0;
}



Measured memory_bytes: 18840
def main():
    a,b=map(int,input().split())
    grid=[["#"]*100 for _ in [0]*50]+[["."]*100 for _ in [0]*50]
    cnt=0
    flag=False
    for i in range(0,40,2):
        for j in range(0,100,2):
            if cnt>=a-1:
                flag=True
                break
            grid[i][j]="."
            cnt+=1
        if flag:break
    cnt=0
    flag=False
    for i in range(60,100,2):
        for j in range(0,100,2):
            if cnt>=b-1:
                flag=True
                break
            grid[i][j]="#"
            cnt+=1
        if flag:break
    for i in range(100):
        grid[i]="".join(grid[i])
    print(100,100)
    for i in grid:
        print(i)
main()

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int ans = 0;


		if(N>=195) ans = 5;

		else if(N>=189) ans = 4;

		else if(N>=165) ans = 3;

		else if(N>=135) ans = 2;

		else if(N>=105) ans = 1;

		System.out.println(ans);

	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POSSIBLE(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Possible(i) cout<<(i?"Possible":"Impossible")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
//
int main(){
	int N;
	cin>>N;
	ll V[200000],VV[200000];
	FOR(i,0,N){
		cin>>V[i];
		VV[i]=V[i];
	}
	FOR(i,1,N){
		V[i]+=V[i-1];
	}
	ROF(i,0,N-1){
		VV[i]+=VV[i+1];
	}
	reverse(VV,VV+N);
	ll P,Q,R,S;
	ll p,q,r,s;
	ll ans=1e18+7;
	//
	for(int i=1;i<=N-3;i++){
		//
		ll A=V[i]/2;
		ll nu=upper_bound(V,V+i+1,A)-V;
		P=V[nu];Q=V[i]-V[nu];
		if(nu!=0){
			p=V[nu-1];q=V[i]-V[nu-1];
		}
		//
		ll B=VV[N-i-1-1]/2;
		ll mu=upper_bound(VV,VV+N-1-i,B)-VV;
		S=VV[mu];R=VV[N-1-i-1]-VV[mu];
		if(mu!=0){
			s=VV[mu-1];r=VV[N-1-i-1]-VV[mu-1];
		}
		//
		ll ma=max({P,Q,R,S});
		ll mi=min({P,Q,R,S});
		ans=min(ans,abs(ma-mi));
		if(nu!=0&&mu!=0){
			ma=max({p,q,r,s});
			mi=min({p,q,r,s});
			ans=min(ans,abs(ma-mi));
		}
		if(nu!=0){
			ma=max({p,q,R,S});
			mi=min({p,q,R,S});
			ans=min(ans,abs(ma-mi));
		}
		if(mu!=0){
			ma=max({P,Q,r,s});
			mi=min({P,Q,r,s});
			ans=min(ans,abs(ma-mi));
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll=long long;

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define rrep(i,m) RREP(i,m,0)
const int MOD=1e9+7;

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;}
template<typename T>
void fail(T v){cout << v << endl;exit(0);}

void solve(){
  int a,b;
  cin >> a >> b;
  if(a>9||b>9)
    fail(-1);
  cout << a*b << endl;
  
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

	for (int ans = 0; ans < 10000; ans++) {
		if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			cout << ans << endl;
			return 0;
		}
		ll aa = A / 2, bb = B / 2, cc = C / 2;
		A = bb + cc;
		B = cc + aa;
		C = aa + bb;
		if (A % 2 == 0 && A == B && A == C) break;
 	}
	cout << -1 << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  set_bool_name("YES", "NO");
  int x;
  //for (int i = 0; i < 1e9; ++i)
  cin >> x;
  cout << (x == 3 || x == 5 || x == 7) << endl;
}



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

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}

    ll root(ll x) {
        if (data[x] < 0)
            return x;
        else
            return data[x] = root(data[x]);
    }

    ll size(ll x) { return -data[root(x)]; }

    bool isConnect(ll x, ll y) { return root(x) == root(y); }

    bool connect(ll x, ll y) {
        x = root(x);
        y = root(y);

        if (x == y)
            return false;

        if (data[x] > data[y]) {
            x ^= y;
            y ^= x;
            x ^= y;
        }

        data[x] = data[x] + data[y]; // membersize++
        data[y] = x;
        return true;
    }
};

class DFriendSuggestions {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, M, K;
	    in >> N >> M >> K;
	    UnionFind U = UnionFind(N);
	    int adj[N];
	    REP(i, N) adj[i] = 0;
	    REP(i, M) {
	        int a, b;
	        in >> a >> b;
	        a--;
	        b--;
	        adj[a]++;
	        adj[b]++;
	        U.connect(a, b);
	    }
	    int block[N];
	    REP(i, N) block[i] = 0;
	    REP(i, K) {
	        int c, d;
	        in >> c >> d;
	        c--;
	        d--;
	        if (U.isConnect(c, d)) {
	            block[c]++;
	            block[d]++;
	        }
	    }
	    REP(i, N) {
	        int x = U.size(i) - 1;
	        x -= adj[i];
	        x -= block[i];
	        out << x << ' ';
	    }
	    out << '\n';
	}
};


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


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 2019;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

	int l, r;
	cin >> l >> r;

	int ans = MOD * MOD;
	for (int i = l; i < min(r, l + 2 * MOD); i++) {
		for (int j = i + 1; j <= min(r, l + 2 * MOD); j++) {
			ans = min(ans, (i % MOD) * (j % MOD) % MOD);
		}
	}

	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	string n;
	cin>>n;
	for(int i =0; i<n.length(); i++)
	{
		if( n[i] == '1')
		{
			cout<<"9";
		}
		else if(n[i] == '9')
		{
			cout<<"1";
		}
		else 
			cout<<n[i];
	}

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextString() string {
	sc.Scan()
	return sc.Text()
}

const (
	a = "A"
	t = "T"

	c = "C"
	g = "G"
)

func main() {
	n := nextString()
	f := func(n string) string {
		switch n {
		case a:
			return t
		case t:
			return a
		case c:
			return g
		case g:
			return c
		}
		return ""
	}
	r := f(n)
	fmt.Println(r)
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    ll x, y;
    cin >> x >> y;
    ll a = x;
    ll ans = 0ll;
    while(a <= y){
        ans++;
        a = a << 1;
    }
    cout << ans << "\n";
}

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

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


def main():
    N = int(input())
    result = 0
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            result += i
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
// use procontools::prelude::*;
use proconio::input;
macro_rules! p {
    ($x:expr) => {
        println!("{}", $x);
    };
}
fn main() {
    input! {
    mut x:u64,
        }
    let mut n = 100;
    for i in (1..) {
        n = ((n as f64) * 1.01).floor() as u64;
        if n >= x {
            p!(i);
            return;
        }
    }
}


Measured memory_bytes: 2620
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,x;
    scanf("%d %d %d %d",&a,&b,&c,&x);
    int k=0;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
           for(int q=0;q<=c;q++)
           {
               if(x==(i*500+j*100+q*50))
               {
                   k++;
                   break;
               }
           }
        }
    }
    printf("%d\n",k);
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
N = len(S)

for i in range(-(-N//2)):
  if S[i*2] == "L":
    print("No")
    exit()
    
for i in range(N//2):
  if S[i*2+1] == "R":
    print("No")
    exit()

    
print("Yes")

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, K - Q);
    rep(i, Q) {
        int tmp;
        cin >> tmp;
        A[--tmp] += 1;
    }
    rep(i, N) {
        if (A[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;
bool graph[8][8];
 
const int NUMBER_OF_SAMPLES = 100000000;
int main(){
    ll a,b,n;
    cin >> a >> b >> n;

    ll x = min(n,b-1);

    cout << (a*x)/b << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	double a,b,c,d,s,l,h,PI=3.14159265358979;
	cin>>a>>b>>c;
	c=(c*PI)/180;
	s=(0.5*a*b)*sin(c);
	d=sqrt(((a*a)+(b*b))-(2*a*b*cos(c)));
	h=(s*2)/a;
	l=a+b+d;
	printf("%.8lf\n%.8lf\n%.8lf\n",s,l,h);
	return 0;
}

Measured memory_bytes: 3448
gcd' :: Int -> Int -> Int
gcd' x 0 = x
gcd' x y = gcd' y (x `mod` y)

ans :: Int -> Int -> Int
ans x y =
  if x >= y
  then gcd' x y
  else gcd' y x

main = do
  l <- getLine
  let i  = map read $ words l :: [Int]
      o  = ans (i!!0) (i!!1)
  putStrLn $ show o

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, A[MAXN+10];
ll dp[MAXN+10];

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++) scanf("%d", &A[i]);

    dp[2]=abs(A[2]-A[1]);
    for(i=3; i<=N; i++) dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]));

    printf("%d", dp[N]);
}


Measured memory_bytes: 1408
from collections import Counter
N, M = map(int, input().split())

if M == 1 :
    print(1)

else :
    mod = 10 ** 9 + 7

    fac = [1]
    inv = [1]
    for i in range(1, N + 1) :
        fac.append(fac[-1] * i % mod)
        inv.append(pow(fac[-1], mod - 2, mod))

    def rec(m, pre_divisor, divisors, lev) :
        ret = 0
        if lev == N :
            comb = fac[N]
            for c in Counter(divisors + [m]).values() :
                comb *= inv[c]
                comb %= mod
            ret += comb
            ret %= comb
            return ret
        
        i = pre_divisor
        while i * i <= m :
            if m % i == 0 :
                ret += rec(m // i, i, divisors + [i], lev + 1)
            i += 1
        
        comb = fac[N]
        for c in Counter(divisors + [m]).values() :
            comb *= inv[c]
            comb %= mod
        comb *= inv[N-lev-1]
        comb %= mod
        ret += comb
        ret %= mod
        return ret
        
    print(rec(M, 2, [], 0))

Measured memory_bytes: 72268
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int a[200005];
int main()
{
	int n=rd();
	F(i,2,n) ++a[rd()];
	F(i,1,n) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 4436
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  int ans=999;
  REP(i,S.size()-2){
    int X=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0')*1;
    // cerr<<X<<endl;
    ans=min(ans,(int)abs(X-753));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A >= K) {
    cout << K << endl;
  }
  if (K > A && K <= A+B) {
    cout << A << endl;
  }
  if (K > A+B) {
    cout << A - (K - A - B) << endl;
  }
}
    

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/all>
using namespace atcoder;


int main(){
    int n,d;
    scanf("%d%d",&n,&d);
    vector<int> x(n),y(n);
    rep(i,n){
        scanf("%d%d",&x[i],&y[i]);
    }
    two_sat ts(n);
    rep(i,n)rep(j,i){
        if(abs(x[i]-x[j])<d){
            ts.add_clause(i,false,j,false);
        }
        if(abs(x[i]-y[j])<d){
            ts.add_clause(i,false,j,true);
        }
        if(abs(y[i]-x[j])<d){
            ts.add_clause(i,true,j,false);
        }
        if(abs(y[i]-y[j])<d){
            ts.add_clause(i,true,j,true);
        }
    }

    if(!ts.satisfiable()){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    vector<bool> ans = ts.answer();

    for(int i=0;i<n;i++){
        if(ans[i]) cout << x[i] << endl;
        else cout << y[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2,s3;
  cin >>s1>>s2>>s3;
  int A,B;
  A=s1.size();
  B=s2.size();
  if(s1[A-1]==s2[0]&&s2[B-1]==s3[0])cout <<"YES"<< endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T>
class CuSum {
private:
	vector<T> cusum;
public:
	// Constructors 
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)vec.size(); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(int N) : cusum(N + 1) {}
	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)cusum.size() - 1; i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r)
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r] - cusum[l];
	}
	// 0-indexed
	T operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<lint> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	CuSum<lint> sA(A);

	auto biSearch = [&](int l, int r) {

		int ng = l;
		int ok = r;

		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if (sA(l, mid) - sA(mid, r) > 0) ok = mid;
			else ng = mid;
		}
		DMP(ok, ng);
		return sA(l, ok) - sA(ok, r) > sA(ng, r) - sA(l, ng) ? ng : ok;
	};

	lint ans = LINF;
	for (int div = 2; div < N - 1; div++) {
		DMP(div);
		int lmin = biSearch(0, div);
		int rmin = biSearch(div, N);

		auto tmp = minmax({ sA(0, lmin), sA(lmin, div), sA(div, rmin), sA(rmin, N) });
		DMP(tmp);
		ans = min(ans,tmp.second-tmp.first);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e18+100;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int N;
int a[10];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	int odd = 0, even = 0;
	REP(i, N) if (a[i] & 1) odd++; else even++;

	
	int ans = pow(3, N) - pow(2, even);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int date[11];
	for(int i = 0; i < 10; i++){
		scanf("%c", &date[i]);
	}
	
	for(int i = 0; i < 10; i++){
		date[3] = '8';
		printf("%c", date[i]);
	}

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>

using namespace std;

const double EPS = 1e-11;

int K;
double R, L, P, E, T;

double calc(double l, double r, int k, double p){
  if(T-E-EPS < l && r < T+E+EPS) return p;
  if(l < T-E-EPS && r < T-E-EPS) return 0.0;
  if(l > T+E+EPS && r > T+E+EPS) return 0.0;
  double h = (r + l) / 2.0;
  if(k >= K) return (T-E-EPS < h && h < T+E+EPS ? p : 0.0);
  double res = 0.0;
  if(h < T){
    res += calc(h, r, k+1, p * (1-P));
    res += calc(l, h, k+1, p * P);
  }else{
    res += calc(l, h, k+1, p * (1-P));
    res += calc(h, r, k+1, p * P);
  }
  return res;
}

main(){
  cin >> K >> L >> R >> P >> E >> T;
  printf("%.6f\n", calc(L, R, 0, 1.0));
}

Measured memory_bytes: 1248
#include <iostream>
#include <cmath>

using namespace std;

double P, E, T;

int C(int n, int r) {
    int res = 1;
    for (int i = 1; i <= r; ++i)
        res = res * (n - i + 1) / i;
    return res;
}

double Dfs(double L, double R, int cnt)
{
    if (cnt == 0) {
        if (abs((R + L) * 0.5 - T) <= E)
            return 1.0;
        else
            return 0.0;
    }
    else if (T < R - E || L + E < T)
        return 0.0;
    else if (max(abs(R - T), abs(L - T)) <= E) {
        double res = 0.0;
        for (int i = 0; i <= cnt; ++i)
            res += C(cnt, i) * pow(1.0 - P, i) * pow(P, cnt - i);
        return res;
    }

    double H = (R + L) * 0.5;
    double res = 0.0;

    if (T > H) {
        res += (1.0 - P) * Dfs(L, H, cnt - 1);
        res += P * Dfs(H, R, cnt - 1);
    }
    else {
        res += (1.0 - P) * Dfs(H, R, cnt - 1);
        res += P * Dfs(L, H, cnt - 1);
    }

    return res;
}

int main()
{
    int K;
    double R, L;

    cin >> K >> R >> L >> P >> E >> T;

    printf("%.8f\n", Dfs(L, R, K));

    return 0;
}

Measured memory_bytes: 1292