akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int a,b,ans=-1;
	cin>>a>>b;
	for(int i=1;i<=1250;i++){
		if(floor(i*0.08)==a&&floor(i*0.1)==b){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
x_list = list(map(int, input().split()))
sorted_x = sorted(x_list)

medi = N//2
l = sorted_x[medi-1]
r = sorted_x[medi]
for x in x_list:
    if x < r:
        print(r)
    else:
        print(l)


Measured memory_bytes: 30864
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 
#include <unordered_set>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

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

struct Block {
	ll w;
	ll s;
	ll v;
};

Block arr[1000];
int n;

bool cmp(Block a, Block b) {
	return a.s + a.w < b.s + b.w;
}
ll dp[1000][10001];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i].w >> arr[i].s >> arr[i].v;
	}
	sort(arr, arr + n, cmp);
	ll ans = 0;
	dp[0][arr[0].w] = arr[0].v;
	ans = max(ans, arr[0].w);
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= 10000; j++) dp[i][j] = dp[i - 1][j];
		for (int j = 0; j <= arr[i].s; j++) {
			ans = max(ans, dp[i - 1][j] + arr[i].v);
			if (j + arr[i].w > 10000) continue;
			dp[i][j + arr[i].w] = max(dp[i][j + arr[i].w], 
				dp[i - 1][j] + arr[i].v);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

void BGoToJail(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    int cnt = 0;
    int suc = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        in >> a >> b;
        if (a == b) {
            ++cnt;
            if (cnt >= 3) suc = 1;
        } else {
            cnt = 0;
        }
    }
    out << (suc ? "Yes" : "No") << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    BGoToJail(in, out);
    return 0;
}

Measured memory_bytes: 3636
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
const int MAXN = 8e2 + 10 , INF = 1e10;
int w , h , k , idx , idy , _mn = INF , mn , dis[MAXN][MAXN];
int dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0 , 0 , 1 , -1};
char a[MAXN][MAXN];
bool bo[MAXN][MAXN];
queue<pii> q;
bool isval(int x , int y)
{
	return (x >= 0 and y >= 0 and x < w and y < h and a[x][y] != '#' and !bo[x][y]);
}
void bfs()
{
	while(!q.empty())
	{
		pii u = q.front();
		q.pop();
		for(int i = 0 ; i < 4 ; i ++)
			if(isval(u.f + dx[i] , u.s + dy[i]))
				dis[u.f + dx[i]][u.s + dy[i]] = dis[u.f][u.s] + 1 , q.push(mp(u.f + dx[i] , u.s + dy[i])) , bo[u.f + dx[i]][u.s + dy[i]] = true;
	}
	return;
}
void input()
{
	cin >> w >> h >> k;
	for(int i = 0 ; i < w ; i ++)
		for(int j = 0 ; j < h ; j ++)
		{
			cin >> a[i][j];
			if(a[i][j] == 'S')
				idx = i , idy = j;
		}
	return;
}
int32_t main()
{
	input();
	for(int i = 0 ; i < w ; i ++)
		for(int j = 0 ; j < h ; j ++)
			dis[i][j] = INF;
	dis[idx][idy] = 0 , bo[idx][idy] = true , q.push(mp(idx , idy)) , bfs();
	for(int i = 0 ; i < w ; i ++)
		for(int j = 0 ; j < h ; j ++)
			if(dis[i][j] <= k)
				mn = min(i , j) , mn = min(mn , min(w - i - 1 , h - j - 1)) , _mn = min(_mn , (k + mn - 1) / k + 1);
	return cout << _mn << endl , 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,s=0;
	char c;
	for(i=0;i<4;i++)
	{
		scanf("%c",&c);
		if(c=='+')
			s+=1;
		else
			s--;
	}
	printf("%d",s);
	return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int l,r,d,ans=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++)
		if(i%d==0)
			ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3644
h,w,k = gets.split.map(&:to_i)
c = h.times.map{gets.chomp}

sum_black = 0
sum_h = Array.new(h, 0)
sum_w = Array.new(w, 0)
(h).times do |i|
  (w).times do |j|
    if c[i][j] == '#'
      sum_black += 1
      sum_h[i] += 1
      sum_w[j] += 1
    end
  end
end

