akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();

        WriteLine(n * n);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int MA = 83;
ll dp[MA][MA][2*MA*MA];
int A[MA][MA], B[MA][MA];

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


	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)cin >> A[i][j];
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)cin >> B[i][j];

	dp[1][1][max(A[0][0], B[0][0]) - min(A[0][0], B[0][0])] = 1;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			for (int k = 0; k < 2*MA*MA; k++) {
				int ma = max(A[i - 1][j - 1], B[i - 1][j - 1]);
				int mi = min(A[i - 1][j - 1], B[i - 1][j - 1]);
				if (dp[i - 1][j][k] == 1 || dp[i][j - 1][k] == 1) {
					dp[i][j][abs(ma - mi - k)] = 1;
					dp[i][j][abs(ma - mi + k)] = 1;
				}
			}
		}
	}
	for (int i = 0; i < 2 * MA*MA; i++) {
		if (dp[H][W][i]) {
			puts(i);
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 717056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const int INF = 2e9;
const int N_MAX = 200010;
int a[N_MAX];
vector<vector<int>> tree(N_MAX);
int ans[N_MAX];
stack<pair<int,int>> st;
void calc(int now,int root,vector<int> &vec){
    auto itr = lower_bound(ALL(vec),a[now]);
    st.push(make_pair(itr-vec.begin(),*itr));
    *itr = a[now];
    if(itr-vec.begin()!=ans[root]){
        ans[now] = ans[root];
    }
    else{
        ans[now] = ans[root] + 1;
    }
    for(int i:tree[now]){
        if(i==root) continue;
        calc(i,now,vec);
    }
    auto p=st.top();
    st.pop();
    vec[p.first]=p.second;
}
void Main(){
    int n;cin>>n;
    For(i,0,n) cin>>a[i];
    For(i,0,n-1){
        int u,v;
        cin >> u >> v;
        u--;
        v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    vector<int> vec(n,INF);
    vec[0]=a[0];
    ans[0]=1;
    for(int i:tree[0]) calc(i,0,vec);
    For(i,0,n) cout << ans[i] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

using namespace std;

int main(){
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	int x[100];
	int y[100];
	int x_max = X;
	int y_min = Y;

	for(int i = 0;i < N; i++){
		//int x[i];
		cin >> x[i];
		if(x_max < x[i]) x_max = x[i];
	}
	for(int j = 0;j < M;j++){
		cin >> y[j];
		if(y_min > y[j]) y_min = y[j];
	}
	
	if(y_min <= x_max){
		cout << "War" << endl;
	}else{
		cout << "No War" << endl;
	}
	
	//debug
	//cout << x_max << y_min << endl;
}



Measured memory_bytes: 256
import math

def main():
    A, B, N = map(int, input().split(" "))
    max_score = -float("inf")

    if B <= N:
        x = B-1 
    else:
        x = N
    score = math.floor((A*x)/B) - A*math.floor(x/B)
    print(score)

if __name__ == "__main__":
    main()

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

int main(){
  double a;
  int n;
  double sum=0.0,ans=0.0;
  cin >> n;
  vector<double> v(n);
  rep(i,n) cin >> v.at(i);
  rep(i,n) v.at(i)=1/v.at(i);
  rep(i,n) sum+=v.at(i);
  ans = 1/sum;
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[3*N];
		for(int i=0; i<3*N; i++){
			a[i]  = sc.nextInt();
		}
		
		Arrays.sort(a);
		
		long sum = 0;
		int min = 0;
		int max = 3*N-1;
		int set_num = 0;
		while(min!=max){
			if(set_num==0){
				max -= 1;
				set_num = 1;
			}else if(set_num==1){
				sum += a[max];
				max -= 1;
				set_num = 2;
			}else if(set_num==2){
				min += 1;
				set_num = 0;
			}
		}
		
		System.out.println(sum);

	}

}


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

static class Program
{
    static int[] Paint(int N, List<int>[] hands)
    {
        var colors = new int[N];
        var queue = new Queue<int>();
        colors[0] = 1;
        queue.Enqueue(0);
        while (queue.Count > 0)
        {
            int a = queue.Dequeue();
            foreach (int b in hands[a])
            {
                if (colors[b] == 0)
                {
                    colors[b] = -colors[a];
                    queue.Enqueue(b);
                }
                else if (colors[b] != -colors[a])
                {
                    return null;
                }
            }
        }
        return colors;
    }

    static long Solve(int N, int M, int[][] edges)
    {
        var hands = new List<int>[N];
        for (int i = 0; i < N; ++i) { hands[i] = new List<int>(); }
        foreach (var edge in edges)
        {
            int a = edge[0];
            int b = edge[1];
            hands[a].Add(b);
            hands[b].Add(a);
        }
        var colors = Paint(N, hands);
        if (colors != null)
        {
            int e = colors.Count(color => color == 1);
            int o = colors.Count(color => color == -1);
            return Math.BigMul(e, o) - M;
        }
        else
        {
            return Math.BigMul(N, N - 1) / 2 - M;
        }
    }

    static void Main(string[] args)
    {
        int[] V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], M = V1[1];
        var edges = new int[M][];
        for (int i = 0; i < M; ++i)
        {
            edges[i] = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) - 1);
        }
        Console.WriteLine(Solve(N, M, edges));
    }
}


