akhauriyash/Code-Regression huggingface dataset:
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005

#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
lli f(string s,lli k)
{
    char ch=k+'a';
    lli i;
    string s1=s,s2="";
    while(1)
    {
        s2="";
        if(s1.sz()==1)
        {
            return 1;
        }
        rep(i,0,s1.sz()-1)
        {
            if(s1[i]==ch or s1[i+1]==ch)
            {
                s2.pb(ch);
            }
            else
            {
                s2.pb(s1[i]);
            }
        }
        string s3=s2;
        UN(s2);
        if(s2.sz()==1)
        {
            return s3.sz();
        }
        s1=s3;
    }

}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    string s;
    cin>>s;
    lli fre[26]={0};
    lli i,l=s.sz();
    rep(i,0,s.sz())
    {
        fre[s[i]-'a']++;
    }
    string s1=s;
    UN(s1);
    if(s1.sz()==1)
    {
        cout<<0;
        exit(0);
    }
    lli ans=0;
    rep(i,0,26)
    {
        if(fre[i])
        {
            ans=max(ans,f(s,i));
        }
    }
    cout<<s.sz()-ans;
}


Measured memory_bytes: 256
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]
ans = 0
for a in A:
    i = 1
    count = 1
    while count <= D:
        count = 1 + a*i
        ans += 1
        i += 1
ans += X
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

#define PI 3.14159265
int main()
{
double a,b,x;
scanf("%lf %lf %lf",&a,&b,&x);
double c,d,t,k;
t=x/a/a;
if(t<b)
{
if(t<=b/2)
{
c=x*2/a/b;
//printf("%lf\n",c);
d=atan(b/c)*180/PI;
}
else
{
c=(b*a*a)-x;
c=c*2/a/a;
d=atan(c/a)*180/PI;

}
}

else
d=0;
printf("%.10f\n",d);
}


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

