akhauriyash/Code-Regression huggingface dataset:
k=int(input())
a=[i+1 for i in range(9)]
while (1):
  if k<=len(a):
    print(a[k-1])
    f=1
    break
  
  k=k-len(a)
  #print(k)
  b=[]
  for x in a:
    for i in [-1,0,1]:
      d=x%10+i
      #print(d)
      if d<0 or d>=10: continue
      b.append(x*10+d)
  a=b.copy()
  #print(a)



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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;


int N, L[500000], R[500000], depth[500000];
int64 sub[500000], dp1[500000], dp2[500000];

int main()
{
  scanf("%d", &N);
  int ptr = N - 1;

  for(int i = 0; i < N - 1; i++) {
    scanf("%d %d", &L[i], &R[i]);
    --L[i];
    --R[i];
    depth[L[i]] = depth[i] + 1;
    depth[R[i]] = depth[i] + 1;
  }

  sub[N - 1] = 1;
  dp1[N - 1] = dp2[N - 1] = 0;
  for(int i = N - 2; i >= 0; i--) {
    sub[i] = sub[L[i]] + sub[R[i]];
    dp1[i] = dp1[L[i]] + dp1[R[i]] + sub[i];
    dp2[i] = dp1[L[i]] + sub[L[i]] + dp2[R[i]] + 1;
    dp2[i] = min(dp2[i], dp1[R[i]] + sub[R[i]] + dp2[L[i]] + 1);
    dp2[i] = min(dp2[i], dp2[L[i]] + dp2[R[i]] + depth[i] + 2);
  }
  printf("%lld\n", dp2[0]);
}


Measured memory_bytes: 20724
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long h = sc.nextInt();
        long w = sc.nextInt();
        long ans = 0;
        
        if(h==1 || w==1){
            ans = 1;
        }else if(h*w%2==0){
        	ans = h*w/2;
        }else{
        	ans = h*w/2+1;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
int n,m,cnt;
vector<int>h(100000);
vector<bool>g(100000,1);

int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>h[i];
	
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		--a,--b;
		if(h[a]<=h[b])g[a]=0;
		if(h[b]<=h[a])g[b]=0;
	}
	
	for(int i=0;i<n;i++)cnt+=g[i];
	cout<<cnt;
	return 0;
}



Measured memory_bytes: 3652
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}

// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// 1:???????¨??????? -1:????¨??????? 2:p2-p0-p1 -2:p0-p1-p2 0:p2???p0-p1???
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1-p0;
  Vector b = p2-p0;
  if (cross(a, b) > EPS) return 1;
  if (cross(a, b) < -EPS) return -1;
  if (dot(a, b) < -EPS) return 2;
  if (a.norm() < b.norm()) return -2;

  return 0;
}

// s1???s2????????§???????????????????????????????????§?????????????????¨???????????¶????????????
Point getCrossPoint(Segment s1, Segment s2) {
  Vector base = s2.p2-s2.p1;
  double d1 = abs(cross(base, s1.p1-s2.p1));
  double d2 = abs(cross(base, s1.p2-s2.p1));
  double t = d1/(d1+d2);
  return s1.p1+(s1.p2-s1.p1)*t;
}