Measured memory_bytes: 31212
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val scores = readLine()!!.split(" ").map { it.toInt() }
    val cnt = mutableMapOf<Int, Int>()
    for(i in scores) {
        for(j in (i-1..i+1)) {
            if(cnt.containsKey(j)) {
                cnt[j] = cnt[j]!! + 1
            } else {
                cnt[j] = 1
            }
        }
    }
    println(cnt.maxBy { it.value }!!.value)
}


Measured memory_bytes: 58888
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;



int main(){
   int n,x;
   cin >> n >>x;
   vector<int>a(n);
   rep(i,n)cin >> a[i];
   sort(a.begin(),a.end());
   int cnt=0;
   rep(i,n-1){
       if(x<a[i]) break;
       x-=a[i];
       cnt++;
   }
   if(a[n-1]==x) cnt++;
   cout << cnt <<endl;
}

Measured memory_bytes: 3560
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}

	ans := A[0]
	for _, a := range A {
		ans = gcd(ans, a)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4208
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	size_t n;
	scanf("%ld\n", &n);
	size_t[ubyte[]] map;
	foreach(i; 0..n) {
		auto l = readln.chomp.representation.dup;
		l.sort!"a<b";
		immutable key = l.dup;
		if (key in map) {
			++map[key];
		}
		else {
			map[key] = 1;
		}
	}
	size_t ans;
	foreach(key; map.keys) {
		ans += map[key] * (map[key] - 1) / 2;
	}
	ans.write;
}


