akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //Read the question silly billy
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) a[i] = I.nextInt();
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		int ptr = N-1;
		while (ptr>=0) {
			A+=a[ptr];
			ptr-=2;
		}
		ptr = N-2;
		while (ptr>=0) {
			B+=a[ptr];
			ptr-=2;
		}
		O.pln(A-B);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}



Measured memory_bytes: 25616
using System;

public class Hello
{
    public const int E5 = 100000;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var w = new long[n+1];
        for (int i = 1; i <= n - 1; i++)
            w[i] = long.Parse(Console.ReadLine().Trim()) % E5;
        var a = new int[n+1];
        var p = 1;
        for (int i = 0; i < m; i++)
        {
            var t =  int.Parse(Console.ReadLine().Trim());
            var np = p + t;
            if (np > p) { a[p]++; a[np]--; }
            else { a[p]--;  a[np]++; }
            p = np;
        }
        for (int i = 1; i < n + 1; i++)
            a[i] += a[i - 1];
        var ret = 0L;
        for (int i = 0; i < n+1; i++)
        {
            ret += (a[i] * w[i]) % E5;
            ret %= E5;
        }
        Console.WriteLine(ret);
    }
}


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

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


Measured memory_bytes: 2040
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    ans = n*a;
    if(ans>=b){
        cout << b;
    }
    else{
        cout << ans;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=305,INF=1<<30;
int dp[MAX][MAX][MAX];

int main(){
    
    string S;cin>>S;
    int N=S.size();
    int K;cin>>K;
    int maxi=0;
    
    for(int i=0;i<N;i++){
        dp[i][i][0]=1;
    }
    
    for(int w=1;w<N;w++){
        for(int l=0;l<N;l++){
            int r=l+w;
            if(r>=N) continue;
            for(int k=0;k<=K;k++){
                if(k==0){
                    if(S[l]==S[r]){
                        dp[l][r][k]=max(dp[l][r][k],dp[l+1][r-1][k]+2);
                    }else{
                        dp[l][r][k]=max({dp[l][r][k],dp[l+1][r][k],dp[l][r-1][k],dp[l+1][r-1][k]});
                    }
                }else{
                    if(S[l]==S[r]){
                        dp[l][r][k]=max(dp[l][r][k],dp[l+1][r-1][k]+2);
                    }else{
                        dp[l][r][k]=max({dp[l][r][k],dp[l+1][r][k],dp[l][r-1][k],dp[l+1][r-1][k]});
                        dp[l][r][k]=max({dp[l][r][k],dp[l+1][r-1][k-1]+2});
                    }
                }
            }
        }
    }
    
    for(int k=0;k<=K;k++){
        maxi=max(maxi,dp[0][N-1][k]);
    }
    
    cout<<maxi<<endl;
}






Measured memory_bytes: 110848
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll max(ll a, ll b, ll c){
  return max(max(a,b),c);
}
ll min(ll a, ll b, ll c){
  return min(min(a,b),c);
}

int main(){
  ll h,w; cin >> h >> w;

  ll ans = INF;

  //縦3分割
  if(h%3==0) ans = 0; else ans = min(ans,w);

  //横3分割
  if(w%3==0) ans = 0; else ans = min(ans, h);

  //ト分割
  REP(i,w-1){
    ll s1 = (i+1)*h, s2, s3;
    if(h%2==0) s2 = s3 = (h*w-s1)/2; else{
      s2 = (h*w-s1+w-(i+1))/2;
      s3 = (h*w-s1-w+(i+1))/2;
    }
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3));
  }

  //-|分割
  REP(i,h-1){
    ll s1 = (i+1)*w, s2, s3;
    if(w%2==0) s2 = s3 = (h*w-s1)/2; else{
      s2 = (h*w-s1+h-(i+1))/2;
      s3 = (h*w-s1-h+(i+1))/2;
    }
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3));
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    double ans = 0;
    int N, K;
    cin >> N >> K;
    REPA(i, N+1){
        double d = 1.0 / N;
        int sum = i;
        while(sum<K){
            d *= 0.5;
            sum *= 2;
        }
        ans += d;
    }
    printf("%.10f\n", ans);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    pair<int, int> p;
    rep(i, n) {
        cin >> p.first;
        p.second = i + 1;
        v[i] = p;
    }
    sort(v.begin(), v.end());
    rep(i, n) { cout << v[i].second << " "; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4028
h = {}
h[?a] = gets.chomp
h[?b] = gets.chomp
h[?c] = gets.chomp
turn = ?a
loop {
    if h[turn] == ""
        puts turn.upcase
        break
    else
        next_turn = h[turn][0]
        h[turn] = h[turn][1..-1];
        turn = next_turn
    end
    }

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<vector<int> >vvi(n+100);
    for(int i=0;i<n;i++){
      int a;cin>>a;
      for(int j=0;j<a;j++){
	int b;cin>>b;
	vvi[b-1].pb(i);
      }
    }
    bool flag[200][200]={};
    int num=-1;
    for(int i=0;i<200;i++)
      flag[i][i]=true;
    for(int i=0;i<30;i++){
      if(num>0)break;
      for(int j=0;j<vvi[i].size();j++){
	for(int k=0;k<vvi[i].size();k++){
	  for(int l=0;l<200;l++){
	    if(flag[vvi[i][k]][l])
	      flag[vvi[i][j]][l]=true;
	  }
	}
      }
      for(int j=0;j<200;j++){
	int cnt=0;
	for(int k=0;k<200;k++){
	  if(flag[j][k])
	    cnt++;
	}
	//if(cnt>0)cout<<cnt<<endl;
	if(cnt==n)num=i+1;
      }
    }
    cout<<num<<endl;
  }
  return 0;
}



