akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;



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

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];

  ll now=a[0],ans=0;

  std::vector<ll> cost(m+1,0),len(m+2,0);

  rep(i,1,n){
    cost[a[i]]+=(a[i]-now+m)%m-1;
    if(now<a[i]){
      ans+=a[i]-now;
      len[now+1]++;
      len[a[i]]--;
    }else{
      ans+=a[i];
      len[now+1]++;
      len[m+1]--;
      len[1]++;
      len[a[i]]--;
    }
    now=a[i];
  }

  rep(i,1,m+2)len[i]+=len[i-1];

  ll val=ans;
  rep(i,1,m){
    val-=len[i];
    val+=cost[i];
    chmin(ans,val);
  }

  std::cout<<ans<<"\n";

  return 0;
}

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

int main(){
    char c;
    while(1){
        scanf("%c", &c);
        if(c == '\n')break;
        if('a' <= c && c <= 'z') printf("%c",c - 32);
        else if('A' <= c && c <= 'Z') printf("%c", c + 32);
        else printf("%c", c);
    }
    printf("\n");
}


Measured memory_bytes: 3168
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    n=II()
    lis=[]
    for _ in range(n):
        a=II()
        i=bisect_left(lis,a)
        if i==len(lis):lis.append(a)
        else:lis[i]=a
    print(len(lis))

main()



Measured memory_bytes: 9884
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1<<30
#define pi M_PI
#define eps (1e-9)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}

// counter clock wise
Point rotationPoint(Point base,Point a,double r){
  if(r<0)r=360-r;
  Point b=a-base;
  a.x=b.x*cos((r/180)*M_PI)-b.y*sin((r/180)*M_PI);
  a.y=b.x*sin((r/180)*M_PI)+b.y*cos((r/180)*M_PI);
  a=a+base;
  return a;
}

class Buggy{
public:
  Point A,R,L;
  Buggy(Point a,Point r,Point l):A(a),R(r),L(l){}
};

