akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t=0,u=0;
		LinkedList<Integer> b = new LinkedList<Integer>();
		LinkedList<Integer> c = new LinkedList<Integer>();
		while(s.hasNext()){
		    String[] a = s.next().split(",");
		    b.add(Integer.parseInt(a[0]));
		    c.add(Integer.parseInt(a[1]));
		}
		for(int i=0 ; i<b.size() ; i++)
		    t+=b.get(i)*c.get(i);
		for(int i=0 ; i<c.size() ; i++)
		    u+=c.get(i);
		System.out.println(t);
		System.out.println(1+Math.round(u/c.size()));
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python3
import sys

# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    w_list = ['Sunny', 'Cloudy', 'Rainy']
    w = str(input())
    print(w_list[(w_list.index(w) + 1) % 3])

if __name__ == '__main__':
    main()


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

//100000000

int main(){


    long long int n,m;
    cin >> n;
    m=n;
    long long int tmp = 0;

    for(int i = 0;i < 8;i++){
        tmp += n%10;
        n/=10;
    }

    if(m % tmp == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#[macro_export]
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 $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
  }
  println!("{}", i32::pow(n,3));
}


Measured memory_bytes: 5036
#include<iostream>
using namespace std;
int main()
{
    int i,j;
    for(i=1;i<10;i++)
    {
        for(j=1;j<10;j++)
        {
            cout <<i<<'x'<<j<<'='<<i*j<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1116
import math
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
sum = 0
for i in range(n-1):
    for j in range(i+1, n):
        sum += math.sqrt((l[j][0] - l[i][0]) ** 2 +
                         (l[j][1] - l[i][1]) ** 2)
print(sum * 2 / n)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-10;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(void) {
  int n;
  scanf("%d",&n);
  if(n%2==0){
    printf("%d\n",n);
  }else{
    printf("%d\n",2*n);
  }
  return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    double[] x, y;
    String s;
    char[] ch;
    int n, i, j, l, r;
    double a;

    x = new double[20]; y = new double[20]; n = 0;
    for(;sc.hasNext();){
      s = sc.next();
      ch = new char[s.length()];
      for(i = 0;i < s.length();i++)ch[i] = s.charAt(i);
      j = 0; l = 0;r = 0;
      for(;j < s.length() + 1;j++){
        if(ch[j] == ','){
          r = j; x[n] = readdouble(ch, l, r); l = ++j; break;
        }
      }
      y[n++] = readdouble(ch, l, s.length());
    }

    a = area(x, y, n);
    if(a < 0)a *= -1;
    out.println(a);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static double readdouble(char[] ch, int l, int r){
    int i;
    double res, d, s;

    s = 1;
    if(ch[l] == '-'){
      s = -1; l++;
    }
    d = 1.0; res = 0.0;
    for(i = l;i < r;i++){
      if(ch[i] == '.')break;
      d *= 10;
    }
    d /= 10;

    for(i = l;i < r;i++){
      if(ch[i] != '.'){
        res += d * (double)(ch[i] - '0');
        d /= 10;
      }
    }
    return res * s;
  }
  private static double area(double[] x, double[] y, int k){
    int i;
    double sum, ax, ay, bx, by;
    sum = 0.0;
    for(i = 0;i < k - 2;i++){
      ax = x[i + 1] - x[0]; ay = y[i + 1] - y[0];
      bx = x[i + 2] - x[0]; by = y[i + 2] - y[0];
      sum += (ax * by - ay * bx) / 2.0;
    }
    return sum;
  }
}

Measured memory_bytes: 17148
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int h = 2;
    	int m = 0;
    	int s = 0;
        while(scan.hasNext()){
        	int sh = scan.nextInt();
        	int sm = scan.nextInt();
        	int ss = scan.nextInt();
        	if(sh == -1 && sm == -1 && ss == -1){
        		break;
        	}
        	h = 2;
        	m = 0;
        	s = 0;
        	h -= sh;
        	m -= sm;
        	s -= ss;
        	if(s < 0){
        		m--;
        		s += 60;
        	}
        	if(m < 0){
        		h--;
        		m += 60;
        	}
        	System.out.printf("%02d:%02d:%02d\n",h,m,s);
        	h *= 3;
        	m *= 3;
        	s *= 3;
        	if(s >= 60){
        		m += s/60;
        		s %= 60;
        	}
        	if(m >= 60){
        		h += m/60;
        		m %= 60;
        	}
        	System.out.printf("%02d:%02d:%02d\n",h,m,s);
        }
    }
}

Measured memory_bytes: 18904
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#define c(a,b,c,d,e,f) (a-d)*(a-d)+(b-e)*(b-e)+(c-f)*(c-f)
using namespace std;
int f(string s){
  int n=0;
  if('a'<=s[0]&&s[0]<='f')
    n+=(s[0]-'a'+10)*16;
  else
    n+=(s[0]-'0')*16;
  if('a'<=s[1]&&s[1]<='f')
    n+=s[1]-'a'+10;
  else
    n+=s[1]-'0';
  return n;
}
int main(){
  int i;
  int r[8]={0,0,0,0,0xff,0xff,0xff,0xff},g[8]={0,0,0xff,0xff,0,0,0xff,0xff},b[8]={0,0xff,0,0xff,0,0xff,0,0xff};
  int d,e;
  string s[]={"black","blue","lime","aqua","red","fuchsia","yellow","white"},t;
  for(;;){
    cin>>t;
    if(t=="0")
      break;
    d=255*255*3;
    for(i=0;i<8;i++){
      if(d>c(f(t.substr(1,2)),f(t.substr(3,2)),f(t.substr(5,2)),r[i],g[i],b[i])){
	e=i;
	d=c(f(t.substr(1,2)),f(t.substr(3,2)),f(t.substr(5,2)),r[i],g[i],b[i]);
      }
    }
    cout<<s[e]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    s[k-1] = s[k-1] + ( 'a'-'A' ) ;
    
    cout << s << endl;;
    return 0;

}



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

int main(){
	int a[] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
	int x, y;
	cin >> x >> y;
	if(a[x] == a[y])
		cout << "Yes";
	else
		cout << "No";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  for (int i=0; i<S.size(); i++) {
    int d = S[i] - 'A';
    d = (d + N) % 26;
    char c = d + 'A';
    cout << c;
  }
  cout << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const LL INF = LL(1e18);

int n;
int a[1000];
LL d[1001];
int p[1001];
vector<int> pos, ans;

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    forn(i, n) {
        d[i] = a[i];
        p[i] = -1;
        for (int j = i - 2; j >= 0; j -= 2) {
            if (d[i] < d[j] + a[i]) {
                d[i] = d[j] + a[i];
                p[i] = j;
            }
        }
    }
    int ri = 0;
    forn(i, n) if (d[i] > d[ri]) {
        ri = i;
    }
    cout << d[ri] << endl;
    int le = ri;
    pos.pb(ri);
    while (p[le] != -1) {
        le = p[le];
        pos.pb(le);
    }
    while (n - 1 > ri) {
        ans.pb(n - 1);
        --n;
    }
    forn(i, (int)pos.size() - 1) {
        int mid = (pos[i] + pos[i + 1]) / 2;
        int times = (pos[i] - pos[i + 1]) / 2;
        forn(_, times) {
            ans.pb(mid - _);
        }
    }
    forn(i, le) {
        ans.pb(0);
    }
    printf("%d\n", (int)ans.size());
    for (int x : ans) printf("%d\n", x + 1);
    return 0;
}


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


int main()
{
    int N;
    cin >> N;
    double T[N], V[N];
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> V[i];

    //各iの終りでの可能な最大速度を計算する
    double endSpeed[N];
    endSpeed[N - 1] = 0; //終点は速度0必須
    for (int i = N - 2; i >= 0; i--) {
        double dt = T[i + 1];
        double v1 = endSpeed[i + 1] + dt;
        endSpeed[i] = min(V[i + 1], min(v1, V[i]));
    }
    //先頭から計算
    double spd = 0;
    double area = 0;
    for (int i = 0; i < N; i++) {
        //仮に区間最高速がないとしたときの、加速と減速グラフの交点を計算
        double dt = T[i];
        double ed = min(endSpeed[i], min(V[i], spd + T[i]));
        double dv = (ed - spd);
        double ta = (dv + dt) / 2.0;
        double va = ta + spd;
        if (va > V[i]) {
            //最高速に達する場合。加速完了地点と減速完了地点を計算
            double t1 = V[i] - spd;
            double t2 = T[i] - (V[i] - ed);
            area += (spd + V[i]) * (t1) / 2.0;
            area += V[i] * (t2 - t1);
            area += (V[i] + ed) * (T[i] - t2) / 2.0;
        } else {
            //
            area += (spd + va) * ta / 2.0;
            area += (va + ed) * (T[i] - ta) / 2.0;
        }
        spd = ed;
    }
    printf("%.5f\n", area);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

bool even(string S)
{
  int N = S.size();
  if (N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2, N / 2))
    return true;
  return false;
}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  for (int i = 0; i < N; i++)
  {
    S.erase(S.end() - 1);
    if (even(S)) break;
  }
  
  cout << S.size() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INFTY 2000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,A[100][100];

void dijkstra(){
  int i,j,k,u,min,d[100],color[100];
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
}
  d[0]=0;
  color[0]=GRAY;
  while(1){
    min=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i] && color[i]!=BLACK){
	u=i;
	min=d[i];
      }
    }
    if(u==-1)
      break;
    color[u]=BLACK;
    for(k=0;k<n;k++){
      if(color[k]!=BLACK && A[u][k]!=INFTY){
	if(d[k]>d[u]+A[u][k]){
	  d[k]=d[u]+A[u][k];
	  color[k]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==INFTY)
       d[i]=-1;
       printf("%d %d\n",i,d[i]);
  }
}
int main(){
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}



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


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

  if (N % 1000 == 0) {
    cout << 0 << endl; 
  } else {
    cout << 1000 - N % 1000 << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define rep(i,N) FOR(i,0,N)
using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int> botton(N);


	rep(i,N){
		cin >> botton.at(i);
	}

	int count=1;
	int number=1;
	bool judge=false;
	while (count < N) {
		if (botton.at(number-1) == number) {
			judge=false;
			break;
		}
		else if (botton.at(number-1)==2) {
			judge = true;
			break;
		}
		else {
			number = botton.at(number-1);
			count++;
			
		}
	}

	if (judge == true) {
		cout << count;
	}
	else {
		cout << -1;
	}

	return 0;
}