Measured memory_bytes: 14844
#include <cstdio>
#include <vector>
using namespace std;
vector<int> G[200005];
int n,m,a,b;
bool flag,f[200005];
void dfs(int now,int add) {
	if(flag)
		return;
	if(add == 2) {
		if(now == n)
			flag = true;
		return;
	}
	for(int i = 0; i < G[now].size(); ++i) {
		if(!f[G[now][i]]) {
			f[G[now][i]] = true;
			dfs(G[now][i],add + 1);
			f[G[now][i]] = false;
		}
	}
}
int main() {
	scanf("%d %d",&n,&m);
	for(int i = 1; i <= m; ++i) {
		scanf("%d %d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}	
	f[1] = true;
	dfs(1,0);
	if(flag)
		printf("POSSIBLE");
	else
		printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 12144
import java.util.Scanner;

public class Main {

	static int n, m;
	static boolean[][] graph;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		boolean[] vis = new boolean[n];
		vis = new boolean[n];
		graph = new boolean[n][n];
		for(int i = 0 ; i < m ; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			graph[a][b] = graph[b][a] = true;
		}
		for(int i = 0 ; i < n ; i++) vis[i] = false;
		vis[0] = true;
		System.out.println(dfs(0, vis));
	}

	public static int dfs(int v, boolean[] vis) {
		boolean all_vis = true;
		for(int i = 0 ; i < n ; i++) {
			if(vis[i] == false) {
				all_vis = false;
			}
		}
		if(all_vis == true) return 1;
		int ret = 0;
		for(int i = 0 ; i < n ; i++) {
			if(vis[i] == true) continue;
			if(graph[v][i] == false) continue;
			vis[i] = true;
			ret += dfs(i, vis);
			vis[i] = false;
		}
		return ret;
	}

}


Measured memory_bytes: 23764
h, w = gets.split.map(&:to_i)

visit = Array.new(h) {Array.new(w, false)}
que = []
h.times do |i|
    gets.each_char.with_index do |c, j|
        if c == "#"
            que << [i, j] 
            visit[i][j] = 0
        end
    end
end

ans = 0
while ij = que.shift
    i, j = ij

    if i > 0 && !visit[i - 1][j]
        que << [i - 1, j]
        ans = visit[i - 1][j] = visit[i][j] + 1
    end

    if i < h - 1 && !visit[i + 1][j]
        que << [i + 1, j]
        ans = visit[i + 1][j] = visit[i][j] + 1
    end

    if j > 0 && !visit[i][j - 1]
        que << [i, j - 1]
        ans = visit[i][j - 1] = visit[i][j] + 1
    end

    if j < w - 1 && !visit[i][j + 1]
        que << [i, j + 1]
        ans = visit[i][j + 1] = visit[i][j] + 1
    end
end

puts ans

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

T, *L = map(int, open(0).read().split())

for a, b, c, d in zip(*[iter(L)] * 4):

    if a < b or d < b:
        flag = False
    elif c >= b - 1:
        flag = True
    else:
        g = gcd(b, d)
        flag = (b + a % g - g) <= c

    if flag:
        print("Yes")
    else:
        print("No")


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

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  char X,Y;
  cin >> X >> Y;
  if(X>Y)
  {
    cout << ">" << endl;
  }
  else if(X<Y)
  {
    cout << "<" << endl;
  }
  else
  {
    cout << "=" << endl;
  }
  return 0;
}


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

typedef array<int, 26> Vec;

char buf[114514];
int cnt[2][114514][26];
string S[2];
vector<int> appear[2][26];

int main() {
  scanf("%s", buf);
  S[0] = buf;
  scanf("%s", buf);
  S[1] = buf;

  for (int k=0; k<2; k++) {
    for (int i=0; i<S[k].size(); i++) {
      appear[k][S[k][i]-'a'].emplace_back(i);
      if (i > 0) {
        for (int j=0; j<26; j++) {
          cnt[k][i][j] = cnt[k][i-1][j];
        }
      }
      cnt[k][i][S[k][i]-'a']++;
    }
  }

  int t = (int)min(S[0].size(), S[1].size());
  for (int k=t; k>=1; k--) {
    vector<Vec> vs;
    for (int i=0; i+k<=S[0].size(); i++) {
      Vec v;
      for (int j=0; j<26; j++) {
        v[j] = cnt[0][i+k-1][j];
        if (i > 0) v[j] -= cnt[0][i-1][j];
      }
      vs.emplace_back(v);
    }
    sort(vs.begin(), vs.end());

    for (int i=0; i+k<=S[1].size(); i++) {
      Vec v;
      for (int j=0; j<26; j++) {
        v[j] = cnt[1][i+k-1][j];
        if (i > 0) v[j] -= cnt[1][i-1][j];
      }

      if (binary_search(vs.begin(), vs.end(), v)) {
        printf("%d\n", k);
        return 0;
      }
    }
  }
  puts("0");
}



Measured memory_bytes: 4596
#include <stdio.h>

int main(void){
  int S, x, y, A, B;
  x=0; y=0;
  scanf("%d", &S);
  A=(S-S%100)/100; B=S%100;
  if(1<=A && A<=12) x=1;
  if(1<=B && B<=12) y=1;
  if(x==1 && y==1) printf("AMBIGUOUS");
  if(x==1 && y==0) printf("MMYY");
  if(x==0 && y==1) printf("YYMM");
  if(x==0 && y==0) printf("NA");
  return(0);
}


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

int main()
{
    ll N, x;
    cin >> N >> x;

    vector<ll> a(N);
    rep(i, N) cin >> a.at(i);

    ll ans = 0;
    if (a.at(0) > x)
    {
        ans += a.at(0) - x;
        a.at(0) = x;
    }

    for (int i = 1; i < N - 1; i++)
    {
        if (a.at(i) + a.at(i - 1) > x)
        {
            ans += a.at(i) + a.at(i - 1) - x;
            a.at(i) = x - a.at(i - 1);
        }
    }

    if (a.at(N - 1) + a.at(N - 2) > x)
    {
        ans += a.at(N - 1) + a.at(N - 2) - x;
    }

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

Measured memory_bytes: 4024
k=int(input())
g = []
i = 0
while k >3:
  if k%2 == 1:
    g.append([1,20-i,(k-1)*2**i])
    k = k//2
    g.append([20-i-1,20-i,0])
    g.append([20-i-1,20-i,1*2**i])
    i+=1
  else:
    k = k//2
    g.append([20-i-1,20-i,0])
    g.append([20-i-1,20-i,1*2**i])
    i+=1
if k==3:
  g.append([1,20-i,(k-1)*2**i])
  k = k//2
  g.append([20-i-1,20-i,0])
  g.append([20-i-1,20-i,1*2**i])
  if 20-i-1 != 1:
    g.append([1,20-i-1,0])
elif k == 2:
  g.append([20-i-1,20-i,0])
  g.append([20-i-1,20-i,1*2**i])
  if 20-i-1 != 1:
    g.append([1,20-i-1,0])
print(20,len(g))
for x,y,z in g:
  print(x,y,z)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
// #define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  ll p;
  cin >> n >> m >> l;
  cin >> p;
  if(abs(n-l) <= p)puts("Yes");
  else if(abs(n-m) <= p && abs(m-l) <= p)puts("Yes");
  else puts("No");
  return 0;
}

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

using namespace std;

struct Dice {
    int s[6];

    int &top() { return s[0]; }

    int &south() { return s[1]; }

    int &east() { return s[2]; }

    int &west() { return s[3]; }

    int &north() { return s[4]; }

    int &bottom() { return s[5]; }

    void roll(char c) {
        string b("EWNSRL");
        int v[6][4] = {{0, 3, 5, 2},
                       {0, 2, 5, 3},
                       {0, 1, 5, 4},
                       {0, 4, 5, 1},
                       {1, 2, 4, 3},
                       {1, 3, 4, 2}};
        for (int k = 0; k < 6; ++k) {
            if (b[k] != c) continue;
            int t = s[v[k][0]];
            s[v[k][0]] = s[v[k][1]];
            s[v[k][1]] = s[v[k][2]];
            s[v[k][2]] = s[v[k][3]];
            s[v[k][3]] = t;
        }
    }
};

int main() {
    Dice d;
    int q, top, south;

    for (int i = 0; i < 6; ++i) cin >> d.s[i];
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> top >> south;
        if (d.west() == top) d.roll('E');
        if (d.east() == top) d.roll('W');
        while (d.top() != top) d.roll('N');
        while (d.south() != south) d.roll('R');
        cout << d.east() << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; (int)(n); i++)
 
 int main() {
  string text;
  cin >> text;
  
  if (text.back() == 's') {
    cout << text << "es" << endl;
  } 
  else {     
    cout << text << "s" << endl;
  }   
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
	string s;
	cin >> s;
	cout << "ABC" << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,k,a[100005],b[100005],ans;
int main(){
	cin>>n>>m>>k;
	int aa=100001,bb=100001;
	for(int i=1;i<=n;i++)cin>>a[i],aa=min(aa,a[i]);
	for(int i=1;i<=m;i++)cin>>b[i],bb=min(bb,b[i]);
	ans=aa+bb;
	for(int i=1;i<=k;i++){
		int x,y,z;
		cin>>x>>y>>z;
		ans=min(ans,a[x]+b[y]-z);
	}
	cout<<ans;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	bool flag = true;
	
	while (1) {
		int n;
		int a, b, c, d;
		int aa = 0, bb = 0, cc = 0, dd = 0;
		int maxi = INF;
		int point = 0;
		int money;

		cin >> n;
		if (n == 0) {
			break;
		}
		if (!flag) {
			cout << endl;
		}
		else {
			flag = false;
		}
		cin >> a >> b >> c >> d;

		FOR(p, 0, a) {
			FOR(q, 0, b) {
				FOR(r, 0, c) {
					FOR(s, 0, d) {
						point = a + b + c + d;
						point -= p + q + r + s;
						money = (p * 10 + q * 50 + r * 100 + s * 500) - n;
						if (money<0) {
							continue;
						}
						else {
							point += (money / 500);
							money -= (money / 500) * 500;
							point += (money / 100);
							money -= (money / 100) * 100;
							point += (money / 50);
							money -= (money / 50) * 50;
							point += (money / 10);
							money -= (money / 10) * 10;
							if (point < maxi) {
								aa = p;
								bb = q;
								cc = r;
								dd = s;
								maxi = point;
							}
						}
					}
				}
			}
		}
		if (aa != 0) {
			cout << 10 << " " << aa << endl;
		}
		if (bb != 0) {
			cout << 50 << " " << bb << endl;
		}
		if (cc != 0) {
			cout << 100 << " " << cc << endl;
		}
		if (dd != 0) {
			cout << 500 << " " << dd << endl;
		}
	}
	
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T&a , T b){
    if(a<b){
        a=b; return true;
    }else{
        return false;
    }
}
template<class T> inline bool chmin(T&a , T b){
    if(a>b){
        a=b; return true;
    }else{
        return false;
    }
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a[200005];
int b[200005];

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

    int j;
    for(int i=n;i*2>n;i--){
        if(a[i]==0){
            b[i] = 0;
        }else{
            b[i] = 1;
        }
        j=i;
    }
    for(int k=j-1;k>0;k--){
        int sum=0;
        for(int m=2;k*m<=n;m++){
            sum += b[k*m];
        }
        if(a[k]==1){
            if(sum%2==0) b[k]=1;
            else b[k]=0;
        }else{
            if(sum%2==0) b[k]=0;
            else b[k]=1;
        }
    }

    int cnt=0;
    for(int i=1;i<=n;i++){
        if(b[i]==1) cnt++;
    }

    cout << cnt << endl;
    for(int i=1;i<=n;i++){
        if(b[i]==1) cout << i << endl;
    }
}

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

int main()
{
	string s, t;
    cin >> s >> t;
	int n = s.size();
	vector<int> b(n);
	for (int i = 0; i < n - 1; i++) {
		b[i] = s[i + 1] - s[i];
		b[n - 1] = s[0] - s[n - 1];
	}
	vector<int> c(n);
	for (int i = 0; i < n - 1; i++) {
		c[i] = t[i + 1] - t[i];
		c[n - 1] = t[0] - t[n - 1];
	}
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	if (s == t && b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	long long a,b,k;
	cin>>a>>b>>k;
	if(k<=a) cout<<a-k<<" "<<b<<endl;
	else if(k<=a+b) cout<<0<<" "<<a+b-k<<endl;
	else cout<<0<<" "<<0<<endl;
	return 0;
} 

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

int N,K,L[50],res;

int main(){
	cin>>N>>K;
	for(int i=0;i!=N;++i){
		cin>>L[i];
	}
	sort(L,L+N);
	for(int i=0;i!=K;++i)
		res+=L[N-1-i];
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,K;
    cin >> h >> w >> K;
    char c[h][w];
    int ans=0;
    int tmp;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin >> c[i][j];
    for(int i=0;i<(1 << h);i++){
        for(int j=0;j<(1 << w);j++){
            tmp=0;
            for(int k=0;k<h;k++){
                for(int l=0;l<w;l++){
                    if( (i & (1 << k)) && (j & (1 << l)) )if(c[k][l]=='#')tmp++;
                }
            }
            if(tmp==K)ans++;
        }
    }
    cout << ans;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  int num[N+1] = {0};
  for (int i = 0; i < N; i++) num[A[i]]++;
  sort(num, num + N, greater<int>());
  int sum = 0;
  for (int i = 0; i < K; i++) sum += num[i];
  cout << N - sum << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  ll k,n;
  cin>>k>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll ans=INF;
  chmin(ans,k-(a[0]+k-a.back()));
  rep(i,n-1){
      chmin(ans,k-(a[i+1]-a[i]));
  }
  cout<<ans;
}


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


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, r; cin>>n>>r;

    if(n >= 10) cout << r << endl;
    else cout << 100 * (10 - n) + r << endl;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<double> t(n), v(n); 
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> t.at(i);
        sum += t.at(i);
    }
    for (int i = 0; i < n; i++) cin >> v.at(i); 
    
    vector<double> maxv(sum * 2 + 1);
    int s = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= t.at(i) * 2; j++)
        {
            if (maxv.at(s + j) > 0) maxv.at(s + j) = min(maxv.at(s + j), v.at(i));
            else maxv.at(s + j) = v.at(i);
        }
        s += t.at(i) * 2;
    }
    
    maxv.at(0) = 0;
    maxv.at(sum * 2) = 0;
    
    for (int i = 1; i <= sum * 2; i++)
    {
        maxv.at(i) = min(maxv.at(i), maxv.at(i - 1) + 0.5);
    }
    for (int i = sum * 2 - 1; i >= 0; i--)
    {
        maxv.at(i) = min(maxv.at(i), maxv.at(i + 1) + 0.5);
    }
    
    double ans = 0; 
    for (int i = 0; i < sum * 2; i++)
    {
        ans += (maxv.at(i) + maxv.at(i + 1)) * 0.5 / 2;
    }
    
    printf("%.10f\n", ans);
}

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