int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    Segment s1, s2;
    cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y
        >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
    Vector cp = getCrossPoint(s1, s2);
    cout << fixed << setprecision(20) << cp.x << " " << cp.y << endl;
  }
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int cnt = 0;
	sort(a, a + n);
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			for(int k = j + 1; k < n; k++){
				if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
				if(a[i] + a[j] > a[k]) cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int sum = 0;
    for(int i=0; i<N; i++) {
        int l;
        int r;
        cin >> l >> r;
        int add = r-l+1;
        sum += add;
    }
    
    cout << sum <<endl;
    
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    string answer = "Yes";
    rep(i, a + b + 1)
    {
        if (i != a)
        {
            if (!isdigit(s.at(i)))
            {
                answer = "No";
                break;
            }
        }
        else
        {
            if (s.at(i) != '-')
            {
                answer = "No";
                break;
            }
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define VI vector<int>
#define VII vector<pair<int, int>>
#define PII pair<int, int>
#define MP make_pair
// #define log(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define log(fmt, ...)
// #define check(...) assert(##__VA_ARGS__)
#define check(...)

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

    string n;
    cin >> n;
    bool has = false;
    rep(i,0,n.length()) {
        if (n[i] == '7') {
            has = true;
        }
    }
    if (has) {
        cout << "Yes";
    }else {
        cout << "No";
    }
}


Measured memory_bytes: 3004
N = int(input())
A = list(map(int, input().split()))
ans = []

x1 = 0
for i in range(N):
  if i % 2 == 0:
    x1 += A[i]
  else:
    x1 -= A[i]

ans.append(x1)

for i in range(N-1):
  ans.append(2*A[i] - ans[i])

print(*ans)

Measured memory_bytes: 14028
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

int main() {
	char s[1201], g;
	int i = 0, j, a[26] = {0}, k, h;
	while(scanf("%c", &s[i]) != EOF) ++i;
	k = i;
	for (h = 0; h <= i; ++h) {
		if (isupper(s[h])) s[h] = tolower(s[h]);
		for (j = 0; j < 26; ++j) {
			g = 'a' + j;
			if (s[h] == g) {
				++a[j];
				break;
			}
		}
	}
	for (i = 0; i < 26; ++i) {
		g = 'a' + i;
		printf("%c : %d\n", g, a[i]);
	}
}


Measured memory_bytes: 2048
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i =0;
int[][] a = new int[300][2];
while (true) {
int H = sc.nextInt();
int W= sc.nextInt();
if (H == 0 && W == 0) {
break; }
a[i][0]=H;
a[i++][1]=W;
}
for (int k=0;k<i;k++){
	for (int l=0;l<a[k][0];l++){
		if (l%2==0){
	for (int j=0;j<a[k][1];j++){
		if(j%2==0){
		System.out.print("#");
	} else{
		System.out.print(".");
	}
}} else {
	for (int j=0;j<a[k][1];j++){
		if(j%2==0){
		System.out.print(".");
	} else{
		System.out.print("#");
	}
	}}
 System.out.print("\n");}
System.out.print("\n");}
sc.close();
	}
 }


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

void chmax(long long int* former_number,long long int* x) {//xよりもyが大きければ更新
    if (*former_number < *x) { long long int a = *former_number; *former_number = *x; *x = a; } else { /*no action*/ }
}
void chmin(long long int* former_number,long long int* x) {//xよりもyが大きければ更新
    if (*former_number > *x) { long long int a = *former_number; *former_number = *x; *x = a; } else {/* no action */}
}
const int INF = 100000000;
using ll = long long int;
using ul = unsigned long long int;
using vi = vector<int>;
#define all(v) v.begin(),v.end()
#define pb push_back


int main(){
    ll a,b,x;
    cin>>a>>b>>x;
    if(a+b>=x && a<=x){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  stack<int> st;
  string s;;
  while(cin>>s){
    if('0'<=s[0]&&s[0]<='9'){
      int x=0;
      rep(i,s.size()){
        x*=10;
        x+=s[i]-'0';
      }
      st.push(x);
    }else{
      int y=st.top(); st.pop();
      int x=st.top(); st.pop();
      if(s[0]=='+')
        st.push(x+y);
      if(s[0]=='-')
        st.push(x-y);
      if(s[0]=='*')
        st.push(x*y);
    }
  }

  cout<<st.top()<<endl;


}


Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <set>
using namespace std;

struct UnionFind {
  vector<int> data;

  UnionFind(int N) : data(N, -1) { }

  bool unite(int x, int y) {
    x = root(x); y = root(y);

    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }

    return x != y;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  int size(int x) {
    return -data[root(x)];
  }
};

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

  vector<int> ps(N);

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

  UnionFind tree(N);

  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    tree.unite(x - 1, y - 1);
  }

  int answer = 0;

  for (int i = 0; i < N; i++) {
    if (tree.root(i) == tree.root(ps[i] - 1)) {
      answer++;
    }
  }

  cout << answer << endl;
}


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

