akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<limits.h>
#include<math.h>
#include<string>
#include<string.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<complex.h>
#include<map>

using namespace std;
const int INF = 1e9;


int main(){
  int n,p;
  while(1){
    cin>>n>>p;
    if(n==0){
      break;
    }
    int owan=p;
    vector<int> a(n,0);
    int i=0;
    while(1){
      //cerr<<"i="<<i<<endl;
      bool end_flg=false;
      //for(int x: a){
        //cerr<<x<<" ";
      //}
      //cerr<<endl;
      //cerr<<"owan="<<owan<<endl;
      if(owan==0){
        if(a[i]!=p){
          //tuduku
          owan+=a[i];
          a[i]=0;
        }else{
          //winner
          cout<<i<<endl;
          end_flg=true;
          break;
        }
      }else{
        a[i]++;
        owan--;
      }
      i++;
      if(i==n){
        i=0;
      }
      if(end_flg)break;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
import collections

n = int(input())
es = [[] for _ in range(n + 1)]
counter = [0 for _ in range(n + 1)]
edges = []
for i in range(n - 1):
	a, b = list(map(int, input().split()))
	edges.append([i, a, b])
	counter[a] += 1
	counter[b] += 1

#print(counter)
#print(counter)
max_e = max(counter)
colors_node = [-1 for _ in range(n + 1)]

edges.sort(key = lambda x: (x[1], x[2]))

colors = [-1 for _ in range(n + 1)]
cnt = 1
origin = -1
for i in range(n - 1):
	if origin == edges[i][1]:
		cnt += 1
	else:
		cnt = 1
		origin = edges[i][1]

	edges[i].append((colors[edges[i][1]] + cnt) % max_e)
	colors[edges[i][2]] = (colors[edges[i][1]] + cnt) % max_e

print(max_e)
edges.sort(key = lambda x: x[0])
for i in range(n - 1):
	print(edges[i][3] + 1)


Measured memory_bytes: 44340
/*
_________________________
|   LIVE FREE OR DIE     |
|       327 2153         |
|          New           |
|_______HAMPSHIRE________|

*/
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MAX 20
#define int long long
#define MOD 998244353

int32_t main()
{
	IOS
	int k;cin>>k;
	int a,b;cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	string s; cin >> s;
	int n; cin >> n;
	int a, b;
	string t, ss;
	rep(i, 0, n) {
		cin >> t >> a >> b;
		if(t == "replace"){
			cin >> ss;
			s.replace(a, b - a + 1, ss);
		} else if (t == "reverse") {
			reverse(s.begin() + a, s.begin() + b + 1);
		} else {
			P(s.substr(a, b - a + 1));
		}
	}
	return 0;
}

Measured memory_bytes: 3244
#include <stdio.h>

int main() {
  int A[110];
  int N;

  scanf("%d", &N);

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

  double temp = 0;

  for (i = 0; i < N; i++) {
    temp = temp + (1 / (double)A[i]);
  }

  printf("%f\n", 1 / temp);




  return 0;
}


Measured memory_bytes: 128
def calc():
    abc = list(map(int, input().split()))
    k = int(input())
    for i in range(0, 7):
        for j in range(0, 7):
            for l in range(0, 7):
                sum = i+j+l
                con1 = sum <= k
                con2 = abc[0]*(1 << i) < abc[1]*(1 << j)
                con3 = abc[1]*(1 << j) < abc[2]*(1 << l)
                if(con1 & con2 & con3):
                    print('Yes')
                    return
    print('No')
    return


calc()


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

 
int main() {
   int n;
   cin>>n;
   ll H[n];
   int ans=0;
   int zan=0;
   rep(i,n)cin>>H[i];
   rep(i,n){
       if(H[i+1]>H[i]){
           if(zan>=ans)ans=zan;
           zan=0;
       }else zan++;
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
int t_adjust(int now,int dish){
  if( (now+dish) %10==0){
    return now+dish;
  } else {
    return ((now+dish)/10+1)*10;
  }
}
    
int main(){
  int t[5];
  int i,j,now=0,min_time=1000;
  
  for(i=0;i<5;i++){
    scanf("%d",&t[i]);
  }
  
  for(j=0;j<5;j++){
    now=0;
    for(i=0;i<5;i++){
      if(i!=j){
        now=t_adjust(now,t[i]);
      }
    }
    now+=t[j];
    if(now<min_time){
      min_time=now;
    }
  }
  
  printf("%d",min_time);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main() {
        Scanner cin = new Scanner();
        int sx = cin.Int();
        int sy = cin.Int();
        int tx = cin.Int();
        int ty = cin.Int();

        for (int i = 0; i < ty-sy; i++) {
            Console.Write("U");
        }
        for (int i = 0; i < tx-sx; i++) {
            Console.Write("R");
        }
        for (int i = 0; i < ty-sy; i++) {
            Console.Write("D");
        }
        for (int i = 0; i < tx-sx+1; i++) {
            Console.Write("L");
        }
        for (int i = 0; i < ty-sy+1; i++) {
            Console.Write("U");
        }
        for (int i = 0; i < tx-sx+1; i++) {
            Console.Write("R");
        }
        Console.Write("D");
        Console.Write("R");
        for (int i = 0; i < ty-sy+1; i++) {
            Console.Write("D");
        }
        for (int i = 0; i < tx-sx+1; i++) {
            Console.Write("L");
        }
        Console.Write("U");
        Console.WriteLine();
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define q_type vector<ll>
using namespace std;
using namespace __gnu_pbds;

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

int main()
{
    ll a, b;
    cin>>a>>b;
    ll g = __gcd(a, b);
    cout<<g*(a/g)*(b/g)<<endl;
}

Measured memory_bytes: 256
A, B, C, D = gets.chop.split.map(&:to_i)

all = B - A + 1
div_c = B / C - (A - 1) / C
div_d = B / D - (A - 1) / D
div_cd = B / (C * D / C.gcd(D)) - (A - 1) / (C * D / C.gcd(D))

puts all - div_c - div_d + div_cd


Measured memory_bytes: 3836
#include <iostream>
#include <string>
#define ll long long
using namespace std;
string s;
int len;
ll res=0;
inline ll num(string ss)
{
	ll r=0;
	ll t=1;
	for (int i=ss.size()-1;i>=0;i--)
	{
		r+=(ss[i]-'0')*t;
		t*=10;
	}
	return r;
}
int main()
{
	cin >>s;
	len=s.size();
	for (int tap=0;tap<(1<<(len-1));tap++)
	{
		ll t=0;
		int b=0;
		//cout <<tap<<"\n";
		for (int i=0;i<len;i++)
		{
			if (tap & (1<<i))
			{
				t+=num(s.substr(b,i-b+1));
				//cout <<num(s.substr(b,i-b+1))<<" ";
				b=i+1;
			}
		}
		t+=num(s.substr(b));
		//cout <<num(s.substr(b))<<"\n";
		res+=t;
		//cout <<tap<<" "<<t<<" "<<res<<"\n";
	}
	cout <<res;
	return 0;
} 

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;

int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        vector<int>vec;
        for(int i=512;i>0;i=i>>1){
            if(n>=i){
                n-=i;
                vec.push_back(i);
            }
        }
        for(int i=0;i<vec.size()-1;i++)
            cout<<vec[vec.size()-1-i]<<" ";
        cout<<vec[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 2005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,z,w;
int in[M],dp[2][M][M];
int main()
{
	while(~scanf("%d %d %d",&n,&z,&w))
	{
		REP(i,1,n) RI(in[i]);
		if(n==1) {
			printf("%d\n", abs(in[n]-w));
			continue;
		}
		printf("%d\n", max(
			abs(in[n] - in[n-1]),
			abs(in[n] - w)
		));
	}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>  // memset()
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define For(i, a, b) for (int i = (int)(a), sz = (int)(b); i < sz; i++)
#define rFor(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(0), cin.tie(0)

const int MAX = 2e2 + 5;

int main() {
    IO;
    int n;
    cin >> n;
    vector<int> v(n + 1);
    For(i, 1, 100) For(j, 1, 100) For(k, 1, 100) {
        int a = i * i + j * j + k * k + i * j + j * k + i * k;
        if (a <= n)
            v[a]++;
    }
    For(i, 1, n + 1) printf("%d\n", v[i]);
    return 0;
}

Measured memory_bytes: 3760
n,x,y = map(int, input().split())

dis = [0]*n

for i in range(n):
    for j in range(i+1, n):
        kyori = min(j-i, abs(x - (i+1)) + 1 + abs(y - (j+1)))
        dis[kyori] += 1

for k in range(1, n):
    print(dis[k])

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

typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000000007;

bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a);//a進数におけるNの各桁の和、計算量はloga(N)
ll mpow(ll x, ll n);
ll inv_mod(ll a){return mpow(a,mod-2);}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

int main(){
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    vector<vector<int>> col(H,vector<int>(W)),row(H,vector<int>(W));
    REP(i,H) cin>>S[i];
    REP(i,H){
        int l=0,r;
        REP(j,W){
            if(S[i][j]=='#'){
                col[i][j]=-1;
                r=j;
                for(int k=l;k<r;k++) col[i][k]=r-l;
                l=j+1;
            }
        }
        if(S[i][W-1]=='.') for(int k=l;k<W;k++) col[i][k]=W-l;
    }
    //cout<<col[1][1]<<endl;
    REP(i,W){
        int u=0,d;
        REP(j,H){
            if(S[j][i]=='#'){
                row[j][i]=-1;
                d=j;
                for(int k=u;k<d;k++) row[k][i]=d-u;
                u=j+1;
            }
        }
        if(S[H-1][i]=='.') for(int j=u;j<H;j++) row[j][i]=H-u;
    }
    //cout<<row[1][1]<<endl;
    int ans=0;
    REP(i,H) REP(j,W) ans=max(ans,col[i][j]+row[i][j]-1);
    cout<<ans<<endl;
}

int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
/*
class Fuctorical{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Fuctorical(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
*/

/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/

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

int main()
{
  int n, m;
  cin >> n >> m;
  int even = 0, odd = 0;
  for (int i = 0; i < n; i++)
  {
    even += i;
  }
  for (int i = 0; i < m; i++)
  {
    odd += i;
  }
  cout << even + odd << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
long long i,N,K,n;
cin >> N >> K;
n==0;
for (long long i=K+1; i<=N; i=i+1 ){
n=n+(N-N%i)*(i-K)/i;
if(N%i-K>=0 && K!=0){n=n+N%i-K+1;}
if(N%i-K>=0 && K==0){n=n+N%i-K;}
;}
printf("%lld",n)
;}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int time[2][3];
    for(int i=0;i<3;i++){
        for(int x=0;x<2;x++){
            for(int y=0;y<3;y++){
                cin >> time[x][y];
            }
        }
        int si=time[0][0]*3600+time[0][1]*60+time[0][2];
        int so=time[1][0]*3600+time[1][1]*60+time[1][2];
        int clo=so-si;
        int a,b,c;
        a=clo/3600;
        clo%=3600;
        b=clo/60;
        clo%=60;
        c=clo;
        cout << a << " " << b << " " << c << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;
import java.util.List;
import java.awt.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    /* 変数宣言 */
    final String S, T;

    AtCoder(FastScanner sc) {
        S = sc.next();
        T = sc.next();
    }

    void solve(PrintWriter out) {
        out.println(T+S);
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21204
import copy
import sys

array_data = map(int, raw_input().split())
r = array_data[0]
c = array_data[1]

array = []
for i in range(r):
	partial_array = map(int, raw_input().split())
	array.append(partial_array)

ans = copy.deepcopy(array)
for i in range(r):
	ans[i].append(sum(array[i]))
ans.append([])
for j in range(c+1):
	wa = 0
	for i in range(r):
		wa += ans[i][j]
	ans[r].append(wa)

for i in range(len(ans)):
	for j in range(len(ans[i])):
		if j != len(ans[i])-1:
			sys.stdout.write("{:} ".format(ans[i][j]))
		else:
			print(ans[i][j])

Measured memory_bytes: 6584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<queue>
using namespace std;


int main()
{
    int n,m;
    cin>>n;
    if(n%2==1) m=n/2+1;
    else m=n/2;
    double d=1.0*m/n;
    //cout<<m<<" "<<d<<endl;
    printf("%.10f",d);
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<string> song(n);
	vector<int> t(n);
	for(int i = 0; i < n; i++) {
		cin >> song[i] >> t[i];
	}
	
	string s;
	cin >> s;
	int ans = 0;
	bool ok = false;
	for(int i = 0; i < n; i++) {
		if(song[i] == s) {
			ok = true;
		} else if(ok) {
			ans += t[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int X; cin >> X;
  ll ans = 0;
  ans += (X/500)*1000;
  ans += ((X%500)/5)*5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=510;
int n,a[maxn][maxn];
long long suma[maxn][maxn],sumb[maxn][maxn],f[maxn][maxn],ans=1e18;
inline long long getsum(int a,int b,int c){return sumb[b+1][c]+suma[n][b]-suma[n][a]+suma[c][a]-suma[c][b];}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(i^j) scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) suma[i][j]=suma[i-1][j]+suma[i][j-1]-suma[i-1][j-1]+a[i][j];
	for(int j=1;j<=n;j++) for(int i=j;i>=1;i--) sumb[i][j]=sumb[i+1][j]+sumb[i][j-1]-sumb[i+1][j-1]+a[i][j];
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=1e18;
	for(int i=1;i<n;i++)
	{
		f[i][0]=getsum(0,0,i);
		ans=min(ans,f[i][0]+getsum(0,i,n));
		for(int j=1;j<i;j++)
		{
			for(int k=0;k<j;k++) f[i][j]=min(f[i][j],f[j][k]+getsum(k,j,i));
			ans=min(ans,f[i][j]+getsum(j,i,n));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 10664
from collections import defaultdict


if __name__ == "__main__":
    num_query = int(input())
    d: defaultdict = defaultdict()

    for _ in range(num_query):
        op, *v = input().split()
        if ("0" == op):
            d[v[0]] = v[1]
        else:
            print(d[v[0]])



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

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    long long sum = 0;
    for (long long i = 0; i <= 2; ++i) {
        if (s[i] == t[i]) {
            sum += 1;
        }
        else {
            
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double 
#define foi(a,n) for(int i = a; i < n; i++)
#define ee 1000000007
#define pb push_back

ll fast(ll base, ll power, ll mod=ee){
    ll ans =1;
    base%=mod;
    while(power){
        if(power&1){
            ans*=base;
            ans%=mod;
        }
        base*=base;
        base%=mod;
        power>>=1;
    }
    return ans;
}

void solve() {
    ll n;
    cin >> n;
	ll x = fast(10, n);
	x -= 2LL * fast(9, n);
	x += fast(8, n);
	x%=ee;
	if(x < 0) x += ee;
	x %= ee;
	cout << x << '\n';
}

int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t = 1;
    //~ cin >> t;
    while(t--){
		solve();
		//~ cout << '\n';
	}
}


Measured memory_bytes: 3616
//sjf in cpp
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
string s;
cin>>s;
int val;
if(s=="SUN")
val=7;
else if(s=="MON")
val=6;
else if(s=="TUE")
val=5;
else if(s=="WED")
val=4;
else if(s=="THU")
val=3;
else if(s=="FRI")
val=2;
else
val=1;
cout<<val<<endl;
	
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N, M; cin >> N >> M;
    int S[N+1] = {}; rep(i, N) cin >> S[i+1];
    int T[M+1] = {}; rep(i, M) cin >> T[i+1];
    //dp[i][j]: S[0]-S[i], T[0]-T[j]まで考えた時の一致する部分列の個数
    //dp[i][j]とdp[i][j+1]を考えると, dp[i][j+1] = dp[i][j] + (T[j+1]で終わる部分列の個数)
    //ようはT[j+1]を使うということ
    //S[k] = T[j+1]となるような最大のk(k <= i)を考えると
    //(S[i]まででT[j+1]で終わる部分列の一致個数)はdp[k-1][j]のはず -> ほんまか? -> うそ
    //(S[i]まででT[j+1]で終わる部分列の一致個数)T[j+1]のSにおける出現リストを{k1, k2,...}とすると
    //dp[k1-1][j] + dp[k2-1][j] + ...となる
    //しかしdp[i-1][j+1]でもほぼ同じ計算をするので,この結果が使える
    //dp[i-1][j+1] = dp[i-1][j] + (S[i-1]まででT[j+1]で終わる部分列の一致個数)
    //よってS[i] != T[j+1]ならdp[i-1][j+1] - dp[i-1][j],
    //S[i] == T[j+1]なら(dp[i-1][j+1] - dp[i-1][j]) + dp[i-1][j] = dp[i-1][j+1]が(S[i]まででT[j+1]で終わる部分列の一致個数)
    ll dp[N+1][M+1];
    rep(i, N+1) rep(j, M+1) dp[i][j] = 0;
    dp[0][0] = 1;
    rep(i, N) dp[i+1][0] = 1;
    rep(j, M) dp[0][j+1] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= M-1; j++){
            if(S[i] == T[j+1]) dp[i][j+1] = (dp[i][j] + dp[i-1][j+1]) % mod;
            else dp[i][j+1] = (dp[i][j] + (dp[i-1][j+1] - dp[i-1][j])) % mod;
        }
    }
    if(dp[N][M] < 0) dp[N][M] += mod;
    cout << dp[N][M] << endl;
    return 0;
}

Measured memory_bytes: 31488
N=int(input())
List=list(input() for i in range(N))

if len(set(List))!=len(List):
  print("No")

else:
  count=0
  for i in range(N-1):
    if List[i][-1]!=List[i+1][0]:
      count+=1
  if count==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const int N = 101;

struct Point {
  let x, y;
  friend let Times(Point a, Point b) {
    return a.x * b.y - a.y * b.x;
  }
};

let Area(int n, Point *point) {
  let res = 0;
  for (int i = 1; i < n; ++i)
    res += Times(point[i], point[i + 1]);
  res += Times(point[n], point[1]);
  return res / 2;
}

Point ReadPoint() {
  Point t;
  scanf("%Lf%Lf", &t.x, &t.y);
  return t;
}

Point point[N];

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_3_A.in", "r", stdin);
//   freopen("CGL_3_A.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_3_A.log", "w", stderr);
// #endif
  int n = read();
  for (int i = 1; i <= n; ++i)
    point[i] = ReadPoint();
  printf("%.1LF\n", Area(n, point));
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_3_A CGL_3_A.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_3_A CGL_3_A.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_3_A < CGL_3_A.in > CGL_3_A.out
==================
}}} */



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

int main(void) {
    int N;cin>>N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin>>A[i];
    sort(A.begin(), A.end());
    cout << A.at(N - 1) - A.at(0) << endl;
    return 0;
}

Measured memory_bytes: 888
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n, *a = map(int, read().split())

    maxa = max(a) + 1  # aはint配列
    d = [i for i in range(maxa)]
    for p0 in range(2, maxa):
        if p0 == d[p0]:
            for p1 in range(p0 ** 2, maxa, p0):
                if d[p1] % p0 == 0:
                    d[p1] = p0

    def factorization(f):  # f > maxaだとエラー
        l = []
        t = f
        while True:
            if t == d[t]:
                l.append(d[t])
                break
            else:
                l.append(d[t])
                t = t // d[t]
        return l

    if all([i == 1 for i in a]):
        print('pairwise coprime')
        sys.exit()
    if len(set(a)) == 1:
        print('not coprime')
        sys.exit()
    d1 = defaultdict(int)
    for ae in a:
        t1 = set(factorization(ae))
        for t1e in t1:
            d1[t1e] += 1
    if 1 in a:
        d1[1] = 1
    d1v = tuple(d1.values())
    if all([i == 1 for i in d1v]):
        print('pairwise coprime')
    elif max(d1v) == n:
        print('not coprime')
    else:
        print('setwise coprime')

if __name__ == '__main__':
    main()

Measured memory_bytes: 281464
let s = read_line ()

let rec f i =
  if s.[i] = 'A' then i
  else f (i + 1)

let rec g i =
  if s.[i] = 'Z' then i
  else g (i - 1)

let () = print_int (g (String.length s - 1) - f 0 + 1)

Measured memory_bytes: 2816
#include<stdio.h>

	int main(){
	
	int n,a,b,i,A,B;
		
		while(1){
			scanf("%d",&n);
			if(n==0){
				break;
			}
			
			A=0;
			B=0;
			
			for(i=0;i<n;i++){
				scanf("%d%d",&a,&b);
				if(a>b){
					A=A+a+b;
				}
				else if(a<b){
					B=B+a+b;
				}
				else if(a==b){
					A=A+a;
					B=B+b;
				}
			}
			printf("%d %d\n",A,B);
		}
		
	return 0;
}

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

using namespace std;

int nr, N, M, pr[50009];
bool cr[100009];
long long INF = 10000000000LL;
map < long long, int > mp;
map < long long, long long > ops;

void prod (long long &x, long long y) {if (INF / x >= y) x = 1LL * x * y; else x = INF + 1;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N), M = 1e5;
for (int i=2; i * i <= M; i++)
    if (cr[i] == 0)
        for (int j=i * i; j<=M; j+=i)
            cr[j] = 1;
for (int i=2; 1LL * i * i * i <= INF; i++)
    if (cr[i] == 0)
        pr[++nr] = i;
for (int POS = 1; POS <= N; POS ++)
{
    long long x;
    scanf ("%lld", &x);
    long long OPS = 1, CURR = 1;
    for (int i=1; i<=nr && 1LL * pr[i] * pr[i] * pr[i] <= x; i++)
    if (x % pr[i] == 0)
    {
        int e = 0;
        while (x % pr[i] == 0) x /= pr[i], e ++;
        e %= 3;
        if (e == 2) prod (OPS, pr[i]), CURR = 1LL * CURR * pr[i] * pr[i];
        else
        if (e == 1) prod (OPS, 1LL * pr[i] * pr[i]), CURR = 1LL * CURR * pr[i];
    }
    CURR = 1LL * CURR * x;
    int p = 1, u = M, mij, ras = -1;
    while (p <= u)
    {
        mij = (p + u) >> 1;
        if (1LL * mij * mij <= x) ras = mij, p = mij + 1;
        else u = mij - 1;
    }
    if (1LL * ras * ras == x && cr[ras] == 0) prod (OPS, ras);
    else prod (x, x), prod (OPS, x);
//    printf ("%lld %lld\n", CURR, OPS);
    mp[CURR] ++, ops[CURR] = OPS;
}
int ans = 0;
for (auto it = mp.begin (); it != mp.end (); it ++)
{
    if (it->first == 1) ans ++;
    else
    {
        int curr = 0;
        if (mp.count (ops[it->first])) curr = mp[ops[it->first]];
        if (it->second > curr || (it->second == curr && it->first < ops[it->first]))
            ans += it->second;
    }
}
printf ("%d\n", ans);
return 0;
}


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

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int sum = 0;
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			sum += parseInt(line) >= 40 ? parseInt(line) : 40;
		}
		System.out.println(sum / 5);

	}

}

Measured memory_bytes: 16864
s=input()
pcount,gcount=0,0
pp=False
res=0
for ele in s:
  if pcount<gcount:
    pp=True
  else:pp=False
  if pp :
    pcount+=1
    if ele=="g":
          res+=1
  else:
      gcount+=1
      if ele=="p":
          res-=1
print("{}".format(res))

  

Measured memory_bytes: 39664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <iomanip>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    string N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N.size(); i++) {
        if (N.at(i) == '2') ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
# AtCoder Beginner Contest 131
# D - Megalomania

import numpy as np


N=int(input())
ls=[]
for _ in range(N):
    p=list(map(int,input().split()))
    ls.append(p)

ls.sort(key= lambda x:x[1])
# print(ls)

time=0

for i in range (N):
    time+=ls[i][0]
    if ls[i][1] < time:
        print("No")
        exit()
    else:
        pass

print("Yes")

Measured memory_bytes: 64924
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int


int main() {
  int n;
  cin >> n;
  
  vector < int > v(n),c(n);
  for ( int i = 0; i < n; i++ ) {
    cin >> v[i];
  }

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

  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    if( ( v[i] - c[i] ) > 0 ) {
      ans += (v[i] - c[i]);  
    }
  }

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



Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto &it : A)
        cin >> it;

    if (A[0] != 0)
    {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 1; i < N; i++)
    {
        if (A[i] > A[i - 1] + 1)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0;
    for (int i = 1; i < N; i++)
    {
        if (A[i] == A[i - 1] + 1)
            ans++;
        else
            ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4788
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

// セグメントツリーのライブラリ
template<typename T>
class SegmentTree {
public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegmentTree(size_t _n, T _def, std::function<T(T, T)> _operation,
        std::function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        node = std::vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        node[i] = update(node[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添字でアクセス
    T operator[](int i) {
        return node[i + n - 1];
    }

    int n;                       // 葉の数
    std::vector<T> node;              // データを格納するvector
private:
    T def;                       // 初期値かつ単位元
    std::function<T(T, T)> operation; // 区間クエリで使う処理
    std::function<T(T, T)> update;    // 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return node[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }
};

int main() {

    int n;
    cin >> n;

    // x座標，イベント, y座標(min), y座標(max)
    vector<tuple<int, int, int, int>>  events;

    vector<int> vy;

    for (int i = 0; i < n; ++i) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 == x2) { // 縦
            events.emplace_back(x1, 0, min(y1, y2), max(y1, y2));
            vy.emplace_back(y1);
            vy.emplace_back(y2);
        }
        else { // 横
            events.emplace_back(min(x1, x2), -1, y1, 0);
            events.emplace_back(max(x1, x2), 1, y1, 0);
            vy.emplace_back(y1);
        }
    }

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

    // y座標の圧縮を行う
    sort(vy.begin(), vy.end());
    vy.erase(unique(vy.begin(), vy.end()), vy.end());

    map<int, int> mp;
    for (int i = 0, n = vy.size(); i < n; ++i) {
        mp[vy[i]] = i;
    }

    long long ans = 0LL;

    auto update = [](int a, int b) {return a + b; };
    auto operation = [](int a, int b) {return a + b; };
    SegmentTree<int> seg(n, 0, operation, update);

    //for (auto& [x, e, y1, y2] : events) {
    for (auto& event : events) {
        int e = get<1>(event);
        int y1 = get <2>(event);
        int y2 = get<3>(event);
        if (e == -1)seg.change(mp[y1], +1); // 追加
        else if (e == 1) seg.change(mp[y1], -1); // 削除
        else { // チェック
            ans += seg.query(mp[y1], mp[y2] + 1);
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 10276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  double l;
  cin >> l;
  cout << fixed << setprecision(10);
  cout << (l/3)*(l/3)*(l/3) << endl;
}






Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

int main(){
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  if(c < d){
    int fuflag = 0;
    int suflag = 0;
    for(int i = b-1; i < d; i++){
      if(i == d-1) fuflag = 1;
      if(s[i+1] == '.') continue;
      else if(s[i+2] == '.'){
        i++;
        continue;
      }
      else break;
    }
    for(int i = a-1; i < c; i++){
      if(i == c-1) suflag = 1;
      if(s[i+1] == '.') continue;
      else if(s[i+2] == '.'){
        i++;
        continue;
      }
      else break;
    }
    if(fuflag && suflag) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    int fuflag = 0;
    int suflag = 0;
    for(int i = b-1; i < d; i++){
      if(i == d-1) fuflag = 1;
      if(s[i+1] == '.' && s[i-1] == '.' && !suflag){
        s[i] = '.';
        for(int j = a-1; j < c; j++){
          if(j == c-1) suflag = 1;
          if(s[j+1] == '.') continue;
          else if(s[j+2] == '.'){
            j++;
            continue;
          }
          else break;
        }
      }
      if(s[i+1] == '.') continue;
      else if(s[i+2] == '.'){
        i++;
        continue;
      }
      else break;
    }
    if(fuflag && suflag) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

int main() {
	int N;
	cin >> N;
	int x[N+5];
	for(int i = 1; i <= N; i++) {
		cin >> x[i];
	}
	
	sort(x + 1, x + 1 + N);
	if(N % 2 == 1){
		ll maks = 0;
		
		ll sum = 0;
		int y[N+5];
		y[1] = x[(N + 1)/ 2];
		
		for(int i = 2; i <= N; i += 2){
			y[i] = x[i/2];
			y[i + 1] = x[N - i/2 + 1];
		}
		
		for(int i = 2; i <= N; i++) {
			sum += abs(y[i] - y[i-1]);
			
		
		}
		maks = max(maks, sum);
		
		sum = 0;
		
		for(int i = 2; i <= N; i += 2){
			y[i] = x[N - i/2 + 1];
			y[i + 1] = x[i/2];
		}
		
		for(int i = 2; i <= N; i++) {
			sum += abs(y[i] - y[i-1]);
		}
		maks = max(maks, sum);
		
		cout << maks << "\n";
	}
	else {
		ll maks = 0;
		ll sum = 0;
		
		
		int y[N+5];
		y[1] = x[N / 2];
		y[N] = x[N / 2 + 1];
		
		for(int i = 2;i < N; i+= 2) {
			y[i] = x[N - i / 2 + 1];
			y[i + 1] = x[i / 2];
		}
		
		for(int i = 2; i <= N; i++) {
			sum += abs(y[i] - y[i-1]);
		}
		maks = max(maks, sum);
		
		sum = 0;
		y[N] = x[N / 2];
		y[1] = x[N / 2 + 1];
		
		for(int i = 2; i <= N; i += 2){
			y[i] = x[i/2];
			y[i + 1] = x[N - i/2 + 1];
		}
		
		maks = max(maks, sum);
		
		cout << maks << "\n";
		
	}
}


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

int main(void){
  int K;
  int ki,gu;
  int ans;
  cin >> K;
  gu = K / 2;
  ki = K - gu;
  ans = gu * ki;
  cout << ans << "\n";
  return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int a,b;cin >> a >> b;
  if(a>b)swap(a,b);
  rep(i,b)cout<<a;
  cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;
signed main(){
    int n; cin >>  n;
    map<string,int> map;
    vstr s(n);
    //rep(i,n) map[s[i]]=1;
    rep(i,n) {
        cin >> s[i];
        map[s[i]]++;
    }
    int max=0;
    rep(i,n){
        chmax(max,map[s[i]]);
    }
    set<string> set;
    rep(i,n) set.insert(s[i]);
    for(string s:set){
        if(map[s]==max) cout<<s<<endl;
    }
    
}

Measured memory_bytes: 36224
import java.io.*;
 
public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] cut = input.split(" ");
        int width = Integer.parseInt(cut[0]);
        int height = Integer.parseInt(cut[1]);
        int x = Integer.parseInt(cut[2]);
        int y = Integer.parseInt(cut[3]);
        int r = Integer.parseInt(cut[4]);
        
        
        if(x + r <= width && y + r <= height && x - r >= 0 && y - r >= 0)
            System.out.println("Yes");
        else
            System.out.println("No");    
    }
}

Measured memory_bytes: 24356
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[105];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    int i;    
    vector<int> a(26,-1);
    vector<int> num(26,0);
    for(i=0; i<n; i++) {
        int tmp=str[i]-'a';
        num[tmp]=MAX(num[tmp], i-a[tmp]-1);
        a[tmp]=i;
    }
    int ans=INF;
    for(i=0; i<26; i++) {
        num[i]=MAX(num[i], n-a[i]-1);
        ans = MIN(ans, num[i]);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for(int i = 0; i < values.length; i++){
			values[i] = i+1;
		}
		for(int i = 0; i < n; i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int temp;
			temp = values[a];
			values[a] = values[b];
			values[b] = temp;
		}
		for(int i = 0; i < values.length; i++){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26088
<?php
// 整数の入力
fscanf(STDIN, "%d", $n);

$answer = true;
//単語たちの入力
$data = array();
for ($i = 0; $i < $n; $i++) {
  // 文字列の入力
  $string = fscanf(STDIN, "%s");
  foreach($data as $d) {
    if($d === $string) {
      $answer = false;
    }
  }
  $data[] = $string;
}

if ($answer) {
  $word = $data[0];
  foreach($data as $a) {
    if ($a === $word) {
      continue;
    }
    //前の単語の最後の文字と今の単語の最初の文字が合ってるか
    $last = $word[0][strlen($word[0]) - 1];
    $first = $a[0][0];
    if ($last !== $first) {
      $answer = false;
      break;
    }
    $word = $a;
  }
}

if ($answer) {
  echo "Yes\n";
} else {
  echo "No\n";
}

?>


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
int main(void){
    while(1){
        int i,o,sum1=0,sum2=0,ans[4],line[4],sign=0;
        char num[2]={0};
        for(i=0;i<9;i++){
            num[0]=(char)getchar();
            if(i == 1 && num[0] == ' '){
                sign=1;
                break;
            }
            if(i <= 3){
                ans[i]=atoi(num);
            }
            else if(i >= 5){
                line[i-5]=atoi(num);
                for(o=5;o<=8;o++){
                    if(ans[o-5] == line[i-5]){
                        if(o-5 == i-5){
                            sum1++;
                        }
                        else{
                            sum2++;
                        }
                    }
                }
            }
        }
        if(sign == 1)
            break;
        printf("%d %d\n",sum1,sum2);
        sum1=0;
        sum2=0;
        num[0]=(char)getchar();
    }
    return 0;
}

Measured memory_bytes: 524