Measured memory_bytes: 3188
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<int, int> P;

const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_N = 9;
const int INF = INT32_MAX;

char maze[MAX_H][MAX_W + 1];

int H, W, N;
int si, sj;
int gi[MAX_N + 1], gj[MAX_N + 1];
int d[MAX_H][MAX_W];

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

int bfs(int goalNum)
{
  queue<P> que;
  int cgi = gi[goalNum], cgj = gj[goalNum];

  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      d[i][j] = INF;

  que.push(P(si, sj));
  d[si][sj] = 0;

  while (que.size()) {
    P p = que.front(); que.pop();

    if (p.first == cgi && p.second == cgj) break;

    for (int i = 0; i < 4; i++) {
      int ni = p.first + dx[i], nj = p.second + dy[i];

      if (0 <= ni && ni < H && 0 <= nj && nj < W && maze[ni][nj] != 'X' && d[ni][nj] == INF) {
        que.push(P(ni, nj));
        d[ni][nj] = d[p.first][p.second] + 1;
      }
    }
  }

  return d[cgi][cgj];
}

int solve()
{
  int res = 0;
  for (int i = 1; i <= N; i++) {
    // printf("%d:(%d, %d) => ", i, si, sj);
    res += bfs(i);
    si = gi[i]; sj = gj[i];
    // printf("(%d, %d):%d\n", si, sj, res);
  }
  return res;
}

