akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> numbers = Arrays.asList(br.readLine().split(" "));
            numbers = numbers.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
            int result = Integer.parseInt(numbers.get(0) + numbers.get(1)) + Integer.parseInt(numbers.get(2));
            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

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

    string res = "";
    for (auto c: s)
    {
        char now = ((c - 'A') + n)%26 + 'A';
        // char now = 'a' + 1;
        
        // cout << c << ' '<< now << endl;
        res += now;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll n, d;
    cin >> n >> d;
    ll xxor = 0;
    REP(i, n){
        ll a;
        cin >> a;
        xxor ^= (a - 1) % (d + 1);
    }
    cout << ((xxor != 0)? "First" : "Second") << endl;
}


Measured memory_bytes: 3076
#include <stdio.h>
#define inf 10e9

int max(int a, int b) {
  return a > b ? a : b;
}

int main(void) {
  int n, i, j, k;
  scanf("%d", &n);
  int dp[n + 1][4], p[n];
  for(i = 0; i < n; ++i) scanf("%d", &p[i]);
  for(i = 0; i <= n; ++i) for(j = 0; j < 4; ++j) dp[i][j] = inf;
  for(i = 0; i < 4; ++i) {
    dp[0][i] = i;
  }
  for(i = 0; i < 4; ++i) {
    dp[0][i] = i;
  }
  for(i = 1; i < n; ++i) 
    for(j = 0; j < 4; ++j) 
      for(k = 0; k < 4; ++k) 
        if(k + j >= p[i - 1] && dp[i][j] > dp[i - 1][k] + 2 * j)
           dp[i][j] = dp[i - 1][k] + 2 * j;
  int min = inf;
  for(i = 0; i < 4; ++i) if(min > dp[n - 1][i] + max(p[n - 1] - i, 0))
    min = dp[n - 1][i] + p[n - 1] - i;
  /*for(i = 0; i < n; ++i) {
    for(j = 0; j < 4; ++j) printf("%d ", dp[i][j]);
    printf("\n");
  }*/
  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 2852
def main():
    N = int(input())
    vals = set([])
    for v1 in range(1, 10):
        for v2 in range(1, 10):
            vals.add(v1 * v2)
    if N in vals:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

using namespace std;

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

	int n;
	string s;
	cin >> n >> s;

	s.resize(unique(s.begin(), s.end()) - s.begin());
	cout << s.length();

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		String k=in.next();
		int z=0;
		int flag=0;
		char[] a=new char[k.length()];
		char[] b=new char[k.length()];
		for(int i=0;i<k.length();i++)
		{
			a=k.toCharArray();
		}
		for(int i=0;i<k.length();i++)
		{
			if(a[i]=='C'||a[i]=='F')
			{
				b[z]=a[i];
				z++;
			}
		}
		for(int i=0;i<z;i++)
		{
			for(int j=i+1;j<=z-1;j++)
			{
				if(b[i]=='C'&&b[j]=='F')
					flag=1;
			}
		}
		if(flag==1)
			System.out.println("Yes");
		else
			System.out.println("No");

		
		in.close();
	}

}

 

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;
ll a , b  , cnt , n , m , ans , mn;
int main(){
    cin >> m >> n;
    ll arr[n];
    for( int i = 0; i < n;i ++ )
        cin >> arr[i];
    mn = arr[n - 1] - arr[0];
    for( int i = 1;i < n;i ++ )
        mn = min( arr[i - 1] + m - arr[i] , mn );
    cout << mn;
}
/// ab#c ad#c
/// ab## c#d#


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1 != M2 ? 1: 0) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

#N個の重り
#T以下の重りとTより大きい重りに分けて最小値を求めて

#入力
N = int(input())

W = []
spline = input().split()
for i in range(0,len(spline)):
    W.append(int(spline[i]))

#print(N)
#print(W)

#重りの数だけ繰り返す
delta = []
for t in range(1,N+1):
    #T以下の重さの和
    TLow_sum = sum(W[:t])
    #print(TLow_sum)

    #T以上の重さの和 = 全てのW和 - T以下の重さの和
    THigh_sum = sum(W) - TLow_sum
    #print(THigh_sum)

    #差の絶対値
    delta.append(abs(TLow_sum - THigh_sum))

#絶対値の最小値
print(min(delta))