ans = 0
[0, 1].repeated_permutation(h) do |h_bits|
  [0, 1].repeated_permutation(w) do |w_bits|
    t = 0
    h.times do |i|
      if h_bits[i] == 1
        t += sum_h[i]
      end
    end
    w.times do |i|
      if w_bits[i] == 1
        t += sum_w[i]
      end
    end
    h.times do |i|
      w.times do |j|
        if h_bits[i] == 1 && w_bits[j] == 1 && c[i][j] == '#'
          t -= 1
        end
      end
    end
    if sum_black - t == k
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 14340
#include <iostream>

int main()
{
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;

	int duration = (b < c) ? 0 : (d < a) ? 0 : std::min(b, d) - std::max(a, c);

	std::cout << duration << std::endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];

  int s = 0;
  rep(i,N) s ^= a[i];
  rep(i,N) cout << (a[i] ^ s) << endl;
}


Measured memory_bytes: 4024
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int w,h;
int b;
char c[33][33];

struct P{
  int x,y;
  P(int x,int y):x(x),y(y){}
};

vector<P> v;
int used[33][33];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int d[11][11];
int p;

int dp[1<<11][11];
int solve(int bit,int a){
  if(bit == (1<<p)-1) return 0;
  if(dp[bit][a] >= 0) return dp[bit][a];

  int ret = 1 << 28;
  for(int i = 1; i < p; i++){
    if(bit & 1 << i)continue;
    ret = min(ret,solve(bit | 1<<i,i) + d[a][i]);
  }
  return dp[bit][a] = ret;
}

int main(void){
  while(cin >> w >> h && w){
    v.clear();
    memset(c,-1,sizeof(c));
    v.push_back(P(0,0));
    p = 1;
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	cin >> c[j][i];
	if(c[j][i] == 'o'){
	  c[j][i] = 0;
	  v[0].x = j;
	  v[0].y = i;
	}else if(c[j][i] == '*'){
	  c[j][i] = p;
	  p++;
	  v.push_back(P(j,i));
	}else if(c[j][i] == 'x'){
	  c[j][i] = -1;
	}
      }
    }

    memset(d,-1,sizeof(d));
    bool f = false;
    for(int i = 0; i < p; i++){
      memset(used,-1,sizeof(used));
      queue<P> que;
      que.push(P(v[i].x,v[i].y));
      used[v[i].x][v[i].y] = 0;
      while(!que.empty()){
	P a = que.front(); que.pop();
	if(c[a.x][a.y] == -1) continue;
	if(c[a.x][a.y] != '.'){
	  //cout << (int)c[a.x][a.y] << " : " << used[a.x][a.y] << endl;
	  d[i][(int)c[a.x][a.y]] = used[a.x][a.y];
	}
	for(int i = 0; i < 4; i++){
	  int nx = a.x + dx[i];
	  int ny = a.y + dy[i];
	  if(used[nx][ny] == -1){
	    que.push(P(nx,ny));
	    used[nx][ny] = used[a.x][a.y] + 1;
	  }
	}
      }

      for(int j = 0; j < p; j++){
	//cout << i << " > " << j << " = " << d[i][j] << endl;
	if(d[i][j] == -1){
	  f = true;
	  break;
	}
      }
      if(f) break;
    }
    if(f){
      cout << -1 << endl;
    }else{
      memset(dp,-1,sizeof(dp));
      cout << solve(1,0) << endl;
    }
  }
}

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

int main()
{
	long long a,b=1;
	cin >> a;
	for (int i = 1; i <= a; i++) {
		b = i*b;
		b = b % 1000000007;
	}
	cout << b << endl;
    return 0;
}


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

