akhauriyash/Code-Regression huggingface dataset:
// abc159_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[] = {1, 0, -1, 0};
long nCr(int n, int r) {
  long ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans*i;
  }
  for (int i = 1 ; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}

int main(int argc, char *argv[])
{
  ll n,m,ans_n=0,ans_m=0;
  cin>>n>>m;
  if (n>1) {
    ans_n = nCr(n,2);
  }

  if (m>1) {
    ans_m = nCr(m,2);
  }

  cout<<ans_m+ans_n<<endl;

  return 0;
}


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

const int inf = 1e9;
const int H = 13;
const int W = 1004;
string grid[H];
int val[H][W];
int h, w, k;
vector<int> v;
vector<int> cst;

void pre()
{
    int i, j;
    for (i = 1; i <= h; i++) {
        for (j = 1; j <= w; j++) {
            val[i][j] = val[i - 1][j] + val[i][j - 1] - val[i - 1][j - 1] + (grid[i][j] - '0');
        }
    }
}

int getCost(int ux, int uy, int lx, int ly)
{
    int c = val[lx][ly] - val[lx][uy - 1] - val[ux - 1][ly] + val[ux - 1][uy - 1];
    //cout << ux << ' ' << uy << ' ' << lx << ' ' << ly << " = " << c << '\n';
    return c;
}

int hahahihi( )
{
    int cost = 0, i, j, l, ux, fl, uy, lx, ly, c = 0, lw = 0;
    for (j = 1; j <= w; j++) {
        fl = 1;
        for (i = 1; i < (int) v.size(); i++) {
            //cout << "  %j " << j << " %i   " << v[i] << '\n';
            ux = v[i - 1] + 1;
            lx = v[i];
            uy = j;
            ly = j;
            l = getCost(ux, uy, lx, ly);
            if (cst[i] + l > k) {
                if (c == 0) {
                    //cout << " *** " << cst[i] << ' ' << l << "\n";
                    return inf;
                }
                else {
                    //cout << "backing \n";
                    cost++;
                    lw = j - 1;
                    for (int i = 0; i < (int) cst.size(); i++) {
                        cst[i] = 0;
                    }
                    j--;
                    c = 0;
                    fl = 0;
                    break;
                }
            }
            else {
                cst[i] += l;
            }
        }
        if (fl) c++;
    }
    return (cost + (int) v.size() - 2);
}

int main( )
{
    cin >> h >> w >> k;
    for (int i = 1; i <= h; i++) {
        cin >> grid[i];
        grid[i] = "#" + grid[i];
    }
    pre();
    int fl;
    int i, j, l, last;
    int mn = inf;
    for (i = 0; i < ( 1 << (h - 1) ); i++) {
        v.clear();
        cst.clear();
        v.push_back(0);
        cst.push_back(0);
        ////cout << i << " --- >\n";
        if ((i & (1<<0)) != 0) fl = 1;
        else                   fl = 0;
        last = -1;
        ////cout << i << " --- >\n";
        for (j = 1; j < h; j++) {
            l = (i & (1<<j)) ? 1 : 0;
            ////cout << i << ' ' << j << ' ' << l << '\n';
            if (fl != l) {
                v.push_back(j);
                cst.push_back(0);
                last = j;
                fl = l;
            }
        }
        if (last != h) {
            v.push_back(h);
            cst.push_back(0);
        }
//        //cout << "\n\n";
//        for (int i = 0; i < (int) v.size(); i++) {
//            //cout << v[i] << '\n';
//        }
        int haha = hahahihi();
        mn = min(mn, haha);
        //cout << i << " -> " << haha << "    *  \n";
    }
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)


typedef long long ll;
//const int MOD = pow(10,9)+7;
//const int MAX = 100001;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



ll gcb(ll a, ll b){
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}

int main() {
    
    ll N = lin();
   
    vector<ll> T;
    
    ll ans = 1;
    ll inp;
    for(auto i = 0; i<N; i++){
        inp = lin();
        
        ans = lcm(ans,inp);
        
    }
    
    cout << ans << endl;
    return 0;
    
    
}









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

#define M 1000000
#define L 14

int H[M]; /* Hash Table */

const int getChar[] = {1,0,2,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,4};

/* convert a string into an integer value */
int getKey(char str[]){ // max = 4^12-1 = 16777215
  int i, sum = 0, p = 1;
  for (i = 0; str[i]!='\n'; i++) {
    sum += p*(getChar[str[i]-'A']);
    p *= 5;
  }
  return sum;
}

void find(int key){
  int i;
  for (i=key%M; H[i]>0 ; i=(i+1)%M) {
    if (H[i]==key) {
      fputs("yes\n", stdout);
      return;
    }
  }
  fputs("no\n", stdout);
}

void insert(int key){
  int i;
  for (i=key%M; H[i]>0 ; i=(i+1)%M) {
    if (H[i]==key) return;
  }
  H[i]=key;
}

