akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
 
static const int INF = 10000007;
 
int main()
{
	int h, w;
	int ma[101][101];
	cin >> h >> w;
	string in;
	for (int i = 1; i <= h; ++i)
	{
		cin >> in;
		for (int j = 1; j <= w; ++j)
		{
			ma[i][j] = (in[j-1] == '#');
		}
	}
	int dp[101][101] = {};
	for (int i = 0; i < 101; ++i)
	{
		for (int j = 0; j < 101; ++j)
		{
			dp[i][j] = INF;
		}
	}
 
	dp[1][0] = dp[0][1] = 0;
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			dp[i][j] = min((ma[i-1][j]==0&&ma[i][j]?1:0) + dp[i-1][j], (ma[i][j-1]==0&&ma[i][j]?1:0) + dp[i][j-1]);
		}
	}
	cout << dp[h][w] << endl;
	return 0;
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  string S;
  cin >> S;
  
  ll l = S.length();
  
  rep(i,l){
    if(S[i]=='?') S[i] = 'D';
  }
  
  cout << S;
  
  return 0;
}

Measured memory_bytes: 3724
using System;
using System.Linq;
using System.Collections.Generic;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var h = long.Parse(Console.ReadLine());

            var a = LargestExponent2(h);

            var ans = a*2 - 1;

            Console.WriteLine(ans);

        }

        private static double LargestExponent2(double a)
        {
            double x = 1;
            while (a>=x)
            {
                x *= 2;
            }
            return x/2;
        }
    }
}


Measured memory_bytes: 11092
n, m = map(int, input().split())

ac = set()
wa = {}

for i in range(m):
    p, s = input().split()
    if s == 'AC':
        ac.add(p)
        wa[p] = wa.get(p, 0)
    else:
        if not p in ac:
            wa[p] = wa.get(p, 0)+1

ans = sum([wa[i] for i in ac])

print(len(ac), ans)



Measured memory_bytes: 26024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int a[3];

long divCeil(long num1, long num2){
	return (num1+num2-1)/num2;
}

signed main(){
	for(int i = 0; i < 3; i++){
		scanf("%ld", &a[i]);
		if(a[i] % 2 == 0){
			printf("0\n");
			return 0;
		}
	}
	std::sort(a, a+3);
	printf("%ld\n", a[0] * a[1]);
	return 0;
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int h,n;
  cin>>h>>n;
  bool ans=false;
  rep(i,n){
    int k;
    cin>>k;
    h-=k;
    if(h<=0){
      ans=true;
      break;
    }
  }
  if(ans){cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MOD = 1e9+7;

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

    vi A(N);
    rep(i, N) cin >> A[i];

    vvi bits(N+1, vi(62, 0));
    rep(i, N) {
        int a = A[N-1-i];
        rep(j, 61) {
            bits[N-1-i][j] = bits[N-i][j];
            if((a>>j)&1) {
                bits[N-1-i][j]++;
            }
        }
    }

    /*rep(i, N+1) {
        rep(j, 61) cout << bits[i][j] << " ";
        cout << endl;
    }*/

    int res = 0;
    rep(i, N-1) {
        int a = A[i];
        int cnt = 0;
        rep(j, 61) {
            int t = pow(2, j);
            t %= MOD;
            if(!((a>>j)&1)) {
                //cout << t << " " << bits[i+1][j] << endl;
                
                res += t*(bits[i+1][j]);
                res %= MOD;
                
            } else {
                
                    res +=t*(N-i-1-bits[i+1][j]);
                    res %= MOD;
                
            }
        }
    }

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

Measured memory_bytes: 161664
g = [[] for _ in range(4)]
for _ in range(3):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].append(b)
  g[b].append(a)
  
for i in range(4):
  if len(g[i]) != 1 and len(g[i]) != 2:
    print('NO')
    exit()
else:
  print('YES')

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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] deque = new int[n];
        for(int i = 0 ; i < n ; i++) {
            deque[i] = scan.nextInt();
        }
        
        long[][] dp = new long[n][n];
        // We would have to get the 2d loop for getting the answer.
        for(int left = n-1 ; left >= 0 ; left--) {
            for(int right = left ; right < n ; right++) {
                if(left == right) {
                    dp[left][right] = deque[left];
                } else {
                    dp[left][right] = Math.max(deque[left] - dp[left+1][right] , deque[right]-dp[left][right-1]);
                }
            }
        }
        System.out.println(dp[0][n-1]); // last column in the first row will give the max gain for the entire range for the first player.
    }
}

