akhauriyash/Code-Regression huggingface dataset:
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,d[li],mx;
int cev;
string s;
vector<PII> v[li];

inline void dfs(int node,int ata,int maxr,int renk){
	int suan=0;
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i].fi;
		int go1=v[node][i].se;
		if(go==ata)continue;
		suan++;
		if(suan==renk)suan++;
		d[go1]=suan;
	}
	//~ cout<<suan<<endl;
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i].fi;
		int go1=v[node][i].se;
		if(go==ata)continue;
		dfs(go,node,max(maxr,suan),d[go1]);
	}
	mx=max(mx,maxr);
}

int main(void){
	scanf("%d",&n);
	//~ d[1]=1;
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		v[x].pb(mp(y,i));
		v[y].pb(mp(x,i));
	}
	dfs(1,0,0,0);
	printf("%d\n",mx);
	for(int i=1;i<n;i++) printf("%d\n",d[i]);
	return 0;
}


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

int main(){
    int64_t N,K;
    cin >> N >> K;
    int64_t amari;
    amari = N % K;
    
    if ( K - amari < amari ){
        amari = K - amari;
    }
    
    cout << amari << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	char c;
	cin >> c;
	if (c == 'A')
		cout << 'T';
	else if (c == 'T')
		cout << 'A';
	else if (c == 'C')
		cout << 'G';
	else if (c == 'G')
		cout << 'C';
	return 0;
}

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