int main()
{
  int n,d,a,b,t;

  while(1){
    cin>>n>>d;
    if((n+d)==0)break;
    Buggy B(Point(0,0),Point(d,0),Point(-d,0));
    for(int k=0;k<n;k++){
      cin>>a>>b>>t;
      for(int i=0;i<t;i++){
	if(a==b){
	  Point p=rotationPoint(B.A,B.R,90);
	  Vector v=(p-B.A);
	  v=v/abs(v);
	  v=v*((double)a/180)*pi;
	  B.A=B.A+v;
	  B.R=B.R+v;
	  B.L=B.L+v;
	}
	else if(a==0){
	  double r=abs(b)/(double)(2*d);
	  if(b<0)r=360-r;
	  B.A=rotationPoint(B.L,B.A,r);
	  B.R=rotationPoint(B.L,B.R,r);
	}
	else if(b==0){
	  double r=abs(a)/(double)(2*d);
	  if(a<0)r=360-r;
	  r=360-r;
	  B.A=rotationPoint(B.R,B.A,r);
	  B.L=rotationPoint(B.R,B.L,r);
	  }
	else {
	    double r=((a+b)/(double)(a-b))*d;
	    Vector v=(B.R-B.A);
	    Point p=B.A+(v/abs(v))*r;
	    double s=abs(b)/abs(p-B.R);
	    /*printf("%.10f %.10f\n",p.x,p.y);
	    printf("%.10f ",B.L.x);
	    printf("%.10f\n",B.L.y);
	    printf("%.10f ",B.A.x);
	    printf("%.10f\n",B.A.y);
	    printf("%.10f ",B.R.x);
	    printf("%.10f\n",B.R.y);
	    cout<<s<<endl;*/
	    if(a>b)s=360-s;
	    B.R=rotationPoint(p,B.R,s);
	    B.A=rotationPoint(p,B.A,s);
	    B.L=rotationPoint(p,B.L,s);     
	  
	}
      }
    }
    if(equals(B.A.x,0))B.A.x=0;
    if(equals(B.A.y,0))B.A.y=0;
    printf("%.10f\n",B.A.x);
    printf("%.10f\n",B.A.y);
  } 

  return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s.at(i);
    vector<vector<int>> cnt(h,vector<int>(w,0));
    rep(i,h){
        vector<int> done(w);
        rep(j,w){
            if(s.at(i).at(j) == '#')continue;
            if(done.at(j)) continue;
            int l = 0;
            while(j+l < w){
                if(s.at(i).at(j+l) == '#')break;
                l++;
            }
            rep(k,l){
                cnt.at(i).at(j+k) += l;
                done.at(j+k) = 1;
            }

        }
    }
    rep(j,w){
        vector<int> done(h);
        rep(i,h){
            if(s.at(i).at(j) == '#')continue;
            if(done.at(i)) continue;
            int l = 0;
            while(i+l < h){
                if(s.at(i+l).at(j) == '#')break;
                l++;
            }
            rep(k,l){
                cnt.at(i+k).at(j) += l;
                done.at(i+k) = 1;
            }

        }
    }
    int ans = 0;
    rep(i,h)rep(j,w) ans = max(ans,cnt.at(i).at(j) -1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26488
import collections

n=int(input())
a_list = list(map(int, input().split()))


q=int(input())

anscol = collections.Counter(a_list)
#print(anscol)

goukei=sum(a_list)

for i in range(q):
  b,c = map(int, input().split())
  tmp=anscol[b]
  
  goukei+=(c-b)*tmp
  
  anscol[c]+=tmp
  anscol[b]=0
  print(goukei)
  

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    while (a % 2 == 0 && a > 1) {
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int N,K,h,count = 0;
    scanf("%d %d",&N,&K);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &h);
        if(h >= K) count++;
    }
    
    printf("%d\n",count);
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {
	int w,h,x,y,r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if (x - r < 0 || y - r < 0 || x + r > w || y + r > h) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}



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

#define MAX_N 1000000

int bit[MAX_N]; 
int a[MAX_N], b[MAX_N];
int n;

void add(int p) {
	while (p <= n) {
		bit[p] += 1;
		p += p&-p;
	}
}
int sum1(int p) {
	int sum2 = 0;
	while (p > 0) {
		sum2 += bit[p];
		p -= p&-p;
	}
	return sum2;
}
int sum(int l, int r) {
	return sum1(r - 1) - sum1(l - 1);
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b + 1, b + n + 1);
	long long res = 0LL;
	for (int i = 1; i <= n; i++) {
		int v = lower_bound(b + 1, b + n + 1, a[i]) - b;
		add(v);
		res += sum(v + 1, n + 1);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 10144
N, D = [int(x) for x in input().split(' ')]

points = []
for _ in range(N):
  X = [int(x) for x in input().split(' ')]
  points.append(X)
  
def distance(x, y):
  d = 0
  for i in range(D):
    d += (x[i] - y[i]) ** 2
  return d ** 0.5

ans = 0
from itertools import combinations
for a, b in combinations(points, 2):
  if distance(a, b).is_integer():
    ans += 1
      
print(ans)

Measured memory_bytes: 3188
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

am = a.max
m = (am+1)/2
mi = -1
mn = nil

n.times do |i|
	if a[i] == am
		next
	end
	if !mn || (a[i]-m).abs < mn
		mi = i
		mn = (a[i]-m).abs
	end
end

print "#{am} #{a[mi]}\n"

Measured memory_bytes: 9476
r, c = map(int, input().split())
a = [[0] * c for i in range(r + 1)]
for i in range(r):
	a[i] = list(map(int, input().split()))
for j in range(c):
	for i in range(r):
		a[r][j] += a[i][j]
for i in range(r + 1):
	m = 0
	for j in range(c):
		m += a[i][j]
		print(a[i][j], end=" ")
	print(m)


Measured memory_bytes: 6220
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair< ll,pair<ll , ll> >; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(N);
  vl a(N); in(a);
  int num = 0;
  rep(i , N){
    if(num + 1 == a[i]) num++;
  }
  if(num == 0) die(-1);
  out(N - num);
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
if a[0] != 1:
	ans += 1
child = [[] for _ in range(n)]
for i in range(1, n):
	child[a[i]-1].append(i)


def dfs(x):
	global ans
	M = 0
	for v in child[x]:
		M = max(M, (dfs(v)+1)%k)
	if M == k-1 and a[x] != 1 and x != 0:
		ans += 1
	return M

dfs(0)
print(ans)

Measured memory_bytes: 110284
#include<stdio.h>
int main(void){
	char str1[1000] = {0};
	char str2[1000] = {0};
	int i;
	int n;
	int flag;
	int count = 0;
	while(scanf("%s",str1) != EOF){
		for(i = 0;str1[i] != 0x00;i++);
		n = i;
		for(i = 0;i < n;i++){
			str2[i] = str1[n-1-i];
		}
		str2[n] = 0;
		flag = 0;
		for(i = 0;i < n - 1;i++){
			if(str1[i] != str2[i]){
				flag = 1;
			}
		}
		if(flag == 0){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 544
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = np.arange(N) + 1
    C = A - B
    m = int(np.median(C))

    B += m
    m0 = np.sum(np.abs(A - B))
    m1 = np.sum(np.abs(A - (B + 1)))
    m2 = np.sum(np.abs(A - (B - 1)))

    print(min(m0, m1, m2))


main()


Measured memory_bytes: 31020
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	string s; cin >> s;
	if (s == "ABC") {
		cout << "ARC" << '\n';
	}
	else cout << "ABC" << '\n';






}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N;
inline void input(){
    fast_io();
    cin >> N;
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b!=0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    }
    else{
        x = 1, y = 0;
    }
    return d;
}

void chmin(ll &a, ll b){if(a>b)a=b;}

ll solve(ll n){
    if(n==1) return 1;
    auto pf = prime_factor(2*n);
    ll k = 2*n;
    vector<ll> Pfs;
    for(auto [p,e]:pf){
        Pfs.push_back((ll)pow(p,e));
    }
    debug(Pfs);
    int m = Pfs.size();
    for (int bit = 1; bit < (1<<m); bit++)
    {
        ll a = 1LL;
        for (int i = 0; i < m; i++)
        {
            if((bit>>i)&1LL){
                a *= Pfs[i];
            }
        }
        ll b = 2*n/a;
        // if(a==1LL || b==1LL) continue;
        ll x = 1,y = 1;
        extgcd(a,b,x,y);
        debug(a,b,x,y);
        if(x==0 || y==0) continue;
        if(x<0) chmin(k,-a*x);
        else chmin(k,-b*y);
    }
    return k;
}   

int test(){
    solve((ll)1e8);
    return 0;
}

int main()
{
    // test();
    input();
    cout << solve(N) << "\n";
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    double ans=(v[0]+v[1])/2.0;
    for(int i=2;i<n;i++){
        ans=(v[i]+ans)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}

  
int main(){
  fastIO();
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++){
  		if(((i<b)&&(j>=a))||((i>=b)&&(j<a))){
  			cout<<1;
  		}else{
  			cout<<0;
  		}
  	}
  	cout<<endl;
  }
}







Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ss = new int[n].Select(_ => Console.ReadLine().Select(c => c - 'a').ToArray()).OrderBy(s => s.Length).ToArray();

		var r = 0L;
		var nodes = new List<int[]> { new int[26] };
		var ends = new List<int[]> { new int[26] };

		foreach (var s in ss)
		{
			var id = 0;
			for (int i = s.Length - 1; i >= 0; i--)
			{
				if (i == 0)
					ends[id][s[i]]++;
				else
					for (int j = 0; j < 26; j++)
					{
						if (ends[id][j] == 0) continue;
						if (Array.IndexOf(s, j, 0, i + 1) >= 0)
							r += ends[id][j];
					}

				var nid = nodes[id][s[i]];
				if (nid == 0)
				{
					nodes[id][s[i]] = nid = nodes.Count;
					nodes.Add(new int[26]);
					ends.Add(new int[26]);
				}
				id = nid;
			}
		}
		Console.WriteLine(r);
	}
}


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