int main() {
    int n;
    string s, t, ans = "";
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double pi = 2 * acos(0.0);
	double am = m * pi / 30.0;
	double ah = (h * 60 + m) * pi / 360.0;
	double ag = fabs(am - ah);
	double res = sqrt(a * a + b * b - 2 * a * b * cos(ag));
	printf("%.12f\n", res);
	return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int n, m;

int main(){
	while (std::cin >> n >> m, n || m){
		int c[15];
		for (int i = 0; i < 3; i++){
			int size;
			std::cin >> size;
			for (int j = 0, a; j < size; j++){
				std::cin >> a;
				a = n - a;
				c[a] = i;
			}
		}

		int x = 0;
		int p = 0;
		for (int i = n - 1; i >= 0; i--){
			int d = std::abs(p - c[i]);
			x += d * std::pow(3, i);

			if (d == 1)p = 2 - p;
		}

		int y = 0;
		p = 2;
		for (int i = n - 1; i >= 0; i--){
			int d = std::abs(p - c[i]);
			y += d * std::pow(3, i);

			if (d == 1)p = 2 - p;
		}

		std::cout << (std::min(x, y) <= m ? std::min(x, y) : -1) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MAX_H=50,MAX_W=50;
const int INF=1e8;
int dp[MAX_H+1][MAX_W+1];
char s[MAX_W+1];
int main(){
	int H,W;
	scanf("%d %d",&H,&W);
	REP(i,H+1){
		REP(j,W+1){
			dp[i][j]=INF;
		}
	}
	REP(i,H){
		scanf("%s",s);
		REP(j,W){
			dp[i+1][j+1]=s[j]-'0';
		}
	}
	FOR(i,1,H+1){
		FOR(j,1,W+1){
			if (i-1 || j-1){
				dp[i][j]+=min(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	printf("%d\n",dp[H][W]);
	return 0;
}

Measured memory_bytes: 1196
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 200050;
const int P = 1e9 + 7;
struct node {
	int x, y, w;
	bool operator < (const node &i) const {
		return w < i.w;
	}
}ed[N];

int ne[N<<1], to[N<<1], w[N<<1], val[N], fa[N], f[N], h[N], dep[N], tot; 
inline void add(int x, int y, int z) {
	ne[++tot] = h[x], to[h[x] = tot] = y, w[tot] = z;
}

void dfs(int x, int fat) {
	dep[x] = dep[fat] + 1;
	for (int i = h[x]; i; i = ne[i]) {
		int y = to[i]; if (y == fat) continue;
		val[y] = w[i], fa[y] = x, dfs(y, x);
	}
}

ll fpw(ll x, ll mi) {
	ll res = 1;
	for (; mi; mi >>= 1, x = x * x % P)
		if (mi & 1) res = res * x % P;
	return res;
}

int vis[N], cnt, cc, m, n;
ll res[N], sum, S;
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }

int get(int x, int y) {
	int res = 0;
	while (x != y) {
		if (dep[x] < dep[y]) swap(x, y);
		Mx(res, val[x]), x = fa[x];
	}
	return res;
}

int main() {
	read(n), read(m), read(S);
	for (int i = 1;i <= m; i++) read(ed[i].x), read(ed[i].y), read(ed[i].w);
	sort(ed + 1, ed + m + 1);
	for (int i = 1;i <= n; i++) f[i] = i;
	for (int i = 1;i <= m; i++) {
		int x = find(ed[i].x), y = find(ed[i].y);
		if (x == y) continue; f[x] = y, sum += ed[i].w, vis[i] = 1, cnt++;
		add(ed[i].x, ed[i].y, ed[i].w), add(ed[i].y, ed[i].x, ed[i].w);
	}
	dfs(1, 0); ll ans = 1;
	if (sum > S || cnt < n - 1) return puts("0"), 0;
	cnt = 0;
	for (int i = 1;i <= m; i++) {
		if (vis[i]) continue;
		ll t = ed[i].w - get(ed[i].x, ed[i].y);
		res[++cnt] = t;
	}
	sort(res + 1, res + cnt + 1);
	int fl = 0;
	for (int i = 1;i <= cnt; i++) {
		if (res[i] + sum < S) continue;
		if (res[i] + sum > S) {
			ans = ans * (fpw(2, cc) - 1) % P * fpw(2, cnt - i + 1) % P;
//			ans = ans * fpw(2, cnt - i + 1) % P;
			cc = 0; break;
		}
		cc++, fl = 1;
	}
	if (cc) ans = ans * (fpw(2, cc) - 1) % P;
	ans = 2 * ans % P;
	if (!fl) ans = 0;
	if (sum == S) ans = (ans + (fpw(2, n - 1) - 2) * fpw(2, cnt)) % P;
	write((ans + P) % P);
	return 0;
}

Measured memory_bytes: 3128
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let n = input!(usize);
    let a1 = input!(i32; n);
    let a2 = input!(i32; n);

    let mut max: i32 = 0;

    for i in 1..n+1 {
        let sum = a1.iter().take(i).sum::<i32>() + a2.iter().skip(i-1).sum::<i32>();
        if sum > max {
            max = sum;
        }
    }
    println!("{}", max);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
    int n;
    char s[101];
    scanf("%d %s",&n,s);

    int alfa[26][2],count = 0,max = 0;

    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            alfa[j][0] = 0;
            alfa[j][1] = 0;
        }
        for (int j = 0; j <= i; j++)
        {
            alfa[s[j] - 'a'][0] = 1;
        }
        for (int j = i + 1; j < n; j++)
        {
            alfa[s[j] - 'a'][1] = 1;
        }
        for (int j = 0; j < 26; j++)
        {
            if(alfa[j][0] + alfa[j][1] == 2)count++;
        }
        if(max < count)max = count;
        count = 0;
    }

    printf("%d\n",max);
}

Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  if (N%2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < N/2; ++i) {
    if (S[i] != S[i + N/2]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharp_AtCoder
{


    class Program
    {
        const int MAX = 1000000000;

        static int D;    // 問題の種類数
        static int G;    // 目標点
        static int[] p;  // p[i] := 100i点の問題数
        static int[] c;  // 100i点のボーナス点

        static List<string> binary;

        static void SetBinaryList(string now, int length)
        {
            if (length >= D)
            {
                binary.Add(now);
                return;
            }

            SetBinaryList(now + "1", length + 1);
            SetBinaryList(now + "0", length + 1);
        }

        static int SolvedPNum(string case_str)
        {
            int solved_num = 0;  //解いた問題数
            int point = 0;  //獲得ポイント
            bool[] has_solved = new bool[D];
            int incomplete_ind = -1;

            for(int i = 0; i < D; i++)
            {
                if(case_str[i] == '1')
                {
                    has_solved[i] = true;
                    solved_num += p[i];
                    point += 100 * (i + 1) * p[i] + c[i];  // 完全に解いた
                }
                else
                {
                    if(incomplete_ind < i)
                    {
                        incomplete_ind = i;
                    }
                }
            }

            if(incomplete_ind != -1)
            {
                for(int i = 0; i < p[incomplete_ind] - 1; i++)
                {
                    if (point >= G) break;
                    point += 100 * (incomplete_ind + 1);
                    solved_num++;
                }
            }

            if (point < G) return MAX;

            return solved_num;
        }


        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            D = input[0];
            G = input[1];

            p = new int[D];
            c = new int[D];
            for(int i = 0; i < D; i++)
            {
                input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                p[i] = input[0];
                c[i] = input[1];
            }

            binary = new List<string>();
            SetBinaryList("", 0);

            int min_solved_num = MAX;
            foreach(string case_str in binary)
            {
                min_solved_num = Math.Min(min_solved_num, SolvedPNum(case_str));
            }

            Console.WriteLine(min_solved_num);
        }
    }
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int Mod = 1e9 + 7;

const int inv2 = (Mod + 1) >> 1;

const int maxn = 110;

int n, K;
int dp[maxn + 5][maxn * maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &K);
	dp[n][0] = 1;
	for (int i = n; i >= 1; --i) REP(j, 0, n * n + 1) if (dp[i][j])
	{
		REP(k, 0, K + 1)
		{
			if (k > i) (dp[i - 1][j] += dp[i][j]) %= Mod;
			else
			{
				(dp[i - 1][j + (k + j) / i] += dp[i][j]) %= Mod;
			}
		}
	}
	int ans = 1;
	REP(i, 0, n) ans = (LL)ans * (K + 1) % Mod;
	ans = (LL)ans * n % Mod * K % Mod * inv2 % Mod;
	REP(i, 0, n * n + 1) (ans -= (LL)i * dp[0][i] % Mod) %= Mod;
	(ans += Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<long long>A(X), B(Y), C(Z), D(X*Y),E(Z*K,0);
	for (int i = 0; i < X; i++)cin >> A[i];
	for (int i = 0; i < Y; i++)cin >> B[i];
	for (int i = 0; i < Z; i++)cin >> C[i];
	sort(C.begin(), C.end(), greater<long long>());
	long long ans = 0; int z = 0;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			D[z] = A[i] + B[j]; z++;
		}
	}
	sort(D.begin(), D.end(),greater<long long>());
	int mi = min(K, X*Y); z = 0;
	for (int i = 0; i < mi; i++) {
		for (int j = 0; j < Z; j++) {
			E[z] = D[i] + C[j]; z++;
		}
	}
	sort(E.begin(), E.end(),greater<long long>());
	for (int i = 0; i < K; i++)cout << E[i] << endl;
}



Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


signed main(){
  string str;
  cin>>str;

  if(str.size() >= 4 && str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  
  return 0;
}


Measured memory_bytes: 256
import sys
f = sys.stdin

for line in f:
    c1, c2, c3 = map(int, line.split())
    cards = set([i + 1 for i in range(10)])
    cards.remove(c1)
    cards.remove(c2)
    cards.remove(c3)
   
    print( 'YES' if 0.5 <= sum(1 for i in cards if c1 + c2 + i <= 20) / len(cards) else 'NO')

Measured memory_bytes: 6748
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int h,w;
    cin>>h>>w;
    vector<vector<bool>> grid(h,vector<bool>(w));
    char tmp;
    queue<pair<int, int>> q;
    q.push(make_pair(-1, -1));
    REP(i,h){
        REP(j,w){
            cin>>tmp;
            if(tmp=='#'){
                grid[i][j]=true;
                q.push(make_pair(j, i));
            }else{
                grid[i][j]=false;
            }
        }
    }
    int loop = 0,x,y;
    bool f = true;
    while(f){
        f = false;
        q.push(q.front());
        q.pop();
        while(q.front().first!=-1){
            x = q.front().first;
            y = q.front().second;
            if(0<=x+1&&w>x+1){
                if(grid[y][x+1]==false){
                    grid[y][x + 1] = true;
                    q.push(make_pair(x + 1, y));
                    f = true;
                }
            }
            if(0<=x-1&&w>x-1){
                if(grid[y][x-1]==false){
                    grid[y][x - 1] = true;
                    q.push(make_pair(x - 1, y));
                    f = true;
                }
            }
            if(0<=y+1&&h>y+1){
                if(grid[y+1][x]==false){
                    grid[y+1][x ] = true;
                    q.push(make_pair(x, y+1));
                    f = true;
                }
            }
            if(0<=y-1&&h>y-1){
                if(grid[y-1][x]==false){
                    grid[y-1][x ] = true;
                    q.push(make_pair(x, y-1));
                    f = true;
                }
            }
            q.pop();
        }
        
        loop++;
    }

    cout << loop -1<< endl;
    return 0;
}


Measured memory_bytes: 8320
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CGacha {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        set<string> s;
        REP(i, N) {
            string a;
            cin >> a;
            s.insert(a);
        }
        cout << s.size() << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CGacha solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  s += s;
  if (s.find(t) == string::npos) {
    cout << "No" << '\n';
  }
  else {
    cout << "Yes" << '\n';
  }
}


Measured memory_bytes: 3216
n = int(input())

ans = 10 ** 5

for i in range(n + 1):
    count = 0
    
    s = i
    while s > 0:
        count += s % 6
        s //= 6
    
    t = n - i
    while t > 0:
        count += t % 9
        t //= 9
    
    ans = min(count, ans)
    
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <fstream>

using namespace std;

typedef unsigned long long ll;
const ll INF=18000000000000000000ULL;

//ifstream ifs("input.txt");
//ofstream ofs("output.txt");
//#define cin ifs
//#define cout ofs

map<int,int> prime_decompos(int a){
	map<int,int> res;
	for(int i=2;i*i<=a;i++){
		if(a%i==0){
			res[i]++;
			a/=i;
			i--;
		}
	}
	if(a!=1)res[a]++;
	return res;
}

int main(){
	int n;
	ll m;
	string str;
	while(cin>>n>>str&&!(n==0&&str=="0")){
		ll mul=1;
		m=0;
		for(int i=str.size()-1;i>=0;i--){
			ll a=str[i]-'0';
			if(str[i]>='A'&&str[i]<='Z')a=10+str[i]-'A';
			m+=a*mul;
			mul*=n;
		}
		map<int,int> np=prime_decompos(n);
		ll res=INF;
		for(map<int,int>::iterator it=np.begin();it!=np.end();it++){
			ll a=it->first;
			int b=it->second;
			ll cnt=0;
			while(a<=m){
				cnt+=(m/a);
				a*=it->first;
			}
			res=min(res,cnt/b);
		}
		cout<<res<<endl;
	}

	return 0;
}

Measured memory_bytes: 932
def main():
    goods, weight_limit = map(int, input().split())
    weight = []
    value = []
    for _ in range(goods):
        w, v = map(int, input().split())
        weight.append(w)
        value.append(v)
    dp = [[0 for _ in range(weight_limit + 1)] for _ in range(goods + 1)]
    for i in range(goods):
        for j in range(weight_limit + 1):
            if j >= weight[i]:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i])
            else:
                dp[i + 1][j] = dp[i][j]
    print(dp[-1][-1])


if __name__ == '__main__':
    main()



Measured memory_bytes: 171528
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;
ll ans;

int main() {
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;

  priority_queue<ll> p,q,r;
  
  for(int i = 0; i < a; i++) {
    ll P;
    cin >> P;
    p.push(P);
  }
  for(int i = 0; i < b; i++) {
    ll Q;
    cin >> Q;
    q.push(Q);
  }
  for(int i = 0; i < c; i++) {
    ll R;
    cin >> R;
    r.push(R);
  }

  priority_queue<ll, vector<ll>, greater<ll> > pq;
  
  while(x--) {
    ll v = p.top();
    p.pop();
    pq.push(v);
  }
  while(y--) {
    ll v = q.top();
    q.pop();
    pq.push(v);
  }

  while(!r.empty()) {
    ll v = r.top();
    r.pop();
    ll u = pq.top();
    pq.pop();
    pq.push(max(v,u));
  }

  while(!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
   


  cout << ans << endl;
    
}
  


Measured memory_bytes: 4724
program abc22
 implicit none
 integer::N,K,i,ia
 integer,allocatable::a(:)
 read(*,*)N,K
 allocate(a(N))
 read(*,*)(a(i),i=1,N)
 do ia=1,N-K
  if(a(ia)<a(ia+K))then
   print'(a)',"Yes"
  else
   print'(a)',"No"
  end if
 end do
 deallocate(a)
end program abc22

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/tree_policy.hpp>

template <class Key>
using rb_tree_set =
    __gnu_pbds::tree<Key, __gnu_pbds::null_type, std::less<Key>,
                     __gnu_pbds::rb_tree_tag,
                     __gnu_pbds::tree_order_statistics_node_update>;
template <class Key, class T>
using rb_tree_map =
    __gnu_pbds::tree<Key, T, std::less<Key>, __gnu_pbds::rb_tree_tag,
                     __gnu_pbds::tree_order_statistics_node_update>;

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, Q;
  cin >> N >> Q;
  vector<int> colors(N);
  REP(i, N) cin >> colors[i];
  vector<int> lefts(Q), rights(Q), ids(Q);
  REP(i, Q) {
    cin >> lefts[i] >> rights[i];
    --lefts[i];
    --rights[i];
    ids[i] = i;
  }
  sort(ids.begin(), ids.end(),
       [&](int i, int j) { return rights[i] < rights[j]; });

  rb_tree_set<pair<int, int>> st;
  vector<int> prev(500'005, -1);
  vector<int> res(Q);
  int j = 0;
  for (int i = 0; i < N; ++i) {
    int pc = prev[colors[i]];
    if (pc >= 0) {
      st.insert(make_pair(pc, i));
    }
    for (; j < Q && rights[ids[j]] == i; ++j) {
      auto it = st.lower_bound(make_pair(lefts[ids[j]], -1));
      int dup_count = 0;
      if (it != st.end()) {
        int k = st.order_of_key(*it);
        dup_count = st.size() - k;
      }
      res[ids[j]] = rights[ids[j]] - lefts[ids[j]] + 1 - dup_count;
      DEBUG(j, ids[j], lefts[ids[j]], rights[ids[j]], dup_count, res[ids[j]]);
    }
    prev[colors[i]] = i;
  }
  for (int i = 0; i < Q; ++i) cout << res[i] << '\n';
}


Measured memory_bytes: 46008
#include "bits/stdc++.h"

typedef long long ll;

using namespace std;

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

	string S; cin >> S;
	int n = 0;
	for (int i = 0; i < S.size(); i++)
	{

		if (S[i] == 'o') {
			n++;
		}
	}
	if ((n + 15 - S.size()) >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;
    vec a(n);
    rep(i, n) cin >> a[i];

    lint asum = accumulate(all(a), 0LL);

    vec div;
    for (lint i = 1; i * i <= asum; i++) {
        if (asum % i == 0) {
            div.push_back(i);
            if (i * i != asum) div.push_back(asum/i);
        }
    }

    sort(all(div), greater<lint>());

    lint res = 1;

    for (auto&& d : div) {
        vec r(n);
        rep(i, n) r[i] = a[i] % d;

        sort(all(r));

        vec L(n+1), R(n+1);
        rep(i, n) L[i+1] = L[i] + r[i];
        for (int i = n-1; i >= 0; --i) {
            R[i] = R[i+1] + (d - r[i]);
        }

        for (int i = 0; i <= n; i++) {
            if (L[i] == R[i] && L[i] <= k) {
                res = max(res, d);
                break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
	int sum[1000];
	int i;
	int j;
	int k=0;
	char array[1000];
	char n[10]={'0','1','2','3','4','5','6','7','8','9'};
		for(i=0;i<1000;i++){
	sum[i]=0;
	}
	while(1){
		for(i=0;i<1000;i++){
	array[i]='0';
	}
	scanf("%s",array);
		if(array[0]=='0'){
			break;
		}
	for(i=0;i<1000;i++){
		for(j=0;j<10;j++){
			if(n[j]==array[i]){
				sum[k]+=j;
			}
		}
	}
	k++;
	}
	
	for(i=0;i<=k;i++){
		if(sum[i]==0){
			break;
		}
	printf("%d\n",sum[i]);
	}
	return 0;
}	

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


int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    bool flg = false;
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == 0)
            if (!(tmp % 5 == 0 || tmp % 3 == 0))
                flg = true;
    }
    if (flg)
        cout << "DENIED" << endl;
    else
        cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())

left_x = 0
right_x = w
bottom_y = 0
top_y = h

xya = []
for _ in range(n):
    x, y, a = map(int, input().split())
    xya.append((x, y, a))

for x, y, a in xya:
    if a == 1:
        left_x = max(x, left_x)
    elif a == 2:
        right_x = min(x, right_x)
    elif a == 3:
        bottom_y = max(y, bottom_y)
    else:
        top_y = min(y, top_y)

    if left_x >= right_x or bottom_y >= top_y:
        print(0)
        exit()

ans = (right_x - left_x) * (top_y - bottom_y)
print(ans)


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(3 * N);
  for (int i = 0; i < 3 * N; ++i) {
    scanf("%lld", &A[i]);
  }
  ll S = accumulate(A.begin(), A.begin() + N, 0LL);
  vector<ll> former;
  former.push_back(S);
  priority_queue<ll, vector<ll>, greater<ll>> fque(A.begin(), A.begin() + N);
  for (int i = N; i < 2 * N; ++i) {
    fque.push(A[i]);
    ll val = fque.top(); fque.pop();
    S = S + A[i] - val;
    former.push_back(S);
  }

  ll T = accumulate(A.begin() + 2 * N, A.end(), 0LL);
  vector<ll> latter;
  latter.push_back(T);
  priority_queue<ll> lque(A.begin() + 2 * N, A.end());
  for (int i = 2 * N - 1; i >= N; --i) {
    lque.push(A[i]);
    ll val = lque.top(); lque.pop();
    T = T + A[i] - val;
    latter.push_back(T);
  }

  ll ans = -1 * LLINF;
  for (int i = 0; i < N + 1; ++i) {
    ans = max(ans, former[i] - latter[N - i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 6772
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=1;i<50000;i++){
            if((int)((float)i*1.08) == N){
                System.out.println(i);
                return;
            }
        }
        
        System.out.println(":(");
        return;
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
using namespace std;
typedef long long ll;

int main(){
	ll n, max = 0, ans=0;
	cin >> n;
	vector<ll> h(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (h[i] >=h[i + 1]) {
			max++;
		}
		else {
			if (ans < max)
				ans = max;
			max = 0;
		}
	}
	if (ans < max)
		ans = max;
	cout << ans << endl;

}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main()
{
    string n;
    cin >> n;
    int s = (int)n.length(), mx = 0;
    vector<vector<vector<int>>> dp(s + 1, vector<vector<int>>(10, vector<int>(2, -100000000)));
    dp[0][0][0] = 0;
    for (int i = 0; i < s; ++i)
    {
        for (int j = 0; j < 10; ++j)
        {
            for (int k = 0; k < 2; ++k)
            {
                int lim = k ? 9 : n[i] - '0';
                for (int l = 0; l <= lim; ++l)
                {
                    dp[i + 1][l][k || l < lim] = max(dp[i + 1][l][k || l < lim], dp[i][j][k] + l);
                }
            }
        }
    }
    for (int i = 0; i < 10; ++i)
    {
        for (int j = 0; j < 2; ++j)
        {
            mx = max(mx, dp[s][i][j]);
        }
    }
    cout << mx << endl;
}


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

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

int main(void) {
  int i, ans = 0, j, n;
  char a[110], b[110];
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%s\n%s", a, b);
    if(strlen(a) > 80 || strlen(b) > 80) {
      printf("overflow\n");
      continue;
    }
    for(j = 0; j < strlen(a); ++j) a[j] -= '0' - 1;
    for(j = 0; j < strlen(b); ++j) b[j] -= '0' - 1;
    /*for(j = 0; j < strlen(a); ++j) printf("%d", (int)a[j] - 1);
    printf("\n");
    for(j = 0; j < strlen(b); ++j) printf("%d", (int)b[j] - 1);
    printf("\n");*/
    if(strlen(a) < strlen(b)) {
      char t[110];
      for(j = 0; j <= strlen(a); ++j) t[j] = a[j];
      for(j = 0; j <= strlen(b); ++j) a[j] = b[j];
      for(j = 0; j <= strlen(t); ++j) b[j] = t[j];
    }
    char t[110];
    int st = 0;
    for(j = 0; j <= strlen(b); ++j) t[j] = b[j];
    for(j = 0; j <= strlen(a); ++j) b[j] = 1;
    for(j = strlen(a) - strlen(t); j <= strlen(a); ++j) b[j] = t[j - strlen(a) + strlen(t)];
    /*for(j = 0; j < strlen(a); ++j) printf("%d", (int)a[j] - 1);
    printf("\n");
    for(j = 0; j < strlen(a); ++j) printf("%d", (int)b[j] - 1);
    printf("\n");*/
    for(j = strlen(a) - 1; j >= 0; --j) {
      a[j] = a[j] + b[j] - 1;
      if(a[j] >= 11) {
        if(j) {
          a[j - 1]++;
          a[j] -= 10;
        } else {
          st = 1;
          a[j] -= 10;
        }
      }
    }
    if(st) {
      if(strlen(a) == 80) {
        printf("overflow\n");
        continue;
      } else printf("1");
    }
    for(j = 0; j < strlen(a); ++j) printf("%d", (int)a[j] - 1);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2596
package main

import "fmt"

func main() {
	var k, s, ans int
	fmt.Scan(&k, &s)
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - x - y
			if 0 <= z && z <= k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;



void solve()
{
	string s,t;
	cin>>s>>t;
	cout<<t+s;
}

int main()
{
//	fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
// B - Trained?
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, e, f, h, k, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n), z;
  set<lli> g;
  rep(i, 0, n)
  {
    cin >> d[i];
    z.pb(d[i] - 1);
  }
  // rep(i, 0, n)
  // {
  //   if (d[i] != 2)
  //   {
  //     ans++;
  //   }
  // }
  // if (ans == n)
  // {
  //   cout << -1 << endl;
  //   return 0;
  // }

  // a = d[0];
  // if (a == 2)
  // {
  //   cout << count << endl;
  //   return 0;
  // }

  // while (!g.count(a) && count < n)
  // {

  //   g.insert(a);
  //   a = d[a - 1];
  //   count++;
  //   if (a == 2)
  //   {
  //     cout << count + 1 << endl;
  //     return 0;
  //   }
  // }
  rep(i, 0, n)
  {
    if (ans == 1)
    {
      cout << count << endl;
      return 0;
    }
    if (count >= n)
    {
      cout << -1 << endl;
      return 0;
    }
    count++;
    ans = z[ans];
  }
  cout << -1 << endl;
}

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

using namespace std;

int main() {
    // 締め切りが早い順に片付ける以外の方法はない
    int N;
    cin >> N;

    int timeSpent = 0;
    string ans = "Yes";
    unordered_map<int, vector<int>> dic; // {残り日数: [所要時間, 所要時間, ...]}
    set<int> deadlines;

    for (int i = 0; i < N; ++i) {
        int A, B; // timeframe, deadline
        cin >> A >> B;
        dic[B].push_back(A);
        deadlines.insert(B);
    }

    for (auto deadline : deadlines) {
        for (auto timeframe : dic.at(deadline)){
            timeSpent += timeframe;
            if (deadline < timeSpent){
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27208
import java.util.*;
public class Main{
     public static void main(String [] args){
          Scanner sc=new Scanner(System.in);
          int a=sc.nextInt();
          int b=sc.nextInt();
          int c=sc.nextInt();
          int z=Findmax(a,b,c);
          System.out.println(z);
          
     }
     public static int Findmax(int a, int b, int c){
          
          if(a>=b&&a>=c){
               return a*10+b+c;}
          else if(b>=a&&b>=c){
               return b*10+c+a;}
          else if(c>=a&&c>=b){
               return c*10+b+a;}
          return 0;
     }
     
}

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

int dp[50000] = { 0 };
int n,m,c[20];

int solve(int money){
 if(money < 0) return 1<<30;
 if(money==0)return 0;
 if(dp[money] != 0) return dp[money];
 int ans = 1 << 30; 
 for(int i=0; i < m;i++){
  ans = min(solve(money-c[i])+1,ans);
 }
 dp[money] = ans;
 return dp[money];
}

int main(){
 cin >> n;
 cin >> m;
 for(int i = 0;i < m;i++){
  cin >> c[i];
 }
 cout << solve(n) << endl;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 2000 + 5;

LL n, x;
LL a[N << 1];
LL c[N][N];

LL calc(LL k) {
	LL ans = k * x;
	for (int i = 1; i <= n; i++)
		ans += c[i][k];
	return ans;
}

int main() {
	read(n), read(x);
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 1; i <= n; i++) a[i + n] = a[i];
	for (int i = 1; i <= n; i++) c[i][0] = a[i];
	for (int i = n + 1; i <= 2 * n; i++)
		for (int j = 1; j < n; j++)
			c[i - n][j] = a[i - j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j < n; j++) c[i][j] = min(c[i][j], c[i][j - 1]);
	int l = 0, r = n - 1; LL ans = (1LL << 60);
	while (l + 3 <= r) {
		int m = (2 * l + r) / 3;
		int mm = (l + 2 * r) / 3;
		LL tmp1 = calc(m), tmp2 = calc(mm);
		if (tmp1 < tmp2) {
			ans = min(ans, tmp1);
			r = mm;
		} else {
			ans = min(ans, tmp2);
			l = m;
		}
	}
	for (int i = l; i <= r; i++) ans = min(ans, calc(i));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


int main(){
    int n; cin >> n;
    for(int i = n; i <= 999; ++i){
        int t = i;
        int a = t % 10;
        t /= 10;
        int b = t % 10;
        t /= 10;
        int c = t;
        if(a == b && b == c) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
from collections import Counter

S1 = input()
K = int(input())
S1C = Counter(S1)
if len(S1C) == 1:
    print(len(S1) * K // 2)
    exit()

start = S1[0]
end = S1[-1]
now = S1[0]
a1 = 0
flag = False
for s in S1[1:]:
    if flag:
        flag = False
        now = s
        continue
    else:
        if s == now:
            a1 += 1
            flag = True
        now = s
S2 = S1 + S1

start = S2[0]
end = S2[-1]
now = S2[0]
a2 = 0
flag = False
for s in S2[1:]:
    if flag:
        flag = False
        now = s
        continue
    else:
        if s == now:
            a2 += 1
            flag = True
        now = s
b = a2 - 2 * a1

print(a1 * K + b * (K-1))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, M, K;
	cin >> N >> M >> K;
	for (int i = 0; i <=M; i++) {
		for (int j = 0; j <=N; j++) {
			int x = N * i + M * j - 2*i*j;
			if (x == K) { puts("Yes"); return 0; }
		}
	}
	puts("No");
}



Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

#include <boost/heap/fibonacci_heap.hpp>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	int tank;
	Edge() {}
	Edge(int to, T cost, int tank = 0) : to(to), cost(cost), tank(tank) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, L;
	cin >> N >> M >> L;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < M; i++) {
		int u, v, len;
		cin >> u >> v >> len;
		u--, v--;
		if (len > L) continue;
		edges[u].emplace_back(v, len);
		edges[v].emplace_back(u, len);
	}

	auto dijkstra = [&](int st) {
		vector<pair<int, int>> dp(N, { -INF, 0 });
		dp[st] = { 0, L };
		using ppi = pair<pair<int, int>, int>;
		boost::heap::fibonacci_heap<ppi> que;
		vector<decltype(que)::handle_type> handles(N);
		for (int v = 0; v < N; v++) handles[v] = que.emplace(dp[v], v);
		while (!que.empty()) {
			auto now = que.top();
			que.pop();

			for (const auto &e : edges[now.second]) {

				auto tmp = now.first;
				if (e.cost > tmp.second) {
					tmp.first--;
					tmp.second = L - e.cost;
				}
				else tmp.second -= e.cost;

				if (tmp > dp[e.to]) {
					dp[e.to] = tmp;
					que.update(handles[e.to], ppi(tmp, e.to));
				}

			}
		}
		return dp;
	};

	vector<vector<pair<int, int>>> memo(N);
	for (int i = 0; i < N; i++) memo[i] = dijkstra(i);

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		auto tmp = memo[s][t].first;
		if (tmp != -INF) cout << -tmp << "\n";
		else cout << -1 << "\n";
	}

	return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner


object Main {

  case class MyRange(left: Int, right:Int)

  def read() = {
    val sc = new Scanner(System.in)
    val n, q = sc.nextInt()
    val s = sc.next()
    val ranges = for(i <- 0 until q) yield MyRange(sc.nextInt()-1, sc.nextInt()-1)// 0-origin化
    (n, q, s, ranges)
  }

  def solve(n:Int, q:Int, s:String, ranges: IndexedSeq[MyRange]): IndexedSeq[Int] = {
    // hasAC(i): s(i)='A'かつs(i+1)='C'
    val hasAC = for(i<-0 until n-1)yield{
      s(i) == 'A' && s(i+1) == 'C'
    }
    // countAC(i) = #{j| j<i, hasAC(i)==True}
    val countAC = hasAC.map(p=> if(p) 1 else 0).scanLeft(0)(_+_)
    for (range <- ranges)yield{
      // [range.left, range.right-1]の範囲でhasACがTrueの数を調べる
      countAC(range.right) - countAC(range.left)
    }
  }


  def main(args: Array[String]): Unit = {
    val (n, q, s, ranges) = read()
    solve(n,q,s,ranges).foreach(println)
  }
}

Measured memory_bytes: 75212
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0: break
    for j in range(h):
        for i in range(w):
            if (i + j)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7000