int main(){
  int i, n;
  char buf[32];
  for (i = 0; i < M; i++) H[i]=0;
  fgets(buf, 32, stdin);
  n=0;
  for (char *p=buf; *p!='\n'; n=n*10+*(p++)-'0');
  for (i = 0; i < n; i++){
    fgets(buf, 32, stdin);
    if (buf[0] == 'i'){
      insert(getKey(buf+7));
    } else {
      find(getKey(buf+5));
    }
  }
  return 0;
}



Measured memory_bytes: 5564
#include <iostream>
#define int long long
using namespace std;

signed main(){
	int chg[] = {0,1,2,3,5,7,8,9};
	int n;
	while(cin >> n,n){
		int nn = n,to = 0,tmp = 1,keta = 0;
		while(nn){
			to += (nn % 8) * tmp;
			tmp *= 10;
			nn /= 8;
			keta++;
		}
		tmp = 1;
		for(int i = 0;i < keta;i++){
			int pos = (to / tmp) % 10;
			to += (chg[pos] - pos) * tmp;
			tmp *= 10;
		}
		cout << to << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
const MOD: u64 = 1e9 as u64 + 7;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u64 = sc.read();
    let m: u64 = sc.read();
    let k: usize = sc.read();

    let mut a = 0;
    for w in 2..(m + 1) {
        a += (m - w + 1);
        a %= MOD;
    }

    let mut x = 0;
    for w in 2..(m + 1) {
        x += (n + 1) * (m - w + 1) + MOD - ((m - w + 1) * (w - 2)) % MOD;
        x %= MOD;
    }

    let mut z = 0;
    for w in 2..(m + 1) {
        z += (n + 1) * (m - w + 1) * (w - 2);
        z %= MOD;
    }

    let mut ans = 0;
    for h in 2..(n + 1) {
        // w = 2..(m+1) (n-h+1)*(m-w+1)*(h+w-2)
        // (n-h+1)*(m-w+1)*(h+w-2)
        // -(m-w+1)*h^2 + (n+1)*(m-w+1)*h - (m-w+1)*(w-2)h + (n-1)(m-w+1)(w-2)
        // w = 3 (n-h+1)
        ans += x * h + z + MOD - a * (h * h) % MOD;
        ans %= MOD;
    }
    ans *= 2;

    for w in 2..(m + 1) {
        ans += (w - 1) * n * (m - w + 1);
        ans %= MOD;
    }
    for h in 2..(n + 1) {
        ans += (h - 1) * m * (n - h + 1);
        ans %= MOD;
    }

    // (n*m-2)C(k-2)

    let mut inv = vec![1; k];
    for i in 1..k {
        inv[i] = mod_pow(i as u64, MOD - 2);
    }
    let mut comb = 1;
    for i in 1..(k - 2 + 1) {
        comb *= n * m - 2 - (i as u64 - 1);
        comb %= MOD;
        comb *= inv[i];
        comb %= MOD;
    }
    ans *= comb;
    ans %= MOD;

    println!("{}", ans);
}

fn mod_pow(x: u64, mut e: u64) -> u64 {
    let mut cur = x;
    let mut result = 1;
    while e > 0 {
        if e & 1 == 1 {
            result *= cur;
            result %= MOD;
        }
        e >>= 1;
        cur = (cur * cur) % MOD;
    }
    result
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args){
		BigDecimal one = new BigDecimal("1.00");
		int[] abo = {0,0,0,0};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		int cup = 0;
		int mun = 0;
		int ter = 0;
		String[] rrr;
		int st = 0,sr = 0;
		double mon = 0;
		int syo=0,hisi=0;
		double aaaa = 1;
		
		
		while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			
			if(tmp.equals("")){
				break;
			}
			
			st = Integer.parseInt(tmp);
			
			if(st == 0){
				break;
			}
			
			int[][] eee = new int[st][st];
			
			for(int i=0;i<st;i++){
				for(int j=0;j<st;j++){
					eee[i][j] = -1;
				}
			}
			
			eee[(st/2)+1][st/2] = 1;
			
			int[] vn = new int[2];
			vn[0] = st/2;
			vn[1] = st/2;
			vn[0]++;
			vn[0]++;
			vn[1]++;
			for(int i=2;i<st*st+1;i++){
				
				saiki(eee,vn,i);
				vn[0]++;
				vn[1]++;
				
			}
			
			
			for(int i=0;i<st;i++){
				for(int j=0;j<st;j++){
					System.out.printf("%4d",eee[i][j]);
				}
				System.out.println();
			}
			
		}
		
	}
	public static void saiki(int[][] eee, int[] vn,int s){
		
		
		if(vn[1] >= eee.length){
			vn[1] = 0;
		}else if(vn[1] < 0){
			vn[1] = eee.length -1;
		}else if(vn[0] >= eee.length){
			vn[0] = 0;
		}else if(eee[vn[0]][vn[1]] != -1){
			vn[0]++;
			vn[1]--;
		}else{
			eee[vn[0]][vn[1]] = s;
			return;
		}
		
		saiki(eee,vn,s);
	}

}

Measured memory_bytes: 19780
#include <iostream>
#define INF (int)1e09

