akhauriyash/Code-Regression huggingface dataset:
def main():
    sx, sy, tx, ty = map(int, input().split())
    x = tx - sx
    y = ty - sy
    s = "R"*x + "U"*y
    s += s.translate(str.maketrans({"U": "D",
                                    "D": "U", "L": "R", "R": "L"}))
    tmp = "D" + "R"*(x+1) + "U"*(y+1) + "L"
    s += tmp + tmp.translate(str.maketrans({"U": "D",
                                            "D": "U", "L": "R", "R": "L"}))
    print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9152
#include <stdio.h>
#define N 500001

int key[N];
int left[N];
int right[N];
int root;
int head;

void printpre(int x){
    if(x == -1) return;
    printf(" %d", key[x]);
    printpre(left[x]);
    printpre(right[x]);
}

void printin(int x){
    if(x == -1) return;
    printin(left[x]);
    printf(" %d", key[x]);
    printin(right[x]);
}

int find(int x, int y){
    if(x == -1)
        return -1;
    if(y < key[x])
        return find(left[x], y);
    else if(y == key[x])
        return x;
    else
        return find(right[x], y);
}

void insert(int x){
    int y = -1;
    int z = root;
    while(z != -1){
        y = z;
        if(x < key[z])
            z = left[z];
        else
            z = right[z];
    }

    if(y == -1) {
        root = head;
    } else if(x < key[y]) {
        left[y] = head;
    } else {
        right[y] = head;
    }
    key[head] = x;
    left[head] = -1;
    right[head] = -1;
    head++;
}

int main(void){
    int n;
    scanf("%d", &n);
    root = -1;
    while(n--){
        char cmd[8];
        scanf("%s", cmd);
        if(cmd[0] == 'i'){
            int z;
            scanf("%d", &z);
            insert(z);
        } else if(cmd[0] == 'f') {
            int z;
            scanf("%d", &z);
            printf("%s\n", find(root, z) == -1 ? "no" : "yes");
        } else {
            printin(root);
            puts("");
            printpre(root);
            puts("");
        }
    }
}




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

void maxHeapify(vector<int>& v, int i)
{
    int l = 2 * i + 1;
    int r = 2 * i + 2;
    int largest;
    if(l < v.size() && v[l] > v[i]){
        largest = l;
    } else {
        largest = i;
    }
    if(r < v.size() && v[r] > v[largest]){
        largest = r;
    }
    if(largest != i){
        swap(v[i],v[largest]);
        maxHeapify(v, largest);
    }
}

void buildMaxHeap(vector<int>& v)
{
    for(int i = (v.size() - 1) / 2; i >= 0; --i){
        maxHeapify(v, i);
    }    
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    
    buildMaxHeap(v);
    
    for(int i = 0; i < n; ++i){
        cout << ' ' << v[i];
    }
    cout << endl;
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int n = in();
	string s, t;
	cin >> s >> t;

	int beet = 0;
	rep(i, n) {
		if (s[i] == t[beet]) {
			beet++;
		}
	}

	cout << 2 * n - beet << endl;
}



