akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text.RegularExpressions;

class Program {
	static void Main (string[] args) {
		string str = Console.ReadLine();
    	MatchCollection matche_a = Regex.Matches(str, "[0]");
    	MatchCollection matche_b = Regex.Matches(str, "[1]");
    	if (matche_a.Count >= matche_b.Count) {
        	int ans = matche_b.Count * 2;
        	Console.WriteLine(ans);
        }
    	else
        {
        	int ans = matche_a.Count * 2;
        	Console.WriteLine(ans);
        }
	}
}

Measured memory_bytes: 45396
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, d;
  cin >> n >> d;
  long long int x, y, ans = 0;
  for(int i =0; i < n; i++)
  {
    	cin >> x >> y;
    	long long int k = x*x + y*y;
    	double s = sqrtl(k);
    	if(s <= d)
        {
          ans++;
        }
  }
  cout << ans;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,z=0;
	cin>>n;
	if(n/1000==2)z++;
	if(n%1000/100==2)z++;
	if(n%100/10==2)z++;
	if(n%10==2)z++;
	cout<<z;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, m, ret;
  ret = scanf("%d %d", &n, &m);
  
  int left = 1, right = n, L, R;
  
  for(int i = 0; i < m; i++){ 
    ret = scanf("%d %d", &L, &R);    
    if(left < L) left = L;
    if(right > R) right = R;
  }
  
  left = right - left + 1;
  if(left < 0) left = 0;
  
  printf("%d\n", left);
  
  return 0;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 端点を間違えないように気をつけること!
#define FOR(i, m, n) for (ll i = (ll)(m); i <= (ll)(n); i++)
#define RFOR(i, m, n) for (ll i = (ll)(m); i >= (ll)(n); i--)
// 割り算をするときは自作関数syou,amariを使うこと!
// 入力は変数を宣言した直後に入れること!