int main() {
    int n, m, xp, yp; cin >> n >> m >> xp >> yp;
    vector<int> x(n);
    vector<int> y(m);
    /*
    for (int i=0; i<2*n; i++) {
        if (i<n) cin >> x[i];
        else cin >> y[i%n];
    }
    */

    for (int i=0; i<n; i++) {
        cin >> x[i];
    }

    for (int i=0; i<m; i++) {
        cin >> y[i];
    }
    /*
    for (int z=xp; z<=yp; z++) {
        if (xp<z && z<=yp) {
            int xcount=0;
            int ycount=0;
            cout << xcount << endl;
            for (int i=0; i<n; i++) {
                if (x[i] < z) xcount++;
                //else if (y[i] >= z) ycount++;
            }
            for (int i=0; i<n; i++) {
                if (y[i] >= z) ycount++;
            }
            if (xcount == n && ycount == n) {
                cout << "No War" << endl;
                return 0;
            }
        }
    }
    */
    int xmax = *max_element(x.begin(), x.end());
    int ymin = *min_element(y.begin(), y.end());
    if (xp < xmax && xmax < ymin && ymin < yp) {
        cout << "No War" << endl;
        return 0;
    }




    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
N= int(input())
A= [int(x) for x in input().split()]
c_2 = 0
c_4 = 0
for i in range(N):
  if A[i]%4==0:
    c_4 += 1
  elif A[i]%2==0 and A[i]%4!=0:
    c_2 += 1
c=N-c_4-c_2
print('Yes' if (c_2==0 and c_4>=c-1) or c_4>=c else'No')

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

using namespace std;
long long a, b, c, k;
int main()
{
	cin >> a >> b >> c >> k;
	if(k % 2 == 0){
		cout << a - b;
	}
	else{
		cout << b - a;
	}
	return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    bool flag  = true;
    int x=1, x_a, x_b, ans;
    while(flag){
        x_a = x * 0.08;
        x_b = x * 0.10;
        if(x_a == a && x_b == b){
            flag = false;
            ans = x;
        }
        if(x >= 1009){
            ans = -1;
            break;
        }
        x++;
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
n = int(input())
mod = 10**9+7

def prime_decomposition(n):
    i = 2
    tank = []
    while i * i <= n:
        while n%i == 0:
            n /= i
            tank.append(i)
        i += 1
    if n > 1:
        tank.append(int(n))
    return tank

dic = {i:0 for i in range(n+1)}
for i in range(2, n+1):
    l = prime_decomposition(i)
    for x in l:
        dic[x] += 1
ans = 1
for k,v in dic.items():
    if v!=0:
        ans *= (v+1)
        ans %= mod
print(ans%mod)

Measured memory_bytes: 3064
using System;

namespace ABC122_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string letter = Console.ReadLine();
            string a = "A";
            string c = "C";
            string g = "G";
            string t = "T";
            if (letter == t)
            {
                Console.WriteLine("A");
            }
            else if (letter == a) 
            {
                Console.WriteLine("T");
            }
            else if (letter == c)
            {
                Console.WriteLine("G");
            }
            else if(letter == g)
            {
                Console.WriteLine("C");
            }



        }
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i % 3600)/60;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl;

 

   
   return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#include<boost/range/irange.hpp>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/algorithm/string/classification.hpp>
#include<boost/algorithm/string/split.hpp>
#include<boost/algorithm/string/join.hpp>
#include<boost/algorithm/string/replace.hpp>
#include<boost/math/tools/minima.hpp>
#include<boost/pending/disjoint_sets.hpp>
using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;
using boost::algorithm::split;
using boost::is_any_of;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::math::tools::brent_find_minima;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
int main(){
	string s;cin >> s;
	int size = 1;
	for(int i = 0; i < s.size()-1; i++){
		if(s[i] != s[i+1])size += 1;
	}
	cout << size -1 << endl;
}   



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
int main(){
    lli a, b;
    cin >> a >> b;
    int best = 0;
    for(lli i=a; i<=a+10000;i++){
        lli x = i;
        int curr = 0;
        while(x <= b){
            x*=2;
            curr++;
        }
        best = max(curr, best);
    }
    cout << best;
}


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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
//  char s[101][101]={};
  char s[100001]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d", &a);
  if(a>9){
    printf("-1\n");
    return 0;
  }
  scanf("%d", &b);
  if(b>9){
    printf("-1\n");
    return 0;
  }
 
  printf("%d\n", a*b);
  
return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int s;
  cin >> s;
  cout << s / 3600 << ":" << (s % 3600) / 60 << ":" << s % 3600 % 60 << endl;
  return 0;
}