#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 DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << 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 debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    ll x, n, val = 1e18;
    cin >> x >> n;
    if(n == 0)
    {
    	cout << x << endl;
    	return 0;
    }
    ll p[n], pres[100000] = {0};
    for(int i=0;i<n;i++) cin >> p[i], pres[p[i]] = 1;
    for(ll i=x-500;i<x+500;i++)
    {
    	if(!pres[i])
    	{
    		if(abs(x - i) < abs(x - val))
    			val = i;
    	}
    }
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








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

	vector<pair<int, int>> sail(m);

	vector<int> sail_from;
	vector<int> sail_to;

	pair<int, int> wk = make_pair(0, 0);



	for (int i = 0; i < m; i++) {
		cin >> wk.first >> wk.second;
		sail[i] = wk;

		if (wk.first == 1 || wk.second == 1) {
			sail_from.push_back(max(wk.first,wk.second));
		}
		else if (wk.first == n || wk.second == n) {
			sail_to.push_back(min(wk.first, wk.second));
		}
	}

	sort(sail_from.begin(), sail_from.end());
	sort(sail_to.begin(), sail_to.end());

	int from = 0, to = 0;
	bool flg = false;
	while (from < sail_from.size() && to < sail_to.size()) {
		if (sail_from[from] == sail_to[to]) {
			flg = 1;
			break;
		}

		if (sail_from[from] < sail_to[to]) {
			from++;
		}
		else {
			to++;
		}

	}

	if (flg) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}


	return 0;

}