int main()
{
  scanf("%d %d %d", &H, &W, &N);
  for (int i = 0; i < H; i++) {
    scanf("%s", maze[i]);
    maze[i][W] = 0;

    for (int j = 0; j < W; j++) {
      if ('0' < maze[i][j] && maze[i][j] <= '9') {
        gi[maze[i][j] - '0'] = i;
        gj[maze[i][j] - '0'] = j;
      }
      if (maze[i][j] == 'S') {
        si = i;
        sj = j;
      }
    }
  }

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



Measured memory_bytes: 7516
#include <stdio.h>

int main(void)
{
	int A;
	int B;
	
	scanf("%d",&A);
	scanf("%d",&B);
	
	if(A>=1&&A<=8&&B>=1&&B<=8)
	{
	    printf("Yay!\n");
	}
	else 
	{
	    printf(":(\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

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


int main() {
  const	int MOD	= 2019;
  string S; cin>>S;
  long long ans = 0;
  vector<int> cnt(MOD, 0);
  int base = 1;
  int rem = 0;
  cnt[0] = 1;
  for(int i = S.length() - 1; i >= 0; i--) {
    int	v = S[i] - '0';
    rem = rem + base * v;
    rem %= MOD;
    //    cout << rem << " " << cnt[rem] << endl;                               
    if(v  != 0) ans += cnt[rem];
    cnt[rem]++;
    base = (base	* 10) % MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3344
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<random>
#include<bitset>
#include <queue>
#include <map>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

int h, w;
vector<string> sts;

int idx(int x, int y) {
    return x + (y * w);
}

int main() {
    cin >> h >> w;
    sts.resize(h);
    for (string& s : sts) cin >> s;
    queue<int> sst;
    sst.push(0);
    vector<int> dmap(h * w);
    dmap[0] = 0;
    for (int i = 1; i < h * w; ++i)dmap[i] = -1;
    int dist = -1;
    while (!sst.empty()) {
        int x = sst.front() % w;
        int y = sst.front() / w;
        sst.pop();
        if (x == w - 1 && y == h - 1) {
            dist = dmap[idx(x, y)];
            break;
        }
        if (x > 0 && sts[y][x - 1] == '.' && dmap[idx(x - 1, y)] == -1) {
            dmap[idx(x - 1, y)] = dmap[idx(x, y)] + 1;
            sst.push(idx(x - 1, y));
        }
        if (x < w - 1 && sts[y][x + 1] == '.' && dmap[idx(x + 1, y)] == -1) {
            dmap[idx(x + 1, y)] = dmap[idx(x, y)] + 1;
            sst.push(idx(x + 1, y));
        }
        if (y > 0 && sts[y - 1][x] == '.' && dmap[idx(x, y - 1)] == -1) {
            dmap[idx(x, y - 1)] = dmap[idx(x, y)] + 1;
            sst.push(idx(x, y - 1));
        }
        if (y < h - 1 && sts[y + 1][x] == '.' && dmap[idx(x, y + 1)] == -1) {
            dmap[idx(x, y + 1)] = dmap[idx(x, y)] + 1;
            sst.push(idx(x, y + 1));
        }
    }
    if (dist == -1) {
        cout << -1 << endl;
        return 0;
    }
    int whtc = 0;
    for (string& s : sts) whtc += count(s.begin(), s.end(), '.');
    cout << whtc - (dist + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Math.abs(sc.nextLong());
        long k = sc.nextLong();
        long d = sc.nextLong();
        int kd = 0;
        long tk = k;
        while(0 < tk / 10){
            kd++; tk /= 10;
        }
        int dd = 0;
        long td = d;
        while(0 < td / 10){
            dd++; td /= 10;
        }
        long ans = x;
        if(15 < kd + dd || x < k * d){
            long sho = x / d;
            long rk = k - sho;
            boolean odd = rk % 2 == 1;
            if(odd){
                ans = Math.abs(x % d - d);
            }else{
                ans = x % d;
            }
        }else{
            ans = x - k*d;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 35700
#include<bits/stdc++.h>  
using namespace std;  
  
bool isprime(int n){  
    int m = sqrt(n);  
    for(int i = 2; i <= m; i++){  
        if(n % i == 0) return 0;  
    }  
    return 1;  
}  
  
int main()  
{  
    int n;  
    cin >> n;  
    int k = 11;  
    while(n){  
        if(isprime(k) && k % 10 == 1){  
            cout << k << ' ';  
            n--;  
        }  
        k += 10;  
    }  
    cout << endl;  
    return 0;  
}  

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

const int maxn = 105;
int K, T;

priority_queue<int, vector<int>, less<int> > Q;

int main() {
    while (scanf("%d%d", &K, &T) != EOF) {
        while (!Q.empty()) Q.pop();
        for (int i = 1; i <= T; i++) {
            int a;
            scanf("%d", &a);
            Q.push(a);
        }
        while (Q.size() >= 2) {
            int t1 = Q.top(); Q.pop();
            int t2 = Q.top(); Q.pop();
            // printf("pop %d %d\n", t1, t2);
            if (t1 > 1) Q.push(t1 - 1);
            if (t2 > 1) Q.push(t2 - 1);
        }
        int v = Q.top();
        if (v == 0) v = 1;
        printf("%d\n", v - 1);
    }
    return 0;
}


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

int main() {
    int a;
    cin >> a;
    string s = to_string(a);
    if(s.at(0) == '7' || s.at(1) == '7' || s.at(2) == '7'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3696
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const K = Number(input[1][0]);
  const X = input[2].map(Number);

  let answer = 0;

  X.forEach((x) => {
    answer += Math.min(x, K - x) * 2;
  });

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 29604
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	printf("%d\n", c - (a - b < c ? a - b : c));

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int input[100000][2] = {};
	int memo = 0;

	for (int i = 0; i < 100000; ++i) {
		CI input[i][0];
		CI input[i][1];
		if (input[i][0] == 0) {
			memo = i;
			break;
		}
	}

	for (int i = 0; i < memo; ++i) {
		for (int k = 0; k < input[i][0]; ++k) {
			for (int j = 0; j < input[i][1]; ++j) {
				CO "#";
			}
			CO "\n";
		}
		CO "\n";
	}
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
long long dp[3003][3003],n,a[3002];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int l=n-1;l>=0;l--){
        for(int r=l;r<n;r++){
            if(r==l) dp[r][l]=a[l];
            else{
                dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
            }
        }
    }
    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<bool> V(100001,0);
  for(int i=0; i<6; i++) V[100+i]=1; 
  for(int i=106; i<100001; i++) V[i]=V[i-100]||V[i-101]||V[i-102]||V[i-103]||V[i-104]||V[i-105];
  int X;cin >> X;cout << V[X] << endl;
}

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

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

    string w, before_w = "";
    map<string, bool> m;

    for (int i = 0; i < n; i++) {
        cin >> w;
        if (m.find(w) != m.end()) {
            cout << "No" << endl;
            return 0;
        }

        if (i > 0 && before_w.back() != w[0]) {
            cout << "No" << endl;
            return 0;

        }

        before_w = w;
        m[w] = true;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

struct my{
    ll a,b;
}x[maxn];

bool cmp(my &a, my &b)
{
    return a.a < b.a;
}

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%lld%lld",&x[i].a, &x[i].b);
    }
    sort(x, x+n, cmp);
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(x[i].b >= m){
            ans += m*x[i].a;
            m = 0;
        }else{
            ans += x[i].b*x[i].a;
            m -= x[i].b;
        }
        if(m == 0) break;
    }
    cout<<ans;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

char z[] = "RYGB";

int kol2(int a,int b,int d){
//  debug(a,b,d);
  a += d * 10000;
  b += d * 10000;
  return 2 * ((a / d) % 2) + ((b / d) % 2) ; 
}

int kol(int a,int b,int d){
  if(d & 1){
    return (a + b) & 1;
  }else{
  //  debug(a,b,d);
    if((a + b) & 1){
      a--;
    }
    return kol2((a+b) >> 1, (a - b) >> 1,d/2);
  }
    
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n,m,d;
  cin >> n >> m >> d;
  R(i,n){
    R(j,m)
      cout << z[kol(i,j,d)];
    cout << "\n";
  }
}


Measured memory_bytes: 512
import math

def n_2(n):
  c=0
  while n%2==0:
    c+=1
    n>>=1
  return (n,c)

N,M=map(int,input().split())
A=list(map(int,input().split()))
A[0],a=n_2(A[0])
p=False
for i in range(1,N):
  A[i],b=n_2(A[i])
  if a!=b:
    p=True
    break
if p:
  print(0)
  exit()
n=1
for _ in range(a-1):
  n*=2
l=n
for a in A:
  l=l*a//math.gcd(l,a)
ans=M//l-M//(2*l)
print(ans)

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

double alen(int a){//時針
  return (a * pi)/(3600 * 6);
}
double blen(int b){//秒針
  return (b * pi) / 1800;
}

int main(){
  double a,b,h,m;
  cin >> a >> b >> h >>m;
  double rada,radb;
  rada = alen(h*3600 + m*60);
  radb = blen(m*60);
  double ans = pow(a,2) + pow(b,2) - 2 * a * b * cos((abs(rada-radb)));
  ans = pow(ans,0.5);
  printf("%.16f\n",ans);
}

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

int main(){
    double n;
    
    while(cin >> n,n){
        double angle,nn = 360;
        double first = 0 , second = 0;
        for(int i = 0 ; i < n-1 ; i++){
            cin >> angle;
            first += sin((angle*M_PI)/180.0);
            nn -= angle;
        }

        first += sin((nn*M_PI)/180.0);
   
        cin >> n;
        nn = 360;
        for(int i = 0 ; i < n-1 ; i++){
            cin >> angle;
            second += sin((angle*M_PI)/180.0);
            nn -= angle;
        }
        second += sin((nn*M_PI)/180.0);
  
        if((float)first == (float)second) cout << '0' << endl;
        else if((float)first > (float)second) cout << '1' << endl;
        else cout << '2' << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#define at putchar('\n')
using namespace std;
int main(void)
{
	switch(getchar())
	{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':puts("vowel");break;
		default:puts("consonant");
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;


int N, Q;
vector<ll> dat;
void badd(int id) {
	while (id <= N){
		dat[id]++;
		id += (id & -id);
		//printf("id=%d\n", id);
	}
}

int bsum(int id) {
	int res = 0;
	while (id > 0) {
		res += dat[id];
		id -= (id & -id);
	}
	return res;
}

int main() {
	cin >> N >> Q;
	vector<int> c(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> c[i];
	}
	
	vector<int> a(N + 1,-1);
	vector<vector<int>> ran(N + 1);
	for (int i = 1; i <= N; i++) {
		if (a[c[i]] != -1)ran[a[c[i]]].push_back(i);
		a[c[i]] = i;
	}
	//cout << "after range " << endl;


	vector<vector<ll>> qs(N + 1);
	vector<pair<int, int>> id(Q);
	for (int i = 0; i < Q; i++) {
		int l, r; cin >> l >> r;
		qs[l].push_back(r);
		id[i].first = l, id[i].second = r;
	}

	map<pair<int,int>,ll> ans;
	dat = vector<ll>(N + 1);
	for (int i = N; i >= 1; i--) {
		//cout << "i=" << i << endl;
		if (ran[i].size() != 0) {
			badd(ran[i][0]);
		}

		for (int j = 0; j < qs[i].size(); j++) {
			pair<int, int> pr = make_pair(i, qs[i][j]);
			ans[pr] = qs[i][j] - i + 1 - bsum(qs[i][j]);

		}

	}
	
	for (int i = 0; i < Q; i++) {
		cout << ans[id[i]] << endl;
	}
}


Measured memory_bytes: 94944
#include <iostream>
#include <vector>
#include <algorithm>
#define BIGNUM 1000000000
using namespace std;
int main(){
	int n;
	cin >> n;
	int num;
	vector<long long int> a(n);
	long long int input=0, ans=0;
	for(int i=0;i<n;i++){
		cin >> input;
		a.push_back(input);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	// check
	/*
	cout << "check start" << endl;
	for(int i=0; i<n; i++){
		cout << a.at(i) << endl;
	}
	cout << "check end" << endl;
	*/
	// check_end
	ans = a.at(0);
	for (int i=2;i<n;i++){
		num = i / 2;
		ans += a.at(num);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6432
N =int(input())
a = []
for i in range(N):
	a.append(input())

count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0

for i in range(N):
	if a[i] == 'AC':
		count_AC += 1
	if a[i] == 'WA':
		count_WA += 1
	if a[i] == 'TLE':
		count_TLE += 1
	if a[i] == 'RE':
		count_RE += 1

print('AC x ', end='')
print(count_AC)
print('WA x ', end='')
print(count_WA)
print('TLE x ', end='')
print(count_TLE)
print('RE x ', end='')
print(count_RE)


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

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

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

int main(void)
{
	ll n; cin >> n;
	vector<ll> a(n);
	each(i, e, a)
		cin >> e;

	ll sum = 0;
	each(i, e, a)
		sum += e;

	ll ans = LLONG_MAX;
	ll temp = 0;
	each(i, e, a)
	{
		if (i == size(a) - 1)
			continue;
		temp += e;
		ans = min(abs(temp - (sum - temp)), ans);
	}

	cout << ans;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    ll res = 0;
    REP(i, N-1){
    	ll tori = min(max(a[i+1]+a[i]-x, 0ll), a[i+1]);
    	a[i+1] -= tori;
    	res += tori;
    	tori = min(max(a[i+1]+a[i]-x, 0ll), a[i]);
    	a[i] -= tori;
    	res += tori;
    }

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

Measured memory_bytes: 1024
def gcd(a,b):
    if a > b:
        t = a
        a = b
        b = t
    if b % a == 0:
        return a
    else:
        return gcd(b % a, a)

def lcm(a,b):
    return a*b/gcd(a,b)

n = int(raw_input())
l = [int(raw_input()) for _ in range(n)]
print reduce(lcm, l)


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}
const ll MOD = 1000000007;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
 
const ll mod = 1E9 + 7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t; cin >> s >> t;
	int ans = INT_MAX, i;
	vector<string> sub;
	for(i = 0; i < s.size(); i++){
		for(int j = 1; j <= (int)s.size() - i; j++){
			sub.push_back(s.substr(i, j));
		}
	}
	for(i = 0; i < (int)sub.size(); i++){
		if(sub[i].size() == t.size()){
			int cnt = 0;
			for(int j = 0; j < (int)t.size(); j++){
				if(sub[i][j] != t[j]) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans;
}


Measured memory_bytes: 189820
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    int[] b = new int[n];
    for (int i = 0; i < n; i++) {
      b[i] = sc.nextInt();
    }

    int[] c = new int[n - 1];
    for (int i = 0; i < n - 1; i++) {
      c[i] = sc.nextInt();
    }

    int before = -99;
    int satisfaction = 0;
    for (int i = 0; i < n; i++) {

      satisfaction += b[a[i] - 1];
      if (before + 1 == a[i]) {
        satisfaction += c[before - 1];
      }
      before = a[i];
    }
    System.out.println(satisfaction);
  }
}


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

struct cell{
	string name;
	int n;
};

bool compare(const cell& left, const cell& right)
{
	return left.n > right.n ;
}

int main()
{
	vector<cell> team;
	vector<cell>::iterator it;
	cell c;
	int n, i;
	string s;
	int w, l, d;
	bool f = false;
	while (cin>>n, n) {
		if (f) cout<<endl;
		f = true;
		team.clear();
		for (i = 0; i < n; i++) {
			cin>>s>>w>>l>>d;
			c.name = s;
			c.n = 3*w+d;
			team.push_back( c );
		}
		sort(team.begin(), team.end(), compare);
		for (i = 0; i < n; i++)
			cout<<team[i].name<<","<<team[i].n<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        int left = int.Parse(line.Substring(0, 2));
        int right = int.Parse(line.Substring(2, 2));
        bool left_month = left >= 1 && left <= 12;
        bool right_month = right >= 1 && right <= 12;

        if (left_month && right_month)
        {
            Console.WriteLine("AMBIGUOUS");
        }
        else if (right_month)
        {
            Console.WriteLine("YYMM");
        }
        else if (left_month)
        {
            Console.WriteLine("MMYY");
        }
        else
        {
            Console.WriteLine("NA");
        }

    }
}

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

int main(){
  long int X, K;
  cin >> X >> K;
  
  if(X > K){
    X = X % K + K;
  }
  
  while(true){
    if(X >= K){
      X = max(X - K, K - X);
    }else if(X <= K / 2){
      break;
    }else{
      X = K - X;
      break;
    }
  }
      
  cout << X << endl;
}

Measured memory_bytes: 256
# D - Maze Master
from collections import deque, defaultdict

INF = 1 << 30
MOD = 10 ** 9 + 7
dxy = [(-1, 0), (0, -1), (0, 1), (1, 0)]


def bfs(sx: int, sy: int):
    queue = deque([(sx, sy)])
    dist = defaultdict(lambda: INF)
    dist[sx * MOD + sy] = 0
    while queue:
        x, y = queue.popleft()
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if S[nx][ny] == "." and dist[x * MOD + y] + 1 < dist[nx * MOD + ny]:
                dist[nx * MOD + ny] = dist[x * MOD + y] + 1
                queue.append((nx, ny))
    return max(dist.values())


def main():
    global S
    H, W, *S = open(0).read().split()
    H, W = int(H) + 2, int(W) + 2
    S = ["#" * W] + ["#" + s + "#" for s in S] + ["#" * W]  # put sentinels
    ans = max(bfs(i, j) for i, s in enumerate(S) for j, c in enumerate(s) if c == ".")
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	vector<vector<char>> vec(h, vector<char>(w));
	rep(i, h)
	{
		rep(j, w)
		{
			cin >> vec.at(i).at(j);
		}
	}
	vector<vector<char>> temp(h, vector<char>(w));
	rep(i, h)
	{
		rep(j, w)
		{
			temp.at(i).at(j) = vec.at(i).at(j);
		}
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << h); bit++)
	{ //2^n繰り返す
		for (int bit2 = 0; bit2 < (1 << w); bit2++)
		{ //2^n繰り返す
			int count = 0;
			rep(i, h)
			{
				rep(j, w)
				{
					if (bit & (1 << i))
					{ //1が立っていればホニャララ
						temp.at(i).at(j) = '.';
					}
					if (bit2 & (1 << j))
					{
						temp.at(i).at(j) = '.';
					}
				}
			}
			rep(i, h)
			{
				rep(j, w)
				{
					if (temp.at(i).at(j) == '#')
						count++;
				}
			}
			if (count == k)
				ans++;

			rep(i, h)
			{
				rep(j, w)
				{
					temp.at(i).at(j) = vec.at(i).at(j);
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>

int main(){
  char weather[10];
  scanf("%s",weather);
  // printf("%s",weather);
  if(*weather=='S')
    printf("Cloudy\n");
  else if(*weather =='R')
    printf("Sunny\n");
  else
    printf("Rainy\n");
  
  return 0;
}


Measured memory_bytes: 128
N = int(input())
maxdiv = 0
ans = 1
for i in range(1, N + 1):
    d = i
    count = 0
    while d % 2 == 0:
        d //= 2
        count += 1
    if count > maxdiv:
        ans = i
        maxdiv = count
print(ans)


Measured memory_bytes: 2940
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {

    ll k, n;
    cin >> k >> n;
    ll a[n+1];
    priority_queue<ll> q;
    rep(i, n) {
        cin >> a[i];
        if(i>1) {
            q.push(a[i]-a[i-1]);
        }
    }

    q.push(a[0]+k-a[n-1]);

    ll c = q.top();
    print(k-c);
    return 0;
}


Measured memory_bytes: 3444
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",(a-c)/(b+c))
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

bool ispalin(int x)
{
	char s[10];
	int n=sprintf(s,"%d",x);
	for(int i=0,j=n-1;i<j;i++,j--)
		if(s[i]!=s[j])
			return false;
	return true;
}

int main()
{
	for(int n;cin>>n;){
		int i,j;
		for(i=n;!ispalin(i);i--);
		for(j=n;!ispalin(j);j++);
		if(n-i<=j-n) cout<<i<<endl;
		else         cout<<j<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;
const int N = 100;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int a, b;
    cin >> a >> b;
    vector <vector <int> > res(N, vector <int> (N, 1));
    for (int i = 0; i < N / 2; i++) {
        for (int j = 0; j < N; j++) {
            res[i][j] = 0;
        }
    }
    a--, b--;
    int x = 0, y = 0;
    while (b) {
        res[x][y] = 1;
        y += 2;
        if (y >= N) {
            y = 0;
            x += 2;
        }
        b--;
    }
    x = N / 2 + 2, y = 0;
    while (a) {
        res[x][y] = 0;
        y += 2;
        if (y >= N) {
            y = 0;
            x += 2;
        }
        a--;
    }
    cout << N << " " << N << "\n";
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << (res[i][j] ? "#" : ".");
        }
        cout << "\n";
    }
}


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

int main(){
  string s;
  cin >> s;
  int ans;
  while(true){
    s.pop_back();
    if(s.substr(0,s.size()/2) == s.substr(s.size()/2,s.size()/2) && s.size() % 2 == 0){
      cout << s.size() << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int s = 0;
		int n2 = n;
		while (n2 > 0) {
			s += n2 % 10;
			n2 /= 10;
		}
		if (n % s == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23892
#include <stdio.h>

int main() {
    char palavra[3];
    scanf("%s", palavra);
    if(palavra[0] == 'A' && palavra[1] == 'B' || palavra[1] == 'B' && palavra[2] == 'A' || palavra[0] == 'B' && palavra[2] == 'A' || palavra[0] == 'B'&& palavra[1] == 'A' || palavra[1] == 'A' && palavra[2] == 'B'){
        printf("Yes\n");   
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	ll a, b;
	cin >> a >> b;
	
	ll x = a * b;
	ll tmp;
	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	/* 最小公倍数を出力 */
	cout << x / b << endl;



	return 0;

}

Measured memory_bytes: 256
s = input()

ans = s
ansa = s
a = 'abcdefghijklmnopqrstuvwxyz'
a = [a[i] for i in range(26)]
if len(s)<26:
    for i in a:
        if ans.count(i) == 0:
            ans += i
            break
    print(ans)
else:
    b = 26
    for i in range(1,26):
        if a.index(s[i]) > a.index(s[i-1]):
            b = i
    if b == 26:
        print(-1)
    else:
        s = s[:b]
        for j in a:
            if a.index(j) > a.index(s[b-1]) and j not in s:
                s = s[:b-1]+j
                break
        print(s)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b && b<c){
	  printf("Yes\n");
	}
	else {
	  printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

ll N;
ll dp[100001][3][3];//日にち、前日、今日
int main(void) {
	cin >> N;
	if (N == 1) { int X[3]; cin >> X[0] >> X[1] >> X[2]; sort(X, X + 3); ct(X[2]); return 0; }
	FOR(i, 0, N) {
		int a, b, c; cin >> a >> b >> c;
		if (i == 0) {
			int A, B, C; cin >> A >> B >> C;
			dp[2][0][1] = a + B;
			dp[2][0][2] = a + C;
			dp[2][1][0] = b + A;
			dp[2][1][2] = b + C;
			dp[2][2][0] = c + A;
			dp[2][2][1] = c + B;
			i++; continue;
		}
		FOR(k, 0, 3) { dp[i + 1][1][0] =max(dp[i][0][1],dp[i][2][1])+a; dp[i + 1][2][0] =(max(dp[i][0][2], dp[i][1][2]) +a); }
		FOR(k, 0, 3) { dp[i + 1][0][1] = max(dp[i][1][0], dp[i][2][0]) +b; dp[i + 1][2][1] = max(dp[i][0][2], dp[i][1][2]) + b; }
		FOR(k, 0, 3) { dp[i + 1][0][2] = max(dp[i][1][0], dp[i][2][0]) + c; dp[i + 1][1][2] = max(dp[i][0][1], dp[i][2][1]) + c; }
	}
	ll ans = 0;
	FOR(i, 0, 3)FOR(k, 0, 3) {
		if (i == k)continue;
		
		ans = max(ans, dp[N][i][k]);
	}
	ct(ans);
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long llong;

int func(int w[], int n, int k, llong P){
    int i = 0, j = 0, weight = 0; //j は積める荷物の数, iはトラックの数
    int tmpw[n];
    for(j = 0; j < n; j++){
        tmpw[j] = w[j];
    }
    for(j = 0; j < k; j++){
        llong s = 0;
        while( s + tmpw[i] <= P){
            s += tmpw[i];
            i++;
            if( i == n )return n;
        }
    }
    return i;
}

int main(){
    int n, k, i;
    llong left = 0, right = 100000 * 10000, mid;

    cin >> n;
    scanf("%d", &k);
    int w[n];
    for(i = 0; i < n; i++){
        scanf("%d", &w[i]);
    }
    while(right - left > 1){
        mid = (left + right) / 2;
        if(func(w, n, k, mid) >= n){
            right = mid;
        }else{
            left = mid;
        }
    }
    cout << right << endl;
    return 0;
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

    int H=1,W;cin>>W;
    vector<vector<ll>> A(H,vector<ll>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>A[i][j];
        }
    }
    
    ll ans=0;
    
    for(int i=0;i<H;i++){
        stack<pair<ll,int>> ST;
        vector<int> L(W),R(W);
        for(int j=0;j<W;j++){
            if(ST.empty()){
                L[j]=0;
                ST.push(make_pair(A[i][j],j));
            }
            else if(ST.top().first<A[i][j]){
                L[j]=ST.top().second+1;
                ST.push(make_pair(A[i][j],j));
            }else if(ST.top().first>=A[i][j]){
                while(!ST.empty()&&ST.top().first>=A[i][j]){
                    ST.pop();
                }
                if(ST.empty()) L[j]=0;
                else L[j]=ST.top().second+1;
                ST.push(make_pair(A[i][j],j));
            }
        }
        reverse(all(A[i]));
        
        while(!ST.empty()) ST.pop();
        
        for(int j=0;j<W;j++){
            if(ST.empty()){
                R[j]=0;
                ST.push(make_pair(A[i][j],j));
            }
            else if(ST.top().first<A[i][j]){
                R[j]=ST.top().second+1;
                ST.push(make_pair(A[i][j],j));
            }else if(ST.top().first>=A[i][j]){
                while(!ST.empty()&&ST.top().first>=A[i][j]){
                    ST.pop();
                }
                if(ST.empty()) R[j]=0;
                else R[j]=ST.top().second+1;
                ST.push(make_pair(A[i][j],j));
            }
            R[j]=W-R[j];
        }
        reverse(all(R));
        reverse(all(A[i]));
        
        for(int j=0;j<W;j++){
            ans=max(ans,A[i][j]*(R[j]-L[j]));
        }
        
        /*for(int j=0;j<W;j++){
            ans=max(ans,A[i][j]*(R[j]-L[j]));
            cout<<R[j];
            cout<<" ";
        }
        cout<<endl;*/
    }
    
    cout<<ans<<endl;
    
}




Measured memory_bytes: 6148
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;

vector<vector<int>> enuCmb(int n, int k) {
    vector<vector<int>> res;
    if (n==0 || k==0 || n<k) {
      	return res;
    } else { 
		res=enuCmb(n-1,k);
		vector<vector<int>> res1=enuCmb(n-1,k-1);
		rep(i,res1.size()) {
			res1[i].push_back(n-1);
			res.push_back(res1[i]);
		}
		if (k==1) {
			vector<int> ins={n-1};
			res.push_back(ins);
		}
		return res;
    }
}

int main() {
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<ll> a(n),ma(n);
    rep(i,n) {
        cin >> a[i];
        if (i>0) ma[i]=(a[i]>ma[i-1])?a[i]:ma[i-1];
        else ma[0]=a[0];
    }
    vector<vector<int>> enu=enuCmb(n-1,k-1);
    rep(i,enu.size()) {
        rep(j,k-1) ++enu[i][j];
    }
    ll ans=10e15;
	rep(i,enu.size()) {
        ll tans=0;
        vector<ll> b(n);
        copy(a.begin(),a.end(),b.begin());
		rep(j,k-1) {
            int now=enu[i][j];
            if (j==0) {
                if (b[now]<=b[0]) {
                    tans+=b[0]+1-b[now];
                    b[now]=b[0]+1; 
                }
            } else {
                int prev=enu[i][j-1];
                int l=(b[prev]>ma[now-1])?b[prev]:ma[now-1];
                if (b[now]<=l) {
                    tans+=l+1-b[now];
                    b[now]=l+1;
                }
            }
        }
        ans=(tans<ans)?tans:ans;
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640