Measured memory_bytes: 14532
#include <iostream>
using namespace std;
int main(){
	char graph[42] = {0,  0,  0,  0,  0,  0,  0,
										0, 97,102,107,112,117,122,
										0, 98,103,108,113,118,'.',
										0, 99,104,109,114,119,'?',
										0,100,105,110,115,120,'!',
										0,101,106,111,116,121,' '};
	string s;
	while(cin >> s,!cin.eof()){
		string ans = "";
		if(s.size() % 2 == 1){cout << "NA" << endl;continue;};
		for(int i = 0;i < s.size();i += 2){
			if(s[i] - '0' <= 0 || s[i+1] - '0' <= 0 || s[i] - '0' > 6 || s[i+1] - '0' > 5){ans = "NA";break;}
			ans += graph[(s[i+1] - '0') * 7 + s[i]-'0'];
		}
		cout << ans << endl;
	}	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    string S;
    cin >> S;
    long long K;
    cin >> K;
    char ans='1';
    int i;
    for(i=0;i<min((long long) S.size(),K);i++){
        if(S[i]!='1'){
            ans=S[i];
            break;
        }
    }
    cout << ans << endl;

}


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

struct Move{
	int x,y,p,q;
};
vector<Move> ans;
int main() {
	int rn,cn;
	cin>>rn>>cn;
	int lne[510];
	int have=0;
	for (int i=0; i<rn; i++) {
		for (int j=0; j<cn; j++)
			cin>>lne[j];
		// cout<<"Process: line "<<i<<endl;
		for (int j=(i%2?cn-1:0); (i%2?(j-1>=0):(j+1<cn)) ; (i%2?j--:j++) )
			if ( (lne[j]+have)%2 == 1)
				have=1, ans.push_back(Move{i, j, i, (i%2?j-1:j+1)});
			else
				have=0;

		int lastidx = i%2?0:cn-1;
		// cout<<"ans.size="<<ans.size()<<endl;
		if ( (lne[lastidx]+have)%2 == 1)
			have=1, ans.push_back(Move{i, lastidx, i+1, lastidx});
		else
			have=0;
	}
	if (have == 1)
		ans.pop_back();
	cout<<ans.size()<<endl;
	for (auto it: ans)
		cout<<it.x+1<<" "<<it.y+1<<" "<<it.p+1<<" "<<it.q+1<<endl;
	return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int i;
  ll tempdiff;
};
bool operator<(const ST& a, const ST& b){
  return a.tempdiff < b.tempdiff;
}

int main(){
  int N;
  cin >> N;
  ll T, A;
  cin >> T >> A;
  T *= 1000;
  A *= 1000;

  vector<ST> v;
  
  rep(i,N){
    ll H;
    cin >> H;
    ST st;
    st.i = i+1;
    st.tempdiff = abs((T - H * 6LL) - A);
    v.push_back(st);
  }

  sort(ALLOF(v));

  cout << v[0].i << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, Q;
  while(cin>>N>>Q && (N || Q)){
    vector<string> name(N);
    vector<int> max(N);
    vector<int> base(N);
    REP(i, N){
      cin>>name[i];
      int  y;
      cin>>max[i]>>y;
      base[i] = y - max[i];
    }
    REP(i, Q){
      int y; cin>>y;
      int h = INF;
      string era = "";
      REP(i, N){
        if(y - base[i] >= 1 && y - base[i] <= max[i]){
          h = y - base[i];
          era = name[i];
        }
      }
      if(h == INF) cout<<"Unknown"<<endl;
      else cout<<era<<" "<<h<<endl;
    }
  }
  return 0;
}

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

n = int(input())
H = list(map(int, input().split()))
hnow = 0
cou = 0

for i in range(n):
    h = H[i]
    if h > hnow:
        cou += (h - hnow)
        hnow = h
    elif h < hnow:
        hnow = h

