akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String text="";
        String target="";
        text=scan.nextLine();
        target=scan.nextLine();
        
        text=text+text;
        int index=text.indexOf(target);
        if(index!=-1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26180
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, m, x) = intList()
    val a = intList()
    val cost = Math.min(
        a.filter { it < x }.count(),
        a.filter { it > x }.count()
    )
    println(cost.toString())
}



Measured memory_bytes: 35940
from collections import deque

s = input()
s = deque(s)
q = int(input())
rev = 1

for _ in range(q):
    input_ = input()
    if input_ == '1':
        rev *= -1
        continue
    _, f, c = input_.split()
    if rev == 1:
        if f == '1':
            s.appendleft(c)
        else:
            s.append(c)
    else:
        if f == '1':
            s.append(c)
        else:
            s.appendleft(c)
ans = list(s)
if rev == -1:
    ans = ans[::-1]

print(''.join(ans))


Measured memory_bytes: 9972
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,cnt=1,i;
  cin>>n;
  string s;
  cin>>s;
  for(i=0;i<n-1;i++)
  {
    if(s[i]!=s[i+1])
      cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	vector<string> s;
	vector<pii> v;
	char c[21];
	int n,w,l,d,p,f=0;
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		if(f)puts("");
		v.clear();
		s.clear();
		rep(i,n){
			scanf("%s%d%d%d",c,&w,&l,&d);
			p=w*3+d;
			s.push_back(string(c));
			v.push_back(make_pair(p,n-i));
		}
		sort(v.rbegin(),v.rend());
		f=1;
		rep(i,n)printf("%s,%d\n",s[n-v[i].second].c_str(),v[i].first);
	}
	return 0;
}

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