Measured memory_bytes: 256
//ΔAGC024B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,a[N];
int main()
{
	int i,x,ans;
	scanf("%d",&n);
	for(i=1;i<=n;i=i+1){
		scanf("%d",&x);
		a[x]=i;
	}
	ans=0;
	for(i=1;i<=n;i=i+1){
		x=1;
		while(a[i]<a[i+1]){
			i++;
			x++;
		}
		ans=max(ans,x);
	}
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int a[205][205],n,m,x,s;
int b[11][11];

int main()
{
	cin>>n>>m;
	for(int i=0;i<=9;i++)
	for(int j=0;j<=9;j++)
	cin>>b[i][j];
	
	for(int k=0;k<=9;k++)
	for(int i=0;i<=9;i++)
	for(int j=0;j<=9;j++)
	{
		if(b[i][j]>b[i][k]+b[k][j])
		b[i][j]=b[i][k]+b[k][j];
	}
	
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		cin>>x;
		if(x!=-1&&x!=1)
		s+=b[x][1];
	}
	cout<<s;
	
	
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(input())
 
l0 = []
l1 = []
pred = s[0]
if s[0] == "0":
    l0.append(1)
    l1.append(0)
else:
    l1.append(1)
 
for i in range(1,n):
    if pred == s[i]:
        if s[i] == "0":
            l0[-1] += 1
        else:
            l1[-1] += 1
    else:
        if s[i] == "0":
            l0.append(1)
        else:
            l1.append(1)
    pred = s[i]
if s[-1] == "0":    
    l1.append(0)
 
ans = sum(l0[:k])+sum(l1[:k+1])
tmp = ans
for i in range(k,(len(l0))):
    tmp -= l0[i-k]
    tmp -= l1[i-k]
    tmp += l0[i]
    tmp += l1[i+1]
    ans = max(ans, tmp)
print(ans)

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

int main(){
  int N, K, X, Y; cin >> N >> K >> X >> Y;
  int ans = 0;
  
  ans += X * min(N, K);
  if(N > K)
    ans += Y * (N - K);
  
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
int main() 
{ 
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	string s;
	string t;
	cin>>s>>t;
	int n = s.length();
	int m = t.length();
	int dp[n+1][m+1];
	for (int i = 0; i<=n; ++i)
	{
		dp[i][0]=0;
	}
	for (int i = 0; i<=m; ++i)
	{
		dp[0][i]=0;
	}
	
	for (int i = 1; i<=n; ++i)
	{
		for (int j = 1; j<=m; ++j)
		{
			if(s[i-1]==t[j-1]){
				dp[i][j] = 1 + dp[i-1][j-1];
			}
			else{
				dp[i][j] = max(dp[i][j-1], dp[i-1][j]);	
			}
		}
	}


	char lcs[dp[n][m]+1];
	int index = dp[n][m];
	lcs[index] = '\0';
	int i=n;
	int j=m;

	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			lcs[index-1] = s[i-1];
			i--;
			j--;
			index--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	cout<<lcs;

} 

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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_in_out;
    string s;
    cin >> s;
    int n = s.length();
    for(int i = 0; i < n; i++)
    {
        cout << "x";
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include<string.h>
using namespace std;

int main(){
  int a,b;
  int i = 0,k = 0;
  string s = "#";
  while(1){
    cin >> a >> b;
    while(i < a){
      while(k < b ){
        cout << s;
        k++;
      }
      k = 0;
      i++;
      cout << endl;
    }
     i = 0;
    if( a == 0 && b ==0){
      break;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int f[3005],a[3];
signed main(){
	f[0]=1;
	int n;
	cin>>a[0]>>a[1]>>a[2]>>n;
	for(int i=0;i<3;++i){
		for(int j=a[i];j<=n;++j)
			f[j]+=f[j-a[i]];
	} 
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>

int main(){
    int r, c, a[101][101];
    scanf("%d %d", &r, &c);
    for (int i = 0; i < r; i++){
        a[i][c] = 0;
    }
    for(int i = 0; i<c; i++){
        a[r][i] = 0;
    }
    a[r][c] = 0;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            scanf("%d", &a[i][j]);
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
            printf("%d ", a[i][j]);
        }
        printf("%d\n", a[i][c]);
    }
    for(int i = 0; i < c; i++){
        printf("%d ", a[r][i]);
    }
    printf("%d\n", a[r][c]);
    return 0;
}


Measured memory_bytes: 2708
n = gets.to_i
ary = Array.new(n+1,[0,0,0].to_a)
s = 0
n.times do |i|
  t,x,y = gets.strip.split.map(&:to_i)
  ary[i+1] = [t,x,y].to_a
  lag = ary[i+1][0]-ary[i][0]
  xs = (ary[i+1][1]-ary[i][1]).abs
  ys = (ary[i+1][2]-ary[i][2]).abs
  if xs<=lag && ys<=lag && xs+ys<=lag && (xs+ys+lag)%2==0
    s += 1
  end
end
if s == n
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 20920
input = $stdin.read.chomp.split("\n")

N, M = input.shift.split(" ").map(&:to_i)

queue = []
input = input.map{|line| line.split(" ").map(&:to_i) }

map = {}
input.each do |a, b|
  map[a] ||= []
  map[b] ||= []
  map[a] << b
  map[b] << a
end

class P
  attr_reader :n,:prev,:dist
  def initialize(n, prev,dist)
    @n = n
    @prev = prev
    @dist = dist
  end
end

queue << P.new(1,nil,0)

ans = {}
visited = {}
until (p = queue.shift).nil?
  if visited[p.n]
    next
  end
  if p.n != 1
    if ans[p.n] && ans[p.n].dist > p.prev.dist
      ans[p.n] = p.prev
    else
      ans[p.n] = p.prev
    end
  end
  if map[p.n]
    queue.concat map[p.n].map {|n| P.new(n, p.n, p.dist+1)}
  end
  visited[p.n] = true
end


puts "Yes"
(2..N).each do |i|
  puts ans[i]
end

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

char s[100005];

int main(){
	scanf("%s", s);
	int l = strlen(s);

	int ans = 0;
	int r = l-1;
	l = 0;
	while(l <= r){
		if(s[l] == 'x' && s[r] != 'x') ans++, l++;
		else if(s[l] != 'x' && s[r] == 'x')  ans++, r--;
		else if(s[l] != s[r]){
			ans = -1;
			break;
		}
		else l++, r--;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
/**
 *    author:  tourist
 *    created: 22.10.2017 08:50:34       
**/
#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9;

const int N = 1234567;

char s[N];
int f[N];
int best[1 << 26];
int a[N];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  a[0] = 0;
  for (int i = 0; i < n; i++) {
    a[i + 1] = a[i] ^ (1 << (s[i] - 'a'));
  }
  for (int t = 0; t < (1 << 26); t++) {
    best[t] = inf;
  }
  f[0] = 0;
  best[a[0]] = 0;
  for (int i = 1; i <= n; i++) {
    f[i] = inf;
    for (int bit = -1; bit < 26; bit++) {
      int new_a = a[i];
      if (bit >= 0) {
        new_a ^= (1 << bit);
      }
      f[i] = min(f[i], best[new_a] + 1);
    }
    best[a[i]] = min(best[a[i]], f[i]);
  }
  printf("%d\n", f[n]);
  return 0;
}


Measured memory_bytes: 267392
import math

nums = list(map(int, input().split()))
n = nums[0] #偶数
m = nums[1] #奇数

if n == 0:
    print(int(m*(m-1) / 2))
elif m == 0:
    print(int(n*(n-1) / 2))

elif n == 1 and m == 1:
    print(0)
else:
    result = m*(m-1) / 2 + n*(n-1) / 2
    print(int(result))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;

    int n = s.length();
    bool flag = true;
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]){
            flag = false;
            break;
        }
    }

    if(flag == true){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;

}

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

int cost[20][20];

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<20;i++)for(int j=0;j<20;j++)cost[i][j]=1<<29;
	for(int i=0;i<20;i++)cost[i][i]=0;
	for(int i=0;i<m;i++){
		int a,b,c,d;
		cin>>a;
		cin.ignore();
		cin>>b;
		cin.ignore();
		cin>>c;
		cin.ignore();
		cin>>d;
		a--;b--;
		cost[a][b]=c;
		cost[b][a]=d;
	}
	int x1,x2,y1,y2;
	cin>>x1;
	cin.ignore();
	cin>>x2;
	cin.ignore();
	cin>>y1;
	cin.ignore();
	cin>>y2;
	x1--;x2--;
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
	cout<<y1-y2-cost[x1][x2]-cost[x2][x1]<<endl;
	return 0;
}

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

int main(){
  	int ans=0,count,j;
	string s;
  	cin>>s;
  	for(int i=0;i<s.size();++i){
      	count=0,j=0;
        while(s[i+j]=='A'||s[i+j]=='T'||s[i+j]=='G'||s[i+j]=='C'){
            	++count;++j;
            }ans=max(count,ans);
        }
	cout<<ans<<endl;return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	vi d(n);
	for (int i = 0; i < n; i++) scanf("%d", &d[i]);
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = i+1; j < n; j++)
			ans += d[i]*d[j];
	printf("%d\n", ans);
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int A[] = new int[N + 1];
            int B[] = new int[N];
            for (int i = 0; i < N + 1; i++) {
                A[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < N; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                int tmp = Math.min(B[i], A[i]);
                ans += tmp;
                tmp = Math.min(B[i] - tmp, A[i + 1]);
                A[i + 1] -= tmp;
                ans += tmp;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 53096
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
char s[3005], t[3005];
int dp[3005][3005];
int main() {
  int n, m, x, y;
  scanf("%d %d", &n, &m);
  scanf("%s", s + 1);
  strcpy(t + 1, s + 1);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    y++;
    sort(s + x, s + y);
    sort(t + x, t + y);
    reverse(t + x, t + y);
  }
  dp[0][0] = 1;
  int atleast = 0, atmost = 0;
  for (int i = 1; i <= n; i++) {
    atleast += s[i] == '1';
    atmost += t[i] == '1';
    for (int j = atleast; j <= atmost; j++) {
      dp[i][j] = dp[i - 1][j] + (j > 0 ? dp[i - 1][j - 1] : 0);
      if (dp[i][j] >= MOD) dp[i][j] -= MOD;
    }
  }
  printf("%d\n", dp[n][atleast]);
  return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  if (str.at(0) == '7' || str.at(1) == '7' || str.at(2) == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3568
import java.util.Scanner;

/**
 * http://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_d
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final long K = sc.nextLong();
		final long[] a = new long[N];
		final long[] b = new long[N];
		for (int i = 0; i < N; ++i) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		sc.close();
		
		long ans = 0;
		for (int j=0; j<N; j++) {
			if( (a[j] & K) == a[j] ) ans +=b[j];
		}
		
		for (int i = 0; i <= 30; i ++) {
			long bit = 1<<i;
			if ((K & bit) != 0) {
				long x = (K^bit)|(bit-1);
				long sum = 0;
				for (int j=0; j<N; j++) {
					if( (a[j] & x) == a[j] ) sum+=b[j];
				}
				ans = Math.max(sum, ans);
			}
		}
		 
		System.out.println(ans);
		
	}
	
}


Measured memory_bytes: 91240
import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{min, max, abs}

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val H = sc.nextInt()
    val W = sc.nextInt()
    val N = sc.nextInt()
    val p = mutable.Map[(Int, Int), Int]().withDefault(_ => 0)

    (0 until N) foreach { _ =>
      val a = sc.nextInt() - 1
      val b = sc.nextInt() - 1
      for {
        i <- -2 to 0
        j <- -2 to 0
        a0 = a + i
        b0 = b + j
        if 0 <= a0 && a0 <= H - 3 && 0 <= b0 && b0 <= W - 3
      } {
        p((a0, b0)) = p((a0, b0)) + 1
      }
    }

    def max = (H - 2).toLong * (W - 2).toLong
    
    val d = Array.ofDim[Long](10)
    p foreach { case (_, j) => d(j) += 1 }
    d(0) = max - d.drop(1).sum
    d.indices map d foreach println
  }

  def main(args: Array[String]): Unit = {
    solve()
  }



  class InputReader(val stream: InputStream) {
    val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 177752
def inpl(): return list(map(int, input().split()))

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

N = int(input())
A = inpl()
ans = gcd(A[0], A[1])
for a in A[2:]:
    ans = gcd(ans, a)
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <climits>
using namespace std;

#define MAX_N 101

int n;
vector<vector<int> > A(MAX_N, vector<int>(MAX_N, 0));
queue<int> Q;
int d[MAX_N];

int main()
{
    int i, u, k, v;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> u >> k;
        while (k--) {
            cin >> v;
            A[u][v]++;
        }
        d[i] = -1;
    }
    d[1] = 0;
    Q.push(1);
    while (!Q.empty()) {
        u = Q.front();
        Q.pop();
        for (i = 1; i <= n; i++) {
            if (A[u][i] && d[i] == -1) {
                d[i] = d[u] + 1;
                Q.push(i);
            }
        }
    }
    for (i = 1; i <= n; i++)
        cout << i << " " << d[i] << endl;
    return 0;
}

Measured memory_bytes: 3184
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        char ch=in.next().charAt(0);
        if(ch>='A' && ch<='Z'){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}

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

int n;
int num[11];
int comb(int i){
    if(i==n+1){
        // for(int i=1;i<=n;i++)
        //     cout << num[i] << ' ';
        // cout << endl;
        for(int i=1;i<=n;i++)
            if(num[i]%2==0)return 1;
        return 0;
    }
    int tot = 0;
    tot += comb(i+1);
    num[i]++;
    tot += comb(i+1);
    num[i]-=2;
    tot += comb(i+1);
    num[i]++;
    return tot;
}

int main(){
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> num[i];
    int ans = comb(1);
    // num[1]++;
    // ans += comb(1);
    // num[1]-=2;
    // ans += comb(1);
    cout << ans;
}

Measured memory_bytes: 256
import sys
n,k=list(map(int,input().split()))
num=int((n-1)*(n-2)/2-k)

if num<0:
    print(-1)
else:
    print(n-1+num)
    for i in range(n-1):
        print(1,i+2)
    total=0
    for i in range(n-1):
        for j in range(i+1,n-1):
            total+=1
            if total<=num:
                print(i+2,j+2)
            

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

int main() {
	int item_price;
  	string item_price_s;
  	int item_price_s_len;
  	int hate_num_cnt;

  	bool iroha_ng = true;
  	vector<int> hate_num;
  
  	cin >> item_price >> hate_num_cnt;
  
	for (int i=0; i<hate_num_cnt; i++) {
		int input;
      	cin >> input;
      	hate_num.push_back(input);
    }
  

  	while (iroha_ng || item_price > 90000) {
next_price:
		iroha_ng = false;
		item_price_s = to_string(item_price);
  		item_price_s_len = item_price_s.length();
      	for (int i=0; i<hate_num_cnt; i++) {
        	for (int j=0; j<item_price_s_len; j++) {
				if ((item_price_s[j]-'0') == hate_num[i]) {
              		item_price++;
              		iroha_ng = true;
                  	goto next_price;
            	}
        	}
      	}
    }
  
  	cout << item_price;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
#include <ctime>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int F(ll a, ll b) {
	int dig_a = log10(a) + 1;
	int dig_b = log10(b) + 1;
	return max(dig_a, dig_b);
}

int main() {
	ll n; cin >> n;
	int sq = sqrt(n);
	int i = sq;
	while (n % i > 0) {
		i--;
	}
	cout << F(i, n / i) << endl;
	return 0;
}

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

int N,A,B;
int S[100001];
int nim(){
  int x=S[0];
  for(int i=1;i<N;i++) x^=S[i];
  return x;
}

int solveA(){//A=B
  for(int i=0;i<N;i++) S[i] = S[i]%(A+1);
  return nim();
}

int solveB(){//A>B
  for(int i=0;i<N;i++) if( S[i] > B ) return 1;
  return nim();
}

int solveC(){//A<B
  int x = nim();
  bool f = false;
  int t = -1;
  for(int i=0;i<N;i++)
    if( S[i] > A ) {
      t = x ^ S[i];
      if( A>=t && S[i]-t <= A ) t=1;
      else t = 0;
      if( f ) return 0;
      f = true;
    }
  if( t < 0 ) return nim();
  return t;
}
           
int main(){
  cin >> N >> A >> B;
  for(int i=0;i<N;i++){
    cin >> S[i];
    //cout << bitset<32>(S[i]) << endl;
  }
  if( A == B ) cout << (solveA()?"Hanako":"Jiro") << endl;
  if( A > B ) cout << (solveB()?"Hanako":"Jiro") << endl;
  if( A < B ) cout << (solveC()?"Hanako":"Jiro") << endl;
  //cout << bitset<32>(x) << endl;
}

Measured memory_bytes: 1548
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int q;
  cin>>q;
  int t[q];
  for(int i=0;i<q;i++) cin>>t[i];
  int ans=0;
  for(int i=0;i<q;i++){
    int l=0,r=n;
    while(l+1<r){
      int m=(l+r)/2;
      if(s[m]<=t[i]) l=m;
      else r=m;
    }
    if(s[l]!=t[i]) continue;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for(i = 0; i < (int)(n); i++)
using namespace std;

int n;
int x[100001];

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

signed main() {
	int i;
	
	cin >> n >> x[0];
	rep(i, n) cin >> x[i + 1];
	n++;
	
	sort(x, x + n);
	
	int g = x[1] - x[0];
	rep(i, n - 1) g = gcd(g, x[i + 1] - x[i]);
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 888
import sys
S = input()
def tapdance() :
    i = 0
    L = len(S)
    for i in range(L):
        if i % 2 == 0:
            if S[i] == 'L' :
                print('No')
                return 
        else :
            if S[i] == 'R' :
                print('No')
                return 
    print('Yes')
    return
 
tapdance()

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000009;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
const ul inf = 1000000007;
ul val[1 << 19],powa[1<<19];
string s; int n, m;
void init() {
	ul coef = 1;
	powa[0] = 1;
	rep1(i, n) {
		val[i] = val[i - 1]*inf+(s[i-1]-'a'+1);
		powa[i] = powa[i - 1] * inf;
	}
}
int main(){
	cin >> n >> m;
	cin >> s;
	init();
	vector<ul> v;
	int cl = 0, cr = 1;
	rep(i, m) {
		string t; cin >> t;
		if (t[0] == 'R') {
			if (t[1] == '+') {
				cr++;
			}
			else {
				cr--;
			}
		}
		else {
			if (t[1] == '+') {
				cl++;
			}
			else {
				cl--;
			}
		}
		v.push_back(val[cr] - val[cl]*powa[cr-cl]);
		//cout << val[cl] << " " << val[cr] << endl;
		//cout << val[cr] - val[cl] * powa[cr - cl] << endl;
	}
	sort(v.begin(), v.end());
	cout << unique(v.begin(), v.end()) - v.begin() << endl;
	return 0;
}


Measured memory_bytes: 12252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

template <typename T>
struct ReRooting {
  private:
    using F = function<T(T,int,int)>; //(dp,v,i):dpの更新
    using F2 = function<T(T,int)>;
    using H = function<T(T,T)>;
    int n;
    const vector<vector<int> > G;
    vector<vector<T> > dp;
    vector<T> ans;
    //dp_v = g(combine(f(dp_u1,u1), f(dp_u2,u2), ..., f(dp_uk,uk)), v)
    const F f;
    const H combine;
    const T NE; //neutral of combine
    const F2 g;

    T dfs1(int v, int p = -1) {
      T res = NE;
      dp[v].assign(G[v].size(), NE);
      for (int i = 0; i < (int)G[v].size(); ++i) {
        int to = G[v][i];
        if (to == p) continue;
        dp[v][i] = dfs1(to, v);
        res = combine(res, f(dp[v][i], v, i));
      }
      return g(res,v);
    }
    void dfs2(int v, const T& pre, int p = -1) {
      int m = G[v].size();
      for (int i = 0; i < m; ++i){
        if (G[v][i] == p) {
          dp[v][i] = pre; break;
        } 
      }
      vector<T> dp_l(G[v].size()+1,NE), dp_r(G[v].size()+1,NE); //累積combine
      for (int i = 0; i < m; ++i) {
        dp_l[i+1] = combine(dp_l[i], f(dp[v][i], v, i));
      }
      for (int i = G[v].size(); i > 0; --i) {
        dp_r[i-1] = combine(dp_r[i], f(dp[v][i-1], v, i-1));
      }
      ans[v] = g(dp_l[m], v); //頂点vの答え
      for (int i = 0; i < m; ++i) {
        int to = G[v][i];
        if (to == p) continue;
        dfs2(to, g(combine(dp_l[i], dp_r[i+1]), v), v);
      }
    }
  public:
    ReRooting(const vector<vector<int> >& G, const F &f, const H &combine, T ne, 
    F2 g=[](T a, int b){ return a;}): G(G),f(f),combine(combine),NE(ne),g(g) {
      n = G.size();
      dp.resize(n);
      ans.assign(n,NE);
    }
    void build(int root = 0) {
      dfs1(root);
      dfs2(root, NE);
    }
    T operator[](const int &v) const{
      assert(v < n);
      return ans[v];
    }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n,m;
  cin >> n >> m;
  auto f = [&](ll a, int v, int i){ return (a+1) % m;};
  auto combine = [&](ll a, ll b){ return (a*b) % m;};
  vector<vector<int> > G(n);
  rep(i,n-1) {
    int x,y;
    cin >> x >> y;
    x--; y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  ReRooting<ll> RR(G, f, combine, 1);
  RR.build();
  rep(i,n) cout << RR[i] % m << "\n";
  return 0;
}

Measured memory_bytes: 39936
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N), B(N-1);
    for(int i=0; i<N-1; i++) scanf(" %d", &B[i]);

    int sum = 0;
    A[N-1] = B[N-2];
    for(int i=N-2; i>=1; i--){
        A[i] = std::min(B[i], B[i-1]);
    }
    A[0] = B[0];

    for(int i=0; i<N; i++) sum += A[i];
    std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

LL a[21]={1,2,4,5,8,
        10,13,14,18,21,
        26,28,33,36,40,
        41,46,50,57,60,68};
map<LL,LL> mp;
LL cal(LL x) {
    if(x<=20)
        return a[x];
    if(mp[x])
        return mp[x];
    if(x%2)
        return mp[x]=(2*cal(x/2)%MOD+cal(x/2-1)%MOD)%MOD;
    else
        return mp[x]=(2*cal(x/2-1)%MOD+cal(x/2)%MOD)%MOD;
}
int main() {
    LL n;
    scanf("%lld",&n);
    printf("%lld\n",cal(n));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

//入次数: 入次数が0の頂点からBFS
class TopologicalSort{
public:
	int n;
	vector<int> ans, deg;
	vector<vector<int> > G;
	void init(int N){
		n = N;
		deg.resize(n);G.resize(n);
	}
	void add_edge(int from, int to){	//DAG
		G[from].pb(to);deg[to]++;
	}
	void sort(){
		stack<int> st;
		rep(i,n)if(deg[i] == 0)st.push(i);
		while(!st.empty()){
			int v = st.top();st.pop();ans.pb(v);
			rep(i,G[v].size())if(--deg[G[v][i]] == 0)st.push(G[v][i]);
		}
	}
};

vector<int> G[200000], st[200000];
TopologicalSort topo;
int ans[200000];
void solve(){
  for(int u: topo.ans){
    if(!st[u].empty())ans[u] = st[u].back();
    rep(i,G[u].size()){
      int v = G[u][i];
      st[v].pb(u);
    }
  }
  return;
}

signed main(){
  int n, m;cin >> n >> m;
  topo.init(n);
  fill(ans, ans+200000, -1);
  rep(i,n-1+m){
    int a, b;cin >> a >> b;a--;b--;
    G[a].pb(b);
    topo.add_edge(a, b);
  }
  topo.sort();
  solve();
  rep(i,n)cout << ans[i]+1 << endl;
  return 0;
}





Measured memory_bytes: 25080
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    //cout << s.size() << endl;
    cout << s[0] << (s.size()-2) << s[ (s.size() -1) ] << endl;

    return 0;
}



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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    REP(i, N - 2) {
        if(S[i] != 'A') continue;
        if(S[i + 1] != 'B') continue;
        if(S[i + 2] != 'C') continue;
        ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3648
import math as mt
import itertools as it
import functools as ft
import random as rnd

stdin = lambda type_ = "int", sep = " ": list(map(eval(type_), input().split(sep)))
joint = lambda sep = " ", *args: sep.join(str(i) if type(i) != list else sep.join(map(str, i)) for i in args)

N = int(input())
A, B = stdin()
P = stdin()

_1, _2, _3 = 0, 0, 0

for p in P:
    if p <= A:
        _1 += 1
    elif p <= B:
        _2 += 1
    else:
        _3 += 1

print(min(_1, _2, _3))

Measured memory_bytes: 5836
s = input().strip()
cs = list(map(int, list(s)))
n = len(cs)

a = [0 for _ in range(n)]
for i in range(n):
    if i % 2 == 0:
        a[i] = 1
b = [1 for _ in range(n)]
for i in range(n):
    if i % 2 == 0:
        b[i] = 0

res0 = 0
for x, y in zip(cs, a):
    res0 += abs(x - y)
res1 = 0
for x, y in zip(cs, b):
    res1 += abs(x - y)
print(min(res0, res1))

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int a,b;
  cin>>a>>b;
  if (a <= 0 && b >= 0) {
    cout << "Zero";
    return 0;
  }
  if (a > 0) {
    cout << "Positive";
    return 0;
  }
  if ((a + b) % 2 == 0) {
    cout << "Negative";
    return 0;
  }
  cout << "Positive";
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> H >> W >> R >> L;
	for (int i = 0; i <= H; i++) {
		for (int j = 0; j <= W; j++) {
			int box = i * R + (H - i)*(W - R);
			int bag = j * L + (W - j)*(H - L);
			//cout <<i<<" "<<j<<"  "<< box << " " << bag << endl;
			if (box != bag)continue;
			priority_queue<pair<int, int>>PQ;
			for (int k = 0; k < W; k++) {
				if (k < j)PQ.push({ L,k });
				else PQ.push({ H - L,k });
			}
			vector<string>ret(H, string(W, '1'));
			for (int k = 0; k < H; k++) {
				vector<pair<int, int>>pu;
				if (k < i) {
					for (int l = 0; l < R; l++) {
						auto p = PQ.top();
						PQ.pop();
						ret[k][p.second] = '0';
						p.first--;
						pu.push_back(p);
					}
				}
				else {
					for (int l = 0; l < W - R; l++) {
						auto p = PQ.top();
						PQ.pop();
						ret[k][p.second] = '0';
						p.first--;
						pu.push_back(p);
					}
				}
				for (auto l : pu) {
					PQ.push(l);
				}
			}
			for (auto k : ret)cout << k << endl;
			return 0;
		}
	}
	cout << "No\n";
}

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

bool ok[1000][1000];
int c[1000], w[1000], wsum[1000], dp[1001] = {};

int wei(int i, int j){
    return wsum[j]-(i>0 ? wsum[i-1] : 0);
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)  ok[i][i] = true;
    for(int i = 0; i < n; i++){
        cin >> c[i] >> w[i];
        wsum[i] = w[i];
        if(i)   wsum[i] += wsum[i-1];
    }
    for(int i = 1; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j-i >= 0){
                if(ok[j-i][j-1] && wei(j-i, j-1) <= c[j]){
                    ok[j-i][j] = true;
                }
            }
            if(j+i < n){
                if(ok[j+1][j+i] && wei(j+1, j+i) <= c[j]){
                    ok[j][j+i] = true;
                }
            }
        }
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(ok[i][j]){
                dp[j+1] = min(dp[j+1], dp[i]+1);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 4088
#include<stdio.h>
#include<string.h>
int main(void){
  int i,l;
  char s[11],o[11]={'\0'};
  scanf("%s",s);
  for(i=0;i<strlen(s);l=strlen(o),i++){
    if(s[i]-48){
      if(s[i]-49){
        o[l-1]='\0';
      }
      else o[l]=49;
    }
    else o[l]=48;
  }
  printf("%s",o);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;


int main(void){
  
  int num;
  int house[4][3][10] = {0};
  
  cin >> num;

  for(int i=0; i<num; i++){
      int build,floor,number,person;
      cin >> build >> floor >> number >> person;

      house[build - 1][floor - 1][number - 1] += person;
  }

  for(int i=0; i<4; i++){
     for(int j=0; j<3; j++){
        for(int k=0; k<10; k++){
            cout << " " << house[i][j][k];
        }
        cout << endl;
     }
     if(i != 3){
     for(int j=0; j<20; j++)
        cout << "#";
     cout << endl;
    }
  }

  
  

  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
//SET PRECIOSION   cout << fixed ;  cout << setprecision(n) << ans << endl;
#define ll long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector <ll> v;
ll x,y,z,a,b,c,sum,ans,total,t,cnt,n,m,k,p,kase;
string s1,s2;
map<ll,ll> mp;
set<ll> s;
map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;
int main()
{
	FAST;
	cin>>x;
	y = 360;
	while(1)
    {
        if(y%x==0)
        {
            k+=(y/x);
            break;
        }
        else
            y += 360;
    }

	cout<<y/x<<endl;
	//clear vectors and maps you idiot
	// check array size dumb
	// use long long instead of int too
	return 0;
}


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

public class Main
{

    public void run( )
    {
        Scanner sc = new Scanner( System.in );
        int n = sc.nextInt();
        int[] arr = new int[n];
        
        for ( int i = 0; i < n; i++ )
        {
            arr[i] = sc.nextInt() - (i + 1);
        }
        Arrays.sort( arr );
        
        int median = 0;
        if(n % 2 == 0)
        {
            median = ( arr[n / 2 - 1] + arr[n / 2] ) / 2;
        } else
        {
            median = arr[n / 2];
        }
        long ans = 0;
        for ( int a: arr )
        {
            ans += Math.abs( a - median );
        }
        System.out.println( ans );
    }

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

Measured memory_bytes: 65276
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

K = sum(b) - sum(a)
oneplus = 0
twoplus = 0
for i in range(N):
    if a[i] > b[i]:
        oneplus += a[i] - b[i]
    elif a[i] < b[i]:
        twoplus += (b[i]-a[i]+1)//2

if oneplus <= K and twoplus <= K:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4596
void main()
{
    long n, k;
    rdVals(n, k);
    long[] a = rdRow;

    long[] b = new long[n+1];
    long[] p = new long[n+1];
    foreach (i, x; a)
    {
        b[i+1] = b[i] + x;
        p[i+1] = p[i] + max(0, x);
    }

    long result;
    foreach (i; k .. n+1)
    {
        long diff = b[i] - b[i-k];
        long score = p[n] - p[i] + p[i-k] + max(0, diff);
        result = max(result, score);
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 7240
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>

using namespace std;

const int N = 500 + 5;
int h, w, n, m;
int ans[N][N];
int sum = 0;

int main() 
{
	cin >> n >> m >> h >> w;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (i % h == h - 1 && j % w == w - 1)
			{
				ans[i][j] = (h * w - 1) * -3000 - 1;
			}
			else
			{
				ans[i][j] = 3000;
			}
			sum += ans[i][j];
		}
	}
	if (sum <= 0)
	{
		cout << "No";
		exit(0);
	}
	cout << "Yes" << endl;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}



	

}


Measured memory_bytes: 2560
q = int(input())
a = [list(int(i) for i in input().split()) for i in range(q)]
MAX = 10**5
is_prime = [1]*MAX
for i in range(2, MAX):
    if not is_prime[i]:
        continue
    for j in range(i*2, MAX, i):
        is_prime[j] = 0
s = [0]*MAX
for i in range(3,MAX):
    s[i] = s[i-1] + 1 if is_prime[i] and is_prime[(i+1)//2] else s[i-1]
for i in range(q):
    l,r = a[i]
    print(s[r]-s[l-1])

Measured memory_bytes: 29796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll inf=17441744174417;
vector<P> node[2505];
bool used[2505]={false};
ll mincost[2505]={0};
int main(){
  ll n,m,p;
  cin>>n>>m>>p;
  for(int i=2;i<=n;i++) mincost[i]=inf;
  for(int i=1;i<=n;i++) used[i]=false;
  for(int i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    c-=p;
    c*=-1;
    node[a].push_back(P(b,c));
  }
  for(int cnt=0;cnt<=2*n;cnt++){
    bool upd=false,upd2=false;
    for(int i=1;i<=n;i++){
      for(int j=0;j<node[i].size();j++){
        ll to=node[i][j].first,cos=node[i][j].second;
        if(used[i]) used[to]=true;
        if(mincost[i]!=inf&&mincost[to]>mincost[i]+cos){
          if(cnt>=n) used[to]=true;
          mincost[to]=mincost[i]+cos;
          upd=true;
        }
      }
    }
    if(!upd){
      cout<<max(mincost[n]*-1,(ll)0)<<endl;
      return 0;
    }
  }
  if(used[n]){
    cout<<-1<<endl;
    return 0;
  }
  cout<<max(mincost[n]*-1,(ll)0)<<endl;

}


Measured memory_bytes: 512
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Program{
    public static void Main(){
        int N = int.Parse(ReadLine());
        int count = 0;

        foreach(var item in ReadLine().Split(' ')){
            int a = int.Parse(item);
            while(a % 2 == 0){
                a /= 2;
                count++;
            }
        }
        WriteLine(count);
    } 
}

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

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

	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	int abs = 0;
	while (1) {
		if (find(p.begin(), p.end(), X - abs) == p.end()) {
			cout << X - abs << endl;
			return 0;
		}
		if (find(p.begin(), p.end(), X + abs) == p.end()) {
			cout << X + abs << endl;
			return 0;
		}

		abs++;
	}
	return 0;
}

Measured memory_bytes: 3600