Measured memory_bytes: 640
#import sys
#input = sys.stdin.readline
import math

H, N = map(int, input().split())
AB = []
for i in range(N):
    a_tmp, b_tmp = map(int, input().split())
    AB.append([a_tmp, b_tmp])

dp=[0]*(H+max(s for s,t in AB))

for i in range(1, H+1):
    dp[i]=min(dp[i-a] + b for a,b in AB)

print(dp[H])

Measured memory_bytes: 3568
N,M,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


def Cum(X):
    temp = 0
    Cum = [0]*len(X)
    for i in range(len(X)):
        temp += X[i]
        Cum[i] += temp
    return Cum

a = Cum(A)
a.insert(0,0)
b = Cum(B)
b.insert(0,0)

na = 0
for i in range(N+1):
    if i == N and a[i]<=K:
        na = N
    elif a[i]<=K and a[i+1]>K:
        na = i

ans = na

nb = 0
for i in range(na,-1,-1):
    temp = K-a[i]
    for j in range(nb,M+1):
        if j == M and b[j] <= temp:
            nb = M
            ans = max(ans,i+nb)
        elif b[j]<=temp and b[j+1]>temp:
            nb = j
            ans = max(ans,i+nb)
            break
        
print(ans)

Measured memory_bytes: 118084
#include<bits/stdc++.h>
using namespace std;
int n,a,sum;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	n=read();
	for (int i=1;i<=n;++i)
	{
		a=read();
		sum+=a-1;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  int k, a, b, flag = 1;
  cin >> k;
  cin >> a >> b;

  for(int i = a; i <= b; ++i){
    if(i % k == 0){
      flag = 0;
      break;
    }
  }
  if(flag == 1){
    cout << "NG";
  }else{
    cout << "OK";
  }
}