const int nm = 1e5;
int n, a[nm];
long long ans = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		ans += a[i] / 2;
		if (i < n - 1 && a[i] & 1 && a[i + 1] > 0) {
			ans++;
			a[i + 1]--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from collections import defaultdict
 
def compress(l):
    l = list(set(l))
    l.sort()
    idx = defaultdict(int)
    
    for i in range(len(l)):
        idx[l[i]] = i
    
    return idx
    
class BIT:
    #n:要素数
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(n+1)
    
    #i番目(0-indexed)の値にxを足す
    def add(self, i, x):
        i += 1
        
        while i<=self.n:
            self.bit[i] += x
            i += i&(-i)
    
    #0からi番目までの値の和を求める
    def acc(self, i):
        i += 1
        s = 0
        
        while i>0:
            s += self.bit[i]
            i -= i&(-i)
        
        return s

N, K = map(int, input().split())
a = [int(input()) for _ in range(N)]
l = [0]
acc = 0

for i in range(N):
    acc += a[i]
    l.append(acc-K*(i+1))

idx = compress(l)
bit = BIT(len(list(idx.keys())))
bit.add(idx[0], 1)
ans = 0
acc = 0

for i in range(N):
    acc += a[i]
    ans += bit.acc(idx[acc-K*(i+1)])
    bit.add(idx[acc-K*(i+1)], 1)
    
print(ans)

Measured memory_bytes: 81884
#include<bits/stdc++.h>
using namespace std;
#define N 100000
#define LL long long int
const LL MOD = 1e9+7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  int n, ans = 0;
  string a, b, c;
  cin >> n;
  cin >> a >> b >> c;
  for (int i=0;i<n;i++) {
    vector<char> x;
    x.push_back(a[i]);
    x.push_back(b[i]);
    x.push_back(c[i]);
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    ans += (int)x.size() - 1;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,ans;
  cin>>N;
  ans =0;
  rep(i,N){
  int l,r;
  cin>>l>>r;
  ans += r-l+1;
  }
  cout<<ans<<endl;
}

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

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n, d;
  cin >> n;
  vector<int> v(n), l(n), r(n);
  REP(i, n) {
    cin >> v[i];
  }
  l[0] = v[0];
  FOR(i, 1, n) {
    l[i] = max(l[i - 1], v[i]);
  }
  r[n - 1] = v[n - 1];
  for(int i = n - 2; i > 0; i--) {
    r[i] = max(r[i + 1], v[i]);
  }
  cout << r[1] << endl;
  FOR(i, 1, n - 1) {
    cout << max(l[i - 1], r[i + 1])<< endl;
  }
  cout << l[n - 2] << endl;
  return 0;
}