int main(void){
    char X, Y;
    cin >> X >> Y;

    // implements
    if(X < Y){
        printf("<\n");
    }
    else if(X > Y){
        printf(">\n");
    }
    else{
        printf("=");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    map < string, ll > mp;
    ll n; cin >> n;
    while(n--)
    {
        string s; cin >> s;
        mp[s]++;

    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,ans = 0;
    double t,a;
    cin >> n >> t >> a;
    double h[n];
    rep(i, n){
        cin >> h[i];
        h[i] = t - h[i] * 0.006;
        h[i] = fabs(h[i] - a);
        if (h[ans] > h[i]) {
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a<b?a=b:0;}
template<typename tp>inline void chemn(tp &a,tp b){a>b?a=b:0;}
int mod;
inline int add(int a,int b){return (a+=b)>=mod?(a-mod):a;}
inline int dec(int a,int b){a-=b;return a+(a>>31&mod);}
inline int mul(int a,int b){static ll r;r=1ll*a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){(a+=b)>=mod?(a-=mod):0;}
inline void Dec(int &a,int b){a-=b,a+=a>>31&mod;}
inline void Mul(int &a,int b){static ll r;r=1ll*a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(int x){return (x<0)?x+mod:x;}
int n,m;
cs int N=6005,L=6000;
int f[N][N+L];
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read(),mod=read();
	f[0][L]=1;
	for(int i=1;i<=3*n;i++){
		for(int j=L-i+1,lim=L+i-1;j<=lim;j++){
			Add(f[i][j+1],f[i-1][j]);
			if(i>1)Add(f[i][j-1],mul(f[i-2][j],i-1));
			if(i>2)Add(f[i][j],mul(f[i-3][j],mul(i-1,i-2)));
		}
	}
	int res=0;
	for(int i=L;i<=L+3*n;i++)
	Add(res,f[3*n][i]);
	cout<<res;
}

Measured memory_bytes: 280960
// RGB Cards

#include <iostream>

using namespace std;

int main(){
	int r, g, b;
	cin >> r >> g >> b;

	int rgb = 100*r + 10*g + b;

	if (rgb % 4)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
const int INF=1e5;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	int ans=INF;
	rep(i,N){
		int res=0;
		while(A[i]%2==0){
			A[i]/=2;
			res++;
		}
		ans=min(ans,res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
const int INF = (1<<21);
int n;

struct edge {
  int to, cost;
  edge(int _to, int _cost) {to = _to; cost=_cost;}
};
typedef pair<int, int> P;


int V;
vector<edge> G[20];
int d[20];

int dij(int s,int g) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + n, INF);
  d[s] = 0;
  que.push(P(0, s));
  
  while(!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
  return (d[g]);
}

int main(){
  int m,y1,y2,x1,x2;
  cin>> n>> m;
  for(int i=0;i<m;i++){
    int a,b,c,d;
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    G[a-1].push_back(edge(b-1,c));
    G[b-1].push_back(edge(a-1,d));
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);

  cout<< y1-(y2+dij(x1-1,x2-1)+dij(x2-1,x1-1))<< endl;
}

Measured memory_bytes: 1244
# Here your code !
def printAry(a)
    printf("#{a[0]}")
    
    for i in 1..a.length-1 do
        printf(" #{a[i]}")
    end
    printf("\n")
end


n = STDIN.gets.to_s.to_i
a = STDIN.gets.to_s.split(" ")
a.map!(&:to_i)
counter = 0

for i in 0..(n-1) do
    minj = i
    for j in i..(n-1) do
        if a[j] < a[minj]
            minj = j
        end
    end
    if i != minj then
        counter = counter + 1
        a[i], a[minj] = a[minj], a[i]
    end
end

printAry(a)
p counter

Measured memory_bytes: 8692
X,K,D=(int(x) for x in input().split())
x=abs(X)
a=x//D

b=x-a*D
B=abs(x-(a+1)*D)

if b>B:
  a=a+1

if a>=K:
  print(abs(x-K*D))

else:
  c=K-a
  if c%2 == 0:
    print(abs(x-a*D))
  else:
    d=abs(x-(a-1)*D)
    e=abs(x-(a+1)*D)
    print(min(d,e))

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

vector<int> A;
int N, M, Q;
int maxValue = 0;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

void dfs(int i, const int size, const int range_start, const int range_end) {
    if(i == size) {
        bool flag = true;
        ll temp = 0;
        // for(int i = A.size() - 1; i > 0; i--) {
        //     for(int j = i - 1; j >= 0; j--) {
        //         if(A[j] > A[i]) {
        //             flag = false;
        //         }
        //     }
        // }
        if(flag) {
            rep(i, Q) {
                if((A[b[i] - 1] - A[a[i] - 1]) == c[i]) {
                    temp += d[i];
                }
            }
            if(temp >= maxValue) maxValue = temp;
        }
    } else {
        for(int j = range_start; j <= range_end; ++j) {
            A[i] = j;
            bool flag = true;
            for(int i = A.size() - 1; i > 0; i--) {
                for(int j = i - 1; j >= 0; j--) {
                    if(A[j] > A[i]) {
                        flag = false;
                    }
                }
            }
            if(flag) dfs(i + 1, size, range_start, range_end);
        }
    }
}

void func_A() {
    bool f = false;
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    for(int i = A; i <= B; i++) {
        if(i % K == 0) f = true;
    }
    if(f) {
        cout << "OK";
    } else {
        cout << "NG";
    }
}
void func_B() {
    ll money = 100, X;
    ll i = 0;
    cin >> X;
    while(money < X) {
        i++;
        money = money + money * 0.01;
    }
    cout << i;
}
void func_C() {
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    A.resize(N);
    fill(A.begin(), A.end(), 1);
    dfs(0, N, 1, M);
    cout << maxValue;
}
void func_D() {}
int main() {
    func_C();
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

constexpr auto M = 998244353;

int64_t pow_mod(int64_t x, int64_t y) {
    if (y == 0) {
        return 1;
    }

    if (y == 1) {
        return x;
    }

    auto p = pow_mod(x, y / 2);

    return ((p * p % M) * pow_mod(x, y % 2)) % M;
}

int64_t inv(int64_t x) { return pow_mod(x, M - 2); }

int64_t calc(const vector<int64_t>& ss, const vector<int64_t>& dp, int64_t g) {
    int64_t ret = 0;

    ret += ss[g];

    for (auto gg = 2 * g; gg < dp.size(); gg += g) {
        ret += (-dp[gg] + M) * gg;
        ret %= M;
    }

    return ret * inv(g) % M;
}

main() {
    int64_t n;
    cin >> n;

    vector<int64_t> p(1000001L);
    int64_t mx = -1;
    for (auto _ : irange(0L, n)) {
        int64_t a;
        cin >> a;

        ++p[a];
        mx = max(mx, a);
    }

    int64_t inv2 = inv(2);
    vector<int64_t> ss(mx + 1);
    for (auto i : irange(1L, mx + 1)) {
        int64_t s = 0;
        int64_t s2 = 0;
        for (int64_t j = 1; i * j <= mx; ++j) {
            s += (i * j) * p[i * j];
            s %= M;
            s2 += (i * j) * (i * j) * p[i * j];
            s2 %= M;
        }

        ss[i] = (s * s - s2 + M) % M * inv2;
        ss[i] %= M;
    }

    int64_t ans = 0;
    vector<int64_t> dp(mx + 1);
    for (auto g : irange(1L, mx + 1) | reversed) {
        dp[g] = calc(ss, dp, g);
        ans += dp[g];
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 23680
# Belongs to : midandfeed aka asilentvoice
n, m, l = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for i in range(n)]
b = [[int(x) for x in input().split()] for i in range(m)]
ans = []

for i in range(n):
	rtemp = []
	for j in range(l):
		temp = 0
		for k in range(m):
			temp += (a[i][k] * b[k][j])
		rtemp.append(temp)
	ans.append(rtemp)
	
for row in ans:
	print(" ".join(map(str, row)))

Measured memory_bytes: 8944
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll  long long int
long long int power(long long int a,long long int b )
{
    long long int res=1;
    a=a%mod;
    while(b>0)
    {
        if(b&1)
        res=(res*a)%mod;
        b=b>>1;
        a=(a*a)%mod;
    }
    return res;
}
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
    return 0;
}

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

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    N %= 10;
    if(N == 3){
        cout << "bon" << endl;
    }else if(N == 0 or N == 1 or N==6 or N==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }

}

Measured memory_bytes: 3636
#include<stdio.h>

int data[15];
int c;
int sub(int n,int x,int s,int sum);

int main(void){
int i,j,k,n,s,sum;
while(1){
scanf("%d %d",&n,&s);
if(n==0&&s==0){break;}
   c=0;
   sub(n,0,s,0);
   printf("%d\n",c);
}
return 0;
}

int sub(int n,int x,int s,int sum){
   int i;
   if(n==0){
if(s==sum){
/*      for(i=9;i>=0;i--)printf("%d ",data[i]);printf("\n");*/
      c++;
}
      return 0;
   }
   for(i=x;i<=10-n;i++){
      data[n-1]=i;
      sub(n-1,i+1,s,sum+i);
   }
}

Measured memory_bytes: 600
class Dice:
    def __init__(self,pips):
        self.top = pips[0]
        self.south = pips[1]
        self.east = pips[2]
        self.west = pips[3]
        self.north =pips[4]
        self.bottom=pips[5]
    def n(self):
        self.top,self.south,self.bottom,self.north = \
        self.south,self.bottom,self.north,self.top
    def s(self):
        self.top,self.north,self.bottom,self.south = \
        self.north,self.bottom,self.south,self.top
    def e(self):
        self.top,self.west,self.bottom,self.east = \
        self.west,self.bottom,self.east,self.top
    def w(self):
        self.top,self.east,self.bottom,self.west = \
        self.east,self.bottom,self.west,self.top
    def r(self):
        self.north,self.east,self.south,self.west = \
        self.east,self.south,self.west,self.north
    def set_ts(self,t,s):
        for i in range(4):
            if self.top != t:
                if self.east == t or self.west == t:
                    self.e()
                else:
                    self.n()
            else:
                break
        for i in range(4):
            if self.south != s:
                self.r()
            else:
                break
        if(self.top == t and self.south == s):
            return True
        else:
            return False
    def gen_pattern(self):
        pat = []
        for i in range(6):
            if i < 4:
                self.n()
            elif i == 4:
                self.e()
            elif i == 5:
                self.e()
                self.e()
            for j in range(4):
                self.r()
                pat.append([self.top,self.north,self.south,self.east,self.west,self.bottom])

        return pat


n = int(input())
dices = []
pat = []
for i in range(n):
    pips = [int(x) for x in input().split()]
    dices.append(Dice(pips))
    pat.append(sorted(dices[i].gen_pattern()))
pat_uniq = []
for x in pat:
    if x not in pat_uniq:
        pat_uniq.append(x)

if len(pat) == len(pat_uniq):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7964
# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	H = input().split()
	H = [int(s) for s in H]
	
	DP = [-1 for _ in range(N)]
	DP[0] = 0
	
	for i, val in enumerate(H):
		if i == 0:
			continue
		if i == 1:
			tmp1 = abs(val - H[i-1])
			DP[i] = tmp1
			continue
		tmp1 = abs(val - H[i-1]) + DP[i-1]
		tmp2 = abs(val - H[i-2]) + DP[i-2]
		DP[i] = min(tmp1, tmp2)
		
	print(DP[N-1])
		
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 13976
#include <stdio.h>
#include <queue>
#include <string.h>

using namespace std;
#pragma warning(disable : 4996)
class Proc {
    public:
        char name[10];
        int time;
        Proc(const char *name, int time);
};
Proc::Proc(const char *name, int time) {
    this->time = time;
    strcpy(this->name, name);
}

int main(int argc, char const* argv[])
{
    queue<Proc> pq;
    int n, q, ct = 0;

    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++) {
        char name[10];
        int t;
        scanf("%s %d", name, &t);
        pq.push(Proc(name, t));
    }

    while(!pq.empty()){
        ct += q;
        Proc proc = pq.front();
        pq.pop();

        proc.time -= q;
        if(proc.time <= 0){
            ct += proc.time;
            printf("%s %d\n", proc.name, ct);
        }else{
            pq.push(proc);
        }
    }
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  rep(i, 3) {
    string s;
    cin >> s;
    cout << (char)(s[0]-'a'+'A');
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
string s;
signed main(){
	cin>>s;
	string a="Sunny",b="Cloudy",c="Rainy";
	if(s==a)cout<<b<<endl;
	if(s==b)cout<<c<<endl;
	if(s==c)cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  char grid[h][w];
  rep(i,h){
    rep(j,w){
      char in;
      cin >> in;
      grid[i][j] = in;
    }
  }
  int n = h+w;
  int cnt=0;
    //----- bit 全探索 ------
    //ここで2^n-1個のbit列を列挙
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<int> vec(n);
        char now_grid[h][w];
        rep(i,h){
          rep(j,w){
            now_grid[i][j] = grid[i][j];
          }
        }
        // rep(i,h){
        //   rep(j,w){
        //     cout << now_grid[i][j];
        //   }
        //   cout << endl;
        // }
        //ここで、列の各位が1かをみる
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
            //もし1だったら何か処理
            //今回はbit列を表示させる
            vec[i]=1;
            }

        }
        //0がえらばれた場所の#の数を数える
        // 行 0~h-1
        // 列 h~h+w
        rep(i,n){
          if(vec[i]==1){
            if(i>=0&&i<h){
                //たて
                rep(j,w){
                  now_grid[i][j] = '.';
                }
            }
            if(i>=h&&i<n){
                //よこ
                rep(j,h){
                  now_grid[j][i-h] = '.';
                }
            }
          }
        }
        int c=0;
        rep(i,h){
          rep(j,w){
            if(now_grid[i][j]=='#') c++;
          }
        }
        if(c==k) cnt++;
    }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	static int MAX = 500000;
    static int[] A = new int[MAX];
    static int[] L = new int[MAX/2 + 1];
    static int[] R = new int[MAX/2 + 1];
    static int count;

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        
       
        for (int i=0; i<N; i++){
        	A[i]=sc.nextInt();
        }
        sc.close();
        
      
        Main.MergeSort(A, 0, N);
        
        for (int i=0; i<N; i++){
        	System.out.print(A[i]);
            if(i < N - 1){
                System.out.print(" ");
            }
        }
        System.out.println();
        System.out.println(count);
  
	}

	
	public static void Merge(int []A, int left, int mid, int right){
	  int n1 = mid - left;
	  int n2 = right - mid;
	  
	  L[n1] = 1000000001;
	  R[n2] = 1000000001;
	  
	  for (int i = 0; i<n1; i++){
		  L[i] = A[left + i];
	  }
	
	  for (int i = 0; i<n2; i++){
		  R[i] = A[mid + i];
	  }
	  
	  int i = 0, j = 0;
	  for (int k = left;  k < right; k++){
		  count++;
		  if (L[i] <= R[j]){
			  A[k] = L[i];
			  i++;
		  }
		  else {
			  A[k] = R[j];
			  j++;
		  }
	  }
	}


	public static void MergeSort(int [] A, int left, int right){
	  if (left+1 < right){
		  int mid = (left + right)/2;
		  MergeSort(A, left, mid);
	      MergeSort(A, mid, right);
	      Merge(A, left, mid, right);
	  }
	        
	}
}



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

// 隣接行列を用いた幅優先探索 O(|V|^2)
int n;
vector<int> G[200000];
vector<int> d(200000), visited(200000); // 始点sから頂点iまでの最短距離をd[i]に記録
/*
* main関数からこれらを削除すること
* 隣接行列Mの行数と列数および最短距離dの要素数はnの最大値を整数で入力すること
*/

void bfs(int s) {
  queue<int> q;
  q.push(s);
  visited[s] = 1;
  // d[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
      if(visited.at(G[u][v]) == 0){
        d[G[u][v]] += d[u];
        visited.at(G[u][v]) = 1;
        /* if(M[u][v] == 0) continue;
        if(d[v] != 100000000) continue;
        d[v] = d[u] + 1;*/
        q.push(G[u][v]);
      }
    }
  }
}

int main() {
// 無向(有向)グラフの隣接リスト
  int q, u, v, p, x;
  
  cin >> n >> q;
  
  // vector<int> G[n]; // 頂点数がnのグラフを表す隣接リスト
  
  for(int i = 0; i < n - 1; i++){
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  for(int i = 0; i < q; i++){
    cin >> p >> x;
    d.at(p - 1) += x;
  }
  
  bfs(0);
  
  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << d[i];
  }
  cout << endl;
}

Measured memory_bytes: 16372
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>

void solve(){
	int n,k;
	cin>>n>>k;
	vi v;
	while(n!=0){
		v.push_back(n%k);
		n/=k;
		// cout<<"n is:"<<n<<endl;
	}
	reverse(v.begin(),v.end());
	int i=0;
	while(v[i]==0){
		i++;
	}
	// cout<<i<<endl;
	cout<<v.size()-i<<endl;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		String s = scn.nextLine();
		if (s.isEmpty()) {
			System.out.println("");
		} else {
			String ans = "";
			boolean check = true;
			for (int i = 0; i < s.length(); i++) {
				char ch1 = s.charAt(i);
				if (i > 0 && ch1 == 'B') {
					if (!ans.isEmpty())
						ans = ans.substring(0, ans.length() - 1);
					if (ans.isEmpty()) {
						ans = "";
					}
				} else {
					if (ch1 != 'B')
						ans += ch1;
				}
			}
			if (check) {
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 27008
#include<bits/stdc++.h>
using namespace std;
#define int long long
string str;
int dp[666][666];
int a[666];int k;
int dfs(int pos,int state,bool lead/*前导零*/,bool limit/*数位上界变量*/){
	if(pos==-1) return k==state;
	if(!limit && !lead && dp[pos][state]!=-1) return dp[pos][state];
	int up=limit?a[pos]:9;
	int ans=0;
	for(int i=0;i<=up;i++){
			ans+=dfs(pos-1,state+((i == 0?0:1)),i==0&&lead,limit&& i==a[pos]);
	
	}
	if(!limit && !lead) dp[pos][state]=ans;
	return ans;
}
signed main(){
	memset(dp,-1,sizeof(dp));
	cin>>str>>k;int cnt=0;
	for(int i=str.size()-1;i>=0;i--) a[cnt++]=(str[i]-'0');
	cout<<dfs(cnt-1,0,true,true);
	return 0;
}

Measured memory_bytes: 3712
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll n, m; cin >> n >> m;
  vector<Pii> x(n);
  REP(i, n){
    ll a, b; cin >> a >> b;
    x[i] = mp(a, b);
  }
  SORT(x);
  ll ans = 0, temp = 0;
  REP(i, n){
    if(temp + x[i].second <= m){
      temp += x[i].second;
      ans += x[i].first * x[i].second;
    }
    else if (temp < m){
      ans += x[i].first * (m - temp);
      temp = m;
    }
  }
  cout << ans << endl; 
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    abc087B(args)
}

fun abc087B(args: Array<String>) {
    val A = readLine()!!.toInt()
    val B    = readLine()!!.toInt()
    val C = readLine()!!.toInt()
    val X = readLine()!!.toInt()
    var counter = 0;

    for (a in 0..A) {
        for (b in 0..B) {
            for (c in 0..C) {
                if(a * 500 + b * 100 + c * 50 == X) {
                    counter++
                }
            }
        }
    }
    println(counter)
}


Measured memory_bytes: 34604
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    REP(i, 3) {
        if (n[i] == '1') n[i] = '9';
        else if (n[i] == '9') n[i] = '1';
    }
    cout << n << '\n';
    return 0;
}


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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int h,w;
    cin >>h>>w;
    int mat[h][w];
    for (int i = 0; i < h; i++){
        int s=0;
        for (int j = 0; j < w; j++){
            cin >> mat[i][j];
            cout<<mat[i][j]<<' ';
            s+=mat[i][j];
        }
        cout<<s<<'\n';
    }
    int ss=0;
    for (int i = 0; i < w; i++){
        int s=0;
        for (int j = 0; j < h; j++){
            s+=mat[j][i];
        }
        cout<<s<<' ';
        ss+=s;
    }
    cout<<ss<<'\n';
}


Measured memory_bytes: 3156
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var yymm, mmyy bool
	word := nextLine()
	n, _ := strconv.Atoi(word[0:2])
	k, _ := strconv.Atoi(word[2:4])
	if 1 <= k && k <= 12 {
		yymm = true
	}
	if 1 <= n && n <= 12 {
		mmyy = true
	}
	if yymm && mmyy {
		fmt.Println("AMBIGUOUS")
	} else if yymm {
		fmt.Println("YYMM")
	} else if mmyy {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include <stdio.h>
using namespace std;
int w[30],n,space;
int main(){
	int wa;
	cin>>wa>>n;
	for(int i=0;i<wa;i++){
	w[i]=i+1;}
	for(int i=0;i<n;i++){
	int a,b;char c;
	cin>>a>>c>>b;
	space=w[a-1];w[a-1]=w[b-1];w[b-1]=space;}
	for(int i=0;i<wa;i++){
	cout<<w[i]<<endl;}
	return 0;}


Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  
  int water[31] = {};
  REP(i,ceil((double)f/(a*100))){
    int w = i*a;
    while(w <= f/100){
      water[w]++;
      w += b;
    }
  }
  
 // REP(i,31) cout << i << ":" << water[i] << endl;
  
  ll suger[31] = {};
  REP(i,31){
    if(water[i] != 0){
      REP(j,e*i/c+1){
        int k = 0;
        if(j*c+i*100 > f || j*c > i*e) break;
        while(j*c+k*d+i*100 <= f && j*c+k*d <= i*e){
          k++;
        }
        k--; 
        suger[i] = max(suger[i],j*c+k*d);
      }
    }
  }
  
  //REP(i,31) cout << i << ":" << suger[i] << endl;
  
  double x = 0; int ans = 0;
  REP(i,31){
    if(water[i] != 0){
      if(x < (double)suger[i]/(i*100+suger[i])){
        x = (double)suger[i]/(i*100+suger[i]);
        ans = i;
  //      debug(x);
      }
    }
  }
  
  if(x == 0) cout << a*100 << " " << 0 << endl;
  else cout << ans*100+suger[ans] << " " << suger[ans] << endl;      
  
 return 0;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
AB = []
for _ in range(n):
    a, b = map(int, input().split())
    AB.append((a,b))

AB = sorted(AB, key=lambda x:x[0])
idx = 0
ans = 0

heap = []
heapq.heapify(heap)

for i in range(1,m+1):
    while idx < len(AB):
        if AB[idx][0] == i:
            heapq.heappush(heap, AB[idx][1]*-1)
            idx += 1
        else:
            break
    if len(heap) >= 1:
        ans += heapq.heappop(heap) * -1
    elif idx == len(AB) -1:
        break
print(ans)

Measured memory_bytes: 20988
// abc.64.c   Colorful Leaderboard

#include <bits/stdc++.h>
using namespace std;

int main( void ) {
    int n;
    cin >> n;

    vector<int> rate( n );
    int         color[ 8 ] = {};
    int         cnt        = 0;
    for( int i = 0; i < n; i++ ) {
        cin >> rate.at( i );
        if( rate.at( i ) >= 3200 )
            cnt++;
        else if( rate.at( i ) < 400 )
            color[ 0 ]++;
        else if( rate.at( i ) >= 400 && rate.at( i ) < 800 )
            color[ 1 ]++;
        else if( rate.at( i ) >= 800 && rate.at( i ) < 1200 )
            color[ 2 ]++;
        else if( rate.at( i ) >= 1200 && rate.at( i ) < 1600 )
            color[ 3 ]++;
        else if( rate.at( i ) >= 1600 && rate.at( i ) < 2000 )
            color[ 4 ]++;
        else if( rate.at( i ) >= 2000 && rate.at( i ) < 2400 )
            color[ 5 ]++;
        else if( rate.at( i ) >= 2400 && rate.at( i ) < 2800 )
            color[ 6 ]++;
        else if( rate.at( i ) >= 2800 && rate.at( i ) < 3200 )
            color[ 7 ]++;
    }
    int minans = 0;
    for( int i = 0; i < 8; i++ )if( color[ i ] != 0 ) minans++;
	if(minans!=0)
    	cout << minans << " " << minans + cnt << endl;
	else
        cout << 1 << " " << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int n, W, a, b;
vector<int> v;
vector<int> w;

int memo[101][10001];
int fun(int i, int sw){
    int temp;
    if(memo[i][sw] >= 0) return memo[i][sw];
    if(i == n){
        temp = 0;
    }else if(w[i]>sw) {
        temp = fun(i+1, sw);
    }else{
        temp = max(fun(i+1, sw), fun(i+1, sw-w[i])+v[i]);
    }
    return memo[i][sw] = temp;
}
    

int main(){
    cin >> n >> W;
    for(int i=0; i<n; ++i){
        cin >> a >> b;
        w.push_back(b); v.push_back(a);
    }
    for(int i=0; i<n+1; ++i){
        for(int j=0; j<W+1; ++j){
            memo[i][j] = -1;
        }
    }
    cout << fun(0, W) << endl;
    return 0;
}


Measured memory_bytes: 7112
s = input()
n = len(s)
s1 = s[0:(n-1)//2]
s2 = s1[::-1]
s3 = s[(n+3)//2-1:n]
s4 = s3[::-1]
if s1 == s2 == s3 == s4:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

llint N, M;
string s;
vector<llint> G[200005];
llint dega[200005], degb[200005];
bool invalid[200005];

void dfs(int v)
{
	invalid[v] = true;
	//cout << v << endl;
	for(int i = 0; i < G[v].size(); i++){
		int u = G[v][i];
		if(invalid[u]) continue;
		if(s[v] == 'A') dega[u]--;
		else degb[u]--;
		if(dega[u] * degb[u] == 0) dfs(u);
	}
}

int main(void)
{
	cin >> N >> M;
	cin >> s;
	s = "#" + s;
	
	llint u, v;
	for(int i = 0; i < M; i++){
		cin >> u >> v;
		G[u].push_back(v);
		if(s[u] == 'A') dega[v]++;
		else degb[v]++; 
		
		G[v].push_back(u);
		if(s[v] == 'A') dega[u]++;
		else degb[u]++;
	}
	
	/*for(int i = 1; i <= N; i++){
		cout << dega[i] << " " << degb[i] << endl;
	}*/
	
	for(int i = 1; i <= N; i++){
		if(invalid[i]) continue;
		if(dega[i] * degb[i] == 0) dfs(i);
	}
	
	for(int i = 1; i <= N; i++){
		if(!invalid[i]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 18416
/*
 * ID: ITP1_2_B
 * Problem: Range
 */

#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a < b && b < c)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}



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

#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5,T=N*30;
int nex[T],pre[T],tot,have[N],qx[N],qy[N];
vector<int>lk[N];
int n;
int dfn[N],fa[N],deep[N],sz[N],son[N],top[N];
namespace TREE
{
int tot;
namespace DFS1
{
void dfs(int x,int fr)
{
	fa[x]=fr;
	deep[x]=deep[fr]+1;
	sz[x]=1;
	for(auto y:lk[x])
	if(y!=fr)
	{
		dfs(y,x);
		sz[x]+=sz[y];
		if(sz[y]>sz[son[x]])son[x]=y;
	}
}
};
namespace DFS2
{
void dfs(int x,int ntop)
{
	top[x]=ntop;
	dfn[x]=++tot;
	if(!son[x])return ;
	dfs(son[x],ntop);
	for(auto y:lk[x])
	if(y!=son[x]&&y!=fa[x])dfs(y,y);
}
};
void init()
{
	DFS1::dfs(1,0);
	tot=-1;
	DFS2::dfs(1,1);
}
};
int mn[N*4],ad[N*4];
int ql,qr;
#define in (ql<=l&&qr>=r)
#define out (ql>r||qr<l)
#define mid ((l+r)/2)
#define cl (k*2)
#define cr (cl+1)
namespace SEG
{
int n;
void up(int k)
{
	mn[k]=min(mn[cl],mn[cr])+ad[k];
}
namespace ADD
{
void dfs(int k,int l,int r)
{
	if(in)
	{
		++tot;
		pre[nex[tot]=nex[k]]=tot;
		pre[tot]=k;
		nex[k]=tot;
		
		++ad[k];++mn[k];
		return ;
	}
	if(out)return ;
	dfs(cl,l,mid);
	dfs(cr,mid+1,r);
	up(k);
}
};
namespace DEL
{
void dfs(int k,int l,int r)
{
	if(in)
	{
		--ad[k];--mn[k];
		return ;
	}
	if(out)return ;
	dfs(cl,l,mid);
	dfs(cr,mid+1,r);
	up(k);
}
};
void add(int l,int r)
{
	ql=l;qr=r;
	ADD::dfs(1,1,n);
}
void del(int l,int r)
{
	ql=l;qr=r;
	DEL::dfs(1,1,n);
}
int get_mn()
{
	int k=1,l=1,r=n;
	while(l!=r)
	if(mn[cl]<mn[cr])
	{
		k=cl;
		r=mid;
	}
	else
	{
		k=cr;
		l=mid+1;
	}
	return k;
}
};
#define fx top[x]
#define fy top[y]
void add(int x,int y)
{
	while(fx!=fy)
	{
		if(deep[fx]<deep[fy])swap(x,y);
		SEG::add(dfn[fx],dfn[x]);
		x=fa[fx];
	}
	if(dfn[x]>dfn[y])swap(x,y);
	SEG::add(dfn[x]+1,dfn[y]);
}
void del(int x,int y)
{
	while(fx!=fy)
	{
		if(deep[fx]<deep[fy])swap(x,y);
		SEG::del(dfn[fx],dfn[x]);
		x=fa[fx];
	}
	if(dfn[x]>dfn[y])swap(x,y);
	SEG::del(dfn[x]+1,dfn[y]);
}
#undef fx
#undef fy
void del_mn()
{
	int k=SEG::get_mn();
	mn[k]=N;
	int i=nex[k];
	while(k>>=1)
	{
		SEG::up(k);
		if(!i)i=nex[k];
	}
	i=lower_bound(have+1,have+n,i)-have;
//	cerr<<i<<endl;
	rep(x,have[i-1]+1,have[i])
	{
		pre[nex[x]]=pre[x];
		nex[pre[x]]=nex[x];
	}
	del(qx[i],qy[i]);
}

int main()
{
	//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	cin>>n;SEG::n=n-1;
	rep(i,1,n-1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		lk[x].push_back(y);lk[y].push_back(x);
	}
	TREE::init();
	have[0]=tot=N*4;
	rep(i,1,n-1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		have[i]=tot;
		qx[i]=x;qy[i]=y;
	}
	rep(tmp,1,n-1)
	{
		if(mn[1]!=1)
		{
			puts("NO");
			exit(0);
		}
		del_mn();
	}
	puts("YES");
}

Measured memory_bytes: 33920
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() { 
  int a,b;
  cin>>a>>b;

  string ac=to_string(a);
  string bc=to_string(b);

  for(int i=1;i<b;i++){
      ac+=to_string(a);
  }
  for(int i=1;i<a;i++){
      bc+=to_string(b);
  }

  if(ac>bc) cout<<bc<<endl;
  else cout<<ac<<endl;
  


}



Measured memory_bytes: 256
using System;

namespace abc064_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int x = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == '(')
                {
                    x++;
                }
                else
                {
                    if (x == 0)
                    {
                        Console.Write("(");
                    }
                    else
                    {
                        x--;
                    }
                }
            }
            Console.Write(s);
            for (int i = 0; i < x; i++) Console.Write(")");
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int MAX=1e9;
const int N=105;
int a[N];
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",a+b+c-max(max(a,b),c));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

int solve(){
    ll n,k; cin >> n >> k;
    cout << min(n%k,k-n%k) << endl;
    

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    set<int>a;
    int x;
    while(n--)
    {
        cin>>x;
        if(a.count(x))
            a.erase(x);
        else
            a.insert(x);
    }
    printf("%d",a.size());
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);

//....................................................................................................................//



int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(10);
    int n, k;
    cin >> n >> k;
    set<int> S;
    for (int i = 1; i <= n; ++i) {
        S.insert(i);
    }
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int a;
            cin >> a;
            S.erase(a);
        }
    }
    cout << S.size();
    return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int dp[16][16];
bool field[16][16];
int main(){
    int w,h;
    while(cin>>w>>h,w){
        int k;
        cin>>k;
        rep(i,k){
            int a,b;
            cin>>a>>b;
            field[b-1][a-1]=true;
        }
        dp[0][0]=1;
        rep(i,h)
            rep(j,w){
                if(!field[i][j]){
                    if(i>0)dp[i][j]+=dp[i-1][j];
                    if(j>0)dp[i][j]+=dp[i][j-1];
                }
            }
        cout<<dp[h-1][w-1]<<endl;
        rep(i,16)
            rep(j,16){
                dp[i][j]=0;
                field[i][j]=false;
            }
    }
}

Measured memory_bytes: 1160