print(cou)

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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main(void){

    string s;
    cin >> s;

    for(int i = 0; i < s.length(); ++i){
        if(s[i] == '?'){
            s[i] = 'D';
        }
    }

    cout << s << "\n";

    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
using ll = long long;

int main()
{
    int n,k;
    cin >> n >> k;
    pair<ll, int> a[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i].second >> a[i].first;
    }
    sort(a, a+n);
    reverse(a, a+n);
    priority_queue<ll, vector<ll>, greater<ll>> dupq;
    int kinds = 0;
    set<int> s;
    ll sum = 0;
    ll cnt = 0;
    for(int i=0; i<k; i++){
        if(s.count(a[i].second) == 0){
            s.insert(a[i].second);
            cnt++;
        }else{
            dupq.push(a[i].first);
        }
        sum += a[i].first;
    }
    ll ans = sum + cnt*cnt;
    
    for(int i=k; i<n; i++){
        if(cnt >= k) break;
        if(s.count(a[i].second) == 1) continue;
        cnt++;
        s.insert(a[i].second);
        sum -= dupq.top();
        dupq.pop();
        sum += a[i].first;
        ans = max(ans, sum + cnt*cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MOD = 1000000007;
const int MAX = 700050;
int fac[MAX], finv[MAX];

int mmul(int a, int b) {
    return ((a%MOD)*(b%MOD))%MOD;
}

int mpow(int a, int b) {
    int res = 1;
    while(b) {
        if(b & 1) res = (res*a) % MOD;
        b >>= 1;
        a = (a*a) % MOD;
    }
    return res;
}

int mdiv(int a, int b) {
    return (a * mpow(b, MOD-2)) % MOD;
}

int mcomb(int n, int k) {
    if(n<k || k<0) return 0;
    else return mmul(mmul(fac[n], finv[k]), finv[n-k]);
}

inline void INIT_F(){
    fac[0] = finv[0] = 1;
    for(int i=1; i<MAX-1; i++) {
        fac[i] = (fac[i-1]*i) % MOD;
        finv[i] = mdiv(finv[i-1], i);
    }
}

signed main() {
    int X, Y;
    cin >> X >> Y;
    INIT_F();

    if((X+Y)%3) cout << 0 << endl;
    else {
        int n, m;
        n = (2*X-Y)/3;
        m = (2*Y-X)/3;
        if(n<0 || m<0) {
            cout << 0 << endl;
            return 0;
        }

        int res = mcomb(n+m, n);
        cout << res << endl;
    }

    
    return 0;
}

Measured memory_bytes: 11136
s = input().rstrip().split(' ')
counta = 0
countb = 0
for i in range(int(len(s))):
	if int(s[i]) == 7:
		counta += 1
	elif int(s[i]) == 5:
		countb += 1
if counta == 1 and countb == 2:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n,p;
  cin>>n>>p;
  map<int64_t,int64_t> div_num;
  double lim=sqrt(p);
  for (int i = 2; i <= lim; ++i)
  {
    while(p%i==0){
      p/=i;
      div_num[i]++;
    }
    if(p==1) break;
  }
  if(p!=1) div_num[p]++;

  int64_t ans=1;
  for(auto&& e: div_num) {
    //cout<<e.first<<" "<<e.second<<endl;
    for (int i = 0; i < e.second/n; ++i)
    {
      ans*=e.first;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m,p[100005][2],i,a;
  char s[3];
  scanf("%d",&n);
  scanf("%d",&m);
  for(i=0;i<n;i++){
    p[i][0]=0;
    p[i][1]=0;
  }
  for(i=0;i<m;i++){
    scanf("%d",&a);
    scanf("%s",&s);
    a--;
    if(s[0]=='A'){
      p[a][1]=1;
    }else if(p[a][1]==0){
      p[a][0]++;
    }
  }
  m=0;
  a=0;
  for(i=0;i<n;i++){
    if(p[i][1]){
      m++;
      a+=p[i][0];
    }
  }
  printf("%d %d",m,a);
  return(0);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	string s[100];
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=0;i<w+2;i++)cout<<"#";
	cout<<endl;
	for(int i=0;i<h;i++){
		cout<<"#"<<s[i];
		cout<<"#"<<endl;
	}
	for(int i=0;i<w+2;i++)cout<<"#";
	cout<<endl;
	return 0;
}


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

int main(void){
  int a, b, c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b) printf("%d\n",c);
  else if(a==c) printf("%d\n",b);
  else printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((c>=a)&&(c<=b)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = input().split(' ')

#for i in range(n):
#    A[i] = int(A[i])
print(" ".join(A))

for i in range(1, n):
    v = A[i]
    j = i - 1

    while j >= 0 and int(A[j]) > int(v):
        A[j+1] = A[j]
        A[j] = v
        j -= 1
    print(" ".join(A))

Measured memory_bytes: 7644
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;
int main()
{
	int n,sum=0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
	String[] data = str.split(" ");
	int a = Integer.parseInt(data[0]);
	int b = Integer.parseInt(data[1]);
	
	if(a > b) {
		System.out.println("a > b");
	}else if(a < b) {
		System.out.println("a < b");
	}else {
		System.out.println("a == b");
	}
    }
 
}


Measured memory_bytes: 26224
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll mod=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97


signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(n) LIN(t)
    vector< pair< ll, ll > > p;
    REP( i, 0, n ){
      LIN(c) LIN(t)
      p.EB( make_pair(c,t));
    }
    SORT( p );
    REP( i, 0, n ){
      if( p[i].second <= t ){
        puta( p[i].first );
        return 0;
      }
    }
    puta("TLE");
    return 0;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int N, M;
int dp[100010];
vector<int> G[100010];

int dfs(int pos){
    if(dp[pos] >= 0)return dp[pos];
    int res = 0;
    if(pos == N){
        return 0;
    }
    else{
        for(int to : G[pos]){
            res = max(res, dfs(to) + 1);
        }
    }
    return dp[pos] = res;
}

int main(){


    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, dfs(i));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8192
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N, A;
        {int[] a = in.ii(); N = a[0]; A = a[1];}
        int[] x = in.ii();
        int r = 0;
        int l = 0;
        for(int i = 0; i < x.length; i++){
            x[i] -= A;
            if(x[i] < 0) l += x[i];
            else if(x[i] > 0) r += x[i];
        }
        int M = r-l+1;
        long[][] dp = new long[N+1][M];
        dp[0][-l] = 1;
        
        for(int i = 1; i <= N; i++){
            for(int j = 0; j < M; j++){
                dp[i][j] = dp[i-1][j];
                int j2 = j-x[i-1];
                if(0 <= j2 && j2 < M){
                    dp[i][j] += dp[i-1][j2];
                }
            }
        }
        out.println(dp[N][-l]-1);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int a,b;cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int h,w,n;
	cin>>h>>w>>n;
	
	int tmp=max(h,w);
	
	if(n%tmp) cout<<n/tmp+1<<endl;
	else cout<<n/tmp<<endl;
}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  string s;  cin >> s;
  int gu = 0, pa = 0;
  REP(i, s.length()){
    if(s[i] == 'g')  gu++;
    else             pa++;
  }

  int ans = 0;
  while(pa + 2 <= gu){
    ans++, gu--, pa++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<vector>

int main(void){
   int n, m;
   std::cin >> n >> m;

   std::vector<int> broken(n+1);
   for(int i = 0; i < m; i++){
       int a;
       std::cin >> a;
       broken.at(a) = 1;
   }

   std::vector<int> dp(n+2);
   const int mod = 1000000007;
   dp.at(n) = 1;

   for(int i = n - 1; i>= 0; i--){
       if(broken.at(i)){
           dp.at(i) = 0;
           continue;
       }
       dp.at(i) =(dp.at(i+1) + dp.at(i+2)) % mod;
   }
   std::cout << dp.at(0) << std::endl;
   return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

vector<int> adj[200001];
int main() {
	IO;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;++i) {
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
		
	}
	queue<int> q;
	q.push(1);
	vector<int> par(n+1);
	par[1]=-1;
	while(!q.empty()) {
		int fr=q.front();
		q.pop();
		for(auto i:adj[fr]) {
			if(par[i]==0) {
				par[i]=fr;
				q.push(i);
			}
			
		}
	}
	
	cout<<"Yes\n";
	for(int i=2;i<=n;++i) cout<<par[i]<<"\n";
	return 0;
}


Measured memory_bytes: 12632
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };

int main(void){
    int r, g, b;

    cin >> r >> g >> b;
    if((g*10+b)%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

int main(int qtd, char* nome[])
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    int maior = a[0];
    for (int i = 0; i < n; i++){
        if (maior <= a[i]){
            ans++;
            maior = a[i];
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll sum=0;
  for(int i=1; i<=N; i++){
    if(i%3!=0 && i%5!=0) sum+=i;
  }
  cout << sum <<endl;
}

Measured memory_bytes: 3628
/*
 * 
 * Author: Pranav Bansal
 * 
*/
#include<bits/stdc++.h>

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define V(x) vector<x>
#define P(x,y) pair<x,y>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int maximum(int n){
	int count = 0;
	while( (count*(count+1)/2) <= n){
		count++;
	}
	return count-1;
}

int32_t main(){
    fast
    	
    //int t;
	//cin>>t;
	//rep(_,0,t){
		
	//}	
	int n;
	cin>>n;
	if(n == 1){
		cout<<0;
		return 0;
	}
	
	V(int) arr;
	for(int i=2;i*i<=n;i++){
		if(n%i == 0){
			int count = 0;
			while(n%i == 0){
				n/=i;
				count++;
			}
			arr.pb(count);
		}
	}
	if(n>1)
		arr.pb(1);
		
	//rep(i,0,arr.size())
		//cout<<arr[i]<<" ";
	//cout<<endl;
	
	int count = 0;
	for(int i=0;i<arr.size();i++){
		count += maximum(arr[i]);
		//cout<<count<<" "<<arr[i]<<endl;
	}
	
	cout<<count;
	
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
   int A,B;
   string s;
   scanf("%d %d",&A,&B);
   cin >> s;
   int i=0;
   while(i<A)
   {
       if(s[i]<'0'||s[i]>'9')
        {printf("No");  return 0;}
        ++i;
   }

   if(s[i]!='-')
   {printf("No");return 0;}
   ++i;
   while(i<(A+B+1))
   {
      if(s[i]<'0'||s[i]>'9')
        {printf("No");  return 0;}
        ++i;
   }
   printf("Yes");
   return 0;

}


Measured memory_bytes: 256
S = [input() for _ in range(3)]
now = 0
count = len(S[0]) + len(S[1]) + len(S[2])
for _ in range(count):
	if len(S[now]) == 0:
		if now == 0:
			print("A")
		elif now == 1:
			print("B")
		else:
			print("C")
		exit()
	else:
		if S[now][0] == "a":
			if now == 0:
				S[0] = S[0][1:]
			elif now == 1:
				S[1] = S[1][1:]
			else:
				S[2] = S[2][1:]
			now = 0
		elif S[now][0] == "b":
			if now == 0:
				S[0] = S[0][1:]
			elif now == 1:
				S[1] = S[1][1:]
			else:
				S[2] = S[2][1:]
			now = 1
		else:
			if now == 0:
				S[0] = S[0][1:]
			elif now == 1:
				S[1] = S[1][1:]
			else:
				S[2] = S[2][1:]
			now = 2


Measured memory_bytes: 3064
from sys import stdin
import sys
import math
 
# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# A,B = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]
i=int(input())
print(i*2*math.pi)
# print("YES")
# print("NO")

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

#define all(x) (x).begin(),(x).end()
typedef long long ll;

ll dp[51][2501][51];


int main(){

    ll N, A;
    cin >> N >> A;

    vector<ll>v(N);    
    for(int i = 0; i < N; i++){
        cin >> v[i];
    }

    // dp[i][j][k]; i番目までのカードで合計jをk枚での組み合わせ

    dp[0][0][0] = 1;
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= A * N; j++){
            for(int k = 0; k <= N; k++){
                // i+1番目を使用しない
                dp[i+1][j][k] += dp[i][j][k];

                // i番目を使用
                if(j - v[i] >= 0 && k - 1 >= 0) dp[i+1][j][k] += dp[i][j-v[i]][k-1];
                
            }
        }
    }


    ll ans = 0;
    for(int j = 0; j <= A * N; j++){
        for(int k = 1; k <= N; k++){
            if( (j % k) == 0 && (j / k) == A) ans += dp[N][j][k];
        }
    }

    cout << ans << endl;


    



}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int x,n;
  cin >> x >> n;
  set<int> st;
  rep(i,n){
    int k; cin >> k;
    st.insert(k);
  }
  int ans = x;
  for(int i=0; i<100; i++){
    if(st.find(ans-i)==st.end()){
      ans -= i;
      break;
    }
    if(st.find(ans+i)==st.end()){
      ans += i;
      break;
    }
  }
  cout << ans << ln;
  return 0;
}

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


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

  string s;
  cin >> s;
  int dp[2] ={0,INT_MIN};
  rep(i,s.size()){
    // cout << dp[0] <<" " << dp[1] << endl;
    int v = s[i]-'0';   
    // cout << v << endl; 
    int ndp[2];
    ndp[0] = dp[0] + v;
    ndp[1] = dp[1]+9;
    if(v!=0) {
      ndp[1] = max(ndp[1],dp[0]+v-1);
      // cout << ndp[1] << endl;
    }
    swap(ndp,dp);
  }
  cout << max(dp[0],dp[1]) << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
/*
*    AUTHOR:    mkbaloch
*    CREATED:   26.01.2020 17:43:19
*/

#include<bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i=a; i<=b; i++)
#define repn(i, n) for(int i=0; i<(int)n; i++)
#define all(x) x.begin(), x.end()

using namespace std;

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

  #ifdef DEBUG
    auto start = chrono::high_resolution_clock::now();
  #endif

  //-------Start-------//
  
  int h, n;
	cin >> h >> n;
	vi arr(n);
	int ans = 0;
	for(int i = 0; i<n; i++){
	 	int in;
		cin >> in;
		ans += in;
	}

	if(ans >= h) cout << "Yes" << endl;
	else cout << "No" << endl;

  //-------End---------//

  #ifdef DEBUG
    auto end = chrono::high_resolution_clock::now();
    auto dur = chrono::duration_cast<chrono::microseconds>(end - start);
    cout << "Execution time: " << setprecision(6) << ((long double)dur.count() / 1e6) << " seconds" << endl; 
  #endif

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  vector<ll> ord(n);
  iota(ALL(ord), 0);
  sort(ALL(ord), [&](ll i, ll j) { return a[i] > a[j]; });

  const ll INF = 1e18;
  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));

  dp[0][0] = 0;
  FOR(k, 1, n + 1) {
    REP(i, k + 1) {
      ll j = k - i;
      ll p = ord[k - 1];
      if (i >= 1) {
        chmax(dp[i][j], dp[i - 1][j] + a[p] * abs(p - (i - 1)));
      }
      if (j >= 1) {
        chmax(dp[i][j], dp[i][j - 1] + a[p] * abs(p - (n - j)));
      }
    }
  }

  ll ans = -INF;
  REP(i, n + 1) { ans = max(ans, dp[i][n - i]); }
  cout << ans << endl;
}