Measured memory_bytes: 2812
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,q;
	cin>>n>>q;
	vector<ll>in(n);
	int to=0;
	rep(k,q){
		int a,b;cin>>a>>b;
		a--;
		in[a]+=b;
		if(to==a){
			if(b<0){
				rep(i,n){
					if(in[to]==in[i])to=min(to,i);
					if(in[to]<in[i])to=i;
				}
			}
		}else{
			if(b>0){
				if(in[to]<in[a])to=a;
				if(in[to]==in[a])to=min(to,a);
			}
		}
		//rep(i,n)cout<<" "<<in[i];
		//cout<<endl;
		cout<<to+1<<" "<<in[to]<<endl;
	}
}

Measured memory_bytes: 8984
Var s:ansistring;
      x,y:int64;
Function downPos(ch:char;s:ansistring):int64;
Var i:longint;
  Begin
     for i:=length(s) downto 1 do
     if ch=s[i] then exit(i);
  End;
Begin
    readln(s);
     x:=pos('A',s);
     y:=downPos('Z',s);
    writeln(y-x+1);
End.

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

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    UF uf(N);
    vector<int> friends(N, 0);
    vector<int> enemies(N, 0);
    for(int i = 0; i < M; ++i){
        int A, B;
        cin >> A >> B;
        uf.unite(A - 1, B - 1);
        ++friends[A - 1];
        ++friends[B - 1];
    }
    for(int i = 0; i < K; ++i){
        int C, D;
        cin >> C >> D;
        if(uf.same(C - 1, D - 1)) {
            ++enemies[C - 1];
            ++enemies[D - 1];
        }
    }
    for(int i = 0; i < N; ++i){
        int ans = uf.same_size(i) - 1 - friends[i] - enemies[i];
        cout << ans << " ";
    }
    
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005
#define PI 3.1415926535897932384626433

using namespace std;

ll power(ll x,ll y,ll p) {ll res=1;x=x%p;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        double A,B,H,M,ans;
        cin>>A>>B>>H>>M;
        double angH=H,angM=M;
        ans=sqrt(pow(A,2)-2*A*B*cos(abs(angH/12.0 +(angM/60.0)/12.0-angM/60.0)*2.0*PI) +pow(B,2));
        cout<<fixed<<setprecision(15)<<ans;








    }


    return 0;
}

Measured memory_bytes: 4112
#include<stdio.h>

int A[20];
int n, q;
int M[200];

int IsMakable(int m, int pos) {
	if (pos < 0)return 0;
	else if (A[pos] == m) {
		return 1;
	}
	else if (A[pos] < m) {
		return IsMakable(m - A[pos], pos - 1) + IsMakable(m, pos - 1);
	}
	else if (A[pos] > m) {
		return IsMakable(m, pos - 1);
	}
}

int main() {
	int flag = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &M[i]);
		flag = IsMakable(M[i], n - 1);
		if (flag)printf("yes\n");
		else printf("no\n");
	}


	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		while (true) {
        // 入力されるa,b,opを定義

        String stra = scanner.next();
        String op = scanner.next();
        String strb = scanner.next();

        int a = Integer.parseInt(stra);
        int b = Integer.parseInt(strb);

        // ?の時終了
        if ("?".equals(op)) {
        	break;
        }

        // opを判定してそれぞれ計算
        if ("+".equals(op)) {
        	System.out.println(a + b);
        } else if ("-".equals(op)){
        	System.out.println(a - b);
        } else if ("*".equals(op)) {
        	System.out.println(a * b);
        } else if ("/".equals(op)) {
        	System.out.println(a / b);
        }
		}

	}

}