Measured memory_bytes: 3968
# coding: utf-8
s = raw_input();

k = u = p = c = 0;
for a in s:
    if a == 'K':
        k += 1;
    if a == 'U':
        u += 1;
    if a == 'P':
        p += 1;
    if a == 'C':
        c += 1;

print min(k,u,p,c);

Measured memory_bytes: 6436
S = input()
a = int(S[:2]); b = int(S[2:])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif 0 < a <= 12:
    print("MMYY")
elif 0 < b <= 12:
    print("YYMM")
else:
    print("NA")

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

typedef long long ll;

//const ll INF = 1LL<<60;

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

  vector<int>P(N),Q(N);

  rep(i,N) cin>> P[i];
  rep(i,N) cin>> Q[i];

  vector<int> a(N);
  rep(i,N) a[i] = i+1;

  map<vector<int>,int> mp;

  do{
    mp[a] = mp.size();
  }while(next_permutation(a.begin(), a.end()));


  cout<< abs(mp[P]- mp[Q]) <<endl;

}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B % A == 0) System.out.println(A + B);
        else System.out.println(B - A);
    }
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;


void solve(long long N){
    long long ans =0;
    for(int i=1;i<N;i++){
        ans+=i;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main(void) {
    int N; cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];

    long long sum = 0;
    for (int i = 0; i < N-1; i++)
        for (int j = i+1; j < N; j++)
            sum += d[i] * d[j];
    cout << sum << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x[5], y[5];
    scanf("%d %d %d %d", &x[1], &y[1], &x[2], &y[2]);
    int t = x[2] - x[1];
    int s = y[2] - y[1];
    x[3] = x[2] - s;
    y[3] = y[2] + t;
    x[4] = x[1] - s;
    y[4] = y[1] + t;
    printf("%d %d %d %d\n",x[3], y[3], x[4], y[4]);
    return 0;
}

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


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

class ACalc {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll a;
        in >> a;
        out << a + a*a + a*a*a << endl;
	}
};