Measured memory_bytes: 34676
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 1000
#define n 100

int top, A[N];

void push(int x);

int pop();

int main(){
  int a, b, x;
  top = 0;
  char A2[n];
  
  while( scanf("%s", A2) != EOF ){
    if ( A2[0] == '+' ){
      a = pop();
      b = pop();
      push(a + b);
    } else if ( A2[0] == '-' ){
      b = pop();
      a = pop();
      push(a - b);
    } else if ( A2[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
    } else {
      x = atoi(A2);
      push(x);
    }
  }
  printf("%d\n", pop());

  return 0;
}

void push(int x){
  A[++top] = x;
}

int pop(){
  top--;
  return A[top+1];
}



Measured memory_bytes: 2104
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ni()
a = [2, 4, 5, 7, 9]
b = [0, 1, 6, 8]
c = [3]
r = N % 10
if r in a:
    print('hon')
elif r in b:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 10920
#include<stdio.h>

int main(){
    double pai=3.141592653589;
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1012
N = int(input())
ketasu = len(str(N))
saijoui = int(str(N)[0])
if int(str(saijoui)+"9"*(ketasu-1)) > N:
    print(saijoui + 9*(ketasu-1)-1)
else:
    print(saijoui + 9*(ketasu-1) )


Measured memory_bytes: 2940
package main

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

func main() {
	nextReader = newScanner()
	c := []rune(nextString())
	fmt.Println(string(c[0] + 1))
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll H, W, K;
    cin >> H >> W >> K;
    auto grid = make_vec_nd('$', W, H);
    pair<ll, ll> start;
    for (ll y = 0; y < H; y++) {
        for (ll x = 0; x < W; x++) {
            char c;
            cin >> c;
            grid[x][y] = c;
            if (c == 'S') {
                start = {x, y};
            }
        }
    }
    if (start.first == 0 || start.first == W-1 || start.second == 0 || start.second == H-1) {
        cout << 0 << endl;
        return 0;
    }
    ll min_cost = numeric_limits<ll>::max();
    auto calc_cost = [W, H](pair<ll, ll> pos) -> ll {
        vector<ll> costs = {pos.first - 0, W - pos.first - 1, pos.second - 0, H - pos.second - 1};
        return *min_element(costs.begin(), costs.end());
    };
    auto distance = make_vec_nd(numeric_limits<ll>::max(), W, H);
    using Pos = pair<ll, ll>;
    deque<Pos> queue;
    queue.push_back(start);
    distance[start.first][start.second] = 0;
    min_cost = min(min_cost, calc_cost(start));
    while (!queue.empty()) {
        Pos pos = queue.front();
        queue.pop_front();
        for (Pos vec : {Pos{-1, 0}, Pos{1, 0}, Pos{0, -1}, Pos{0, 1}}) {
            Pos next = {pos.first + vec.first, pos.second + vec.second};
            if (next.first < 0 || next.first >= W || next.second < 0 || next.second >= H) {
                continue;
            }
            if (grid[next.first][next.second] == '#') {
                continue;
            }
            if (distance[pos.first][pos.second] + 1 < distance[next.first][next.second]) {
                distance[next.first][next.second] = distance[pos.first][pos.second] + 1;
                if (distance[next.first][next.second] <= K) {
                    min_cost = min(min_cost, calc_cost(next));
                    queue.push_back(next);
                }
            }
        }
    }
    ll count = min_cost / K + (min_cost % K != 0) + 1;
    cout << count << endl;
}


Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));