Measured memory_bytes: 26132
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
   int N;
   int i;
   cin >> N;
   for(i=1;i<N;i++){
     if(N<=i*111){
       cout <<i*111;
       return 0;
     }
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a;
  cin>>a;
  int ans=0;
  for(int i=1;i<=a;i++)
  {
    int b=floor(log10(i) + 1);
    if(b%2!=0)
    {
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n , a , b , c;
  cin >> n;
  int arr[n][3];
  for(int i = 0 ; i < n ;i ++)
  {
    cin >> a >> b >> c;
    if(i == 0)
      arr[i][0] = a , arr[i][1] = b , arr[i][2] = c;
    else
    {
      arr[i][0] = max(arr[i -1][1] + a , arr[i - 1][2] + a);
      arr[i][1] = max(arr[i -1][0] + b , arr[i - 1][2] + b);
      arr[i][2] = max(arr[i -1][1] + c , arr[i - 1][0] + c);
    }
  }
  cout << max({arr[n - 1][0] , arr[n - 1][1] , arr[n - 1][2]}) << '\n';
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N, M;
    cin >> N >> M;

    if(N%2==0){
        int a = N/2;
        int b = a+1;
        for(int i=0; i<M; i++){
            cout << a << " " << b << "\n";
            a--; b++;
            if(a == (N-1)/4+1) b++;
        }
    }else{
        int a = N/2;
        int b = a+1;
        for(int i=0; i<M; i++){
            cout << a << " " << b << "\n";
            a--; b++;
        }
    }
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_ICPC1 {
	
	class Program {
		static char[][] charset = {
				new char[] {},
				new char[] {'.', ',', '!', '?', ' '},
				new char[] {'a', 'b', 'c'},
				new char[] {'d', 'e', 'f'},
				new char[] {'g', 'h', 'i'},
				new char[] {'j', 'k', 'l'},
				new char[] {'m', 'n', 'o'},
				new char[] {'p', 'q', 'r', 's'},
				new char[] {'t', 'u', 'v'},
				new char[] {'w', 'x', 'y', 'z'}
		};

		struct Data {
			int char_id, num;
			public Data(string str) {
				char_id = int.Parse(str[0].ToString());
				num = str.Length;
			}
			public char GetChar() {
				return charset[char_id][(num - 1) % charset[char_id].Length];
			}
		}

		static void Main(string[] args) {
			int N = int.Parse(Console.ReadLine());
			for (int n = 0; n < N; n++) {
				var strs = Console.ReadLine().Split('0');
				Console.WriteLine(result(strs));
			}

		}

		static string result(string[] strs) {
			List<char> ans = new List<char>();
			foreach (string s in strs) {
				if (s != "") {
					Data d = new Data(s);
					ans.Add(d.GetChar());
				}
			}
			return new string(ans.ToArray());
		}
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9


int main() {
    int A,B,C,X,Y;
    cin >>A>>B>>C>>X>>Y;
    if (A+B<=2*C){
        cout << A*X + B*Y << endl;
    }
    else{
        if(X>Y){
            if (A<2*C){
                cout << 2*C*Y + A*(X-Y) << endl;
            }
            else{
                cout << 2*C*X << endl;
            }
        }
        else if(X<Y){
            if (B<2*C){
                cout << 2*C*X + B*(Y-X) << endl;
            }
            else{
                cout << 2*C*Y << endl;
            }

        }
        else if(X==Y){
            cout << 2*C*X << endl;
        }
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n; 
    long long int y = 0;
    for(int i = 1; ; i++){
        if(0 <= i * (i+1) / 2 - n && i * (i+1) / 2 - n < i){
            y = i;
            break;
        }
    }
    long long int x = y * (y+1) / 2 - n;

    for(int i = 1; i < y+1; i++){
        if(i != x){
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  mat G(N);
  rep(i,N-1){
    ll a;
    cin >> a;
    G.at(a-1).push_back(i+1);
  }
  vec X(N);
  rep(i,N){
    cin >> X.at(i);
  }
  mat A(N,vec(2,0));
  rep(i,N){
    if(G.at(N-1-i).size()==0){
      A.at(N-1-i).at(1)=X.at(N-1-i);
    }else{
      mat dp(G.at(N-1-i).size(),vec(X.at(N-1-i)+1,0));
      ll sum=0;
      rep(j,(ll)G.at(N-1-i).size()){
        sum+=A.at(G.at(N-1-i).at(j)).at(0);
        sum+=A.at(G.at(N-1-i).at(j)).at(1);
        if(j==0){
          if(A.at(G.at(N-1-i).at(j)).at(0)<=X.at(N-1-i)){
            dp.at(j).at(A.at(G.at(N-1-i).at(j)).at(0))=1;
          }
          if(A.at(G.at(N-1-i).at(j)).at(1)<=X.at(N-1-i)){
            dp.at(j).at(A.at(G.at(N-1-i).at(j)).at(1))=1;
          }
        }else{
          rep(k,X.at(N-1-i)+1){
            if(dp.at(j-1).at(k)==1){
              if(A.at(G.at(N-1-i).at(j)).at(0)+k<=X.at(N-1-i)){
                dp.at(j).at(A.at(G.at(N-1-i).at(j)).at(0)+k)=1;
              }
              if(A.at(G.at(N-1-i).at(j)).at(1)+k<=X.at(N-1-i)){
                dp.at(j).at(A.at(G.at(N-1-i).at(j)).at(1)+k)=1;
              }
            }
          }
        }
      }
      ll x=-1;
      rep(j,X.at(N-1-i)+1){
        if(dp.at(G.at(N-1-i).size()-1).at(j)==1){
          x=j;
        }
      }
      if(x==-1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
      }
      A.at(N-1-i).at(1)=X.at(N-1-i);
      A.at(N-1-i).at(0)=sum-x;
    }
  }
  cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 5252
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int q = int.Parse(ReadLine());
            WriteLine(q*q*q);
        }

    }
}



Measured memory_bytes: 11092
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	cout << (int)sqrt(N)*(int)sqrt(N) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
N,M = map(int, input().split())
H = list(map(int, input().split()))
A = [1,]*N
#A = [int(input()) for _ in range(N)]
for i in range(M):
    X,Y = map(int, input().split())
    if H[(X-1)] > H[(Y-1)]:
        A[(Y-1)] = 0
    elif H[(X-1)] < H[(Y-1)]:
        A[(X-1)] = 0
    else:
        A[(X-1)] = 0
        A[(Y-1)] = 0
    #print(H[(X-1)],H[(Y-1)])
    #print(A)

ans = sum(A)

#cnt += 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
print(ans)

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

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

    int X;
    cin >> X;
    vector<bool> dp(X + 1);
    dp[0] = true;
    for (int i = 100; i < dp.size(); i++) {
        if (i >= 100) dp[i] = dp[i] || dp[i - 100];
        if (i >= 101) dp[i] = dp[i] || dp[i - 101];
        if (i >= 102) dp[i] = dp[i] || dp[i - 102];
        if (i >= 103) dp[i] = dp[i] || dp[i - 103];
        if (i >= 104) dp[i] = dp[i] || dp[i - 104];
        if (i >= 105) dp[i] = dp[i] || dp[i - 105];
    }
    if (dp[X])
      cout << 1 << endl;
    else
      cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c-'0'; len++; c=getchar_unlocked(); } *s='\0'; return len; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }
void rsort_str(void *base, const int count, const int size);

char s[200001];
uint32_t m[2019]={1};

int main(void){
	uint32_t n=nextstr(s);
	uint32_t a=0, b=1;
	for(int32_t i=n-1; i>=0; i--){
		a+=b*s[i];
		a%=2019;
		m[a]++;
		b*=10;
		b%=2019;
	}
	uint64_t ans=0;
	for(uint32_t i=0; i<2019; i++){
		ans+=(uint64_t)m[i]*(m[i]-1)/2;
	}
	printf("%"PRIu64"\n", ans);
}


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

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

    int ans = 0;
    int tmp = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
            tmp++;
        }else{
            ans = max(tmp, ans);
            tmp = 0;
        }
    }

    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7


n = INT()
l = MAP()

l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        idx = bisect.bisect_left(l,l[i]+l[j])
        ans+=idx-j-1

print(ans)

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

int main(void){
   int N,K;
   cin>>N>>K;
   vector<long long> h(N);
   for(int i=0;i<N;i++){
      cin>>h[i];
   }
   vector<long long> dp(N,100000007);
   dp[0]=0;
   for(int i=1;i<N;i++){
      dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
      for(int j=2;j<=K;j++){
         if(i-j>=0){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
         }
      }
   }
   cout<<dp[N-1]<<endl;
   return 0;
}


Measured memory_bytes: 4812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	// インデックス定数
	private static final int A = 0;
	private static final int B = 1;

	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		while (true) {

			// カード枚数を取得する
			int loop = Integer.parseInt(readLine(reader));

			// 終了判定を行う
			if (loop == 0) {
				return;
			}

			// スコアを初期化する
			int scoreA = 0;
			int scoreB = 0;

			for (int i = 0; i < loop; i++) {

				// 入力されたカード情報を取得する
				String[] cardArray = readLine(reader).split(" ");
				int[] cardNumArray = new int[cardArray.length];
				for (int j = 0; j < cardNumArray.length; j++) {
					cardNumArray[j] = Integer.parseInt(cardArray[j]);
				}

				// 勝負の結果をスコアに反映する
				if (cardNumArray[A] == cardNumArray[B]) {
					scoreA += cardNumArray[A];
					scoreB += cardNumArray[B];
				} else if (cardNumArray[A] > cardNumArray[B]) {
					scoreA += cardNumArray[A] + cardNumArray[B];
				} else {
					scoreB += cardNumArray[A] + cardNumArray[B];
				}
			}

			// AとBのスコアを表示する
			System.out.println(scoreA + " " + scoreB);
		}

	}

	/**
	 * ストリームから1行読み込んで、文字列として返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return　文字列
	 */
	private static String readLine(BufferedReader reader) {
		String line = null;
		try {
			line = reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return line;
	}
}

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

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


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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll M; cin >> M;
  vector<ll> d(M), c(M);
  for (int i = 0; i < M; i++) cin >> d.at(i) >> c.at(i);
  ll sum = 0;
  ll numD = 0;
  for (int i = 0; i < M; i++) {
    sum += d.at(i) * c.at(i);
    numD += c.at(i);
  }
  cout << (sum - 1) / 9 + numD - 1 << endl;

  return 0;
}



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