Measured memory_bytes: 3580
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        S: chars,
    }

    let s = S.iter().cloned().collect::<String>();

    let mut v = vec!["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
    v.reverse();

    for i in 0..v.len() {
        if v[i] == s {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

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 T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z') cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}

int main()
{
	int N;
	cin>>N;
	vector<int> L(N);

	for(int i=0; i<N; i++)
	{
		cin>>L[i];
	}
	sort(L.begin(), L.end());

	int result = 0;
	for(int k=2; k<N; k++)
	{
		for(int i=0; i<k-1; i++)
		{

			int l = distance(L.begin(),upper_bound(L.begin(), L.end(), L[k] - L[i] ));
			l = max(l, i+1);
			//cout<<"i:"<<i<<"  k:"<<k<<"  l:"<<l<<endl;
			result += max(0,k-l);
			
		}
	}

	cout<<result<<endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
Bs = gets.chomp.split(" ").map(&:to_i)
Bs << Bs.last
befo = Bs[0]
sum = 0
Bs.each do |e|
  if befo <= e
    sum += befo
  else
    sum += e
  end
  befo = e
end
puts sum

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

int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	cout << a + b + c + d - min(a, min(b, min(c, d))) + max(e, f) << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int cn) {
    int N; cin>>N;
    vector<string> a(N);
    ll cnt[5]={0};
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
        switch(a[i][0]){
            case 'M':
                cnt[0]++;
                break;
            case 'A':
                cnt[1]++;
                break;
            case 'R':
                cnt[2]++;
                break;
            case 'C':
                cnt[3]++;
                break;
            case 'H':
                cnt[4]++;
        }
    }

    ll ans=0;
    for (int i = 0; i < 3; ++i) {
        for (int j = i+1; j < 4; ++j) {
            for (int k =j+1; k < 5; ++k) {
                ans += cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout<<ans<<endl;

}


#define SINGLE
int main() {
#ifdef SINGLE
    solve(1);
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve(i);
    }
#endif
    return 0;
}


Measured memory_bytes: 6440
#include<stdio.h>
#define INFTY 1000000000

int c=0;
int n1,n2;

void merge(int A[], int l, int m, int r){
  n1=m-l;
  n2=r-m;
  int L[n1], R[n2];
  int i=0, j=0, k=0;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
      c++;
    }else{
      c++;
      A[k]=R[j];
      j=j+1;
    }
  }
}

void mergesort(int A[], int l, int r){
  if(l+1<r){
    int m;
    m = (l+r)/2;
    mergesort(A, l, m);
    mergesort(A, m, r);
    merge(A, l, m, r);
  }
}

int main(){
  int n,i;
  int A[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergesort(A,0,n);
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n",A[i]);
      break;
    }
    printf("%d ",A[i]);
  }
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 5600
n, k, q = list(map(int, input().split()))
c = [0] * n
for i in range(q):
    c[int(input()) - 1] += 1
p = [k - (q - c[i]) for i in range(n)]
for _p in p:
    if _p > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8636
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
 
#define EXIST(e,s) ((s).find(e)!=(s).end())
 
#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;
 
const int INF=0x3f3f3f3f;
 
typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;
 
typedef pair<int,int> pii;
 
/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}
 
Int x;
 
int main(){
	cin>>x;//1,6,5,6,5,
	x--;
	Int r = x%11, q = x/11;
	if(r<=5)cout<<q*2+1<<endl;
	else cout<<q*2+2<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));