signed main(){
    string s,t; cin >> s >> t;
    int ans=1e9;
    for(int i=0;i<s.size();i++){
        int res=0;
        for(int j=0;j<t.size();j++){
            if(i+j>=s.size()){
                res=1e9;
                break;
            }
            if(s[i+j]!=t[j]) res++;
        }
        chmin(ans,res);
    }
    cout << ans << endl;
}




Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

typedef pair<int, int> P;

char maze[51][51];
int reached[51][51];
int H, W;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {

    cin >> H >> W;
    int cnt = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> maze[i][j];
            reached[i][j] = 1e9+1;
            if(maze[i][j] == '#') cnt++;
        }
    }
    
    reached[0][0] = 1;
    queue<P> que;
    que.push(P(0, 0));
    while(!que.empty()) {
        P p = que.front();
        que.pop();
        int y = p.first, x = p.second;
        for(int k = 0; k < 4; k++) {
            if(y+dy[k] < 0 || H <= y+dy[k] || x+dx[k] < 0 || W <= x + dx[k]) continue;
            if(maze[y+dy[k]][x+dx[k]] == '#' || reached[y+dy[k]][x+dx[k]] != 1e9+1) continue;
            reached[y+dy[k]][x+dx[k]] = reached[y][x] + 1;
            que.push(P(y+dy[k], x+dx[k]));
        }  
    }

    if(reached[H-1][W-1] == 1e9+1) cout << -1 << endl;
    else cout << H * W - reached[H-1][W-1] - cnt << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<char, ll> mp;
  string s;
  cin >> s;
  for(int i=0; i<n; ++i){
    ++mp[s.at(i)];
  }
  ll ans;
  ans = mp['R']*mp['G']*mp['B'];
  for(int i=0; i<n; ++i){
    for(int j=1; j<n; ++j){
      if(i+j*2 >=n) break;
      if(s.at(i) != s.at(i+j) && s.at(i) != s.at(i+j*2) && s.at(i+j) != s.at(i+j*2)){
        --ans;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    println!("{}", std::cmp::max(c - (a - b), 0));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            String result = String.valueOf(a+b);
            System.out.println(result.length());
        }
    }
}

Measured memory_bytes: 20436
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(BufferedReader in) throws IOException {
        int N = Integer.parseInt(in.readLine());
        long[] A = new long[N];
        long[] B = new long[N];
        for (int i = 0; i < N; ++i) {
            String[] s = in.readLine().split(" ");
            A[i] = Long.parseLong(s[0]);
            B[i] = Long.parseLong(s[1]);
        }

        long ans = 0;
        for (int i = N - 1; i >= 0; --i) {
            A[i] += ans;
            long r = A[i] % B[i];
            if (r > 0) {
                ans += B[i] - r;
            }
        }
        _out.println(ans);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) throws IOException {
        long S = System.currentTimeMillis();

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        new Main().solve(in);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 48304