using namespace std;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed<<setprecision(10);
}}init;

inline bool isWall(char c){return c=='#';}
inline bool isSpring(char c){return c=='*';}
inline bool isFloor(char c){return c=='.'||c=='s';}
inline bool isStart(char c){return c=='s';}
inline bool isGoal(char c){return c=='g';}
template<typename T>
istream& operator>>(istream& is,vector<T>& v){
    for(auto &it:v)is>>it;
    return is;
}
typedef long long LL;
using P=pair<int,int>;
typedef vector<LL> V;
typedef vector<V> VV;
const LL INF=1e12;
const int dir4[]={0,1,0,-1,0};
int main(){
    int R,C;
    cin>>C>>R;
    vector<string> maze(R);
    int sr,sc,gr,gc,M=0;
    cin>>maze;
    
    queue<P> que;
    VV dG(R,V(C,INF));
    VV dB(R,V(C,INF));
    for(int r=0;r<R;r++)
        for(int c=0;c<C;c++){
            if(isSpring(maze[r][c])){
                dB[r][c]=0;
                que.push(P(r,c));
            }
            if(isFloor(maze[r][c])){
                M++;
            }
            if(isStart(maze[r][c])){
                sr=r,sc=c;
            }
            if(isGoal(maze[r][c])){
                gr=r,gc=c;
            }
        }
    while(que.size()){
        int r,c;
        tie(r,c)=que.front();
        for(int i=0;i<4;i++){
            int nr=r+dir4[i];
            int nc=c+dir4[i+1];
            if(isWall(maze[nr][nc]))continue;
            if(dB[nr][nc]>dB[r][c]+1){
                dB[nr][nc]=dB[r][c]+1;
                que.push(P(nr,nc));
            }
        }
        que.pop();
    }
    que.push(P(gr,gc));
    dG[gr][gc]=0;
    while(que.size()){
        int r,c;
        tie(r,c)=que.front();
        for(int i=0;i<4;i++){
            int nr=r+dir4[i];
            int nc=c+dir4[i+1];
            if(isWall(maze[nr][nc])||isSpring(maze[nr][nc]))continue;
            if(dG[nr][nc]>dG[r][c]+1){
                dG[nr][nc]=dG[r][c]+1;
                que.push(P(nr,nc));
            }
        }
        que.pop();
    }
    vector<P> fs;
    auto b=[&](P p){return max(0ll,min(INF,dG[p.first][p.second]-dB[p.first][p.second]));};
    for(int r=0;r<R;r++)
        for(int c=0;c<C;c++)
            if(isFloor(maze[r][c])){
                fs.push_back(P(r,c));
            }
    sort(fs.begin(),fs.end(),[&](P p,P q){return b(p)<b(q);});
    LL K=0;
    int B=M;
    for(int i=0,sz=fs.size();i<sz;i++){
        K+=dB[fs[i].first][fs[i].second];
    }
    double res=INF;
    K-=dB[fs[0].first][fs[0].second];
    K+=dG[fs[0].first][fs[0].second];
    B--;
    LL prev=b(fs[0]);
    for(int i=1,sz=fs.size();i<sz;i++){
        LL now=b(fs[i]);
        if(now!=prev){
            double b=1.0-B/(double)M;
            b=(K/(double)M)/b;
            if(prev<=b&&b<=now){
                res=min(res,b);
            }
        }
        K-=dB[fs[i].first][fs[i].second];
        K+=dG[fs[i].first][fs[i].second];
        B--;
        prev=now;
    }
    if(prev<INF){
        double b=1.0-B/(double)M;
        b=(K/(double)M)/b;
        if(prev<=b&&b<=INF){
            res=min(res,b);
        }
    }
    cout<<min((double)dG[sr][sc],dB[sr][sc]+res)<<endl;
    return 0;
}