int main() {
	ACalc solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3580
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) throws FileNotFoundException {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  }
 
}

Measured memory_bytes: 22612
#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)
#define P pair<int,int>
const int MOD=998244353;
const ll INF=2e15;
const double PI=acos(-1);

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

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    ll s=0;
    rep(i,n) {
        cin >> a[i];
        s+=a[i];
    }
    vector<ll> c(n);
    vector<pair<ll,ll>> p(n);
    ll r=k;
    rep(i,n) {
        ll rr=a[i]*k/s;
        c[i]=rr+1;
        r-=rr;
        p[i].first=a[i]/c[i];
        if (a[i]%c[i]>0) ++p[i].first;
        p[i].second=i;
    }
    sort(p.begin(),p.end(),greater<>());
    rep(i,r) {
        ++c[p[i].second];
    }
    ll ans=0;
    rep(i,n) {
        ll tans=a[i]/c[i];
        if (a[i]%c[i]>0) ++tans;
        ans=(tans>ans)?tans:ans;
    }
    cout << ans << endl;
    


    return 0;
}


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

const int INF = 1e+9;

int m[4][4];
bool search(int t){
	if(m[0][0] == t && ((m[0][0] == m[1][1] && m[0][0] == m[2][2])
	 				|| (m[0][0] == m[0][1] && m[0][0] == m[0][2])
	 				|| (m[0][0] == m[1][0] && m[0][0] == m[2][0]))) return true;
	else if(m[2][0] == t && ((m[2][0] == m[1][1] && m[1][1] == m[0][2])
						 || (m[2][0] == m[2][1] && m[2][1] == m[2][2]))) return true;
	else if(m[0][1] == t && m[0][1] == m[1][1] && m[1][1] == m[2][1]) return true;
	else if(m[1][0] == t && m[1][0] == m[1][1] && m[1][1] == m[1][2]) return true;
	else if(m[0][2] == t && m[0][2] == m[1][2] && m[1][2] == m[2][2]) return true;
	
	return false;
}