int main()
{
    ll N;
    cin >> N;
    ll count = 0;
    ll Max = 0;
    ll H[N + 1];
    FOR(i, 1, N)
    {
        cin >> H[i];
        if (Max <= H[i])
        {
            count++;
            Max = H[i];
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------

string S;

int main() {
  cin >> S;
  int len = S.size();
  int ans = len;
  repe(i, 1, len - 1) {
    if (S[i - 1] != S[i]) {
      chmin(ans, max(i, len - i));
    }
  }
  cout << ans;
}


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

int main() {
  int A;
  cin >> A;
  int B[100100];
  int C = A / 2;
  int D = A / 2 - 1;
  rep(i,A){
   cin >> B[i]; 
  }
 sort(B,B + A);
  int Ans = B[C] - B[D];
  cout << Ans << endl;
}


Measured memory_bytes: 4000
//16:15~16:36
#include <bits/stdc++.h>
using namespace std;

int solve(long long &A, long long &B, long long &C)
{
    long long change = 0;
    long long A0, B0, C0;
    A0 = A;
    B0 = B;
    C0 = C;
    while (A0 % 2 == 0 && B0 % 2 == 0 && C0 % 2 == 0)
    {
        A = B0 / 2 + C0 / 2;
        B = A0 / 2 + C0 / 2;
        C = A0 / 2 + B0 / 2;
        A0 = A;
        B0 = B;
        C0 = C;
        change++;
        if (change == pow(10, 5))
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << change << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long int
int main()
{
	ll n,h;
	cin>>n>>h;
	ll count=0;
	for(ll i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		if(temp>=h)
		{
			count++;
		}
	}
	cout<<count;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;

namespace zyt
{
	const int N = 2e5 + 10;
	int n, m[N], ans[N];
	vector<int> g[N];
	unordered_map<int, int> mp[N];
	int cal(const int u, const int f, const int x)
	{
		if (mp[u].count(x))
			return mp[u][x];
		int ans = 0;
		for (auto v : g[u])
		{
			if (v == f || v > x)
				continue;
			ans += cal(v, u, x) + 1;
		}
		return mp[u][x] = ans;
	}
	void dfs(const int u, const int f, const int mx)
	{
		m[u] = mx;
		if (f)
		{
			if (u > m[f])
				ans[u] = ans[f] + cal(u, f, m[u]) + 1;
			else
				ans[u] = ans[f] + cal(u, f, m[u]) - cal(u, f, m[f]);
		}
		for (auto v : g[u])
		{
			if (v == f)
				continue;
			dfs(v, u, max(mx, u));
		}
	}
	int work()
	{
		scanf("%d", &n);
		for (int i = 1; i < n; i++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			g[a].push_back(b), g[b].push_back(a);
		}
		dfs(1, 0, 0);
		for (int i = 2; i <= n; i++)
			printf("%d ", ans[i]);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 53120
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000
 
int main(){
  int n, i, j, C[MAX + 1] = {0};
  unsigned short *A, *B;
 
  scanf("%d", &n);
 
  A = malloc(sizeof(short) *n+1);
  B = malloc(sizeof(short) *n+1);
 
  for(i = 0; i < n; i++)
    scanf("%hu", &A[i]);
 
  for(i = 0; i < n; i++)
    C[A[i]]++;
 
  for(i = 1; i <= MAX; i++)
    C[i] = C[i] + C[i - 1];
 
  for(j = n - 1; j >= 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
   
  for(i = 1; i < n; i++)
    printf("%d ", B[i]);
  printf("%d\n", B[n]);
   
  return 0;
}

Measured memory_bytes: 8464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int[] a = new int[n];
		int max = 0;
		int next = 0;
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			if(a[i] >= max) {
				next = max;
				max = a[i];
			} else if(a[i] > next) {
				next = a[i];
			}
		}
		for(int i = 0 ; i < n ; i++) {
			if(max == a[i]) {
				System.out.println(next);
			} else {
				System.out.println(max);
			}
		}
		sc.close();
	}

}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    map<int,int> mp;
    for(int i=1;i<n;i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }
    return 0;
}




Measured memory_bytes: 13032
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<ll, ll>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int n, m;
    cin >> n >> m;
    
    vector<P> c(n);
    REP(i, n)
    cin >> c[i].first >> c[i].second;

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

    ll ans = 0;
    ll total = 0;
    for (int i = 0; i < n; i++)
    {
        int num = min(c[i].second, m - total);
        if (num < 1)
            break;
        ans += c[i].first * num;
        total += c[i].second;
    }
    Cout(ans);

    return 0;
}

Measured memory_bytes: 1792
import java.util.*; 
import java.lang.Math;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        
        System.out.println(Math.min(N%K, Math.abs(N%K-K)));
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<long long, long long>>s1, s2; long long n, W, Mid, v[40], w[40], maxn = 0;
int main() {
	cin >> n >> W; Mid = n / 2; for (int i = 0; i < n; i++)cin >> v[i] >> w[i];
	for (int i = 0; i < (1 << Mid); i++) {
		long long R1 = 0, R2 = 0; for (int j = 0; j < Mid; j++) { if ((i / (1 << j)) % 2 == 0) { R1 += v[j]; R2 += w[j]; } }
		s1.push_back(make_pair(R2, R1));
	}
	for (int i = 0; i < (1 << (n - Mid)); i++) {
		long long R1 = 0, R2 = 0; for (int j = 0; j < n - Mid; j++) { if ((i / (1 << j)) % 2 == 0) { R1 += v[j + Mid]; R2 += w[j + Mid]; } }
		s2.push_back(make_pair(R2, R1));
	}
	sort(s2.begin(), s2.end()); for (int i = 1; i < s2.size(); i++) { s2[i].second = max(s2[i].second, s2[i - 1].second); }
	for (int i = 0; i < s1.size(); i++) {
		int pos1 = lower_bound(s2.begin(), s2.end(), make_pair(W - s1[i].first + 1, 0LL)) - s2.begin();
		if (pos1 >= 1)maxn = max(maxn, s1[i].second + s2[pos1 - 1].second);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 43732
function main()
    s = readline()
    r = 1
    l = collect(findnext("L", s, 1))[1]
    b = zeros(Int, length(s))
    b[1] = l - 1
    for i in 2:length(s)-1
        if s[i] == 'R'
            b[i] = l - i
            r = i
        else
            b[i] = i - r
            l = collect(findnext("L", s, i+1))[1]
        end
    end
    b[end] = length(s) - r


    ans = zeros(Int, length(s))
    t = 1000000
    for i in 1:length(s)
        d = t - b[i]
        d = ifelse(isodd(d), 1, 0)
        s[i] == 'L' && (ans[i-b[i]+d] += 1)
        s[i] == 'R' && (ans[i+b[i]-d] += 1)
    end

    for a in ans
        print(a, " ")
    end
end

main()

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const double PI = acos(-1);
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	double a, b, x, ans;
	cin >>a >>b >>x;

	if(x > a * a * b / 2) ans = atan(2 * (a * a * b - x) / (a * a * a));
	else ans = atan((a * b * b) / (2 * x));
	
	printf("%.14f\n", ans * 180/PI);
	return 0;
}


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

int main(){
  char c;
  cin >> c;
  
  if (c == 'a'){
    cout << 'b' << endl;
  }
  
  if (c == 'b'){
    cout << 'c' << endl;
  }
  
  if (c == 'c'){
    cout << 'd' << endl;
  }
  
  if (c == 'd'){
    cout << 'e' << endl;
  }
  
  if (c == 'e'){
    cout << 'f' << endl;
  }
  
 if (c == 'f'){
    cout << 'g' << endl;
  }
  
  if (c == 'g'){
    cout << 'h' << endl;
  }
  
  if (c == 'h'){
    cout << 'i' << endl;
  }
  
  if (c == 'i'){
    cout << 'j' << endl;
  }
  
  if (c == 'j'){
    cout << 'k' << endl;
  } 
  
  if (c == 'k'){
    cout << 'l' << endl;
  }
  
  if (c == 'l'){
    cout << 'm' << endl;
  }
  
  if (c == 'm'){
    cout << 'n' << endl;
  }
  
  if (c == 'n'){
    cout << 'o' << endl;
  }
  
  if (c == 'o'){
    cout << 'p' << endl;
  }
  
  if (c == 'p'){
    cout << 'q' << endl;
  }
  
  if (c == 'q'){
    cout << 'r' << endl;
  }
  
  if (c == 'r'){
    cout << 's' << endl;
  }
  
  if (c == 's'){
    cout << 't' << endl;
  }
  
  if (c == 't'){
    cout << 'u' << endl;
  }
  
  if (c == 'u'){
    cout << 'v' << endl;
  }
  
  if (c == 'v'){
    cout << 'w' << endl;
  }
  
  if (c == 'w'){
    cout << 'x' << endl;
  }
  
  if (c == 'x'){
    cout << 'y' << endl;
  }
  
  if (c == 'y'){
    cout << 'z' << endl;
  }
}
 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, a, x[50];
long long dp[51][51][2501];

long long dfs(int num, int sum, int h) {
    if (dp[num][h][sum] != -1) return dp[num][h][sum];
    if (num == n) {
        if (sum == a * h) return 1;
        else return 0;
    } else {
        return dp[num][h][sum] = dfs(num + 1, sum, h) + dfs(num + 1, sum + x[num], h + 1);
    }
}

int main(void){
    // Your code here!
    cin >> n >> a;
    for (int i = 0; i < 51; i++) {
        for (int j = 0; j < 51; j++) {
            for (int k = 0; k < 2501; k++) {
                dp[i][j][k] = -1;
            }
        }
    }
    for (int i = 0; i < n; i++) cin >> x[i];
    cout << dfs(0, 0, 0) - 1 << endl; // 何も選ばないパターン
}


Measured memory_bytes: 51072
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;


int main(){
	string s;
	unsigned long long k,i = 0;
	cin >> s >> k;
	unsigned long long num = 26;

	while(k > 0){
		if(s[i+1] == '\0'){
		//	cout << k<<endl;
			k%=num;
			for(unsigned long long j =0;j<k;j++){
				s[i] ++;
				if(s[i] > 'z')s[i] = 'a';
			}
			break;
		}else{
			unsigned long long n = (unsigned long long)'z' - s[i] + 1;
		//	cout <<n<<" " <<k<<endl;	
			if(n <= k && s[i] !='a' ){
			//	cout <<"ok"<<endl;
				s[i] = 'a';
				k -= n;
			}else{
				
			}
			i++;
		}
	}

	cout <<s<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main()
{
   int n,m;cin>>n>>m;
   int a[n+1];
   for(int i=1;i<=n;i++) cin>>a[i];
   unordered_map<int,set<int>> mp;
   for(int i=0;i<m;i++)
   {
       int x,y;cin>>x>>y;
       mp[x].insert(y);
       mp[y].insert(x);
   }
   int res=0;
   for(auto x:mp)
   {
       
       bool ok=false;
       for(auto itr:x.second)
       {
           if(a[itr]>=a[x.first])
           {
               ok=true;break;
           }
       }
       if(!ok) 
       {
           res++;
       }
   }
   for(int i=1;i<=n;i++)
   {
       if(mp[i].empty()) res++;
   }
   cout<<res<<"\n";
}

Measured memory_bytes: 21876
N,K = map(int,input().split())
i = 0
d = []
As = []
while True:
  if i != K:
    d.append(int(input()))
    As.append(list(map(int,input().split())))
  else:
    break
  i += 1

r = [0]*N
for x in range(len(d)):
  for y in As[x]:
    r[y-1] += 1

print(r.count(0))

Measured memory_bytes: 67888
n = int(input())
ans = {"AC":0, "WA":0, "TLE":0, "RE":0}
for i in range(n):
    s = input()
    ans[s] += 1

print("AC x",ans["AC"])
print("WA x",ans["WA"])
print("TLE x",ans["TLE"])
print("RE x",ans["RE"])

Measured memory_bytes: 9180
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
ans=0.0
1.upto(N) do|x|
    l=Math.log2(K.to_f/x.to_f).ceil
  if x>=K or l.zero?
      ans+=(1.0/N.to_f)
  else
    ans+=(1.0/N.to_f)*(1.0/(2.0**l))
  end
end
puts ans

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

using namespace std;

int main() {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	
	auto cnton = [&](int x) {
		return __builtin_popcount(x);
	};
	
	auto ok = [&](int a,int b) {
		return (cnton(a) + cnton(b)) & 1;
	};
	
	if (!ok(a, b)) {
		puts("NO");
		return false;
	}
	
	auto bit = [&](int x,int id) {
		return (x >> id) & 1;
	};
	
	function<vector<int>(int,int,vector<int>)> solve = [&](int from,int to,vector<int> val) {
		if (val.size() == 2) {
			vector<int> ans;
			ans.push_back(from);
			ans.push_back(to);
			return ans;
		} else {
			int id = -1;
			for (int i = 0; i < n; ++i) {
				if (bit(from, i) != bit(to, i)) {
					id = i;
					break;
				}
			}
			vector<int> valL, valR;
			for (int v : val) {
				if (bit(v, id) == bit(from, id)) {
					valL.push_back(v);
				} else {
					valR.push_back(v);
				}
			}
			for (int v : valL) {
				if (ok(from, v)) {
					vector<int> ll = solve(from, v, valL);
					vector<int> rr = solve(v ^ (1 << id), to, valR);
					vector<int> ans;
					for (int u : ll) ans.push_back(u);
					for (int u : rr) ans.push_back(u);
					return ans;
				}
			}
		}
	};
	
	vector<int> val;
	for (int i = 0; i < (1 << n); ++i) val.push_back(i);
	auto ans = solve(a, b, val);
	puts("YES");
	for (int v : ans) printf("%d ", v);
}

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

#define nguyendz the_best
using namespace std;

#define ll long long
#define endl "\n"
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
#define setpre(x) fixed<<setprecision(x)


const ll maxn=1e3+2;

const ll maxx=1e13;
const ll mod1=1000000007;
const ll mod=998244353;
const ll base=31;
//priority_queue<pll,vector<pll>,greater<pll>> q;
set<ll> adj[maxn];
vector<ll> adj1[maxn];
/*do not use "\n" in interactive problem
((x|y)-y) (x&(~y))
__gcd(fibo(x),fibo(y)=fibo(__gcd(x,y))
so luong tap hop gom d phan tu khac nhau dc tao tu k so phan biet la k mu d
a+b=(a^b)+2*(a&b)
giai 1 bai toan ve n cac cap (xi,yi) ta thuong swap(xi,yi) neu xi>yi ,  sort theo x1 roi chay tu i->n va tim max hoac min 1-> i-1 cua yi dua tren DK:(xi<yi)
log10(n^k)=k*log10(n)
so chu so cua n = (ll)(log10(n))+1*/
ll mp[maxn][maxn];
ll cnt=0;


vector<pll> bri;
vector<string> s;

 ll n,m;
bool y=false;
ll dd[maxn];
void dfs(ll u,ll bd)
{
    for (auto to:adj[u])
    {
        if (mp[to][u])
        {
            cnt++;
            mp[to][u]=0;
            mp[u][to]=0;
            if (cnt==m)
            {
                if (bd==to)
                {
                    //cout <<bd<<endl;
                   // cout <<m<<endl;
                    y=true;
                }
            }
            dfs(to,bd);
            break;
        }
    }
}

void dfs1(ll u)
{
    dd[u]=1;
    for (auto to:adj[u])
    {
        if (!dd[to])
        {

            dfs1(to);
        }
    }
}
int main()
{
    // freopen("test.txt","r",stdin);
    //  freopen("Bridge2P.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   string s;
   cin>>s;
   if(s[2]==s[3]&&s[4]==s[5])
   {
       cout <<"Yes"<<endl;
   }
   else
   {
       cout <<"No"<<endl;
   }
    /*
    5 5
1 3
2 5
1 4
3 5
2 4
1 3
1*/

}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a[100000];

bool solve() {
	LL sum = 0, odd = 0;
	inc(i, n) {
		sum += a[i];
		odd += a[i] % 2;
	}
	
	if((sum - n) % 2 == 1) { return true; }
	
	if(odd >= 2) { return false; }
	
	inc(i, n) { a[i] -= a[i] % 2; if(a[i] < 1) { return false; } }
	LL g = a[0];
	inc(i, n) { g = gcd(g, a[i]); }
	inc(i, n) { a[i] /= g; }
	return (! solve());
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	cout << (solve() ? "First" : "Second") << endl;
	
	return 0;
}


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

using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    vector<char> S1(S.size());
    vector<char> T1(T.size());
    for(int i = 0 ;i < S.size();i++) S1[i] = S[i];
    for(int i = 0 ;i < T.size();i++) T1[i] = T[i];
    sort(S1.begin(),S1.end());
    sort(T1.begin(),T1.end());
    reverse(T1.begin(),T1.end());
    if(S1 < T1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
int nod(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
int gcd(int x, int y) {
	int r;
	if(x<y){
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int isPrime(int x) {
	int i;
	if (x < 2) {
		return 0;
	}
	else if(x==2){
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vi isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	int ii, jj;
	REP(ii, isPrime.size()) {
		isPrime[ii] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (ii = 2; ii * ii <= isPrime.size() - 1; ii++) {
		if (isPrime[ii] == 1) {
			jj= ii * 2;
			while (jj <= isPrime.size() - 1) {
				isPrime[jj] = 0;
				jj = jj + ii;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(int n) {
	//実際にはコピーして中身を改変して使う
	int ii;
	REP(ii, pow(2, n)) {
		ll p = ii;
		REP(ii, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000000 + 7;
ll ans = 0;
//***********//
int main() {
	ll D;
	cin >> N >> D;
	vector<vector<ll>> X(N, vector<ll>(D, 0));
	for (i = 0; i < N; i++) {
		for (j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}
	for (i = 0; i < N-1; i++) {
		for (j = i + 1; j < N; j++) {
			double pre = 0;
			for (k = 0; k < D; k++) {
				pre += pow(X[i][k] - X[j][k], 2);
			}
			for (k = 0; k <= 1000;k++) {
				if (pre == k * k) {
					ans++;
					break;
				}
				else if (pre < k * k) {
					break;
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n]={};
	int p,q;
	for(int i=0;i<m;i++){
		scanf("%d%d",&p,&q);
		p--;
		q--;
		a[p]++;
		a[q]++;
	}
	for(int i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

using R = double;
const int MN = 100100;
R p[MN], d[MN];
int q[MN];

template<class T>
T pow(T x, ll n, T r) {
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

struct Perm {
    //i -> a[i]
    vector<int> a;
    Perm(int n) {
        a = vector<int>(n);
        iota(begin(a), end(a), 0);
    }
    Perm(vector<int> a) : a(a) {}
    Perm operator*(const Perm &r) const {
        int n = int(a.size());
        Perm res(n);
        for (int i = 0; i < n; i++) {
            res.a[i] = r.a[a[i]];
        }
        return res;
    }
    Perm& operator*=(const Perm &r) {
        return *this = *this*r;
    }
};

int main() {
#ifdef LOCAL
    freopen("Ain2.txt", "r", stdin);
#endif
    cout << setprecision(20);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n-1; i++) {
        d[i] = p[i+1]-p[i];
    }
    int m; ll k;
    cin >> m >> k;
    Perm v(n-1);
    for (int i = 0; i < m; i++) {
        int c;
        cin >> c; c--;
        swap(v.a[c-1], v.a[c]);
    }
    Perm u = pow(v, k, Perm(n-1));
/*    for (int i = 0; i < n-1; i++) {
        cout << u.a[i] << " ";
    } cout << endl;*/

    R st = p[0];
    cout << st << endl;
    for (int i = 0; i < n-1; i++) {
        st += d[u.a[i]];
        cout << st << endl;
    }
    return 0;
}

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

using namespace std;

#define int long long

typedef pair<int, int> ii;

int n;
ii a[200001];

int org[200001];
int sum[800001], sub[800001];

void upd(int node, int l, int r, int pos, int val_x)
{
	if (l == r)
	{
		sum[node] = min(sum[node], val_x + org[pos]);
		sub[node] = min(sub[node], val_x - org[pos]);
		return;
	}
	int mi = (l + r)/2;
	if (pos <= mi)
		upd(node * 2, l, mi, pos, val_x);
	else
		upd(node * 2 + 1, mi + 1, r, pos, val_x);
	sum[node] = min(sum[node * 2], sum[node * 2 + 1]);			
	sub[node] = min(sub[node * 2], sub[node * 2 + 1]);			
}

int query_sum(int node, int l, int r, int ll, int rr)
{
	if (r < ll || rr < l)
		return 1e18;
	if (ll <= l && r <= rr)
		return sum[node];
	int mi = (l + r) / 2;
	int a = query_sum(node * 2, l, mi, ll, rr);
	int b = query_sum(node * 2 + 1, mi + 1, r, ll, rr);
	return min(a, b);
}

int query_sub(int node, int l, int r, int ll, int rr)
{
	if (r < ll || rr < l)
		return 1e18;
	if (ll <= l && r <= rr)
		return sub[node];
	int mi = (l + r) / 2;
	int a = query_sub(node * 2, l, mi, ll, rr);
	int b = query_sub(node * 2 + 1, mi + 1, r, ll, rr);
	return min(a, b);
}


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

	for (int i = 0; i <= 800000; i++)
		sum[i] = sub[i] = 1e18;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i].first >> a[i].second;
	sort(a + 1, a + 1 + n);
	
	vector<ii> val_y;
	for (int i = 1; i <= n; i++)	
		val_y.push_back(ii(a[i].second, i));
	sort(val_y.begin(), val_y.end());
	int top = 0, pre = -1;
	for (int i = 0; i < val_y.size(); i++)
	{
		if (val_y[i].first != pre)
		{
			top++;
			org[top] = val_y[i].first;
			pre = val_y[i].first; 
		}
		a[val_y[i].second].second = top;
	}
	int res = 0;
	upd(1, 1, top, a[1].second, a[1].first);
	for (int i = 2; i <= n; i++)
	{
		res = max(res, a[i].first + org[a[i].second] - query_sum(1, 1, top, 1, a[i].second));
		res = max(res, a[i].first - org[a[i].second] - query_sub(1, 1, top, a[i].second, top));
		upd(1, 1, top, a[i].second, a[i].first);
	}
	cout << res;
}

Measured memory_bytes: 23552
#include <iostream>
#include <map>

using namespace std;

int main(void) {
    map<string,int> mp;
    int n,m;
    cin >> n;
    for(int i = 0;i < n;i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    
    cin >> m;
    for(int i = 0;i < m;i++){
        string s;
        cin >> s;
        mp[s]--;
    }
    
    int cnt = 0;
    for(auto x : mp){
        if(x.second > cnt) cnt = x.second;
    }
    cout << cnt << endl;
	return 0;
}


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

int main()
{
   int k,x; //x is black //k is total
   scanf("%d %d",&k,&x);
   int i;
   int count=1;
       for(i=x-k+1;count<k*2;i++)
       {
           printf("%d ",i);
           count++;
       }

}


Measured memory_bytes: 1712
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int n, m;
long long int a[100001];
long long int b, c;

vector<pair<long long int, long long int>> d;

int main()
{
    int n, m;

    cin >> n >> m;

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

    for (int i = 0; i < m; i++)
    {
        cin >> b >> c;
        d.push_back(make_pair(c, b));
    }

    sort(a, a + n);
    sort(d.begin(), d.end(), greater<pair<long long int, long long int>>());

    int now = 0;

    for (int i = 0; i < n; i++)
    {
        if (a[i] < d[now].first)
        {
            a[i] = d[now].first;
            d[now].second--;
            if (d[now].second == 0)
            {
                now++;
            }
        }
        else
        {
            break;
        }
    }

    long long int res = 0;

    for (int i = 0; i < n; i++)
    {
        res += a[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3188
ans=[]

while True:

	try:

		k=int(input())
		if k>18:
			k=36-k

		ct=0

		for i in range(10000):

			tmp=str(i)

			while len(tmp)<4:

				tmp="0"+tmp

			tmp_2=0

			for j in tmp:

				tmp_2+=int(j)

			if tmp_2==k:

				ct+=1

		ans.append(ct)

	except:

		break

for i in range(len(ans)):

	if i==len(ans)-1:

		print(ans[i],)

	else:

		print(ans[i])

Measured memory_bytes: 7636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> vec;
  for (int i = 1; i <= a * b; ++i) {
    if (a % i == 0 && b % i == 0) {
      vec.push_back(i);
    }
  }
  sort(vec.rbegin(), vec.rend());
  cout << vec[k - 1] << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

void output_yoko(vector<char> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}


signed main() {
    int n; cin>>n;
    int  a[n];
    rep(i,0,n) cin>>a[i];
    vector<int> sums(n,0);
    int mod = pow(10,9) + 7;
    sums[n-1] = a[n-1];
    for(int i=n-2;i>=0;i--){
        sums[i] = (sums[i+1]+a[i]) % mod;
    }

    int res = 0;

    for(int i=0;i<n-1;i++){
        res += ((a[i])*(sums[i+1]))%mod;
    }

    cout<<(res%mod)<<endl;
}


Measured memory_bytes: 6352
import re

pattern = re.compile('^(?:\.*)(#+)(?:\.*)$')

H, W = map(int, input().split())
board = [input() for i in range(H)]

c = 0
for row in board:
    result = pattern.match(row)
    if result == None or result.start(1) != c:
        print("Impossible")
        exit()
    else:
        c = result.end(1) - 1

print("Possible")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main() {
  int n,k;cin>>n>>k;
  int cnt = 0;int pre = -1;
  rep(i,k){
    pre += 2;
    if(pre > n){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define reduce200ms ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(6)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define bitcount _builtin_popcount
#define fill(var,val) memset(var,val, sizeof var)
#define rep(i,a,b) for(auto i=a;i<b;++i)
#define per(i,a,b) for(auto i=a;i>b;--i)
#define elif else if
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
/*
    #ifdef DEBUG
         #define debug(args...)            {dbg,args; cerr<<endl;}
    #else
        #define debug(args...)
    #endif
    struct debugger
    {
        template<typename T> debugger& operator , (const T& v)
        {
            cerr<<v<<" ";
            return *this;
        }
    } dbg;
*/
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;

const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long double dist(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
long long min(long long a,long long b,long long c){return min(c,min(a,b));}
long long max(long long a,long long b,long long c){return max(c,max(a,b));}
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	if(_gcd!=1)cerr<<"WA";
	else return mpow(a,mod-2,mod);
}
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
int arr[1000];
int a,b;
int main(){reduce200ms;
arr[1]=1;
rep(i,2,1000){	
	arr[i]=i+arr[i-1];
}
cin>>a>>b;
rep(i,1,999){
	if(arr[i]-a == arr[i+1]-b){
		cout<<arr[i]-a;
		return 0;
	}
}
return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if(a.equals("Sunny")){
      System.out.println("Cloudy");
    }else if(a.equals("Cloudy")){
       System.out.println("Rainy");
    }else if(a.equals("Rainy")){
       System.out.println("Sunny");
    }
  }
}

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

using namespace std;
typedef long long ll;

string s;

int isCheck(string S, int s, int e){
    while(s < e){
        if(S[s] != S[e]){
            return 1;
        }
        s++;
        e--;
    }
    return 0;
}

int main(){
    cin >> s;
    int N = s.length();
    if(isCheck(s,0,N-1) == 1){
        cout << "No" << endl;
        return 0;
    }
    if(isCheck(s,0,(N-1)/2-1) == 1){
        cout << "No" << endl;
        return 0;
    }
    if(isCheck(s,(N+3)/2-1,N-1) == 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
 
        Scanner sc = new Scanner(System.in);
        int i=sc.nextInt();
      int i2=sc.nextInt();
      int i3=sc.nextInt();
      int ans=Math.max((i+i2*10+i3),(i*10+i2+i3));
      ans=Math.max(ans,(i+i2+i3*10));
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        PBDS;

#define int long long
#define endl "\n"
#define MOD 1000000007
const int mxN = 1e6 + 500;

int a[mxN];



// taskkill -im D.exe -f
int32_t main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	/*int t; cin >> t;


	while (t--) {*/

	int n, f = 0; cin >> n;

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

	for (int i = 1000; i <= 10000; i += 1000) {
		if (n < i) {
			f = i - n;
			break;
		}
		if (n == i) {
			f = 0;
			break;
		}
	}
	cout << f;

	cout << endl;
	//}


	return 0;

}

Measured memory_bytes: 3648
inpt = map(int, raw_input().split())
inpt.sort()

x = inpt[2]-inpt[0]
y = inpt[2]-inpt[1]

ans = x/2 + y/2

if x%2 == 1 or y%2 == 1: ans = ans + 1
if x%2 != y%2: ans = ans + 1

print ans

Measured memory_bytes: 2568
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String[] arg) {
		Scanner ob=new Scanner(System.in);
		int k=ob.nextInt();
		int x=ob.nextInt();
		if(k*500>=x){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    int m;
    cin >> m;
    vector<string> t(m);
    rep(i,m) cin >> t[i];
    rep(i,n){
        int cnt = 0;
        string a;
        a = s[i];
        rep(j,n)if(s[j] == a)cnt++;
        rep(j,m)if(t[j] == a)cnt--;
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll m = 0;
  cin >> m;
  ll keta = 0;
  ll all = 0;
  for(int i = 0;i < m;i++){
    ll d,c;
    cin >> d >> c;
    all += d * c;
    keta += c;
  }
  cout << keta - 1 + (all - 1) / 9 << endl;
}

Measured memory_bytes: 256
import re
S=input().replace("?", ".")
T=input()
for i in range(len(S)-len(T), -1, -1):
    if re.match(S[i:i+len(T)], T):
        S = S.replace(".", "a")
        print(S[:i]+T+S[i+len(T):])
        break
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b,i,l,ans=0;
	char s[100005];
	scanf("%s",s);
	l=strlen(s);
	for(i=1;i<l;i++)
	 	if(s[i]!=s[i-1])
	 	ans++;
	printf("%d\n",ans); 		 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
using namespace std;
using namespace atcoder;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N),B(M);
  for(int &i:A)cin>>i;
  for(int &i:B)cin>>i;
  vector<int> C=convolution(A,B);
  for(int i=0;i<N+M-1;i++)cout<<C[i]<<(i==N+M-2?'\n':' ');
  cout<<endl;
}

Measured memory_bytes: 27240
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 1e5+1;

void solve(){
    
    string s, t;
    cin >> s >> t;
    int n, m;
    n = s.length(), m = t.length();
    int ans = m;
    for(int i=0; i<n-m+1; i++){
        int cur = 0;
        for(int j=0; j<m; j++){
            if(s[i+j] == t[j]){
                cur++;
            }
        }
        ans = min(ans, m-cur);
    }
    cout << ans;
    // int n;
    // cin >> n;
    // vector<int> a(n), pref(n);
    // for(int i=0; i<n; i++){
    //     cin >> a[i];
    // }
    // pref[n-1] = a[n-1];
    // for(int i=n-2; i>=0; i--){
    //     pref[i] = pref[i+1] + a[i];
    // }
    // int ans = 0;
    // for(int i=0; i<n-1; i++){
    //     ans = (ans + (a[i]*pref[i+1])%mod)%mod;
    // }
    // cout << ans;

}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    vector<lli> str;

    for (lli i = 1; i <= 9; i++) {
        lli cnt = 0;
        queue<lli> qu;
        qu.push(i);

        while (!qu.empty()) {
            a = qu.front();
            lli p = a % 10;
            cnt++;
            str.pb(a);
            qu.pop();
            if (cnt == 1e5) {
                break;
            }

            if (p == 0) {
                qu.push(a * 10 + p);
                qu.push(a * 10 + p + 1);
            } else if (p == 9) {
                qu.push(a * 10 + p - 1);
                qu.push(a * 10 + p);
            } else {
                qu.push(a * 10 + p - 1);
                qu.push(a * 10 + p);
                qu.push(a * 10 + p + 1);
            }
        }
    }

    sort(all(str));
    cout << str[n - 1] << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 12124
#include <bits/stdc++.h>
#define ALL(X) X.begin(), X.end()
#define SZ(A) int((A).size())
#define RALL(X) X.rbegin(), X.rend()
#define FOR(B) for (size_t i = 0; i < B; i++)
#define FOR2(B) for (size_t j = 0; j < B; j++)
#define FORE(B) for (size_t i = 1; i <= B-1; i++)
#define FORC(A, B) for (size_t i = A; i < B; i++)
#define PRINT(X) cout << X << endl
#define PRINTALL(E, X) { FOR(X) {cout << E[i] << endl; } }
#define PRINTSIDE(E, X) { FOR(X) {cout << E[i] << " ";} }
#define READALLI(V, N) FOR(N) {int x; cin >> x; V.push_back(x); }
#define READALL(V, N) FOR(N) {LL x; cin >> x; V.push_back(x); }
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXN 100000
#define SQRSIZE  317
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll>VL;
typedef vector<pii> vpii;
typedef map<int, int> mii;
typedef map<char, int>mci;
typedef map<string, int> msi;
typedef set<int> si;
const int INF = (1 << 30);
ull gcd(ll a, ll b){ return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }

int main() {
	int n = 0;
	cin >> n;
	int amount = 0;
	while( n > 0){
		int v = n % 10;
		if(v == 2)
			amount++;
		n /= 10;
	}
	cout << amount << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    int n;
    cin >> str;
    char str1[5], str2[7], str3[5];
    for (int i = 0; i < 19; i++)
    {
        if (str[i] == ',')
            str[i] = ' ';
    }
    cout << str << "\n";

    return 0;
}


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

int gcd(int x, int y){
    int z = 0;
    while((z = x % y) != 0){
        x = y;
        y = z;
    }
    return y;
}

int main(){
    int N, X;
    int toshi[100000];
    cin >> N >> X;
    for (int i = 0; i < N; i++){
        cin >> toshi[i];
        toshi[i] -= X;
        if (toshi[i] <= 0){
            toshi[i] = -toshi[i];
        }
    }
    int ans;
    if (N != 1){
        ans = gcd(toshi[0], toshi[1]);
        for (int i = 2; i < N; i++){
            ans = gcd(ans, toshi[i]);
        }
    } else {
        ans=toshi[0];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
n=int(input())
*a, = map(int,input().split())

#遅延セグ木で解く
class segtree:
    x_unit=0 # 要素として入れられる最大値
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[self.x_unit]*(2*self.n)

    def build(self, seq):
        for i,j in enumerate(seq, start=self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = 0
            # セグ木トーナメント表の左右を比較
            # 例えばn=8の時、seq[4]はx[12]に、seq[5]はx[13]に入っている
            # さらにx[14]とx[15]の間に来るのはx[7]、x[12]とx[13]の間に来るのはx[6]

    def fold(self,l,r): # 区間[l, r)値に+1 
        l+=self.n
        r+=self.n-1
        while l<r:
            if l%2==1: # lが奇数
                self.x[l]+=1
                l+=1 # 偶数に調節
            if r%2==0: # rが偶数
                self.x[r]+=1
                r-=1 # 開区間なので1個前は奇数番目の要素
            l //= 2
            r //= 2
        if l==r:
            self.x[l]+=1
        #print(self.x)
    def get(self,i): # seq[i]に対する値を取得 
        i+=self.n
        ret=self.x[i]
        while i>1:
            i //= 2
            ret+=self.x[i]
        return ret

seq=[0]*(10**5+2)
q=[(max(0, a[i]-1), min(10**5,a[i]+1)) for i in range(n)]
seg=segtree(10**5+2)
seg.build(seq)
for i in range(n):
    l,r=q[i]
    seg.fold(l,r+1)
ans=[]
for i in range(10**5+2):
    ans.append(seg.get(i))
print(max(ans))

Measured memory_bytes: 65732