int main(void) {
    int m;
    int n_min;
    int n_max;
    int gap;
    int pass_num;

    int pass;
    int fail;

    while (1) {
        std::cin >> m >> n_min >> n_max;
        pass = INF;
        fail = INF;
        gap = 0;

        if (m == 0) {
           break; 
        }

        for (int i = 0; i < n_min; i++) {
            std::cin >> pass;
        }
        for (int i = n_min; i <= n_max; i++) {
            std::cin >> fail;
            if (pass - fail >= gap) {
                gap =  pass -fail;
                pass_num = i;
            }
            pass = fail;
        }
        for (int i = n_max + 1; i < m; i++) {
            std::cin >> pass;
        }
        std::cout << pass_num << std::endl;
    }
    return 0;
}

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

int main()
{
    int n; cin>>n;
    vector<int> a(n);
    for(auto& e: a) cin>>e;

    auto b=a;
    sort(begin(a), end(a));
    for(auto& e: b) cout<<a[n/2-(e>=a[n/2])]<<endl;
}


Measured memory_bytes: 3712
def resolve():
    N=int(input())
    A=[int(i)-1 for i in input().split()]

    Atbl=[0]*N
    for i in A:
        Atbl[i]+=1
    cmpsum = 0
    for i in Atbl:
        cmpsum+=i*(i-1)//2
    for i in A:
        print(cmpsum-Atbl[i]+1)






if __name__ == "__main__":
    resolve()

Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

struct edge
{
    int to,cost;
};

struct eda
{
    int from,to,cost;
};

vector<edge> G[MAX_N];
int stsize[MAX_N];

//vを根とする各頂点の部分木のサイズ
int subtree_size(int v,int p)
{
    int c = 1;
    rep(i,G[v].size()){
        int w = G[v][i].to;
        if(w == p){
            continue;
        }
        c += subtree_size(G[v][i].to,v);
    }
    stsize[v] = c;
    return c;
}

P centroid(int v,int p,int t)    //最大部分木の頂点数,頂点番号
//v:v以下の頂点について,p:親(startは-1),t:連結成分の数
{
    P res = P(INF,-1);
    int s = 1,m = 0;
    rep(i,G[v].size()){
        int w = G[v][i].to;
        if(w == p){
            continue;
        }
        res = min(res,centroid(w,v,t));
        m = max(m,stsize[w]);
        s += stsize[w];
    }
    m = max(m,t-s);
    res = min(res,P(m,v));
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<eda> vec;
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        vec.pb((eda){a-1,b-1,c});
        G[a-1].pb((edge){b-1,c});
        G[b-1].pb((edge){a-1,c});
    }
    ll sm = 0;
    int ans = subtree_size(0,-1);
    P p = centroid(0,-1,n);
    ans = subtree_size(p.se,-1);
    if(n % 2 == 0 && p.fi == n/2){
        rep(i,n-1){
            eda e = vec[i];
            int cnt = min(stsize[e.from],stsize[e.to]);
            sm += 2*(ll)cnt*e.cost;
        }
        rep(i,G[p.se].size()){
            if(stsize[G[p.se][i].to] == n/2){
                sm -= G[p.se][i].cost;
                cout << sm << endl;
                break;
            }
        }
    }else{
        rep(i,n-1){
            eda e = vec[i];
            int cnt = min(stsize[e.from],stsize[e.to]);
            sm += 2*(ll)cnt*e.cost;
        }
        int mn = INF;
        rep(i,G[p.se].size()){
            mn = min(mn,G[p.se][i].cost);
        }
        cout << sm-mn << endl;
    }
    return 0;
}


Measured memory_bytes: 16692
#include <iostream>

using namespace std;
int price[4] = {6000, 4000, 3000, 2000};