int main() {
	string s;
	while(cin >> s){
		for(int i = 0; i < s.size(); ++i){
			int t;
			if(s[i] == 'o')
				t = 0;
			else if(s[i] == 'x')
				t = 1;
			else
				t = 2;
			m[i / 3][i % 3] = t;
		}
		if(search(0)){
			cout << "o" << endl;
		}
		else if(search(1)){
			cout << "x" << endl;
		}
		else{
			cout << "d" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool F[1000000]={};


int main(){

	for(int i=2;i<1000000;i++)
	for(int j=2;j*j<=i;j++){
		if(i%j==0){F[i]=false;break;}
		else F[i]=true;
	}
	F[2]=true;F[3]=true;
	int N;
	while(cin>>N){
		int c=0;
		for(int i=0;i<=N;i++){
			if(F[i]==true){c++;//cout<<i<<endl;
			}}

		cout<<c<<endl;
	}
	return 0;

}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 100001
using namespace std;

ll n;

int main(){
    cin>>n;
    vector<int> a( n,0 );
    vector<int> b( n,0 );
    vector<int> c( n,0 );
    for(int i =0;i<n; i++){
        cin>>a[i];
    }
    for(int i =0;i<n; i++){
        cin>>b[i];
    }
    for(int i =0;i<n; i++){
        cin>>c[i];
    }
    
    sort(a.begin(), a.end() );
    sort(c.begin(), c.end() );
    ll ans;
    for(int i =0;i<n; i++){
        auto tt = lower_bound(a.begin(), a.end(), b[i] );
        auto ss = upper_bound(c.begin(), c.end(), b[i]) ;
        ll t = tt - a.begin();
        ll s = c.end() - ss; 
        ans += t*s;
    }
    cout<< ans  <<endl;
}

Measured memory_bytes: 1408
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    //グローバル変数を定義
    List<char[]> list = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        List<String> list = new ArrayList();

        for(int i=0; i<N; i++){
            String s = sc.next();
            list.add(s);
        }

        Collections.sort(list);

        String str = "";

        for(String s: list){
            str += s;
        }
        System.out.println(str);
    }
}


Measured memory_bytes: 24148
def f(l, n):
	ans = []
	for i in range(l):
	  ans.append(chr(n % 26 + ord('a')))
	  n//=26
	print(''.join(reversed(ans)))

n = int(input())
val = 26
adds = 0
lastval = 0
cnt = 1
while val < n:
  lastval = val
  val = (val*26)+26
  cnt+=1
f(cnt, n-lastval-1)

Measured memory_bytes: 9096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int m = min(a,b);
  int t;
  if (a + b <= n) {
    t = 0;
  } else {
    t = a + b - n;
  }
  cout << m << " " << t << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define mod 1000000007
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double PI = acos(-1.0);

void cp()
{
    int n;
    cin >> n;
    switch(n % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon";
        break;
    case 3:
        cout << "bon";
    }
}

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

Measured memory_bytes: 3648
N,K=map(int,input().split())
light=list(map(int,input().split()))
for k in range(K):
  imo=[0]*(N+1)
  for i in range(N):
    l=max(0,i-light[i])
    r=min(N-1,i+light[i])+1
    imo[l]+=1
    imo[r]-=1
  for i in range(1,N):
    imo[i]+=imo[i-1]
  if light==imo:
    break
  else:
    light=imo[:]
print(*light[:-1])

Measured memory_bytes: 168744
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}