int main()
{
    int n;
    int a[100005];
    int b[100005];
    scanf("%d",&n);
    long long sum=0;
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    b[0]=abs(0-a[0]);
    sum+=b[0];
    for (int i=1;i<n;i++) { b[i]=abs(a[i]-a[i-1]); sum+=b[i]; }
    b[n]=abs(0-a[n-1]);
    sum+=b[n];
    long long ans=sum-b[0]-b[1]+abs(a[1]);
    printf("%lld\n",ans);
    for (int i=1;i<n;i++)
    {
        ans=sum-b[i]-b[i+1]+abs(a[i+1]-a[i-1]);
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2048
# Coding is about expressing your feeling and there is always a better way to express your feeling _feelme
import sys,math,numpy as np
#sys.stdin,sys.stdout=open('input.txt','r'),open('output.txt','w')
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# np.set_printoptions(sign=' ',legacy='1.13') # legacy add space at sign position
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(arr, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if arr[mid] == val:return mid
        elif arr[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,arr):
    for i in range(1,n):arr[i]+=arr[i-1]
    return arr;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;


n = ii1()
s=is1()
a=Counter(s)
W=a['W']
R=a['R']
# print(W,R)
if W == n or R == n:
    print(0)
else:
    countr=0
    countw=0
    for i in range(R,n):
        if s[i]=='R':
            countr+=1
        else:
            countw+=1
    print(countr)


Measured memory_bytes: 27460
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto &x:a)cin>>x;
    vector<int> dp(n+1);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


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

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

    int sum = 0, ub = 0;
    for(int i=1;i<=n;++i){
        sum += i;
        if(sum >= n){
            ub = i;
            break;
        }
    }

    for(int i=ub;i>0;--i){
        if(n >= i){
            cout << i << endl;
            n -= i;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
	int r[MAX], n;

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

	int maxv = -2000000000;
	int minv = r[0];

	for (int i = 1; i < n; i++)
	{
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}

	cout << maxv
		<< endl;

	return 0;
}


Measured memory_bytes: 3876
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=20010;
const int maxm=20010;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int maxpos=0,minpos=inf;
    for(int i=0;i<n;i++)
    {
        int p;
        scanf("%d",&p);
        maxpos=max(maxpos,p);
        minpos=min(minpos,p);
    }
    printf("%d\n",maxpos-minpos);
    return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        struct ItemInfo
        {
            internal int value, weight;
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int weightLimit = int.Parse(input[1]);

            ItemInfo[] itemList = new ItemInfo[n];

            for (int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');
                itemList[i].value = int.Parse(input[0]);
                itemList[i].weight = int.Parse(input[1]);
            }

            Nullable<int>[] dp = new Nullable<int>[weightLimit + 1];
            dp[0] = 0;

            foreach (var item in itemList)
            {
                for (int i = 0; i <= weightLimit; i++)
                {
                    int sumWeight = i + item.weight;

                    if (sumWeight > weightLimit) continue;

                    if (dp[i] == null) continue;
                    int sumValue = dp[i].Value + item.value;

                    if (dp[sumWeight] == null || dp[sumWeight] < sumValue)
                    {
                        dp[sumWeight] = sumValue;
                    }
                }
            }

            Console.WriteLine(dp.Max());
        }
    }
}

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

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

	static class BFizzBuzzSum {
		public void solve(int testNumber, Scanner in, PrintWriter out) {
			int n = in.nextInt();
			long sum = 0;
			for (int i = 1; i <= n; ++i) {
				if (i % 3 != 0 && i % 5 != 0) {
					sum += i;
				}
			}
			out.print(sum);
		}

	}
}