using Graph=vector<vector<int>>;

Graph g;
double dp1[151000];
double dp2[151000];

double dfs1(int idx,int pre){
    int n=(int)g[idx].size()-1;
    if(pre==-1) n++;
    for(int next:g[idx]){
        if(next==pre) continue;
        dp1[idx]+=(1+dfs1(next,idx))/n;
    }
    return dp1[idx];
}

void dfs2(int idx,int pre){
    if(pre!=-1){
        int n=(int)g[pre].size();
        if(pre==0) dp2[idx]=( (dp1[pre])*(n)-(dp1[idx]+1) )/(max(n-1,1) )+1;
        else dp2[idx]=( (dp2[pre]+1)+(dp1[pre]+1)*(n-1)-(dp1[idx]+2) )/(n-1);
    }
    for(int next:g[idx]){
        if(next==pre) continue;
        dfs2(next,idx);
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout<<fixed<<setprecision(10);
    int n;
    cin>>n;
    g.resize(n);
    for(int i=0;i<n-1;i++){
        int s,t;
        cin>>s>>t;
        s--; t--;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    dfs1(0,-1);
    dfs2(0,-1);
    for(int i=0;i<n;i++){
        int n=(int)g[i].size();
        //cout<<dp1[i]<<" "<<dp2[i]<<endl;
        if(i!=0) cout<< (dp1[i]*(n-1)+dp2[i])/n<<endl;
        else cout<<dp1[i]<<endl;
    }
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int n,d;
  cin>>n>>d;
  int x[n][d];
  int ans=0;
  REP(i,n){
    REP(j,d){
      cin>>x[i][j];
    }
  }
  REP(i,n){
    for(int j=i+1;j<n;j++){
      int sum=0;
      for(int k=0;k<d;k++){
        sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      int k=(int)sqrt(sum);
      if(k*k==sum){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

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

template<typename A, size_t N, typename T> // n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int h,w;cin>>h>>w;

  string s;
  rep(i, h){
    rep(j, w){
      cin>>s;
      if (s=="snuke"){
        string res = "";
        res += 'A'+j;
        res += to_string(i+1);
        cout << res << endl;
      }
    }
  }

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main(int argc, char** argv) {
  int a, b;
  bool flag = false;
  std::cin >> a;
  for (b = 1;b <= 50000;++b) {
    if (std::floor(b * 1.08) == a) {
      flag = true;
      break;
    }
    if (b*1.08 > a) {
      break;
    }
  }
  if (flag == true) {
    std::cout << b << '\n';
  } else {
    std::cout << ":(\n";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200010];
int n;
ll cacl(ll x)
{
    int i;
    ll sum=0;
    for(i = 1; i<=n; i++)
        sum+=abs(a[i]-x-i);//cout<<x<<endl;
    return sum;
}
int main()
{
    int i;
    scanf("%d",&n);
    ll ma=0;
    for(i = 1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        ma=max(ma,a[i]);
    }
    ll  l=-ma,r=ma,sum=0;



    while(l < r-1)
    {
        ll mid  = (l+r)/2;
        ll mmid = (mid+r)/2;
        if( cacl(mid) > cacl(mmid) )
            l = mid;
        else
            r = mmid;
            //cout<<l<<' '<<r<<' '<<mid<<' '<<mmid<<endl;
    sum=min(cacl(l),cacl(r));
    if(l==r-3)
    {
        sum=min(cacl(l+1),cacl(l+2));break;
    }
    }


    printf("%lld\n",sum);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string s;
int sum;
bool c=false;
int main(){
	cin>>s;
	if (s[0]=='A'){
		for (int i=0;i<s.length();i++){
			if (s[i]>='A'&&s[i]<='Z') sum++;
		}
		if (sum==2){
			for (int i=2;i<s.length()-1;i++) if (s[i]=='C') c=true;
		}
	}
	if (c) cout<<"AC"<<endl;else cout<<"WA"<<endl;
	return 0;
}

Measured memory_bytes: 256
import kotlin.math.sqrt

fun main() {
    val N = readLine()!!.toLong()
    var A = 0L
    val sq = sqrt(N.toDouble()).toLong()
    for (i in 1L..sq) {
        if (N % i == 0L) {
            A = i
        }
    }
    val B = N / A
    val cnt = B.toString().length
    println(cnt)
}

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

int main(){
  int x, n;
  static int p[105];

  cin >> x >> n;
  rep(i, n){
    int tmp;cin >> tmp;
    p[tmp]=1;
  }

  if(p[x]==0){
    cout << x;
    return 0;
  }

  rep(i, 105){
    if(p[x-1-i]==0){
      cout << x-1-i;
      return 0;
    }
    if(p[x+1+i]==0){
      cout << x+1+i;
      return 0;
    }
  }

  return 0;
}


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

using namespace std; 
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) reps(i, 0, a)

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a*b -(a+b-1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cassert>
#include<map>
#include<set>

typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 5000000000000;
//typedef std::pair<int, int> P;
struct edge { int to;double cost; };
#define VMAX 1010

     ll N,M,H,W,K;
     ll A[300000],B[300000],C;
     char G[10][10];

     ll ans;

int main() {
    cin>>H>>W>>K;
    REP(i,H)REP(j,W){
        cin>>G[i][j];
        if(G[i][j]=='#')N++;
    }
    REP(Bit1,1<<H)REP(Bit2,1<<W){
        vector<ll> a,b;ll c=N;
        REP(i,H){
            if(Bit1&(1<<i))a.push_back(i);
        }
        REP(i,W){
            if(Bit2&(1<<i))b.push_back(i);
        }
        for(auto x:a){
            REP(i,W){
                if(G[x][i]=='#')c--;
            }
            for(auto y:b){
                if(G[x][y]=='#')c++;
            }
        }
        for(auto x:b){
            REP(i,H){
                if(G[i][x]=='#')c--;
            }
        }
        if(c==K)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
//============================================================================
// Name        : 0104.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cstdio>
#include <string>
#include <utility>
using namespace std;

const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};
char tbl[100][101];

pair<int,int> rec(int y,int x){
	if(tbl[y][x] == '#'){
		return make_pair(-1,-1);
	}else if(tbl[y][x] == '.'){
		return make_pair(y,x);
	}
	if(tbl[y][x] == '>'){
		tbl[y][x] = '#';
		return rec(y,x + 1);
	}else if(tbl[y][x] == 'v'){
		tbl[y][x] = '#';
		return rec(y + 1,x);
	}else if(tbl[y][x] == '<'){
		tbl[y][x] = '#';
		return rec(y, x - 1);
	}else{
		tbl[y][x] = '#';
		return rec(y - 1,x);
	}
}

int main() {
	int h, w;
	pair<int,int> ans;
	while(true){
		scanf("%d%d",&h,&w);
		if(h == 0 && w == 0){
			break;
		}
		getchar();
		for(int i = 0;i < h;i++){
			scanf("%s",tbl[i]);
		}
		ans = rec(0,0);
		if(ans.first == -1 && ans.second == -1){
			printf("LOOP\n");
		}else{
			printf("%d %d\n",ans.second,ans.first);
		}
	}

	return 0;
}

Measured memory_bytes: 1056
w=list(input())
w.sort()
tmp=w[0]
cnt=1
flag=0
if len(w)%2==1:
    print("No")
    exit()
for i in range(1,len(w)):
    if tmp==w[i]:
        cnt+=1
    else:
        if cnt%2==0:
            tmp=w[i]
            cnt=1
        else:
            flag=1
            print("No")
            break
if flag==0:
    print("Yes")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string o, e, ans;
  int n;
  cin >> o >> e;
  
  rep(i, 0, e.size()) {
    ans += o[i];
    ans += e[i];
  }
  if(o.size() > e.size())
    ans += o[o.size()-1];
  
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        
        int N = in.nextInt();
        int K = in.nextInt();
        boolean[] dp = new boolean[K+1];
        int[] a = new int[N];
        
        for(int i = 0; i < N; i++) {
            a[i] = in.nextInt();
        }
        

        for(int stones = 1; stones <= K; stones++) {
           for(int x : a) {
               if(stones >= x && !dp[stones-x]) {
                   dp[stones] = true;
               }
           }
        }
        
        System.out.println(dp[K] == true ? "First" : "Second");
    }
        
}


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

int abs(int a){
	return (a > 0 ? a : -a);
}

int main(){
	int n, m; cin >> n >> m;
	int s[n][2], c[m][2];
	for(int i = 0; i < n; ++i){
		cin >> s[i][0] >> s[i][1];
	}
	for(int i = 0; i < m; ++i){
		cin >> c[i][0] >> c[i][1];
	}
	for(int i = 0; i < n; ++i){
		int ansf = 400000000;
		int ans;
		for(int j = 0; j < m; ++j){
			if(ansf > abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])){
				ansf = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1]);
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
const int N=20;
int a,b,c,x,y;
int main()
{
cin >>a>>b>>c>>x>>y;
int ans=a*x+b*y;
while(1)
	{
	if(x<1||y<1)
		{
		if(x<=0&&y>0&&2*c<b)y--,ans-=b-2*c;
		else {if(y<=0&&x>0&&2*c<a)x--,ans-=a-2*c;
		else break;}
		}
	else 
		{
		if(2*c<=a+b)x--,y--,ans-=a+b-2*c;
		else break;
		}
	}
cout <<ans;
return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] str = br.readLine().split(" ");
          int X = Integer.parseInt(str[0]);
          int Y = Integer.parseInt(str[1]);

          int tmp = 0;
          int result = 0;
          boolean flag = false;
    
          for(int i = 0; i <= X; i++){
            tmp = X-i;
            result = i*2 + tmp*4;
            if(result == Y){
              flag = true;
              break;
            }
          }

          if(flag){
            System.out.println("Yes");
          }else{
            System.out.println("No");
          }
        }

    }
}

Measured memory_bytes: 32708
import java.util.*;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),
			b = sc.nextInt(),
			c = sc.nextInt(),
			x = sc.nextInt(),
			cout = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if(x == i * 500 + j * 100 + k * 50) cout++;
				}
			}
		}
		System.out.println(cout);
	}
}