Measured memory_bytes: 3084
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
        a: i32,
        b: i32,
        s: String,
    }
    let s = s.as_bytes();

    let mut n_q = 0;
    let mut rank = 1;
    for &p in s {
        match p {
            b'a' if n_q < a + b => {
                n_q += 1;
                println!("Yes");
            },
            b'b' if n_q < a + b && rank <= b => {
                n_q += 1;
                rank += 1;
                println!("Yes");
            },
            _ => {println!("No");},
        }
    }
}


Measured memory_bytes: 4732
s=gets.chop.chars.map &:to_i
a,b,c=0,0,0
s.map{|x|c.odd?? a+=x: b+=x;c+=1}
i=s.size
e=i/2
o=i.odd?? e+1: e
p [e-a+b,o-b+a].min

Measured memory_bytes: 8444
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0133

"""
import sys
from sys import stdin
input = stdin.readline


def rotate_ccw(data):
    A = [[''] * 8 for _ in range(8)]
    for i in range(8):
        for j in range(8):
            A[i][j] = data[j][7-i]

    for l in A:
        print(''.join(l))
    return A


def rotate_cw(data):
    A = [[''] * 8 for _ in range(8)]
    for i in range(8):
        for j in range(8):
            A[i][j] = data[7-j][i]

    for l in A:
        print(''.join(l))
    return A


def main(args):
    data = []
    for _ in range(8):
        data.append(list(input().strip()))

    print('90')
    data = rotate_cw(data)
    print('180')
    data = rotate_cw(data)
    print('270')
    data = rotate_cw(data)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7584
N = int(input())
h = [int(i) for i in input().split()] 

# 足場iにたどり着く最小コストをc[i]とすると、
# c[i] = min(c[i-1] + |h[i] - h[i-1]| , c[i-2] + |h[i] - h[i-2]|) 

cost = [0] * N 
for i in range(N):
    if i==0:
        cost[i] = 0
    if i==1:
        cost[i] = abs(h[i] - h[i-1])
    if i > 1:
        cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]) , cost[i-2] + abs(h[i] - h[i-2]))

print(cost[N-1])


Measured memory_bytes: 52208
exception Exodus
let call_cc f =
  let return = ref (fun () -> raise Not_found) in
  try f (fun x -> (return := fun () -> x); raise Exodus)
  with Exodus -> !return ()

let () =
  let n, h = Scanf.scanf "%d %d\n" (fun n h -> n, h) in
  let abs = Array.to_list @@ Array.init n (fun _ ->
    Scanf.scanf "%d %d\n" (fun a b -> a, b)) in
  let max_a = List.fold_left max 0 @@ List.map fst abs in
  Printf.printf "%d\n" @@ call_cc (fun k ->
    List.map snd abs
    |> List.sort (fun a b -> compare b a)
    |> List.filter (( <= ) max_a)
    |> List.fold_left (fun (n, h) b ->
        if h <= b then k (n + 1)
        else (n + 1, h - b)) (0, h)
    |> (fun (n, h) ->
        n + (h + max_a - 1) / max_a))

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

int main(void){
    string S;
    cin >> S;
    int N = S.size();
    // 2^(N-1):文字列の隙間に"+"を入れる組み合わせ
    // N-1: 隙間の入れ方
    //cout << S[0] << endl;
    //cout << S[1] << endl;
    ll ans=0;
    for(int bit=0; bit < (1<<N-1); ++bit){
        ll temp=0;
        rep(i,N-1){
            temp *= 10;
            temp += S[i] - '0';
            
            if(bit & (1<<i)){
                ans += temp;
                temp = 0;
            }
        }
        //最終桁を足し合わせる
        temp *= 10;
        temp += S.back() - '0';
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include<vector>
#define inf 1e9
using namespace std;

struct activity{
    int A,B,C;
};

int solve(vector<activity> ar, int n){
    int dp[n+1][3];
    dp[1][0] = ar[1].A;
    dp[1][1] = ar[1].B;
    dp[1][2] = ar[1].C;

    for(int i=2;i<=n;i++){
        dp[i][0] = ar[i].A + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = ar[i].B + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = ar[i].C + max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main() {
    int n,k;
    cin>>n;
    vector<activity> ar(n+1);
    for(int i=1 ; i<=n ; i++){
        cin>>ar[i].A;
        cin>>ar[i].B;
        cin>>ar[i].C;
    }
    cout<<solve(ar,n);
    return 0;
}


Measured memory_bytes: 3712
package main

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

func main() {
	S, T := ReadString(), ReadString()
	max := 0
	for i := 0; i <= len(S)-len(T); i++ {
		c := 0
		for j := 0; j < len(T); j++ {
			if S[i+j] == T[j] {
				c++
			}
		}
		if max < c {
			max = c
		}
	}
	fmt.Println(len(T) - max)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1860
#include<stdio.h>

int gcd(int x, int y);

int main(void){
    int N, i;
    unsigned int A[100010];
    int min = 0;
    int ans;

    
    scanf("%d", &N);
    for(i=0;i<N;i++){
	scanf("%d", &A[i]);
    }

    ans = gcd(A[0], A[1]);
    for(i=2;i<N;i++){
	ans = gcd(ans, A[i]);
    }

    printf("%d\n", ans);

    return 0;
}

int gcd(int x, int y)
{
    return y==0 ? x:gcd(y,x % y);
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int k = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] == k + 1) {
      k++;
    }
  }
  if (k == 0) {
    cout << -1 << endl;
  } else {
  	cout << N - k << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
x = int(input())
if x == 0:
    print(0)
else:
    happiness = 0

    y500 = x // 500
    happiness += y500 * 1000

    x -= 500 * (x//500)

    y5 = x // 5
    happiness += y5 * 5
    x -= 5 * (x // 5)

    print(happiness)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String cs = "abcdefghijklmnopqrstuvwxyz";
        String[] ca = cs.split("");
        int[] ci = new int[26];
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < 26; j++) {
                if (s.substring(i, i + 1).equals(ca[j])) {
                    ci[j]++;
                }
            }
        }
        for (int i = 0; i <= 26; i++) {
            if (i == 26) {
                System.out.println("None");
            } else if (ci[i] == 0) {
                System.out.println(ca[i]);
                break;
            }
        }
    }
}


Measured memory_bytes: 63128
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		for (;;) {
			String input = sc.next();
			String out = "";
			if (input.equals(".")) {
				return;
			}
			int move = 0;
			for (int i = 0; i < input.length(); i++) {
				char c = input.charAt(i);
				if (Character.isLetter(c)) {
					if (move != 0) {
						c += move;
						if (c > 90) {
							c %= 90;
							c %= 26;
							c = (char) (64 + c);
						} else if (c < 65) {
							c = (char) ((65 - c) % 26);
							c = (char) (91 - c);
						}
						move = 0;
					}
					out += c;
				} else if (c == '+' || c == '-') {
					while (input.charAt(i) == '+') {
						move++;
						i++;
					}
					while (input.charAt(i) == '-') {
						move--;
						i++;
					}
					i--;
				} else if (c == '?') {
					out += 'A';
					move = 0;
				} else {
					out += c;
				}
			}
			StringBuilder sb = new StringBuilder(out);
			Stack<Integer> ss = new Stack<Integer>();
			for (int i = 0; i < out.length(); i++) {
				if (out.charAt(i) == '[') {
					ss.add(i);
				}
				if (out.charAt(i) == ']') {
					int s = ss.pop();
					String tmp = "";
					tmp = sb.substring(s, i + 1);
					StringBuilder t = new StringBuilder(tmp);
					t.reverse();
					t.setCharAt(0, '[');
					t.setCharAt(t.length() - 1, ']');
					sb.replace(s, i + 1, t + "");
				}
			}
			String ans = "";
			for (int i = 0; i < sb.length(); i++) {
				if (Character.isLetter(sb.charAt(i))) {
					ans += sb.charAt(i);
				}
			}
			System.out.println(ans);
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 22376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n&1){
		cout<<"No";
		return;
	}
	for(int i = 0;  i < n / 2; i++){
		if(s[i] != s[i + n / 2]){
			cout<<"No";
			return;
		}
	}
	cout<<"Yes";
}
int main(){
	io;
	solve();
	return 0;
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;

public class Main {
	
    public static void main(String args[] ) throws Exception {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input = reader.readLine().split(" ");
		int n = Integer.parseInt(input[0]), k = Integer.parseInt(input[1]);
		int[] arr = new int[n];
		input = reader.readLine().split(" ");
		for(int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(input[i]);
		}
		Arrays.sort(arr);
		long total = 0;
		for(int i = 0; i < k; i++) {
			total += arr[i];
		}
		out.print(total);
		out.flush();

    }
	

}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

bool check(int n, const vi &a, const vi &b, const set<int> &st) {
  vvi d(51, vi(51, INF));
  REP(i, 51) d[i][i] = 0;

  REP(i, 50) {
    for(auto &e: st) {
      d[(i+1)][(i+1)%(e+1)] = 1;
    }
  }

  REP(k, 51) {
    REP(i, 51) {
      REP(j, 51) {
        if(d[i][k] >= INF || d[k][j] >= INF) continue;
        chmin(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  bool res = true;
  REP(i, n) {
    res &= d[a[i]][b[i]] < INF;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n), b(n);
  REP(i, n) {
    cin >> a[i];
  }
  REP(i, n) {
    cin >> b[i];
  }

  set<int> st;
  REP(i, 50) {
    st.insert(i);
  }

  RREP(i, 49) {
    st.erase(i);
    bool res = check(n, a, b, st);
    if(!res) {
      st.insert(i);
    }
  }

  bool res = check(n, a, b, st);

  ll ans = 0;
  for(auto &e: st) {
    ll now = 1;
    REP(i, e+1) {
      now *= 2;
    }
    ans += now;
  }
  cout << (res ? ans : -1) << endl;

}
























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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = (int)s.size();
    ll ans = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') {
            cnt++;
        } else {
            ans += cnt;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
const int maxn=1e9;
void read(int &xxxxx){scanf("%d",&xxxxx);}

int main()
{
    ll x,y;cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
xy = []

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

dist = 0

for i in range(n):
    for j in range(n):
        dist += (((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5)/n

print(dist)

Measured memory_bytes: 3064
import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.Collections;
	import java.util.Comparator;
	import java.util.HashMap;
	import java.util.HashSet;
	import java.util.List;
	import java.util.Map;
	import java.util.Map.Entry;
	import java.util.PriorityQueue;
	import java.util.Queue;
	import java.util.Scanner;
	import java.util.Set;

	public class Main{

		public static void main(String[] args) {

			Scanner scanner = new Scanner(System.in);
			String[] t = scanner.nextLine().split(" ");
			int n = Integer.parseInt(t[0]);
			int l = Integer.parseInt(t[1]);

			int[] list = new int[n];

			int min = Integer.MAX_VALUE;
			int sum = 0;
			for(int i = 1; i <= n; i++) {
				list[i - 1] = i + l - 1;
				if(Math.abs(min) > Math.abs(list[i - 1])) {min = list[i - 1];}
				sum += list[i - 1];
			}

			System.out.println(sum - min);



		}
	}

Measured memory_bytes: 35668
// atcoder/abc17173/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    map<str, int> m;
    for (int i = 0; i < n; ++i) {
      str s;
      cin >> s;
      ++m[s];
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
  }

  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int m[100005][20]={};	// m[i][k] iの2^k個上の親
int main(){
	int N, L;
	int x[100005];

	cin >> N;
	rep(i,N) cin >> x[i];
	cin >> L;

	int l=0;
	rep(i,N){
		while( x[i]-x[l] > L ) l++;
		for(int p=l, j=0; p>0; p = m[p][j], j++){
			m[i][j] = p;
		}
	}

	int Q, a[100005], b[100005];
	cin >> Q;
	rep(i,Q){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		if( a[i] > b[i] ) swap(a[i], b[i]);
	}

	rep(i,Q){
		int ans = 0;
		for(int p=b[i], k=0; p>a[i]; p = m[p][max(0,k-1)], k=0){
			for(int j=0; m[p][j] > a[i]; j++ ) k++;
			ans += (1<<max(0,k-1));
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 9728
h, w = map(int,input().split())
s = [list(input()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            check = 0
            for x, y in ([1,0],[0,1],[0,-1],[-1,0]):
                new_h, new_w = i + x, j + y
                #print(new_h,new_w)
                if new_h < 0 or new_h >= h or new_w < 0 or new_w >= w:
                    continue
                if s[new_h][new_w] == '.':
                    check += 1
            if check == 4:
                print('No')
                quit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int n , a;
    cin >> n;
    for (int i = 0 ; i < 3 ; i++){
        a = n % 10;
        if (a == 7){
            cout << "Yes";
            return 0;
        }
        n /= 10;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3596
ini = map(int, raw_input().split())

if ini[1] % 2 == 0:
    ans = (ini[0] / ini[1]) ** 3 + ((ini[0] / (ini[1] / 2) + 1)/2) ** 3
else:
    ans = (ini[0] / ini[1]) ** 3
print ans

Measured memory_bytes: 2568
import math

n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]

total = 0
for i in range(n):
    for j in range(i+1,n):
        total += math.sqrt((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)

b = 0
for i in range(1,n):
    b += i

print(total*(n-1)/b)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[41][270000];
int p10[45];
int modpow(int x,int k){
	// x ^ k mod inf
	int p2[55],res=1;
	p2[0]=1;p2[1]=x%inf;
	for(int i=2;i<=50;i++){
		p2[i]=p2[i-1]*p2[i-1];
		p2[i] %= inf;
	}
	for(int i=1;i<=50;i++){
		if(k%2==1){
			res *= p2[i];
			res %= inf;
		}
		k /= 2;
	}
	return res;
}
signed main(){
	int n,x,y,z;
	cin>>n>>x>>y>>z;
	for(int i=0;i<=44;i++){
		p10[i] = modpow(10,i);
	}
	dp[0][0] = 1;
	int good = 1;
	good = good<<x;
	good ++;
	good = good<<y;
	good ++;
	good = good<<(z-1);
	int md = 1<<(x+y+z);
	int mdd = md-1;
	ll ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<md;j++){
			for(int k=1;k<=10;k++){
				dp[i][ ( (j<<k) + (1<<(k-1)) ) & mdd] += dp[i-1][j];
				dp[i][ ( (j<<k) + (1<<(k-1)) ) & mdd] %= inf;
			}
		}
		for(int j=0;j<md;j++){
			if( (good&j) >= good ){
				ans += dp[i][j] * p10[n-i] ;
				dp[i][j] = 0;
				ans %= inf;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >

ll n, k;
vi in;
vvi dp;

ll solve(ll i = k, ll j = 0)
{
    if (i < 0)
        return j;
    
    if (dp[i][j] == -1)
    {
        ll flag = 0;
        for (int it = 0; it < n; it++)
        {
            ll a = solve(i - in[it], j ^ 1);
            if (a == j)
            {
                flag = 1;
                break;
            }
        }

        if (flag == 1)
            dp[i][j] = j;
        else
            dp[i][j] = j ^ 1;
    }
    return dp[i][j];
}

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;
    in.resize(n);
    for (int i = 0; i < n; i++)
        cin >> in[i]; 

    dp.resize(k + 1);
    for (int i = 0; i < k + 1; i++)
        dp[i].resize(2, -1);

    ll ans = solve();
    if (ans == 1)
        cout << "Second\n";
    else
        cout << "First\n"; 
}


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

int main()
{
	ll N, M;
	while (cin >> N >> M, N | M) {
		vector<ll> C(M), x(N);
		for (int i = 0; i < M; i++) {
			cin >> C[i];
		}
		sort(C.begin(), C.end());
		for (int i = 0; i < N; i++) {
			cin >> x[i];
		}
		vector<vector<ll>> dp(N + 1, vector<ll>(256, INF));
		dp[0][128] = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 256; j++) {
				for (int k = 0; k < M; k++) {
					ll id = min(255ll, max(0ll, j + C[k])), d = id - x[i]; d *= d;
					dp[i + 1][id] = min(dp[i + 1][id], dp[i][j] + d);
				}
			}
		}
		ll res = INF;
		for (int i = 0; i < 256; i++) {
			res = min(res, dp[N][i]);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 43748
#include<bits/stdc++.h>
  
using namespace std;
  
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
  
int c=1;
int t;
while(cin>>t && t!=0){

cout<<"Case "<<c<<": "<<t<<"\n";
c++;

}
  
return 0;
  
}


Measured memory_bytes: 3088
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


priority_queue<int> nxtjob;
vector<pii> jobs;
int n, m;

void init()
{
	cin >> n >> m;
	jobs.reserve(n);

	REP(i, n)
	{
		int a, b;
		cin >> a >> b;
		jobs.emplace_back(MP(a, b));
	}

	sort(ALL(jobs), greater<pii>());
}


int main()
{
	init();

	ll ans = 0;
	int j = n - 1;
	for (int days = 1; days <= m; ++days)
	{
		while (j >= 0 && jobs[j].first <= days)
			nxtjob.push(jobs[j--].second);

		if (!nxtjob.empty())
		{
			ans += (ll)nxtjob.top();
			nxtjob.pop();
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

void solve()
{
	char ch;
	cin >> ch;
	if (ch >= 'a' and  ch <= 'z')
		cout << 'a' << "\n";
	else
		cout << 'A' << "\n";
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3644
n = int(input())
s = input()
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans = ""

for j in range(len(s)):
    for i in range(26):
        if s[j]==l[i]:
           ans += l[i+n] 
        else:
            pass

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int n ;
    cin >> n;
    int dp[50];
    for(int i = 0; i <= n; i++) dp[i] = 0;
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(void){
    string n;
    cin>>n;
    if(n=="SUN"){
        cout<<"7"<<endl;
    }else if(n=="MON"){
        cout<<"6"<<endl;
    }else if (n=="TUE"){
        cout<<"5"<<endl;
    }else if (n=="WED"){
        cout<<"4"<<endl;
    }else if(n=="THU"){
        cout<<"3"<<endl;
    }else if(n=="FRI"){
        cout<<"2"<<endl;
    }else{
        cout<<"1"<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b;
  if ((a + b) % 2 == 1){
    cout << (a + b + 1) /2 << endl;
  }else{
    cout << (a + b) / 2 <<endl;}
  
}

Measured memory_bytes: 256