Measured memory_bytes: 27248
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (C >= A && B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 3624
#define		_CRT_SECURE_NO_WARNINGS
#include <cstdio>

#define		MAX			101

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

	int		A[MAX][MAX];

	for (int i = 0; i < r; i++)
	{
		int	sum = 0;
		for (int j = 0; j < c; j++)
		{
			scanf("%d", &(A[i][j]));
			sum += A[i][j];
		}
		A[i][c] = sum;
	}

	for (int i = 0; i <= c; i++)
	{
		int	sum = 0;
		for (int j = 0; j < r; j++)
		{
			sum += A[j][i];
		}
		A[r][i] = sum;
	}

	for (int i = 0; i <= r; i++)
	{
		for (int j = 0; j <= c; j++)
		{
			if (j != 0)	printf(" ");
			printf("%d", A[i][j]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2724
S = input()
ary1 = [int(x) for x in S]
ary2 =[]

for x in ary1:
  if ary2 == []:
    ary2.append(x)
  elif ary2[-1] == x:
    ary2.append(x)
  else :
    ary2.pop()

print(len(S)-len(ary2))
    


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

int day;
int c[27];
int d[366][26], ansday[366];

void read_input() {
        //freopen("b1.in", "r", stdin);
        cin >> day;
        for (int i= 0; i< 26; i++) {
                cin >> c[i];
        }
        for (int i= 0; i< day; i++) {
                for (int j= 0; j< 26; j++) {
                        cin >> d[i][j];
                }
        }
}

void read_ans() {
        for (int i= 0; i< day; i++) {
                int x; cin >> x;
                ansday[i]= x- 1;
        }
}

void simu() {
        int lastuse[27]= {};
        int finalscore= 0;
        for (int i= 0; i< day; i++) {
                int choose= ansday[i];
                int score= d[i][choose];
                lastuse[choose]= i+ 1;
                int dec= 0;
                for (int j= 0; j< 26; j++) {
                        dec+= c[j]* ((i+ 1)- lastuse[j]);
                }
                finalscore+= score- dec;
        }
        cout << finalscore<< "\n";
}

void query() {
        int m; cin >> m;
        vector<pair<int, int>> vp;
        for (int i= 0; i< m; i++) {
                int a, b; cin >> a>> b;
                vp.push_back({a, b});
        }
        for (int i= 0; i< m; i++) {
                int wday= vp[i].first- 1;
                int wc= vp[i].second- 1;
                ansday[wday]= wc;
                simu();
        }
}

void sol() {
        int lastuse[27]= {};
        for (int i= 0; i< day; i++) {
                vector<pair<int, int>> r;
                for (int j= 0; j< 26; j++) {
                        int dec= 0;
                        for (int k= 0; k< 26; k++) {
                                if (k== j) continue;
                                dec+= c[k]* ((i+ 1)- lastuse[k]);
                        }
                        r.push_back( { (d[i][j]- dec), j } );
                }
                sort(all(r));
                reverse(all(r));
                ansday[i]= r[0].second;
                lastuse[r[0].second]= i;
        }
        for (int i= 0; i< day; i++) {
                cout << ansday[i]+ 1<< "\n";
        }
}

void solve() {
        read_input();
        //sol();
        read_ans();
        //simu();
        query();
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 5320
#include <iostream>
#include <cstdio>
#include <map>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
int main(){
  ll n;
  while(cin >> n,n){
    vector<ll>ve,ans(n/2+1);
    map<ll,ll>mp;
    fill(ans.begin(),ans.end(),0);
    for(int i = 1 ; i*2 < n ; i++ ){
      if(mp[(i*i)%n] == 0)ve.push_back((i*i)%n);
      mp[(i*i)%n] = 1;
    }
    sort(ve.begin(),ve.end());
    vector<ll>::iterator a =  ve.begin(),b;
    for(; a != ve.end() ; a++ ){
      for(b = a; b != ve.end() ; b++ ){
	if(*b == *a)continue;
	if(((*b) - (*a)) > (n-1)/2 ){
	  ans[(n - (*b) + (*a))]+=2;
	} else {
	  ans[(*b) - (*a)]+=2;
	}
      }
    }
    vector<ll>::iterator it =  ans.begin();
    for(; it != ans.end() ; it++)if((*it) != 0)cout << (*it) << endl;
  }
  return 0;
}

Measured memory_bytes: 1592
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#define ll long long
using namespace std;
ll a[200005];
ll cnt=0;
void dfs(ll x)
{
    if(x>1e10)
        return ;
    a[++cnt]=x;
    for(ll k=0;k<=9;k++)
    {
        if(x%10-k<=1&&x%10-k>=-1)
         dfs(x*10+k);
    }
}
int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=9;i++)
        dfs(i);
    sort(a+1,a+cnt+1);
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    vector<P> vp, vq;
    rep(i, n){
        lint l, r; cin >> l >> r; r++;
        vp.push_back(P(l, r)); vq.push_back(P(l, r));
    }

    sort(all(vp));
    sort(all(vq), [](const P& l, const P& r)->bool{
        return l.se < r.se;
    });

    P p = vp[n-1], q = vq[0]; // p: l最大, q: r最小

    // (1)
    lint ans1 = 0;
    rep(i, n) ans1 = max(ans1, vp[i].se - vp[i].fi);
    ans1 += max(0LL, q.se - p.fi);
    
    // (2)
    lint ans2 = 0;
    vector<lint> vl(n); vl[n-1] = p.se;
    repr(i, n-1) vl[i] = min(vl[i+1], vp[i].se);

    rep(i, n-1){
        lint hp = max(0LL, vl[i+1] - p.fi);
        hp += max(0LL, q.se - vp[i].fi);
        ans2 = max(ans2, hp);
    }

    // (3)
    out(max(ans1, ans2));
}

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

using namespace std;


int main(void) {

	int N;
	long long A[100000],B[100000];
	long long ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	long long maxA = 0;
	int num = 0;

	for (int i = 0; i < N; i++) {
		if (A[i] > maxA) {
			maxA = A[i];
			num = B[i];
		}
	}

	ans = maxA + num;

	cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int K,S; cin >> K >> S;
    int ans=0;
    for(int i=K;i>=0;i--){
        for(int j=i;j>=0;j--){
            int k=S-i-j;
            if(k>j || k<0) continue;
            if(i==j&& j==k) ans++;
            else if(i==j || j==k || i==k) ans+=3;
            else ans+=6;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input())

cnt=[0]*(10**3+1)

for dam in range(2,N+1):
    #素因数分解。
    pf={}
    m=dam
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    # print(pf)
    #{136841: 1, 2: 6, 3: 1, 13: 1}
    for key in pf:
        cnt[key]+=pf[key]

out=1
for i in range(2,10**3+1):
    out*=(cnt[i]+1)
print(out % (10**9+7))


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = (1 << 18) + 10;
int h[N], V[N], W[N];
int ind[N];
const int MID = 7;
const int NUM = (1 << (MID + 2)) - 1;
const int MAXW = 100005;
int dp[NUM][MAXW];
int ans, cnt;

void go(int node, int val, int L){
	if(h[node] <= MID){
		ans = max(ans, val + dp[node][L]);
		return;
	}
	go(node >> 1, val, L);
	if(W[node] <= L) go(node >> 1, val + V[node], L - W[node]);
}

int main(){
	h[1] = 0;
	int n; sd(n);
	for(int i = 1; i <= n; i++){
		sd(V[i]); sd(W[i]);
		if(i != 1) h[i] = h[i >> 1] + 1;
		if(h[i] <= MID){
			memcpy(dp[i], dp[i >> 1], sizeof dp[i]);
			for(int j = MAXW - 1; j >= W[i]; j--) dp[i][j] = max(dp[i][j], dp[i >> 1][j - W[i]] + V[i]);
		}
	}
	int Q; sd(Q); 
	for(int i = 0; i < Q; i++){
		int v, L; sd(v); sd(L);
		ans = 0;
		go(v, 0, L);
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 106508
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int n = sc.nextInt();

        // 処理
        int out = 0;
        for (int i = 1; i <= n; i++){
            out += i;
        }

        // 出力
        System.out.println(out);
    }

}

Measured memory_bytes: 21844
import numpy as np

N,M = map(int, input().split())
ABs = [list(map(int, input().split())) for _ in range(M)]


par = [i for i in range(N+1)] #親＝グループ
size = [1 for _ in range(N+1)] #そのグループに属する要素数

def find(x): #親＝グループを出力
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y): #True or False
    return find(x) == find(y)
def unite(x,y): #2グループをまとめる，サイズ管理
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    size[y] = size[x] + size[y]
    size[x] = 0

for AB in ABs:
    unite(AB[0],AB[1])

print(max(size))


Measured memory_bytes: 73000
#include <bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define int long long
using namespace std;

int n, q, bi, ci, maxn = (int)1e6, tmp;
ll tot;
vector<int> freq(maxn,0);

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;

    for(int i=0; i<n; i++){
        cin>>tmp;
        freq[tmp] ++;
        tot+=(ll)tmp;
    }

    cin>>q;
    while(q--){
        cin>>bi>>ci;
        tmp = freq[bi];

        if(tmp){
            freq[bi] = 0;
            freq[ci] += tmp;

            tot += (ll)ci * (ll)tmp - ((ll)bi * (ll)tmp);
        }
        cout<<tot<<endl;
    }
}

Measured memory_bytes: 10944
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w=map(int,input().split())
    S=[input() for _ in range(w)]
    DP=[[0]*w for _ in range(h)]
    if S[0][0]=='#':
        DP[0][0]=1
    for j in range(1,w):
        if S[0][j-1]=='.' and S[0][j]=='#':
            DP[0][j]=DP[0][j-1]+1
        else:
            DP[0][j]=DP[0][j-1]
    for i in range(1,h):
        if S[i-1][0]=='.' and S[i][0]=='#':
            DP[i][0]=DP[i-1][0]+1
        else:
            DP[i][0]=DP[i-1][0]
        for j in range(1,w):
            if S[i-1][j]=='.' and S[i][j]=='#':
                d=DP[i-1][j]+1
            else:
                d=DP[i-1][j]
            if S[i][j-1]=='.' and S[i][j]=='#':
                r=DP[i][j-1]+1
            else:
                r=DP[i][j-1]
            DP[i][j]=min(d,r)
    print(DP[-1][-1])

if __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef long long ll;
int op(int a, int b) {
    return max(a, b);
}
 
int e() {
    return (int)(0);
}
int main(){
  int n,k;
  const int N=3e5;
  cin>>n>>k;
  atcoder::segtree<int,op,e>seg(N+1);
  int ans=0;
  for(int i=0;i<n;i++){
    int a; cin >> a;
        int p = seg.prod(max(0,a-k),min(N+1,a+k+1))+1;
        seg.set(a,p);
        ans = max(ans,p);
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 8572
#include<stdio.h>

int main(){
    int M[100][100];
    int n, u, k, v;
    int i, j;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            M[i][j]=0;
        }
    }

    for(i=0; i<n; i++){
        scanf("%d %d", &u, &k);
        u--;
        for(j=0; j<k; j++){
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }

    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            if(j) printf(" ");
            printf("%d", M[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++) {
			a[i] = new int[m];
			for (int j = 0; j < m; j++) {
				a[i][j] = scan.nextInt();
			}
		}
		int[][] b = new int[m][];
		for (int i = 0; i < m; i++) {
			b[i] = new int[l];
			for (int j = 0; j < l; j++) {
				b[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				long c = 0;
				for (int k = 0; k < m; k++) {
					c += a[i][k] * b[k][j];
				}
				if (j == 0) {
					System.out.print(c);
				} else System.out.print(" " + c);
			}
			System.out.println();
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 53708
// Union Find Tree
// 高速にグループ分けをするデータ構造
// * 2つメンバーが所属するグループを同じグループにまとめる
// * 2つのメンバーが同じグループに所属するか判定する
//
// verifyした問題
// B - Union Find
// https://atcoder.jp/contests/atc001/tasks/unionfind_a

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

// Union Find Tree
class UnionFindTree
{
private:
    vector<int> parent;
    vector<int> rank;
    int root(int x) { return parent[x] == x ? x : parent[x] = root(parent[x]); }
    vector<int> size; // グループのメンバー数
public:
    // コンストラクタ n: メンバー数
    UnionFindTree(int n)
    {
        parent.resize(n);
        iota(parent.begin(), parent.end(), 0);
        rank.assign(n, 0);
        size.assign(n, 1);
    }
    // メンバーxとメンバーyが同じグループに所属しているかどうかを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // メンバーxとメンバーyが所属するグループを合併する
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;

        if (rank[x] < rank[y])
        {
            parent[x] = y;
            size[y] += size[x];
        }
        else
        {
            parent[y] = x;
            size[x] += size[y];
            if (rank[x] == rank[y])
                rank[x]++;
        }
        return true;
    }
    // メンバーxが所属するグループのサイズを返す
    int getGroupSize(int x) { return size[root(x)]; }
};

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

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

    // 愚直に計算するとTLEする？高速化が必要
    // Union Find Tree を使う
    // Union Find Tree はグループの分割ができない
    // 逆順に操作する
    // 具体的にいうとM番目の橋から1番目の橋まで逆順に橋を建設する
    // これにより i番目の橋が崩落した直後の島と橋の状態を高速に計算できる

    // 橋が無いときの不便さは n * (n - 1) / 2
    // グループXの島xとグループYの島yを繋ぐ橋を建設する
    // (Xのサイズ)*(Yのサイズ) 不便さが減少する
    // グループのサイズはUnion Find クラスに記録する

    // Union Find Tree インスタンスを作成
    UnionFindTree uft(n);

    vector<int> anss(m);
    anss[m - 1] = n * (n - 1) / 2;

    // i番目の橋が崩落した後の状態
    for (int i = m - 1; i > 0; i--)
    {
        // 橋を建築したとき減少する不便さを計算
        int unconf = uft.getGroupSize(a[i]) * uft.getGroupSize(b[i]);
        if (uft.same(a[i], b[i]))
            unconf = 0;

        // 不便さ更新
        anss[i - 1] = anss[i] - unconf;

        // i番目の橋を建築
        uft.unite(a[i], b[i]);
    }

    for (auto &&x : anss)
    {
        cout << x << endl;
    }
}


Measured memory_bytes: 6016
A, B = map(int, input().split())

import fractions
gcd = fractions.gcd(A, B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd == 1:
    print(1)
else:
    fact = factorization(gcd) 
    print(len(fact) + 1)

Measured memory_bytes: 5104
#include<stdio.h>
long long int a[100010], max,max1;
int n, t, s;
int main(){
    int i;
    scanf("%d %d",&n,&t);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        if(max<a[i]){
            max=a[i];
        }else{
            if(max-a[i]==max1) s++;
            else if(max-a[i]>max1){
                max1=max-a[i];
                s=1;
            }
        }
    }
    printf("%d",s);
    
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define testcase() int t; cin>>t; while(t--)
#define fo(n) for (int i = 0; i < n; i++)
#define deb(x) cout << #x << " = " << x << endl;
#define ll long long

using namespace std;

void solve()
{
    int n, k;
    cin >> n >> k;
    int arr[n];
    fo(n)
        cin >> arr[i];
    sort(arr, arr+n);
    int sum = 0;
    for (int i = 0; i < k; i++)
        sum += arr[i];
    cout << sum << endl;
}

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

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000001
#define LINF 1000000000000000001

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

Int n, k, a[200000], c[200001] = {0}, d = 0;

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(c[a[i]] == 0){
			d++;
		}
		c[a[i]]++;
	}
	
	priority_queue<Int, vector<Int>, greater<Int>> pq;
	for(int i = 0; i <= n; i++){
		if(c[i] != 0){
			pq.push(c[i]);
		}
	}
	Int ans =0;
	while(pq.size() > k){
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  for(long long i=-1000;i<1000;i++){
    for(long long j = -1000;j<1000;j++){
      if(i*i*i*i*i - j*j*j*j*j == X){
        printf("%d %d\n",i,j);
        return 0;
      }
    }
  }
  //cout << "muri" << endl;
  //cout << 10000*10000*10000*10000 << endl;
  return 0;
}

Measured memory_bytes: 3764
#include <iostream>
using namespace std;
int main(void){
    int x[5];
    for (int i = 0; i < 5; i++) cin >> x[i];
    
    int index = 0;
    int d = 9;
    for (int i = 0; i < 5; i++) {
        int d_tmp = x[i] % 10;
        if (d >= d_tmp && d_tmp > 0) {
            d = d_tmp;
            index = i;
        }
    }

    int res = 0;
    for (int i = 0; i < 5; i++) {
        if (index == i) {
            res += x[i];
            continue;
        }
        while (x[i] % 10 != 0) x[i] += 1;
        res += x[i];
    }
    cout << res << endl;
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int b = sc.nextInt();

        int array[] = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        for (int i = 0; i < n - b; i++) {
            if (array[b + i] > array[i]){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

        sc.close();

    }

}

Measured memory_bytes: 60044
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
        k: i64,
    }
    let mut ans = 0;
    let mut count: i64 = 0;
    for c in s {
        if c != '1' {
            ans = c as i64 - '0' as i64;
            break;
        } else if c == '1'{
            count += 1;
        }
    }
    
    if k <=  count {
        println!("1");
    } else {
        println!("{}", ans);
    }
    
}
    


Measured memory_bytes: 4352
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
int sum = 0;

for(int i = 0;i<2;i++) {
	if(A>B) {
		sum+=A;
		A--;
	}else{
		sum+=B;
		B--;
	}
}
System.out.println(sum);



	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,q;
int dp[502][502];
int main() {
    int a,b;
    scanf("%d%d%d",&n,&m,&q);
    for(int i = 0;i < m;i ++) {
        scanf("%d%d",&a,&b);
        dp[a][b] ++;
    }
    for(int j = 1;j < n;j ++) {
        for(int i = 1;i + j <= n;i ++) {
            int k = i + j;
            dp[i][k] += dp[i + 1][k] + dp[i][k - 1];
            if(j > 1)dp[i][k] -= dp[i + 1][k - 1];
        }
    }
    for(int i = 0;i < q;i ++) {
        scanf("%d%d",&a,&b);
        printf("%d\n",dp[a][b]);
    }
    return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

/**
 * Created by k-mac on 2014/08/21.
 */
public class Main {
    static Scanner s = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            int num = s.nextInt();
            if(num==0)break;
            int count=0;
            for (int i=1;i*2<num;i++){
                int sum=0;
                for(int j=i;sum<num;j++){
                    sum+=j;
                    if(sum==num){
                        count++;
                        break;
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 19800
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector<int> g[100010];
vector<int> gr[100010];
int n, m;
int c[100010];
bool myon;
ll ans;
vector<int> v;
void dfs(int x){
    v.push_back(x);
    for(auto y:g[x]){
        if(c[y]==0){
            c[y]=c[x]+1;
            if(c[y]==4) c[y]=1;
            dfs(y);
        }else{
            if(c[y]%3!=(c[x]+1)%3){
                myon=1;
            }
        }
    }
    for(auto y:gr[x]){
        if(c[y]==0){
            c[y]=c[x]-1;
            if(c[y]==0) c[y]=3;
            dfs(y);
        }else{
            if((c[y]+1)%3!=c[x]%3){
                myon=1;
            }
        }
    }
}
int main()
{
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int a, b;
        cin>>a>>b;
        a--; b--;
        g[a].push_back(b);
        gr[b].push_back(a);
    }
    for(int i=0; i<n; i++){
        if(c[i]!=0) continue;
        c[i]=1;
        myon=0;
        v.clear();
        dfs(i);
        if(myon){
            ans+=(ll)v.size()*v.size();
            continue;
        }
        ll cnt[3]={};
        for(auto x:v) cnt[c[x]-1]++;
        if(cnt[2]==0 || cnt[1]==0){
            for(auto x:v){
                for(auto y:g[x]) ans++;
            }
            continue;
        }
        ans+=cnt[0]*cnt[1]+cnt[1]*cnt[2]+cnt[2]*cnt[0];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16764
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

x, y = map(int,input().split())

a =    2 * x -  y 
b =   - x + 2 * y 

ans = 0
if a % 3 == 0 and b % 3 == 0:
    a = a//3
    b = b//3
    ans = cmb(a+b, a, mod)
print(ans)

Measured memory_bytes: 122068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C,D;
  cin >> A >> B >> C >> D;
for(int a = 0;a < 100000000;a++){
 C -= B;
  if(C <= 0){
    cout <<"Yes"<<endl;
    break;
  }
  A -= D;
  if(A <= 0){
    cout <<"No"<<endl;
    break;
  }
}
 
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

u64 dp[100010];

int main() {
  cout << setprecision(18);
  u32 N, M;
  cin >> N >> M;
  vector<bool> Broken(N, false);
  for (u32 i = 0; i < M; ++i) {
    u32 a;
    cin >> a;
    Broken[a] = true;
  }
  dp[0] = 1;
  dp[1] = (Broken[1]) ? 0 : 1;
  for (u32 i = 2; i <= N; ++i) {
    if (Broken[i])
      dp[i] = 0;
    else
      dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= MAX_NUM;
  }
  cout << dp[N] << endl;

  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  bool ok = false;
  int cnt = 0;
  for(int i=0; i<n; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if(d1 == d2) cnt++;
    else cnt = 0;
    
    if(cnt == 3) ok = true;
  }
  
  puts(ok?"Yes":"No");
}

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

ll calc(ll a, ll b, ll c) {
    ll t;
    if (a < b) { t = a; a = b; b = t; }
    if (b < c) { t = b; b = c; c = t; }
    if (a < b) { t = a; a = b; b = t; }
    return a - c;
}

ll solve(int h, int w) {

    ll ans = 1e8;
    rep(i, h-1) {

        //
        ll sa = (ll)(i+1) * w;
        ll sb = (ll)(h-(i+1)) * (w/2);
        ll sc = (ll)(h-(i+1)) * ((w/2)+bool(w%2));

        if (sa and sb and sc) {
            ans = min(ans, calc(sa, sb, sc));
        }
        //
        sb = (ll)((h-(i+1))/2) * w;
        sc = (ll)((h-(i+1))/2+bool((h-(i+1))%2)) * w;

        if (sa and sb and sc) {
            ans = min(ans, calc(sa, sb, sc));
        }

    }

    return ans;

}

int main() {

    int H, W;
    cin >> H >> W;
    cout << min(solve(H, W), solve(W, H)) << endl;
    return 0;

}


Measured memory_bytes: 256