ll a[100000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,n;
    cin>>h>>n;
    for(int i=1;i<=n;i++)
    {

        cin>>a[i];
        h-=a[i];

    }
    if(h<=0)
    {

        cout<<"Yes"<<'\n';
    }
    else
    {

        cout<<"No"<<'\n';
    }

}
















Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <vector>
const int inf=2147483647;
const int mo=1e9+7;
const int N=100005;
using namespace std;
typedef pair<int,int> par;
int n,m,a[N],b[N],tot,d[N],t,t2;
par c[N];
long long sum[N];
int too(int x)
{
	return x&-x;
}
void put(int x,long long v)
{
    for(;x<=t2;x+=too(x)) sum[x]=(sum[x]+v)%mo;
}
long long find(int x)
{
    long long s=0;
    for(;x;x-=too(x)) s=(s+sum[x])%mo;
    return s;
}
bool cmp(par x,par y)
{
	return x.first<y.first || (x.first==y.first && x.second>y.second);
}
int main()
{
	//freopen("arc101e.in","r",stdin);
	//freopen("arc101e.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
	if(a[i]>b[1] && a[i]<b[m])
	{
		int p=lower_bound(b+1,b+1+m,a[i])-b;
		if(b[p]==a[i]) continue;
		c[++t]=par(a[i]-b[p-1],b[p]-a[i]);
		d[++t2]=b[p]-a[i];
	}
	sort(d+1,d+t2+1);
	t2=unique(d+1,d+t2+1)-d-1;
	for(int i=1;i<=t;i++) c[i].second=lower_bound(d+1,d+t2+1,c[i].second)-d;
	sort(c+1,c+t+1,cmp);
	t=unique(c+1,c+t+1)-c-1;
	long long ans=1;
	for(int i=1;i<=t;i++)
	{
		long long s=find(c[i].second-1)+1;
		ans=(ans+s)%mo;
		put(c[i].second,s);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2688
#create date: 2020-07-03 16:23

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    c = na()
    dif1, dif2 = c[1] - c[0], c[2] - c[1]
    for i in range(2):
        cn = na()
        if cn[1] - cn[0] != dif1 or cn[2] - cn[1] != dif2:
            print("No")
            quit()
    print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9148
def slove():
    import sys, itertools
    input = sys.stdin.readline
    n, a, b, c = list(map(int, input().rstrip('\n').split()))
    l = [int(input().rstrip('\n')) for _ in range(n)]
    ls = [0, 1, 2, 3]
    m_cost = 10 ** 10

    for it in itertools.product(ls, repeat=n):
        if 1 in it and 2 in it and 3 in it:
            lst = [0] * 4
            cost = 0
            for i, v in enumerate(it):
                lst[v] += l[i]
                if v == 1 or v == 2 or v == 3:
                    cost += 10
            cost -= 30
            cost += (abs(lst[1] - a) + abs(lst[2] - b) + abs(lst[3] - c))
            m_cost = min(m_cost, cost)
    print(m_cost)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 75376
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long

int32_t main() {
	_ __

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

	string s;
	cin >> s;
	if (s[s.length() - 1] == 's') {
		s += "es";
	}
	else {
		s += "s";
	}
	cout << s << "\n";


#ifdef LOCAL_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int f[20],t[20],s;
inline void dp(int &x,int y){
  if (y>x) x=y;
  return;
}
int main(){
  int n; cin>>n;
  memset(f,-100,sizeof(f));
  f[0]=0;
  for (int i=1; i<=n; ++i){
    cin>>s;
    memcpy(t,f,sizeof(t));
    for (int j=0; j<10; ++j)
      dp(t[(j+s)%10],f[j]+s);
    memcpy(f,t,sizeof(f));
  }
  int ans=0;
  for (int i=1; i<10; ++i)
    dp(ans,f[i]);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
# 隣接する2文字の入れ替えでAGCとなるパターン(もしくはAGCそのもの)
# AGC
# ACG
# GAC
# AGGC
# ACGC
# ATGC
# AGAC
# AGGC
# AGTC
# 上記を含まない文字列を数える

import sys
readline = sys.stdin.readline

N = int(readline())
DIV = 10 ** 9 + 7

# dp[i][a][b][c] = i文字目について、2つ前がa,1つ前がb,i文字目がdの数で条件を満たすものの数
# 0:"A", 1:"G", 2:"C", 3:"T"
dp = [[[[0] * 4 for b in range(4)] for a in range(4)] for i in range(N)]

C = {0:"A", 1:"G", 2:"C", 3:"T", 4:""}
NG = set(["AGC","ACG","GAC","AGGC","ACGC","AGAC","AGGC","ATGC","AGTC"])

def check_ok(i,j,k,l = 4):
  if (C[i] + C[j] + C[k] + C[l]) in NG:
    return False
  return True

# 3文字目
for i in range(4):
  for j in range(4):
    for k in range(4):
      if check_ok(i,j,k):
        dp[2][i][j][k] += 1

# 4文字目以降を決める
for i in range(2, len(dp) - 1):
  for a in range(4):
    for b in range(4):
      for c in range(4):
        for k in range(4):
          if check_ok(a,b,c,k) and check_ok(b,c,k):
            dp[i + 1][b][c][k] += dp[i][a][b][c]
            dp[i + 1][b][c][k] %= DIV
        
ans = 0
for a in range(4):
  for b in range(4):
    for c in range(4):
      ans += dp[-1][a][b][c]
      ans %= DIV
      
print(ans)

Measured memory_bytes: 9200
#include<stdio.h>
int main()
{
    int x,y;
    scanf("%x%x",&x,&y);
    if(x>y){
        printf(">\n");
    }else if(x==y){
        printf("=\n");
    }else if(x<y){
        printf("<\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int n,i,x[100000];
  long long a,b,ans=0;
  scanf("%d %lld %lld",&n,&a,&b);
  for(i=0;i<n;i++)
    scanf("%d",&x[i]);
  for(i=0;i<n-1;i++){
    long long tmp=(x[i+1]-x[i])*a;
    ans+=tmp<b?tmp:b;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 512
N = int(input())
S = input()

wnums = [0]
enums = [0]
for i in range(0, N-1):
    if S[i] == 'W':
        wnums.append(wnums[i]+1)
    else:
        wnums.append(wnums[i])

j=0
for i in range(N-1, 0, -1):
    if S[i] == 'E':
        enums.append(enums[j]+1)
    else:
        enums.append(enums[j])
    j += 1

ans = 10**9
for i in range(N):
    num = wnums[i] + enums[N-i-1]
    if ans > num:
        ans = num
print(ans)

Measured memory_bytes: 18080
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;
ll dp[100010][13];

int main(){
	string s; cin >> s;
	int n=s.size();
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<13;j++){
			if(s[i]=='?'){
				for(int k=0;k<10;k++){
					(dp[i+1][(j*10+k)%13]+=dp[i][j])%=mod;
				}
			}
			else{
				(dp[i+1][(j*10+s[i]-'0')%13]+=dp[i][j])%=mod;
			}
		}
	}
	cout << dp[n][5] << endl;
}

Measured memory_bytes: 10624
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		BigDecimal r = new BigDecimal(s);
		BigDecimal p = new BigDecimal(Math.PI);

		BigDecimal a = new BigDecimal(0);
		BigDecimal b = new BigDecimal(0);
		BigDecimal c = new BigDecimal(2);
		
		a = p.multiply(r).multiply(r);
		b = p.multiply(r).multiply(c);
		
		a = a.setScale(6, BigDecimal.ROUND_UP);
		b = b.setScale(6, BigDecimal.ROUND_UP);

		System.out.print(a);
		System.out.print(" ");
		System.out.println(b);
	}

}

Measured memory_bytes: 26420
def insert(S, string):
    S.add(string)

def find(S, string):
    if string in S:
        print 'yes'
    else:
        print 'no'

n = input()

S = set()

for i in range(n):
    tmp1, tmp2  = map(str, raw_input().split())
    if tmp1 == 'insert':
        insert(S, tmp2)
    elif tmp1 == 'find':
        find(S, tmp2)
    else:
        print 'error!'

Measured memory_bytes: 59572
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
int done[N]={0};
vector<int> v[N];
void dfs(int x , int p){
	  done[x] = 1;
	for(int i=0;i<v[x].size();i++){
		int y=v[x][i];
		if(!done[y]) dfs(y,x);	
	}
}
signed main(){
  fast;
  int n ,m,x,y,ans=0,z;
  cin>>n>>m;
  for(int i=0;i<m;i++){
  	cin>>x>>y>>z;
  	v[x].pb(y);
  	v[y].pb(x);
  }
  for(int i=1;i<=n;i++){
  	if(done[i]==0) dfs(i,-1) , ans++;
  }
  cout<<ans<<endl;

}
  


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

int main(){
  string S;
  int r = 0;
  cin >> S;
  
    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R' ){
      r=3;
    }else if((S[0] == 'R' && S[1] == 'R') ||(S[1] == 'R' && S[2] == 'R')){
      r=2;
    }else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R'){
      r=1;
    }
  cout << r << endl;
      
  return 0;
}


Measured memory_bytes: 3564
//package Dp;

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        class tuple{
            double a;
            int b;
            double c;
            tuple(double a,int b,double c){
                this.a=a;
                this.b=b;
                this.c=c;
            }
        }
        int q=in.nextInt(),h=in.nextInt(),s=in.nextInt(),d=in.nextInt();
        int n=in.nextInt();
        tuple arr[]={new tuple(0.25,q,q/0.25),new tuple(0.5,h,h/0.5),new tuple(1.0,s,s/1.0),new tuple(2.0,d,d/2.0)};
        Arrays.sort(arr,new Comparator<tuple>(){
           public int compare(tuple o1,tuple o2){
               if(o1.c>o2.c){
                   return 1;
               }
               else if(o1.c<o2.c){
                   return -1;
               }
               return 0;
            }
        });
        long ans=0;
        for (int i = 0; i < 4; i++) {
            int x= (int) (n/arr[i].a);
            if(arr[i].a>n){
                continue;
            }else {
                if(n%arr[i].a!=0) {
                    ans += (long)x*arr[i].b;
                    n= (int) (n-arr[i].a*x);
                }
                else {
                    ans+=(long)x*arr[i].b;
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll dp[100000+10][2];

int main() {
  int N; cin>>N;
  vector<ll> A(N);
  REP(i,N) cin>>A[i];
  dp[0][0] = A[0];
  dp[0][1] = -A[0];
  for(int i = 1; i < N-1; i++) {
    dp[i][0] = max(dp[i-1][0]+A[i], dp[i-1][1]-A[i]);
    dp[i][1] = max(dp[i-1][0]-A[i], dp[i-1][1]+A[i]);
  }
  dp[N-1][0] = dp[N-2][0] + A[N-1];
  dp[N-1][1] = dp[N-2][1] - A[N-1];
  //  REP(i,N) {                                                                         
  //    cout << i << " " << dp[i][0] << " " << dp[i][1] << endl;                         
  //  }                                                                                  
  cout << max(dp[N-1][0], dp[N-1][1]) << endl;
  return 0;
}


Measured memory_bytes: 2560
import collections
import math

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

c = collections.Counter(a)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

all_comb = 0
for v in c.values():
    if v != 1:
        all_comb += combinations_count(v,2)

for i in a:
    print(all_comb-(c[i]-1))

Measured memory_bytes: 26772
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int l=s.length();
  if((s[0]!=s[l-1])^l%2){
    cout<<"Second"<<endl;
  }
  else {
    cout<<"First"<<endl;
  }
  return 0;

}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        int N = int.Parse(Console.ReadLine());
        string[] readSome = new string[3*N];
        readSome = Console.ReadLine().Split(' ');
        int[] a = new int[3*N];
        for (int i = 0; i < 3*N; i++) {
            a[i] = int.Parse(readSome[i]);
        }
        Array.Sort(a);
        long answer = 0;
        for (int i = 0; i < N; i++) {
            answer += a[3*N - (1 + i * 2)-1];
        }
        Console.WriteLine(answer);
    }
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int a;
int b;

int main(){
  cin >> a >> b;
  if(a<=5) cout << "0" <<endl;
  else if(a<=12&&a>=6) cout << b/2 <<endl;
  else cout << b <<endl;
  return 0;
}

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

#define rep(i,a,b) for (int i = (a); i < (b); i++ )

int main() {
    //行列に入力
    string a, s;
    cin >> a >> s;

    int nagasa = a.size();
    int count;
    count = 0;
    rep(i, 0, nagasa) {

        if (a.at(i) == s.at(i)) {
            count++;
        }
    }
    if (count == nagasa) {
        cout << "Yes" << endl;

    }
    else if (count!=nagasa) {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int a[12],b[12],n;
  while(cin >>n,n){
    for(int i=0; i<n; i++){cin >>a[i];}
    for(int i=0;;i++){
      for(int j=0; j<n; j++){
	int s = 0;
	for(int k=0; k<n; k++){
	  if(a[j] == a[k]){s++;}
	}
	b[j] = s;
      }
      bool f = true;
      for(int j=0; j<n; j++){
	if(a[j] != b[j]){f = false;}
	a[j] = b[j];
      }
      if(f){
	cout <<i<<endl<<a[0];
	for(int j=1; j<n; j++){
	  cout <<" "<<a[j];
	}
	cout <<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

ll ans[100];

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

    int N, D, X;
    cin >> N >> D >> X;

    int ans = X;

    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;

        ans += D / a + (D % a > 0 ? 1 : 0) ;
    }

    out(ans);

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")   //Comment optimisations for an interative problem/use endl
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;  
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss;  
typedef vector<pll> vpll; 
typedef vector<ll> vll; 
typedef vector<vll> vvll; 
typedef unordered_map<ll,ll> um;

#define fastio ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define sqr(x) ((ll)(x) * (x)) 
#define reset(a, b) memset(a, b, sizeof(a)) 
#define f first 
#define s second 
#define mp make_pair 
#define pb push_back 
#define all(v) v.begin(), v.end() 
#define alla(arr, sz) arr, arr + sz 
#define showv(v) for(auto it: (v))cout<<it<<" ";newl;
#define newl cout<<"\n"

const ll MAXN=1e+2+7;
const ll MOD=1e+9+7, INF=0x7f7f7f7f7f7f7f7f;const int INFi=0x7f7f7f7f;
double EPS = 1e-9;  
double PI = acos(-1); 

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
ll t,n;
ll i,j;
 
//<<-----Implement Functions Here---->>//
 
 
//<<-----Start of Main--------------->>//

int main()
{
	stringstream ss;string s,e; 
	cin >> n >> t;
	if(n>t)
	{
  		ss<<t;  
  		ss>>s;
  		e = s;
  		for(i=0;i<n-1;i++)s+=e;
  	}
	else
	{
		ss<<n;  
  		ss>>s;
  		e = s;
  		for(i=0;i<t-1;i++)s+=e;
	}
	cout<<s;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    string s;
    cin >> s;

    int n = s.size();
    int b = n;
    int e = 0;
    rep(i,s.size()){
        if(s[i] == 'A' ){
            if(i < b){
                b = i;
            }
        }
        if(s[i] == 'Z' ){
            if(i > e){
                e = i;
            }
        }
    }

    cout << e-b +1 << endl;


}


Measured memory_bytes: 640
n,m,c = map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n):
    tmp=c
    for j in range(m):
        tmp+=b[j]*a[i][j]
    if tmp>0:
        ans+=1
print(ans)

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

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

    int n;
    cin >> n;

    unordered_map<int, int> mp;
    REP(i, n){
        int a;
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for(auto x : mp){
        if(x.first == x.second);
        else{
            if(x.first < x.second) ans += x.second - x.first;
            else ans += x.second;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n),sum(n+1,0);
    int i;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        sum.at(i+1)=sum.at(i)+a.at(i);
    }
    //for(i=0;i<n+1;i++)cout << sum.at(i)<<endl;
    //cout << endl;
    ll ans = 0;
    map<ll,ll> mp;
    for(i=0;i<n+1;i++){
        ans += mp[sum.at(i)];
        mp[sum.at(i)]++;
    }

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

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

void solve() {
    unsigned char x; cin >> x;
    if(x >= 'A' && x <= 'Z') {
        cout << 'A';
    }
    else {
        cout << 'a';
    }
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,M;cin >> N >> M;
    if(N == M)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;
const int INF = 1 << 30;
int dp[100005],h[100005];

int main(){
  int n,k; cin >> n >> k;
  rep(i,n){
    cin >> h[i];
  }
  
  rep(i,100005) dp[i] = INF;
  
  dp[0] = 0;
  
  for(int i = 0; i < n; i++){
    for(int j = 1; j <= k; j++){
      if(i+j < n){
        chmin(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
      }
    }
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod = 1e9 + 7;
constexpr int INF = 2e9;

int main() {
  int a, b;
  cin >> a >> b;
  int res = -INF;
  res = max(res, a + b);
  res = max(res, a - b);
  res = max(res, a * b);
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

bool kaibun(string s)
{
    bool ret = true;
    int n = s.size();
    for (int i = 0; i < n / 2; ++i)
    {
        if (s[i] != s[n - i - 1]) ret = false;
    }
    return ret;
}

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

    string s;
    cin >> s;

    int n = s.size();
    bool ans = kaibun(s) && kaibun(s.substr(0, (n - 1) / 2)) && kaibun(s.substr(n / 2 + 1, (n - 1) / 2));

    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}



Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	var input = parseInt(input);
	if (input == 22) {
		console.log('Christmas Eve Eve Eve');
	} else if (input == 23) {
		console.log('Christmas Eve Eve');
	} else if (input == 24) {
		console.log('Christmas Eve');
	} else if (input == 25) {
		console.log('Christmas');
	}
}

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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


Measured memory_bytes: 256
N = int(input())
for i in range(N) :
    a, b, c = map(int, input().split())
    if a**2 == b**2 + c**2 or b**2 == c**2 + a**2 or c**2 == a**2 + b**2 :
        print("YES")
    else :
        print("NO")


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
using namespace std;

int main()
{
    int n, q;
    string s;
    cin >> n >> q >> s;
    int l[q];
    int r[q];
    for(int i=0;i<q;++i)
        cin >> l[i] >> r[i];

    int cnt[n] = {0};
    bool is_ac[n] = {false};
    int ac_cnt = 0;

    for(int i=0;i<n-1;++i)
    {
        if(s[i] == 'A' && s[i+1] == 'C')
        {
            ++ac_cnt;
            is_ac[i] = true;
        }            
            
        cnt[i] = ac_cnt;
    }

    cnt[n-1] = cnt[n-2];

    for(int i=0;i<q;++i)
    {
        int r_idx = max(0, r[i]-2);
        int l_idx = l[i]-1;
        int tmp_cnt = cnt[r_idx] - cnt[l_idx];

        if(is_ac[l_idx] && r[i] != l[i])
            tmp_cnt++;

        cout << tmp_cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 2304
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def error_mat_print(m):
    for r in m:
        print(r, file=sys.stderr)

def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(L, A):

    dp = [[sys.maxsize] * (L+1) for _ in range(5)]
    dp[0][0] = 0

    for i, a in enumerate(A):
        t = dp[0][i]
        dp[0][i+1] = t + a
        t = min(t, dp[1][i])
        dp[1][i+1] = t+ ((a%2) if a != 0 else 2)
        t = min(t, dp[2][i])
        dp[2][i+1] = t + ((a+1)%2)
        t = min(t, dp[3][i])
        dp[3][i+1] =t + ((a%2) if a != 0 else 2)
        t = min(t, dp[4][i])
        dp[4][i+1] = t + a


    return min([dp[i][L] for i in range(5)])

def main():
    L = read_int()
    A = [read_int() for _ in range(L)]
    print(slv(L, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 90324
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n;
	int k;
	scanf("%d %d", &n, &k);
	
	double prob = 0;

	for(int i = 1; i <= n; i++) {
		double tmp = 1.0 / n;
		int num = i;
		while(num < k) {
			num *= 2;
			tmp /= 2;
		}
		prob += tmp;
	}

	printf("%.12f\n", prob);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9+101;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(ll i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 998244353
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

int main() {
    int p,q;
    cin >> p >> q;
    if(q%p ==0 ){
        cout << p + q << endl;
    }
    else{
        cout <<q-p << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD=1e9+7;
int add(int a,int b){
	return (a+b)%MOD;
}
void dadd(int &a,int b){
	a=add(a,b);
}
int sub(int a,int b){
	return (a-b+MOD)%MOD;
}
int mul(int a,int b){
	return (LL)a*b%MOD;
}
const int N=5050;
int dp[N][N];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		dp[0][i]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j+1<=m;j++){
			dp[i][j+1]=mul(dp[i-1][j],j);
		}
		for(int j=2;j<=m;j++){
			dadd(dp[i][j],mul(dp[i][j-1],2));
		}
		for(int j=1;j<=m;j++){
			dadd(dp[i][j],mul(dp[i-1][j],j+1));
		}
	}
	int ans=dp[n][m];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 102380
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int n, i, s;
	int a[25] = {};
	while (~fscanf(stdin, "%d", &n), n) {
		for (i = 0; i < n; i++) fscanf(stdin, "%d", &a[i]);
		s = 32,i=0;
		while (s>0) {
			s = s - (s - 1) % 5;
			P(d, s);
			s -= a[i++];
			if (i == n) i = 0;
			P(d, s < 0 ? 0 : s);
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
using namespace std;
int main()
{
	long long a,b,x,ans;
	
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a==0){
	
	
	 ans=(b/x)+1;}
	else{
	
	 ans=((b/x)-(a-1)/x);	}
	
	cout<<ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    return;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // #define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max();

// RMQ
template<class T>
struct SegmentTree {
    int n;
    vector<T> dat;
    SegmentTree(int n_ = 0) : n(n_){
        n = 1;
        while(n < n_) n <<= 1;
        dat.resize(n*2, inf);
    }
    T query(int v, int w, int l, int r){
        if(v >= (int)dat.size()) return inf;
        if(r - l == w) return dat[v];
        if(r <= l) return inf;
        T res = inf;
        res = std::min(res, query(v*2, w/2, l, min(r, w/2)));
        res = std::min(res, query(v*2+1, w/2, max(0, l-w/2), r-w/2));
        return res;
    }
    void update(int i, T x){
        i += n;
        dat[i] = x;
        while(i != 1){
            dat[i>>1] = min(dat[i], dat[i^1]);
            i /= 2;
        }
    }
    T query(int l, int r){
        return query(1,n,l,r);
    }
    size_t size() const {
        return n;
    }
};

int main(){
    fastios();
    int n, q;
    while(cin >> n >> q){
        SegmentTree<int> st(n);
        rep(i,q){
            char c;
            int x, y;
            cin >> c >> x >> y;
            if(c == '0'){
                st.update(x,y);
            } else {
                cout << st.query(x,y+1) << endl;
            }
        }
    }
}

Measured memory_bytes: 2052
n = int(input())
a = list(map(int,input().split()))
d = {}
ans = 0
for i in a:
    d[i] = d.get(i,0) + 1
for key in d:
    ans += d[key]*(d[key]-1)//2
for i in a:
    print(ans + 1 - d[i])

Measured memory_bytes: 26268
#include <iostream>
using namespace std;
int main(){
    int a;
    int i = 1;
    while(i <= 10000){
        cin >> a;
        if(a == 0){
            break;
        }
        cout << "Case " << i << ": " << a <<endl;
        i++;
    }
    return 0;
}


Measured memory_bytes: 3020
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    ll a[n+1];
    for(int i=0;i<n+1;i++) cin >> a[i];
    int b[n];
    for(int i=0;i<n;i++) cin >> b[i];

    ll sum=0;
    for(int i=0;i<n;i++){
        if(b[i]<=a[i]){
            sum+=b[i];
        }else{
            sum+=a[i];
            b[i]-=a[i];
            if(a[i+1]>=b[i]){
                sum+=b[i];
                a[i+1]-=b[i];
            }else{
                sum+=a[i+1];
                a[i+1]=0;
            }
        }
    }

    cout << sum << endl;    
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s == u) {
    cout << a - 1 << " " << b << endl;
  }
  else {
    cout << a << " " << b - 1 << endl;
  }
  
}


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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += p[i];
  }
  cout << sum << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}


//modの値の確認をすること
int main(){
    ll cnt = 0;
    string s,t;
    cin >> s >> t;
    rep0(i, max(s.size(),t.size()))if(s[i] != t[i])++cnt;
    pf(cnt);
    return 0;
}


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

char c[60][60];
int h, w;

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

int search(int y, int x) {
	int res = 0;
	for (int i = 0; i < 8; i++) {
		if (c[y + dy[i]][x + dx[i]] == '#')res++;
	}
	return res;
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < 60; i++) {
		for (int j = 0; j < 60; j++) {
			c[i][j] = '.';
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '.') {
				cout << search(i, j);
			}
			else cout << c[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
A_sum = [0]
B_sum = [0]
A_sum.extend(A)
B_sum.extend(B)
for i in range(1,N+1):
    A_sum[i]+=A_sum[i-1]
for i in range(1,M+1):
    B_sum[i]+=B_sum[i-1]
ans,j=0,M
for i in range(N+1):
    if A_sum[i]>K:
        break
    while B_sum[j]+A_sum[i]>K:
        j-=1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 49128
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int R;
  cin >> R;
  if(R < 1200)
    cout << "ABC" << endl;
  else if(R < 2800)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;
  return 0;
}


Measured memory_bytes: 768
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary 
int main()
{
      fast;ll t;t=1;
      while(t--)
      { 
            ll maxi,mini,n,a,b,i,maxi1,mini1;
            cin>>n;
            maxi=0;mini=10e16;
            maxi1=-10e16;mini1=10e16;
            vector<pair<ll,ll> >v;
            for(i=0;i<n;i++)
            {
                  cin>>a>>b;
                  v.pb({a,b});
            }
            sort(v.begin(),v.end());
            for(i=0;i<v.size();i++){
                  a=v[i].f;b=v[i].s;
                  maxi=max(maxi,a+b);
                  mini=min(mini,a+b);
                  maxi1=max(maxi1,(a-b));
                  mini1=min(mini1,(a-b));
            }
            cout<<max(maxi-mini,maxi1-mini1)<<"\n";
      }
}

Measured memory_bytes: 7408
N=int(input())
A,B,C=[sorted(map(int,input().split())) for i in range(3)]
i,j=0,0
r=0
for b in B:
    while i<N and A[i]<b:
        i+=1
    while j<N and C[j]<=b:
        j+=1
    r+=i*(N-j)
print(r)

Measured memory_bytes: 29408
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;
int H[500001];


void printResult(int i, int n){
    printf("node %d: key = %d, ",i,H[i]);
    if(i!=1) printf("parent key = %d, ",H[i/2]);
    if(2*i<=n) printf("left key = %d, ",H[2*i]);
    if(2*i+1<=n) printf("right key = %d, ",H[2*i+1]);
    printf("\n");

}

void maxHeapify(int i, int n){
    int l=2*i; int r=2*i+1;
    int largest=i;
    if(l<=n and H[l]>=H[i]) largest=l;
    if(r<=n and H[r]>=H[largest]) largest=r;

    if(largest!=i){
        swap(H[i],H[largest]);
        maxHeapify(largest,n);
    }
}

void buildMaxHeap(int n){
    for (int i=n/2; i>0; i--)maxHeapify(i,n);
}

int main()
{
    int n,i,x;
    string com;

    cin>>n;
    for(i=1;i<=n;i++){
        cin>>H[i];
    }
    buildMaxHeap(n);
    for(i=1;i<=n;i++){
        printf(" %d",H[i]);
    }
    printf("\n");


    return 0;
}


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

const int MAX_N = 100000;
std::vector<std::pair<int, int>> g[MAX_N];
int visited[MAX_N], cost[MAX_N];

bool dfs(int v) {
  visited[v] = 1;

  for (const auto& e : g[v]) {
    int u = e.first, d = e.second;

    if (visited[u]) {
      if (cost[v] + d != cost[u]) {
        return false;
      }

      continue;
    }

    cost[u] = cost[v] + d;

    if (!dfs(u)) {
      return false;
    }
  }

  return true;
}

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

  for (int i = 0; i < M; i++) {
    int L, R, D;
    std::cin >> L >> R >> D;

    g[L-1].emplace_back(R-1, D);
    g[R-1].emplace_back(L-1, -D);
  }

  bool yes = true;

  for (int i = 0; yes && i < N; i++) {
    if (!visited[i] && !dfs(i)) {
      yes = false;
    }
  }

  std::cout << (yes ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 11392
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n;
	int j = 1;
	while (cin >> n&&n!=0) {
		int a[10][10];
		a[0][0] = 1;
		int x = 0, y = 0, sum = 1;
		int xj, yj;
		bool l = false;
		for (int i = 0; i < n*n; i++) {
			if (y == n - 1 && x == n - 1) {
				a[n-1][n-1] = sum;
				break;
			}
			else if (y == n - 1&&!l) {
				xj = 1;
				yj = -1;
				a[x][y] = sum;
				sum++;
				x++;
				l = true;
			}
			else if (x == n - 1 &&!l) {
				xj = -1;
				yj = 1;
				a[x][y] = sum;
				sum++;
				y++;
				l = true;
			}
			else if (x == 0&&!l) {
				xj = 1;
				yj = -1;
				a[x][y] = sum;
				sum++;
				y++;
				l = true;
			}
			else if (y == 0&&!l) {
				xj = -1;
				yj = 1;
				a[x][y] = sum;
				sum++;
				x++;
				l = true;
			}
			else {
				a[x][y] = sum;
				sum++;
				x += xj;
				y += yj;
				l = false;
			}
		}
		cout << "Case " << j << ":" << endl;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				string g = to_string(a[i][j]);
				while (g.length() !=3)
					g = " " + g;
				if (j == 0) cout <<g;
				else cout <<  g;
			}
			cout << endl;
		}
		j++;
	}
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string p,q;
    string P,Q;
    for(int i=0;i<n;i++){
        cin>>p;
        P+=p;
    }
    for(int i=0;i<n;i++){
        cin>>q;
        Q+=q;
    }
    string array[]={"1","2","3","4","5","6","7","8"};
    string per[100000];
    int j=0;
    int itr_p=0,itr_q=0;
    do{
        for(int i=0;i<n;i++){
            per[j]+=array[i];
        }
        if(per[j]<P){
            itr_p++;
        }
        if(per[j]<Q){
            itr_q++;
        }
        j++;
    }while(next_permutation(array,array+n));
    cout<<abs(itr_p-itr_q)<<endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
using namespace std;
 
short dp[11][1<<10][341];
short ans[11][341];
int main(){
    dp[0][0][0] = 1;
    for(int i = 0 ; i < 10 ; i++){
        for(int j = 0 ; j < (1<<10) ; j++){
            for(int c = 0 ; c < 331 ; c++){
                if(dp[i][j][c] == 0 ) continue;
                for(int k = 0 ; k < 10 ; k++){
                    if(!(j>>k&1)){
                        dp[i+1][j|(1<<k)][(i+1)*k+c] += dp[i][j][c];
                    }
                }
            }
        }
    }
    /*cout << dp[1][2][2] << endl;*/
    for(int i = 0 ; i < 11 ; i++){
        for(int j = 0 ; j < (1<<10) ; j++){
            for(int c = 0 ; c < 331 ; c++){
                ans[i][c] += dp[i][j][c];
            }
        }
    }
    int n,s;
     
    while(~scanf("%d%d",&n,&s)){
        if(n > 10 || s > 330){
            cout << 0 << endl;
        }else{
            cout << ans[n][s] << endl;
        }
    }
}

Measured memory_bytes: 5516
from collections import defaultdict
from itertools import accumulate


N, K = map(int, input().split())

timetables = defaultdict(list)
for i in range(N):
    s, t, c = map(int, input().split())
    timetables[c].append([s, t])

for name, times in timetables.items():
    times.sort()
    new = []
    for i, time in enumerate(times):
        s, t = time
        if i == 0:
            new.append([s, t])
            continue
        if s == new[-1][1]:
            new[-1][1] = t
        else:
            new.append([s, t])
    timetables[name] = new

time_count = [0] * 100010
for name, times in timetables.items():
    for s, t in times:
        time_count[s] += 1
        time_count[t + 1] -= 1

acc = accumulate(time_count)

print(max(acc))

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

int main()
{
    long long int n;
    cin >> n;
    long long int arr[n],sum=0,ans=0,fans=1e18;
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
        sum+=arr[i];
    }
    for(int i=0;i<n;i++)
    {
        ans+=arr[i];
        if(ans==sum/2 && sum%2==0)
        {fans=0;break;}
        else
        {
            fans=min(fans,abs(ans-(sum-ans)));
        }
    }
    cout << fans << endl;
    return 0;
}


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

int main() {
  int A = 0, B = 0;
  char op = 0;
  cin >> A >> op >> B;
  int ans = 0;
  if (op == '+') {
    ans = A+B;
  } else {
    ans = A-B;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256