void solve()
{
	for(int i = 0; i < 4; ++i)
	{
		int t, n;
		cin >> t >> n;
		cout << price[t - 1] * n << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main(void) {
    int a,b;
    cin>>a>>b;
    if(a>b)cout<<a-1<<endl;
    else cout<<a<<endl;
}


Measured memory_bytes: 256
import numpy as np


def my_round(val, digit=0):
    p = 10 ** digit
    return np.ceil((val * p * 2 + 1)) // 2 / p


def main():
    dishes = [input() for _ in range(5)]
    first_digit = float("inf")
    order_dishies = []
    for i in range(5):
        if int(dishes[i][-1]) == 0:
            order_dishies.insert(0, i)
        else:
            first_digit = min(int(dishes[i][-1]), first_digit)
            if first_digit == int(dishes[i][-1]):
                order_dishies.append(i)
            else:
                order_dishies.insert(0, i)
    ans = 0
    for i in range(5):
        if i == 4:
            ans += int(dishes[order_dishies[i]])
        else:
            ans += my_round(int(dishes[order_dishies[i]]), -1)
    print(int(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12784
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


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

    ll n;
    cin >> n;
    ll ans=n*(n-1)/2;
    cout << ans << endl; 
    

    return 0;   
}

Measured memory_bytes: 3560
/*
g++ -std=c++14 -o2 -Wall ABC122B.cpp -o .\out\ABC122B.out
.\out\ABC122B.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  int temp = 0;
  for (int i = 0;i < n; ++i) {
    if (temp == 0 && (s[i] == 'A' || s[i] == 'C' ||s[i] == 'G' || s[i] == 'T')) {
        temp = 1;
    } else if (temp != 0 && (s[i] == 'A' || s[i] == 'C' ||s[i] == 'G' || s[i] == 'T')) {
      ++temp;
    } else {
      ans = max(ans, temp);
      temp = 0;
    }
  }
    ans = max(ans, temp);  
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#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) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll a,v,b,w,t;
    IN(a,v,b,w,t);
    if(v<=w) cout << "NO" << endl;
    else{
        if((v-w)*t>=abs(a-b)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  int k,s;  cin >> k>>s;
  int ans=0;
  rep(x, 0, k+1){
    rep(y, 0, k+1){
      int z=s-x-y;
      if(0<=z && z<=k)  ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
int main()
{
	long long a, b = 0, c = 0;
	long long ans = 1e18;
	cin >> a;
	for(ll i =1; i*i<=a; i++){
		if(a%i == 0){
			b = i-1;
			c = a/i - 1;
			ans = min(b+c, ans);
		}
		else{
			continue;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int n;
vector<int> a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
long long ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, a);
	for(int i=0; i<n; ++i){
		if(i != 0 && a[i-1] > 0 && a[i] > 0){
			--a[i-1];
			--a[i];
			++ans;
		}
		ans += a[i] / 2;
		a[i] -= a[i] / 2 * 2;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D){
    cout << "Left" << endl;
  }else if(A+B == C+D){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

int main(){
  ll a;
  cin >> a;
  ll ans = a + a*a + a*a*a;
  
  cout << ans << endl;
  
  
}
       
        
      
  
    

Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c = A[0]
d = 0
for i in range(N):
    d += max(0, c - B[i])
    c = max(0, A[i+1] + min(0, c - B[i]))
    
print(sum(A) - (d + c))

Measured memory_bytes: 19116
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int result = 0;
		ArrayList<Integer> A = new ArrayList<Integer>();
		ArrayList<Integer> B = new ArrayList<Integer>();
		ArrayList<Integer> C = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}
		for(int i = 0; i < N; i++) {
			B.add(sc.nextInt());
		}
		for(int i = 0; i < N - 1; i++) {
			C.add(sc.nextInt());
		}

		int k = 100;
		int l = 100;
		for(int i = 0; i < N; i++) {
			k = A.get(i) - 1;
			result += B.get(k);
			if(k == l) {
				result += C.get(k - 1);
			}
			l = A.get(i);
		}
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 22868
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int x,y;
	cin>>x>>y;
	cout<<2*y-x<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 1003
#define mod 1000000007
using namespace std;

int n,m;
char s[maxn][maxn];
int dp[maxn][maxn];

int main() {
	scanf("%d%d",&n,&m);
	for( int i = 1 ; i <= n ; i++ )
		scanf("%s",s[i]+1);
	dp[1][1] = 1;
	for( int i = 1 ; i <= n ; i++ )
		for( int j = 1 ; j <= m ; j++ )
			if( s[i][j] == '.' && (i > 1 || j > 1) )
				dp[i][j] = ( dp[i-1][j] + dp[i][j-1] ) % mod;
	printf("%d\n",dp[n][m]);
	return 0;
}


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

int main() {
  int x; cin >> x;
  int ans;
  int tmp;
  for ( int i = 1; i <= x; i++ ) {
    tmp = i;
    for ( int j = 2; j <= 10; j++ ) {
      tmp *= i;
      if ( x >= tmp ) {
	ans = max(tmp,ans);
      }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200000];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=n;i>=1;i--)
	{
		for(int j=i+i;j<=n;j+=i)
		{
			a[i]^=a[j];
			
		}if(a[i])
			{
				ans++;
			}
		
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		if(a[i])
		{
			cout<<i<<endl;
		}
	} 
}

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

const ll mod = 1e9+7;

ll bin_pow(ll a, ll p) {
  ll r = 1;
  while (p) {
    if (p&1) r = r*a%mod;
    a = a*a%mod;
    p >>= 1;
  }
  return r;
}

int main() {
  {
    ios::sync_with_stdio(0); cin.tie(0);
    ll w, h, t;
    cin >> w >> h >> t;
    ll gx = __gcd(w,t);
    ll gy = __gcd(h,t);
    w /= gx;
    h /= gy;
    ll g = __gcd(w, h);
    ll ans = bin_pow(2, w)+bin_pow(2, h)-1+bin_pow(2, g)-2;
    cout << bin_pow(ans%mod, gx*gy) << endl;
    return 0;
  }

  int h = 3;
  int w = 3;
  int t = 1;

  int ans = 0;
  for (int mask = 0; mask < 1<<2*(h*w); mask++) {
    vector<vector<int>> a(h, vector<int>(w));
    int ok = 1;
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) {
	int v = mask>>2*(i*w+j)&3;
	if (v == 3) ok = 0;
	a[i][j] = v;
      }
    if (!ok) continue;
    auto a0 = a;
    int cc = 0;
    while (1) {
      auto b = a;
      for (int i = 0; i < h; i++)
	for (int j = 0; j < w; j++)
	  b[i][j] = -1;
      for (int i = 0; i < h; i++)
	for (int j = 0; j < w; j++)
	  if (a[i][j] == 0) {
	    b[i][j] = 0;
	  } else if (a[i][j] == 1) {
	    b[i][(j+t)%w] = 1;
	  } else if (a[i][j] == 2) {
	    b[(i+t)%h][j] = 2;
	  } else assert(0);
      for (int i = 0; i < h; i++)
	for (int j = 0; j < w; j++)
	  if (b[i][j] == -1) ok = 0;
      if (!ok) break;
      a = b;
      if (a == a0) break;
    }
    if (!ok) continue;
    if (1) {//cc++ > 2) {
	for (int i = 0; i < h; i++) {
	  for (int j = 0; j < w; j++)
	    cout << ".>v"[a0[i][j]];
	  cout << endl;
	}
	cout << endl;
      }
    ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

int rec(int src, vector<int>* adj, vector<bool>& vis, vector<int>& dp){
    if(vis[src])
        return dp[src];
    vis[src]=true;
    int best = 0;
    for(auto i : adj[src]){
        best = max(best, 1+rec(i,adj,vis,dp));
    }
    return dp[src] = best;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int> adj[n];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        --x,--y;
        adj[x].push_back(y);
    }
    vector<bool> vis (n, false);
    vector<int> dp(n+1, 0);
    int ans=0;
    for(int i=0;i<n;i++){
        ans = max( ans, rec(i,adj,vis,dp));
    }
    cout<<ans<<"\n";
}

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int h, m, h1, m1, k;
  cin >> h >> m >> h1 >> m1 >> k;
  cout << (h1 - h) * 60 + m1 - m - k << endl;
  return 0;
}

Measured memory_bytes: 3656
c=[list(map(int,input().split()))for i in range(3)]

a1=c[1][0]-c[0][0]
a2=c[1][1]-c[0][1]
a3=c[1][2]-c[0][2]
b1=c[2][0]-c[1][0]
b2=c[2][1]-c[1][1]
b3=c[2][2]-c[1][2]

if a1==a2==a3 and b1==b2==b3 and a1%1==0 and a2%1==0 and a3%1==0 and b1%1==0 and b2%1==0 and b3%1==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		String str = reader.next();
		String ans = "Yes";
		for (int i = 0; i < A; i++) {
			char ch = str.charAt(i);
			if (!Character.isDigit(ch)) {
				ans = "No";
			}
		}
		if (str.charAt(A) != '-') {
			ans = "No";
		}
		for (int i = A+1; i <= B + A; i++) {
			char ch = str.charAt(i);
			if (!Character.isDigit(ch)) {
				ans = "No";
			}
		}
		System.out.print(ans);
		reader.close();
	}
}





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

main(){
  int n;
  cin >> n;
  string ans="No";
  
  if(n<=81){
    for(int i=1;i<10;i++){
      if(n%i==0 && n/i<10){
        ans="Yes";
        break;
      }
    }
  }    
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
from time import time
import bisect
from random import randint
d = int(input())
T = time()
c = [0]+list(map(int,input().split()))
s = [0]
for i in range(d):
    s.append([0]+list(map(int,input().split())))
dic = defaultdict(int)
contest = [[] for _ in range(27)]
contests = [-1]*(d+1)
for i in range(1,d+1):
    maxscore = 0
    maxcontest = -1
    for k in range(1,27):
        score = 0
        score += s[i][k]
        score += c[k]*(i-dic[k])
        if score > maxscore:
            maxscore = score
            maxcontest = k
    dic[maxcontest] = i
    contests[i] = maxcontest
    contest[maxcontest].append(i)
ans = 0
for i in range(1,d+1):
    ans += s[i][contests[i]]
penalty = [0]*27
for i in range(1,27):
    p = 0
    cur = 1
    for j in contest[i]:
        blank = j-cur
        cur = j+1
        p += blank*(blank+1)//2*c[i]
    blank = d+1-cur
    p += blank*(blank+1)//2*c[i]
    ans -= p
    penalty[i] = p
def dscore(d,q):
    old = contests[d]
    ds = 0
    ds -= s[d][old]
    ds += s[d][q]
    ds += penalty[old]
    ds += penalty[q]
    p1 = 0
    p2 = 0
    cur = 1
    contest_o = contest[old][:]
    contest_o.remove(d)
    contest_q = contest[q][:]
    bisect.insort(contest_q,d)
    for j in contest_q:
        blank = j-cur
        cur = j+1
        p1 += blank*(blank+1)//2*c[q]
    blank = d+1-cur
    p1 += blank*(blank+1)//2*c[q]
    cur = 1
    for j in contest_o:
        blank = j-cur
        cur = j+1
        p2 += blank*(blank+1)//2*c[old]
    blank = d+1-cur
    p2 += blank*(blank+1)//2*c[old]
    ds -= p1+p2
    return (ds,p1,p2)
while time()-T < 1.8:
    di = randint(1,d)
    qi = randint(1,26)
    old = contests[di]
    ds,p1,p2 = dscore(di,qi)
    if ds > 0:
        ans += ds
        penalty[old] = p2
        penalty[qi] = p1
        contest[old].remove(di)
        bisect.insort(contest[qi],di)
        contests[di] = qi
for i in range(1,d+1):
    print(contests[i])

Measured memory_bytes: 86976
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;
    vector<int> h(N);
    vector<int> dp(N,INF);
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(int i=2;i<N;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int K, X; cin >> K >> X;

    int mi = X - K + 1;
    int ma = X + K - 1;
    for(int i=mi; i<=ma; i++) {
        printf("%d%c", i, " \n"[i == ma]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
int gcc(int x,int y);
int main(){
  int n;
  std::cin>>n;
  int a[n];
  int count = 0;
  int c = 0;
  for(int i=0;i<n;i++){
    std::cin>>a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i] >= 2){
      while(true){
	c = 0;
	for(int k=2;k<=sqrt(a[i]);k++){
	  if(a[i]%k == 0 ){ c=-1;
	    break; 
	  }
	}
	if(c==0) count++; 
        break;
      }
    }
  }
  std::cout<<count<<"\n";
  return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main(){
    char s;
    int total_sq = 0;
    stack<int> s1;
    stack<pair<int, int>> s2;
    for (int i = 0; cin>>s ; i++){
        if(s == '\\'){
            s1.push(i);
        }
        else if(s == '/' && s1.size() > 0){
            int j = s1.top();
            int a = i - j;
            s1.pop();
            while(!s2.empty() && s2.top().first > j){
                a += s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j, a));
        }
    }
    vector<int> ans;
    int total = 0;
    int kk = s2.size();
    while(s2.size() > 0){
        total += s2.top().second;
        ans.push_back(s2.top().second);
        s2.pop();}
        cout << total << endl;
        cout << kk;
        if (kk == 0)
            cout << endl;
        else
        {
            cout << ' ';
            for (int i = ans.size() - 1; i >= 0; i--)
            {
                if (i == 0)
                {
                    cout << ans[i] << endl;
                }
                else
                {
                    cout << ans[i] << ' ';
                }
            }
        }
    }


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

const int MOD = 1000000007;

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

    long long int ans = 1;
    for (int i = 1; i <= N; i++) {
        ans = (ans*i) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
ans = []
while True:
    a,b = map(int,raw_input().split())
    if a == 0 and b == 0:
        break
    elif a < b:
        ans.append([a,b])
    else:
        ans.append([b,a])
for char in ans:
    print str(char[0])+" "+str(char[1])


Measured memory_bytes: 4812
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	int n;
	cin >> n;
	vector<int>t(n+1), x(n+1), y(n+1);
	t[0] = x[0] = y[0] = 0;
	rep(i, n)cin >> t[i+1] >> x[i+1] >> y[i+1];
	bool all = true;
	rep(i, n) {
		long l = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		int td = t[i + 1] - t[i];
		if (td < l) {
			all = false;
			break;
		}
		if ((td - l) % 2 != 0) {
			all = false;
			break;
		}

	}
	if (all) cout << "Yes";
	else cout << "No";

	return 0;
}





Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define forn(i,n) for(int i=0;i<n;i++)
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)


void solve() {

	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		/* code */
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			ans++;
			a[i] /= 2;
		}
	}
	cout << ans << endl;

}