Measured memory_bytes: 9272
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}
int dp[1000006][2][2];
int fun(int i,int j,int k,int n){
	if(i==n){
		return (j==1&&k==1);
	}
	if(dp[i][j][k]!=-1)return dp[i][j][k];
	int ans=fun(i+1,1,k,n)+fun(i+1,j,1,n)+8*fun(i+1,j,k,n);
	ans%=mod;
	return dp[i][j][k]=ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	cout<<fun(0,0,0,n);

	return 0;
}

Measured memory_bytes: 97264
def S(l, w):
    s = l * w
    return s

def C(l, w):
    c = 2 * (l + w)
    return c

def main():
    lw = input()
    split_lw = lw.split()
    l = int(split_lw[0])
    w = int(split_lw[1])
    s = S(l, w)
    c = C(l, w)

    print(s,c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for _ in range(n+1)]
dp[0][0] = 1
d = {(j, k):(10*j+k)%13 for k in range(10) for j in range(13)}
for i in range(n):
  if s[i] != "?":
    t = int(s[i])
    for j in range(13):
      dp[i+1][d[(j, t)]] += dp[i][j]
      dp[i+1][d[(j, t)]] %= mod
  else:
    for k in range(10):
      for j in range(13):
        dp[i+1][d[(j, k)]] += dp[i][j]
        dp[i+1][d[(j, k)]] %= mod
print(dp[n][5]%mod)

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

int gcd(int a, int b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (b) {
    int t = a % b;
    a = b;
    b = t;
  }

  return a;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << endl;
  return 0;
}

Measured memory_bytes: 3088
import sys
input = sys.stdin.readline

def segfunc(x,y):
    return x | y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res


n = int(input())
s = input()
q = int(input())

li = []
for i in range(n):
    li.append(1 << ord(s[i]) - ord('a'))

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
init(li)

for _ in range(q):
    q1 = list(input().split())
    if q1[0] == '1':
        update(int(q1[1]) - 1, 1 << ord(q1[2]) - ord('a'))
    else:
        l,r = int(q1[1]), int(q1[2])
        print(bin(query(l-1,r)).count('1'))


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

const int N = 5e3+5;

char arr[N];
vector<string> vec;

int main() {
  scanf("%s", arr);
  int n = strlen(arr);
  for(int i = 0; i < n; ++i) {
    string str;
    for(int j = i; j < n && j < i+5; ++j) {
      str.push_back(arr[j]);
      vec.emplace_back(str);
    }
  }
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  int k; cin >> k;
  cout << vec[k-1] << endl;
}

Measured memory_bytes: 1660