Measured memory_bytes: 21844
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout <<"debug "<< i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

ll max[20][100010];
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,l,q;

  std::cin>>n;
  std::vector<ll> x(n);
  rep(i,0,n)std::cin>>x[i];

  std::cin>>l>>q;

  rep(i,0,n)max[0][i]=(ll)(std::upper_bound(all(x),x[i]+l)-x.begin())-1;

  rep(k,1,20){
    rep(i,0,n){
      max[k][i]=max[k-1][max[k-1][i]];
    }
  }



  rep(_,0,q){
    ll a,b,ans=MOD;
    std::cin>>a>>b;
    a--;b--;
    if(a>b)std::swap(a,b);
    ll now=a,temp=0;
    for(ll i=(1<<19),pow=19;i>0;i/=2,pow--){
      if(max[pow][now]>=b){
        ans=std::min(ans,temp+i);
      }else{
        temp+=i;
        now=max[pow][now];
      }
    }
    std::cout<<ans<<"\n";
  }

  return 0;
}


Measured memory_bytes: 17280
const val modNum = 10L * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7
fun main() {
    val input = rspint()
    function(input[0], input[1])
}

fun function(N: Int, K: Int) {
    var sum = 0L
    for (i in K..N + 1) {
        val min = (i - 1).toLong() * i / 2
        val max = (N + N - i + 1).toLong() * i / 2
        val count = max - min + 1
        sum += count
    }
    println(sum % modNum)
}