Measured memory_bytes: 129900
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=0
ans+=max(a)
a.pop()
n-=2
while n:
#    print("#",ans)
    if n>=2:
        ans+=a.pop()*2
        n-=2
    else:
        ans+=a.pop()
        n-=1
print(ans)


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

typedef long long ll;
using namespace std;

int main() {
    int N, Z, W, a[2000];
    cin >> N >> Z >> W;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = abs(W - a[N - 1]);
    if (N != 1) {
        ans = max(ans, abs(a[N - 2] - a[N - 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e18;

double Mx0, Mxp, Mxm, mx0, mxp, mxm, My0, Myp, Mym, my0, myp, mym;

double solve_area(double t){
    double xmax = max({Mx0,Mxp+t,Mxm-t});
    double xmin = min({mx0,mxp+t,mxm-t});
    double ymax = max({My0,Myp+t,Mym-t});
    double ymin = min({my0,myp+t,mym-t});
    return (xmax-xmin) * (ymax-ymin);
}

signed main(){
    int n; cin >> n;
    Mx0 = Mxp = Mxm = My0 = Myp = Mym = -INF;
    mx0 = mxp = mxm = my0 = myp = mym = INF;

    REP(i,n){
        double x, y; char c; cin >> x >> y >> c;
        if(c == 'U'){
            chmax(Myp,y);
            chmin(myp,y);
            chmax(Mx0,x);
            chmin(mx0,x);
        }
        if(c == 'D'){
            chmax(Mym,y);
            chmin(mym,y);
            chmax(Mx0,x);
            chmin(mx0,x);
        }
        if(c == 'R'){
            chmax(Mxp,x);
            chmin(mxp,x);
            chmax(My0,y);
            chmin(my0,y);
        }
        if(c == 'L'){
            chmax(Mxm,x);
            chmin(mxm,x);
            chmax(My0,y);
            chmin(my0,y);
        }
    }

    set<double> time_table;
    time_table.insert(0);
    if(Mx0 > -INF and Mxp > -INF) time_table.insert(abs(Mx0-Mxp));
    if(Mx0 > -INF and Mxm > -INF) time_table.insert(abs(Mx0-Mxm));
    if(Mxp > -INF and Mxm > -INF) time_table.insert(abs(Mxp-Mxm)/2.0);
    if(My0 > -INF and Myp > -INF) time_table.insert(abs(My0-Myp));
    if(My0 > -INF and Mym > -INF) time_table.insert(abs(My0-Mym));
    if(Myp > -INF and Mym > -INF) time_table.insert(abs(Myp-Mym)/2.0);
    if(mx0 < INF and mxp < INF)   time_table.insert(abs(mx0-mxp));
    if(mx0 < INF and mxm < INF)   time_table.insert(abs(mx0-mxm));
    if(mxp < INF and mxm < INF)   time_table.insert(abs(mxp-mxm)/2.0);
    if(my0 < INF and myp < INF)   time_table.insert(abs(my0-myp));
    if(my0 < INF and mym < INF)   time_table.insert(abs(my0-mym));
    if(myp < INF and mym < INF)   time_table.insert(abs(myp-mym)/2.0);
    double ans = INF;
    for(auto v:time_table){
        chmin(ans,solve_area(v));
    }
    cout << fixed << setprecision(20.20) << ans << '\n';
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
class Dice{
public:
    int n1,n2,n3,n4,n5,n6;
    
    void East(){
        int t = n1;
        n1 = n4;
        n4 = n6;
        n6 = n3;
        n3 = t;
    }
    void West(){
        int t = n1;
        n1 = n3;
        n3 = n6;
        n6 = n4;
        n4 = t;
    }
    void South(){
        int t=n1;
        n1 = n5;
        n5 = n6;
        n6 = n2;
        n2 = t;
    }
    void North(){
        int t=n1;
        n1 = n2;
        n2 = n6;
        n6 = n5;
        n5 = t;
    }
};

int main() {
    Dice dice;
    int n1, n2, n3, n4, n5, n6;
    char ch;
    cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
    dice.n1 = n1;
    dice.n2 = n2;
    dice.n3 = n3;
    dice.n4 = n4;
    dice.n5 = n5;
    dice.n6 = n6;
    while(cin >> ch){
        if(ch=='E'){
            dice.East();
        }
        else if(ch=='W'){
            dice.West();
        }
        else if(ch=='S'){
            dice.South();
        }
        else if(ch=='N'){
            dice.North();
        }
    }
    cout << dice.n1 << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> a){
    ll s =0;
    REP(i, N) s+=a[i];

    vector<pll> r(N);
    REP(i, N){
        r[i].first = abs(a[i] * N - s);
        r[i].second = i;
    }
    sort(ALL(r));
    cout<< r[0].second<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, T = map(int, input().split())

ct = []
for i in range(N):
    c, t = map(int, input().split())
    ct.append([c,t])

ct2 = []
for (c,t) in ct:
    if t <= T:
        ct2.append([c,t])

if len(ct2) > 0:
    ct2.sort(key=lambda x:x[0])
    print(ct2[0][0])
else:
    print("TLE")


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        char[] c = sc.next().toCharArray();


        long[] p26 = new long[2000001];
        long[] p25 = new long[2000001];
        p25[0] = 1;
        p26[0] = 1;
        for(int i=0; i<2000000; i++) {
            p25[i+1] = p25[i] * 25 % mod;
            p26[i+1] = p26[i] * 26 % mod;
        }
        init(2000001);

        long res = 0;
        int s = c.length;
        for(int i=s; i<=k+s; i++) {
            long add = conv(i-1, s-1) * p25[i-s];
            add %= mod;
            add *= p26[k+s-i];
            add %= mod;
            res += add;
            res %= mod;
        }

        System.out.println(res);

    }


    private static long mod = 1000000007;
    static long[] fac;
    static long[] finv;
    static long[] inv;
    static void init(int max) {
        fac = new long[max];
        finv = new long[max];
        inv = new long[max];
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i=2; i<max; i++) {
            fac[i] = fac[i-1] * i % mod;
            inv[i] = mod - inv[(int)mod%i] * (mod / i) % mod;
            finv[i] = finv[i-1] * inv[i] % mod;
        }
    }
    static long conv(int n, int k) {
        if(n<k || n<0 || k<0) return 0;
        return fac[n] * (finv[k]*finv[n-k]%mod) % mod;
    }

}


Measured memory_bytes: 145964
// AtCoder キーエンス プログラミング コンテスト 2020
// A - Painting
// 2020.1.20 bal4u

#include <stdio.h>

int main()
{
	int H, W, N, t;
	
	scanf("%d%d%d", &H, &W, &N);
	if (H > W) t = H, H = W, W = t;
	printf("%d\n", (N-1)/W+1);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC111A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();

            string ans = "";
            for (int i = 0; i < 3; i++)
            {
                if (n[i] == '9') ans += "1";
                else ans += "9";
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	static int X;

	public static void main(String[] args) {
		Main prac = new Main();
		prac.execute();
	}

	public void execute() {

		try (Scanner sc = new Scanner(System.in)) {
			X = Integer.parseInt(sc.next());
			if(X==0) {
				System.out.println(1);
			}else {
				System.out.println(0);
			}
		}
	}
}

Measured memory_bytes: 35736
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, op, B) = nextList()
    val a = A.toLong()
    val b = B.toLong()
    println(if (op == "+") a + b else a - b)
}

Measured memory_bytes: 37872
#!/usr/bin/env python3
import sys
from itertools import *
from operator import itemgetter


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    items = [(P[i], Y[i]) for i in range(M)]

    key_to_value_to_rank = {}
    for key, sorted_items in groupby(sorted(items), key = itemgetter(0)):
        value_to_rank = dict((item, index + 1) for index, item in enumerate(map(lambda x: x[1], sorted_items)))
        key_to_value_to_rank[key] = value_to_rank

    for key, value in items:
        rank = key_to_value_to_rank[key][value]
        print('{0:06d}'.format(key, rank) + '{0:06d}'.format(rank))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 93020
#include <stdio.h>

using namespace std;

struct Node {
    Node() { left_child = right_child = parent = -1; };
    int left_child, right_child, parent;
};

void preORDER(Node order[], int id) {
    printf(" %d", id);
    if (order[id].left_child != -1) preORDER(order, order[id].left_child);
    if (order[id].right_child != -1) preORDER(order, order[id].right_child);
}

void inORDER(Node order[], int id) {
    if (order[id].left_child != -1) inORDER(order, order[id].left_child);
    printf(" %d", id);
    if (order[id].right_child != -1) inORDER(order, order[id].right_child);
}

void postORDER(Node order[], int id) {
    if (order[id].left_child != -1) postORDER(order, order[id].left_child);
    if (order[id].right_child != -1) postORDER(order, order[id].right_child);
    printf(" %d", id);
}

int main() {
    int n, id, left, right, root_id;
    scanf("%d", &n);
    Node order[n];
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &id, &left, &right);
        if (left != -1) {
            order[id].left_child = left;
            order[left].parent   = id;
        }
        if (right != -1) {
            order[id].right_child = right;
            order[right].parent   = id;
        }
    }

    for (root_id = 0; root_id < n; root_id++) {
        if (order[root_id].parent == -1) break;
    }

    printf("Preorder\n");
    preORDER(order, root_id);
    printf("\n");

    printf("Inorder\n");
    inORDER(order, root_id);
    printf("\n");

    printf("Postorder\n");
    postORDER(order, root_id);
    printf("\n");
}



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

int main()
{
    int n;
    cin >> n;
    int h[100];
    int high = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        if(h[i] >= high){
            high = h[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 26.11.2019 11:13:34       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  vector<pair<int, int>> e(n - 1);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    e[i] = make_pair(x, y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<long long> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<int> sz(n);
  vector<int> pv(n);
  vector<int> order;
  function<void(int, int)> Dfs = [&](int v, int pr) {
    order.push_back(v);
    sz[v] = 1;
    for (int u : g[v]) {
      if (u == pr) {
        continue;
      }
      pv[u] = v;
      Dfs(u, v);
      sz[v] += sz[u];
    }
  };
  Dfs(0, -1);
  vector<long long> res(n - 1);
  vector<long long> d(n);
  int id = -1;
  for (int i = 0; i < n - 1; i++) {
    int x = e[i].first;
    int y = e[i].second;
    if (sz[x] > sz[y]) {
      swap(x, y);
    }
    int u = sz[x];
    if (2 * u - n != 0) {
      res[i] = abs(s[x] - s[y]) / abs(2 * u - n);
    } else {
      id = i;
    }
    d[x] = res[i];
  }
  if (id != -1) {
    long long sum = 0;
    for (int i = 1; i < n; i++) {
      d[order[i]] += d[pv[order[i]]];
      sum += d[order[i]];
    }
    res[id] = (s[0] - sum) / (n / 2);
  }
  for (int i = 0; i < n - 1; i++) {
    cout << res[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 17016
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int n = s.length();
    StringBuilder buf = new StringBuilder();
    for (int i = 0;i<n;i++) {
      buf.append(t.substring(i));
      if (i>0) {
        buf.append(t.substring(0,i));
      }
      if (s.equals(buf.toString())) {
        System.out.println("Yes");
        return;
      }
      buf.delete(0,n);
    }
    System.out.println("No");
  }
}


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

int main() {
  int X, Y; cin >> X >> Y;
  int ans = 0;
  if (X == 3) ans += 100000;
  if (X == 2) ans += 200000;
  if (X == 1) ans += 300000;
  if (Y == 3) ans += 100000;
  if (Y == 2) ans += 200000;
  if (Y == 1) ans += 300000;
  if (X == 1 && Y == 1) ans += 400000;
  cout << ans << endl;
}

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

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var n = int.Parse(text);
            text = Console.ReadLine();
            var list = text.Split(' ').Select(x => int.Parse(x)).ToList();

            var count = 0;
            for(int i = 0; i < list.Count; i++){
                var item = list[i];

                if (item != (i + 1)){
                    count++;
                }
            }

            if (count <= 2){
                Console.WriteLine("YES");
            }
            else{
                Console.WriteLine("NO");

            }

        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int K = stdIn.nextInt();
		String S = stdIn.next();
		if(S.length() > K){
			System.out.println(S.substring(0, K) + "...");
		}
		else{
			System.out.println(S);
		}
		stdIn.close();
	}
}

Measured memory_bytes: 38484
from collections import deque

n = int(input())
ans = [0] * n
visited = [False] * n
G = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append([v, w])
    G[v].append([u, w])

q = deque([])
q.append(0)
visited[0] = True

def dfs():
    while q:
        p = q.pop()
        for u, w in G[p]:
            if visited[u]: continue
            else:
                ans[u] = (ans[p] + w) % 2
                visited[u] = True
                q.append(u)

dfs()

for i in range(n):
    print(ans[i])

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

using namespace std;

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

    if (fabs(x - a) < fabs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
"""
def solve(N, X):
	xmax = ymax = zmax = N
	xmin = ymin = zmin = 0

	org = [N-X, X, 0]
	pos = [N-X, X, 0]
	dir = (0, -1, 1)
	ans = 0

	while True:
		if dir == (0,-1,1):
			if pos[1]-ymin < zmax-pos[2]:
				d = pos[1]-ymin
				pos[1] -= d
				pos[2] += d
				dir = (-1,1,0)
				xmax = pos[0]
			else:
				d = zmax-pos[2]
				pos[1] -= d
				pos[2] += d
				dir = (1,0,-1)
				xmin = pos[0]
		elif dir == (1,0,-1):
			if pos[2]-zmin < xmax-pos[0]:
				d = pos[2]-zmin
				pos[2] -= d
				pos[0] += d
				dir = (0,-1,1)
				ymax = pos[1]
			else:
				d = xmax-pos[0]
				pos[2] -= d
				pos[0] += d
				dir = (-1,1,0)
				ymin = pos[1]
		elif dir == (-1,1,0):
			if pos[0]-xmin < ymax-pos[1]:
				d = pos[0]-xmin
				pos[0] -= d
				pos[1] += d
				dir = (1,0,-1)
				zmax = pos[2]
			else:
				d = ymax-pos[1]
				pos[0] -= d
				pos[1] += d
				dir = (0,-1,1)
				zmin = pos[2]
		else:
			print "error"
			break

		ans += d

		if pos==org:
			break
	return ans

for N in range(2, 17):
	print N,
	for X in range(1, N):
		print solve(N, X)/3,
	print

"""

import fractions
N, X = map(int, raw_input().split())
g = fractions.gcd(N, X)
print 3*g*(N/g-1)


Measured memory_bytes: 8352
#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() {
    ll N;
    cin >> N;
    for (ll h = 1; h <= 3500; ++h)
        for (ll n = 1; n <= 3500; ++n) {
            ll w_d = 4 * h * n - N * (n + h);
            ll w_n = N * h * n;
            if (w_d <= 0 || w_n % w_d != 0) continue;
            ll w   = w_n / w_d;
            if (w > 3500 || w < 1) continue;
            ll n_n = 4 * h * n * w;
            ll n_d = h * n + n * w + w * h;
            if (n_n % n_d != 0) continue;
            if (N == n_n / n_d)
                return cout << h << " " << n << " " << w << endl, 0;
        }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;

int main() {
	cin >> s;
	
	int v = 0;
	inc(i, 4) { v += (s[i] == '+' ? +1 : -1); }
	
	cout << v << endl;
	
	return 0;
}


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

int main() {
	int X;
	cin >>X;
	int c,p;
	c=0;
	p=X;
	while(c==0){
		c=1;
		for(int i=2;i<=sqrt(p);i++){
			if(p%i==0){
				c=0;
			}
		}
		p++;
	}
	cout <<p-1<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long power = 1;
		
		for(int i = 0; i < n; i++) {
			power = power * (i+1) % (long)(1e9+7);
		}
		
		System.out.println(power);
		
	}

}


Measured memory_bytes: 23764
N, K = [int(x) for x in input().split()]
td = sorted([[int(x) for x in input().split()] for _ in range(N)],
            key=lambda x: x[1], reverse=True)
INF = 10**9
# print(td)

first = []
second = []
kind = set()
for i in range(K):
    if td[i][0] not in kind:
        first.append(td[i])
        kind.add(td[i][0])
    else:
        second.append(td[i])

yummy = sum([x[1] for x in first + second])
best_ans = yummy + len(kind)**2

for k in range(K, N):
    if len(second) == 0:
        break
    if td[k][0] in kind:
        continue

    a = second.pop(-1)
    yummy -= a[1]
    kind.add(td[k][0])
    first.append(td[k])
    yummy += td[k][1]
    ans = yummy + len(kind)**2
    # print(first, second, ans)
    if best_ans < ans:
        best_ans = ans
print(best_ans)


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

using namespace std;

#define REP(i,n) for(int i = 0; i < n ; i++)
set<char> vowel{'a','e','i','o','u'};

int main()
{
  int n;
  while(cin >> n,n){
    vector<string> vs;
    REP(i,n){
      string s;
      cin >> s;
      string st(s.substr(0,1));
      for(auto it = s.begin();(it+1) != s.end();++it){
        if(vowel.find(*it) != vowel.end())
          st += *(it+1);
      }
      vs.push_back(st);
    }
    int ans = -1;
    REP(k,50){
      bool ok = true;
      set<string> ss;
      REP(i,vs.size()){
        auto sub = vs[i].substr(0,min(k+1,(int)vs[i].size()));
        if(ss.find(sub) != ss.end()){
          ok = false;
          break;
        }
        else{
          ss.insert(sub);
        }
      }
      if(ok){
        ans = k+1;
        break;
      }
  }

    cout << ans << endl;

    }


}

Measured memory_bytes: 3208
n = int(input())
ans = ''
i = 1
while i <= n:
    x = i
    if (x % 3) == 0:
        ans += ' ' + str(i)
        i += 1
    elif (x % 10) == 3:
        ans += ' ' + str(i)
        i += 1
    else:
        while True:
            x = (x // 10)
            if x == 0:
                i += 1
                break
            elif (x % 10) == 3:
                ans += ' ' + str(i)
                i += 1
                break
print(ans)


Measured memory_bytes: 5624
#coding:utf-8
#1_5_A
from itertools import combinations

n = int(input())
A = list(map(int, input().split()))
q = int(input())
ms = list(map(int, input().split()))

numbers = []
for i in range(1, n+1):
    for com in combinations(A, i):
        numbers.append(sum(com))

for m in ms:
    if m in numbers:
        print("yes")
    else:
        print("no")

Measured memory_bytes: 45016
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
 rep(i,0,n) 
 {
   cin>>b>>c;
   if(c<=a) l=min(l,b);
 }
 if(l==1e9+7) cout<<"TLE";
 else
 cout<<l;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

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

    vector<P> task(n);

    rep(i, n) cin >> task[i].second >> task[i].first;
    sort(task.begin(), task.end());

    CumulativeSum times(n);

    rep(i, n) {
        P p = task[i];
        times.set(i, p.second);
    }
    times.calculate();

    rep(i, n) {
        if (times.getSum(i) > task[i].first) {
            cout << "No" << endl;
            ret();
        }
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define ill long long
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  ill n, k;
  cin >> n >> k;
  ill m = n % k;
  cout << min(m, k - m);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int x,y;
    do{
        cin>>x>>y;
        if(x==0&&y==0)break;
        if(x<=y){
            cout<<x<<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
    }while(x!=0||y!=0);
    return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    ll n, mn=0,mx=0;
    cin >> n;
    map<ll,ll> rng;
    ll xt=0;
    while(n--)
    {

        ll x;
        cin >> x;
        ll r;
        if(x >=1 && x <= 399 ) r=1;
        if(x >=400 && x <= 799 ) r=2;
        if(x >=800 && x <= 1199 ) r=3;
        if(x >=1200 && x <= 1599 ) r=4;
        if(x >=1600 && x <= 1999 ) r=5;
        if(x >=2000 && x <= 2399 ) r=6;
        if(x >=2400 && x <= 2799 ) r=7;
        if(x >=2800 && x <= 3199 ) r=8;
        if(x >= 3200) r = 9;
        if(r==9) xt++;
        else
        {

            if(rng[r]==0)
                mn++;
        }
        rng[r]=1;
    }
    cout << max(mn,1LL) << " " << mn+xt;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

sort_list = sorted(a)
rev_list = list(reversed(sort_list))

alice_sum = 0
bob_sum = 0

alice = rev_list[::2]
bob = rev_list[1::2]

for i in alice:
    alice_sum += i
for i in bob:
    bob_sum += i

ans = alice_sum - bob_sum

print(ans)





Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

int main()
{
    double a,b,x;
    cin >> a >> b >> x;
    double theta = atan(a/b)/M_PI*180.0;
    if (x == b*a*a){
        cout << 0 << endl;
        return 0;
    }
    if(x <= b*a*a/2.0){
        cout << fixed << setprecision(10)<< 90-atan(x/a/b*2/b)/M_PI*180.0 << endl;
        return 0;
    }else{
        double c = x- (b*a*a/2.0);
        c = c/a*2/a;
        double gammma = atan(a/(b-c))/M_PI*180.0;
        cout << fixed << setprecision(10)<< 90.0 - gammma << endl;
        return 0;
    }
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  if(n<10){
    cout<<n<<endl;
  }
  else if(n<100){
    cout<<"9"<<endl;
  }
  else if(n<1000){
    cout<<9+n-100+1<<endl;
  }
  else if(n<10000){
    cout<<"909"<<endl;
  }
  else if(n<100000){
    cout<<909+n-10000+1<<endl;
  }
  else{
    cout<<"90909"<<endl;
  }

}

Measured memory_bytes: 256
num = gets.chomp

result = ''
result = 'NA' if num.slice(0..1) == '00' && num.slice(2..3) == '00'

result =
  if (1..12).include? num.slice(0..1).to_i
    if (1..12).include? num.slice(2..3).to_i
      'AMBIGUOUS'
    else
      'MMYY'
    end
  else
    if (1..12).include? num.slice(2..3).to_i
      'YYMM'
    else
      'NA'
    end
  end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int H, W, N;
int px, py;
string S, T;
vector<int> dists(4); // distance from the piece to bounds: L, R, U, D

void UpdateDists() {
    dists[0] = px;
    dists[1] = W - px - 1;
    dists[2] = py;
    dists[3] = H - py - 1;
}

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

    cin >> H >> W >> N >> py >> px >> S >> T;
    --py; --px; // 0-indexed

    // rest commands: L, R, U, D
    vector<int> cTaka, cAoki;
    cTaka = vector<int>(4, 0);
    cAoki = vector<int>(4, 0);

    rep(i, 0, N) {
        switch(S[i]) {
            case 'L': ++cTaka[0]; break;
            case 'R': ++cTaka[1]; break;
            case 'U': ++cTaka[2]; break;
            case 'D': ++cTaka[3]; break;
        }
        switch(T[i]) {
            case 'L': ++cAoki[0]; break;
            case 'R': ++cAoki[1]; break;
            case 'U': ++cAoki[2]; break;
            case 'D': ++cAoki[3]; break;
        }
    }

    vector<int> cScores(4);

    rep(i, 0, N) {
        UpdateDists();

        // Takahashi's turn
        rep(i, 0, 4) {
            cScores[i] = cTaka[i] - dists[i];
        }
        bool wantsToUseL = (cScores[0] >= cScores[1]) ? true : false;
        bool wantsToUseU = (cScores[2] >= cScores[3]) ? true : false;

        switch(S[i]) {
            case 'L':
                if (wantsToUseL) px--;
                break;
            case 'R':
                if (!wantsToUseL) px++;
                break;
            case 'U':
                if (wantsToUseU) py--;
                break;
            case 'D':
                if (!wantsToUseU) py++;
                break;
        }

        if (py < 0 or px < 0 or py >= H or px >= W) {
            cout << "NO\n";
            return 0;
        }

        UpdateDists();

        // Aoki's turn
        rep(i, 0, 4) {
            cScores[i] = cAoki[i] + dists[i];
        }
        wantsToUseL = (cScores[0] >= cScores[1]) ? true : false;
        wantsToUseU = (cScores[2] >= cScores[3]) ? true : false;

        switch(T[i]) {
            case 'L':
                if (wantsToUseL) px--;
                break;
            case 'R':
                if (!wantsToUseL) px++;
                break;
            case 'U':
                if (wantsToUseU) py--;
                break;
            case 'D':
                if (!wantsToUseU) py++;
                break;
        }
    }

    cout << "YES\n";
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int A[N];
  map<int, int> mp;
  for(int i=0; i<N; ++i) {
    cin >> A[i];
    ++mp[A[i]];
  }
  if(mp.size()<=K){
    cout << "0";
    return 0;
  }

  int count[mp.size()];
  int j=0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
      count[j]=itr->second;
      ++j;
   }

   sort(count, count+mp.size());
   int ans=0;
   for(int i=0; i<(mp.size()-K); ++i){
     ans += count[i];
   }

   cout << ans;

  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
char ch;
int cnt[26] ={};
while(cin >>ch){
ch=tolower(ch);
if(isalpha(ch)){
cnt[ch-'a']++;
}
}
for(int i=0;i<26;i++){
printf("%c : %d\n",i+'a',cnt[i]);
}
return 0;
}

Measured memory_bytes: 3200
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int d = scanner.nextInt();
			int sum = 0;
			for (int i = 0; i < 600; i += d) {
				sum += (i * i) * d;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 25784
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

void solve(){
    char c;
    cin>>c;
    if(c>='a' && c<='z'){
        cout<<'a'<<endl;
    }else{
        cout<<'A'<<endl;
    }
}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	int L, R, d;
	cin >> L >> R >> d;
	cout << R / d - (L - 1) / d << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  string X;
  cin >> X;
  if(X=="T") cout << "A" << endl;
  if(X=="A") cout << "T" << endl;
  if(X=="C") cout << "G" << endl;
  if(X=="G") cout << "C" << endl;
}

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

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

int main(void) {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int ans = 1e9;
	rep(i, n) {
		// printf("i %d\n", i);
		vector<vector<int>>	v;
		// for (int l = 0, r = 0; l < n, r < n; ++l) {
		int l = 0, r = 0;
		while(l < n && r < n) {
			r = l;
			vector<int> tmp;
			while (r < n && a[r] >= a[i]) {
				// printf("a %d\n", a[r]);
				tmp.push_back(a[r]);
				r++;
			}
			// [l, r)はすべてa[i]以上
			// printf("%d %d %d\n", l, r, tmp.size());
			if (r > l) v.push_back(tmp);
			if (l != r) l = r;
			else l = r + 1;
		}

		vector<int> select;
		for (auto u : v) {
			sort(u.begin(), u.end());
			if (u.size() >= k) rep(j, u.size() - k + 1) {
				// printf("j %d %d\n", j, u[j]);
				select.push_back(u[j]);
			}
		}
		if (select.size() < q) continue;
		sort(select.begin(), select.end());

		ans = min(ans, select[q - 1] - a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000


int linearSearch(){
  int i,j,count,k,l;
  int s[MAX],t[MAX];

  count = 0;
  
  scanf("%d",&k);
  for(i = 0; i < k; i++)
    scanf("%d",&s[i]);
  
  scanf("%d",&l);
  for(i = 0; i < l; i++)
    scanf("%d",&t[i]);

  if(k > l){
    for(i = 0; i < l; i++)
      for(j = 0; j < k; j++)
	if(t[i] == s[j]){
	  count++;
	  break;
	}
  }
  
  else{
    for(i = 0; i < k; i++)
      for(j = 0; j < l; j++)
	if(s[i] == t[j]){
	  count++;
	  break;
	}
  }
    
  return count;
}

int main(){
  
  printf("%d\n",linearSearch());
  
  return 0;
}



Measured memory_bytes: 2144