int32_t main() {

	fastio;

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	// int t; cin >> t;
	int t = 1;

	while (t--) {
		solve();
	}


	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+10;
int n,head[M],num_edge;
struct Edge
{
    int to;
    int Next;
    int dis;
}edge[M<<2];
void add_edge(int from,int to)
{
    edge[++num_edge].to=to;
    edge[num_edge].Next=head[from];
    head[from]=num_edge;
}
int son[M],cnt,dis[M];
int dfs(int x,int fa)
{
    bool flag;
    if(x==n)
        flag=true;
    else
        flag=false;
    for(int i=head[x];i;i=edge[i].Next)
    {
        int y=edge[i].to;
        if(y==fa)
            continue;
        flag=flag|dfs(y,x);
    }
    son[fa]=son[fa]+son[x]+1;
    if(flag)
    {
        dis[++cnt]=x;
        return 1;
    }
    return 0;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        add_edge(x,y);
        add_edge(y,x);
    }
    dfs(1,0);
    long long ans=0;
    for(int i=cnt;i>cnt/2;i--)
        ans=ans+son[dis[i]]-son[dis[i-1]];
    if(ans*2>n)
        puts("Fennec");
    else
        puts("Snuke");
    return 0;
}

Measured memory_bytes: 13416
#include<stdio.h>