inline fun rsp() = readLine()!!.split(" ")

inline fun rspint() = rsp().map(String::toInt)

inline fun rint() = readLine()!!.toInt()

Measured memory_bytes: 36432
#include <stdio.h>

int main()
{
	int N = 0, H, i, cnt = 0, max = 0;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &H);
		if (max <= H) {
			cnt++;
			max = H;
		}
	}

	printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n,k;
 cin>>n>>k;
 ll a,b,sum=0;
 vector<ll>h,p;
 rep(i,0,n){
  cin>>a>>b;
  push(h,a);
  push(p,b);
 }
 sort(all(h));
 sort(all(p));
 reverse(all(p));
 ans=0;
 rep(i,0,n){
  if(p[i]<h[n-1]){
   break;
  }
  k-=p[i];
  ans++;
  if(k<=0){
   pr(i+1);return 0;
  }
 }
 //cout<<k<<" "<<ans<<endl;
 ans+=cei(k,h[n-1]);
 pr(ans);
return 0;}


Measured memory_bytes: 5072
#include <iostream>
#include <string>
using namespace std;
int main(){
	int i;
	string str;
	cin >> str;
	for(i=0;i<str.length() && str.find(str[i],i+1) == -1;i++);
	if(i < str.length())
		cout << "no" << endl;
	else
		cout << "yes" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }
if(b=='T'){
     cout<<'A'<<endl;
  }
  if(b=='G'){
    cout<<'C'<<endl;
  }
  if(b=='C'){
    cout<<'G'<<endl;
  }
  return 0;
}


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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  string s;
  cin >> s;

  int count = 0, ans = 0;
  for (char& c : s) {
    if (c == 'R')
      count++;
    else
      count = 0;
    ans = max(ans, count);
  }
  cout << ans;
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  // }

  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    int cnt1=0,cnt2=1;
    for(int i=2;i*i<=N;i++){
        if(N%i)continue;
        cnt1++;
        int num=0;
        while(N%i==0){
            N/=i;
            num++;
        }
        cnt2*=num+1;
    }

    if(N!=1){
        cnt1++;cnt2*=2;
    }
    cout<<cnt1<<" "<<cnt2-1<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    string s;cin>>s;
    int cur=0;
    while(cur<s.size()){
        while(cur<s.size()&&s.substr(cur,2)=="ST"){
            s.erase(cur,2);
            cur = max(0,cur-1);
        }
        cur++;
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 640
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    n = gets.to_i
    ary = [2, 1]
    (n-1).times do |i|
      ary << ary[-2] + ary[-1]
    end

    puts ary[n]
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2044