ll pow(int a,int b,int mod){
    vector<bool> bit;
    for(b=b;b>0;b>>=1){
        bit.push_back(b&1);
    }
    vector<ll> fac(bit.size()); fac[0] = a;
    ll res = 1;
    for(int i=1;i<bit.size();i++){
        fac[i] = (fac[i-1] * fac[i-1])%mod;
    }
    for(int i=0;i<bit.size();i++){
        if(bit[i]) res*=fac[i];
        res%=mod;
    }
    return res;
}
class BigCombination{
private:
    const int MAX = 510'000;
    long long fac[510000], inv[510000];
public:
    BigCombination(){
        fac[0] = fac[1] = 1;
        for(int i=2; i<MAX; i++){
            fac[i] = (fac[i-1] * i) % MOD;
        }
        inv[MAX-1] = pow(fac[MAX-1], MOD-2, MOD);
        for(int i=MAX-1;i>0;i--){
            inv[i-1] = (inv[i] * i) % MOD;
        }
        for(int i=0;i<=5;i++){
            // fac[]
        }
    }

    long long combination(int n,int r){
        if(n<r) return 0;
        if(n==r) return 1;
        return ((fac[n] * inv[r])%MOD * inv[n-r]) % MOD;
    }
};


//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    BigCombination BC;
    int ans;
    
    for(int i=1;i<=K;i++){
        ans = BC.combination(N-K+1, i) * BC.combination(K-1,i-1) % MOD;
        cout << ans << endl;
    }



}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int a[4];
  rep(i,4){
    a[i] = 0;
  }  
  rep(i,s.length()){
    if(s[i] == 'E'){
      a[0]++;
    }
    if(s[i] == 'W'){
      a[1]++;
    }
    if(s[i] == 'S'){
      a[2]++;
    }
    if(s[i] == 'N'){
      a[3]++;
    }
  }
  if(a[0] > 0 && a[1] == 0){
	cout << "No" << endl;
    return 0;
  }
  if(a[0] == 0 && a[1] > 0){
	cout << "No" << endl;
    return 0;
  }
  if(a[2] > 0 && a[3] == 0){
	cout << "No" << endl;
    return 0;
  }
  if(a[2] == 0 && a[3] > 0){
	cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  // mid = 1 のとき繰り上がりの回数が非常に多くなることがある？
  bool good = true;
  REP(i, n-1) {
    if (a[i] >= a[i+1]) good = false;
  }
  if (good) {
    cout << 1 << '\n';
    return 0;
  }
  int low = 1, high = n; // (low, high]
  while (high - low > 1) {
    int mid = (low + high) / 2;
    bool ok = true;
    map<int, int> mp;
    REP(i, n-1) {
      if (a[i] >= a[i+1]) {
        mp.erase(mp.lower_bound(a[i+1]+1), mp.end());
        ++mp[a[i+1]];
        for (int j = a[i+1]; j >= 1; --j) {
          if (mp[j] < mid) break;
          if (j == 1) {
            ok = false;
            break;
          }
          mp.erase(j);
          ++mp[j-1];
        }
      }
      if (!ok) break;
    }
    if (ok) high = mid;
    else low = mid;
  }
  cout << high << '\n';
  return 0;
}


Measured memory_bytes: 1024
import sys
 
N = int(sys.stdin.readline())
if N == 0:
    print(0)
    sys.exit()
binN = ""
pN = abs(N)
while N != 0:
    if abs(N % -2) == 1:
        binN += "1"
    else:
        binN += "0"
    N += N%(-2)
    N //= -2
print(binN[::-1])

Measured memory_bytes: 9176