int main(void){
	char x;
	scanf("%c",&x);
	printf("%c", x);
	scanf("%c",&x);
	if((int)x == 66){
		printf("R");
	}
	else{
		printf("B");
	}
	scanf("%c",&x);
	printf("%c\n", x);
	return 0;
}

Measured memory_bytes: 1668
n=int(input())
S=[]
H=[]
C=[]
D=[]
for i in range(n):
    a,b=input().split()
    if a=="S":
        S.append(int(b))
    if a=="H":
        H.append(int(b))
    if a=="C":
        C.append(int(b))
    if a=="D":
        D.append(int(b))

for j in range(1,14):
    if j not in S:
        print("S",j)
for j in range(1,14):
    if j not in H:
        print("H",j)
for j in range(1,14):        
    if j not in C:
        print("C",j)
for j in range(1,14):
    if j not in D:
        print("D",j)


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

int main(){
    int n;
    std::cin>>n;
    std::vector<int> l(n*2);
    for (int i = 0; i < n*2; ++i) {
        std::cin>>l[i];
    }
    std::sort(l.begin(),l.end(),std::greater<int>());
    int ans=0;
    for (int i = 1; i < n*2; i+=2) {
        ans+=l[i];
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [n;m] = reads int
    let xs = List.init m (fun _ -> read int)
    let inf = 1000000007
    let ary = Array.create (n + 1) 0

    List.iter (fun x -> ary.[x] <- -1) xs
    ary.[0] <- 1
    if ary.[1] = -1 then
        ary.[1] <- 0
    else
        ary.[1] <- 1

    for i = 2 to n do
        if ary.[i] = -1 then
            ary.[i] <- 0
        else
            ary.[i] <- (ary.[i-2] + ary.[i-1]) % inf

    printfn "%A" ary.[n]
    0

Measured memory_bytes: 22488
N, K = map(int, input().split())
cans = list(map(int, input().split()))

d = []
for n in range(N-K+1):
  l = abs(cans[n]) + abs(cans[n  + (K-1)] - cans[n])
  r = abs(cans[n  + (K-1)]) + abs(cans[n  + (K-1)] - cans[n])
  d.append(min(l,r))

print(min(d))

Measured memory_bytes: 14384
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

S = raw_input()

if S[0] != 'A':
    print "WA"
    exit()
if S[2:-1].count('C') != 1:
    print "WA"
    exit()

S = S.replace("A", 'a').replace("C", 'c')

if S.islower():
    print "AC"
else:
    print "WA"

Measured memory_bytes: 2936
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N, A, B;
  cin >> N >> A >> B;
  if (N*A >B) cout << B << endl;
  else cout << N*A << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)

int main(){
    while(1){
        int n,x;
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0) break;
        int ans = 0;
        rep(i,1,n+1){
            rep(j,i+1,n+1){
                int tmp = x-i-j;
                if(tmp > j && tmp <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2020
<?php
$n = fgets(STDIN);
$a = range(1, $n);
$FizzBuzz = 0;

for($a=0; $a<=$n; $a++){
  if($a % 3 != 0 && $a % 5 != 0){
    $FizzBuzz += $a;
    }
  }

echo $FizzBuzz;
?>

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

#define testc int t;cin>>t;while(t--)
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define repi(i,n) for(int i=0;i<n;++i)
#define REPI(i,n) for(int i=0;i<=n;++i)

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vld vector < ld >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

void solve(){
    int n;
    cin>>n;
    vvi cost(n,vi(3,0));
    cin>>cost[0][0]>>cost[0][1]>>cost[0][2];
    rep(i,1,n){
        vi c(3);
        repi(j,3){
            cin>>c[j];
        }
        cost[i][0] = c[0] + max(cost[i-1][1],cost[i-1][2]);
        cost[i][1] = c[1] + max(cost[i-1][0],cost[i-1][2]);
        cost[i][2] = c[2] + max(cost[i-1][0],cost[i-1][1]);
    }
    cout<<max(cost[n-1][0],max(cost[n-1][1],cost[n-1][2]))<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 5760
// K = int(input())
// S = input()
// M = int(10**9 + 7)

// fact = [1]
// for i in range(1, K + len(S) + 10):
//     fact.append(fact[-1] * i % M)

// finv = [pow(fact[-1], M - 2, M)]
// for i in range(K + len(S) + 9, 0, -1):
//     finv.append(finv[-1] * i % M)
// finv.reverse()

// def comb(a, b, m):
//     return fact[a] * finv[b] % m * finv[a - b] % m

// def hcomb(a, b, m):
//     return comb(a + b - 1, a - 1, m)

// ans = 0
// for l in range(0, K + 1):
//     ans += pow(26, l, M) * pow(25, K - l, M) % M * hcomb(len(S), K - l, M) % M
//     ans %= M
// print(ans)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll M = 1000000007;


struct CombTool {
    vector<ll> fact;
    vector<ll> finv;

    CombTool(ll max_value) {
        fact = vector<ll>();
        fact.push_back(1);
        for (int i = 1; i < max_value; i++) {
            fact.push_back(fact.back() * i % M);
        }

        finv = vector<ll>();
        finv.push_back(fast_pow(fact.back(), M - 2));
        for (int i = max_value - 1; i > 0; i--) {
            finv.push_back(finv.back() * i % M);
        }
        reverse(finv.begin(), finv.end());
    }

    ll comb(ll a, ll b) {
        return fact[a] * finv[b] % M * finv[a - b] % M;
    }

    ll hcomb(ll a, ll b) {
        return comb(a + b - 1, a - 1);
    }

    ll fast_pow(ll a, ll b) {
        ll res = 1;
        ll base = a;
        while (b) {
            if (b & 1) {
                res = res * base % M;
            }
            base = base * base % M;
            b = b / 2;
        }
        return res;
    }
};



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

    int K; string s;
    cin >> K >> s;

    auto tool = CombTool(K + int(s.size()) + 10);
    ll ans = 0;
    for (int l = 0; l <= K; l++) {
        ans += tool.fast_pow(26, l) * tool.fast_pow(25, K - l) % M * tool.hcomb(s.size(), K - l) % M;
        ans %= M;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 44344
from collections import deque

N = int(input())
edges = []
nb = [[] for _ in range(N)]
maxdeg = 0
root = None
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((min(a, b), max(a, b)))
    nb[a].append(b)
    nb[b].append(a)
    if len(nb[a]) > maxdeg:
        maxdeg = len(nb[a])
        root = a
    if len(nb[b]) > maxdeg:
        maxdeg = len(nb[b])
        root = b

colors = {}
for i, x in enumerate(nb[root]):
    colors[x, root] = colors[root, x] = i + 1
    q = deque([(x, root, i + 1)])
    while q:
        node, parent, pcolor = q.popleft()
        colors[node, parent] = colors[parent, node] = pcolor
        color = 0
        for c in nb[node]:
            if c != parent:
                color += 1
                if color == pcolor:
                    color += 1
                q.append((c, node, color))

print(maxdeg)
for a, b in edges:
    print(colors[a, b])


Measured memory_bytes: 111136
N = int(input())
A = list(map(int , input().split()))
'''
#print(A)
b = [sum(A) - 2 * sum(A[1::2])]
print(b)
W = [0] * N
tmp0 = int(np.ceil(A[N-1] / 2) % 2)
tmp1 = int(np.ceil(A[0] / 2) % 2)
if tmp0 == 0 and tmp1 == 0:
    W[0] = int(min(np.ceil(A[N-1] / 2),np.ceil(A[0] / 2)))
elif tmp0 == 0 and tmp1 == 1:
    W[0] = int(np.ceil(A[N-1] / 2))
elif tmp0 == 1 and tmp1 == 0:
    W[0] = int(np.ceil(A[0] / 2))
else:
    W[0] = 0
for i in range(1,N):
    W[i] = 2 * A[i - 1] - W[i - 1]
print(*W)
'''
W = [0] * N
W[0] = sum(A) - 2 * sum(A[1:N - 1:2])

for i in range(1,N):
    W[i] = 2 * A[i - 1] - W[i - 1]
print(*W)

Measured memory_bytes: 14032
<?php

fscanf(STDIN, "%d %d", $n, $m);

$array = [];

$start = 0;
$sum = [];
for ($i = 1; $i <= $m; $i++) {
    $temp = 1;
    $tempb = 1;
    fscanf(STDIN, "%d", $array[$i]);
    if( $i != 1 && $array[$i] -1 == $array[$i-1]){
        echo 0;
        exit;
    }
    if($i != 1){

        $start = $array[$i-1] + 1;
    }else{
        $start = 0;
    }
    $stop = $array[$i] - 1;
    if($start == $stop){
        $sum[] = 1;
    }elseif($start + 1 == $stop ){
        $sum[] = 1;
    }else{
        for($j = 1; $j < ($stop - $start); $j++){
            $tempc = $tempb;
            $tempb = $temp;
            $temp = $temp + $tempc;
            if($temp > 1000000007){
                $temp = $temp %1000000007;
            }

        }
        $sum[] = $temp;
    }


}
if($m == 0){
    $start = 0;
}else {
    $start = $array[$m] + 1;
}
$stop = $n;
$tempc = 1;
$temp = 1;
$tempb = 1;
if($start == $stop){
    $sum[] = 1;
}elseif($start + 1 == $stop ){
    $sum[] = 1;
}else{
    for($j = 1; $j < ($stop - $start); $j++){
        $tempc = $tempb;
        $tempb = $temp;
        $temp = $temp + $tempc;
        if($temp > 1000000007){
            $temp = $temp %1000000007;
        }

    }
    $sum[] = $temp;
}

$ans = 1;
foreach($sum as $value){
    $value = $value % 1000000007;
    $ans = $ans * $value;
    if($ans > 1000000007){
        $ans = $ans % 1000000007;
    }
}
echo ($ans % 1000000007);


Measured memory_bytes: 10744