akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n, k;
    cin >> n;
    k = 2;
    vec h(n);
    loop(i, n) cin >> h[i];
    vec dp(n, 1e18);
    dp[0] = 0;
    loop(i, n)
    {
        Loop(j, 1, k + 1)
        {
            if ((i + j) >= n)
                break;
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    putout(dp[n - 1]);
    return 0;
}


Measured memory_bytes: 1792
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});

process.stdin.on('end', function() {
  input = input.split("\n");
  i = 0
  while (input[i] != 0) {
    arr = input[i].split(" ");
    if (arr[0] != 0 || arr[1] != 0) {
      arr.sort(function(a,b){ return a - b });
      console.log(arr[0] + " " +  arr[1]);
    }
    i++;
  }
});

Measured memory_bytes: 10620
N = int(input())
S = input()

cnt = 0
ans = 0
for i in S:
	if S[cnt:cnt+3] == "ABC":
		ans += 1
	cnt += 1
	if cnt == (N - 3):
		if S[cnt:cnt+3] == "ABC":
			ans += 1
		break
print(ans)

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool check(int n)
{
    vector<int> k;
    for (; n > 0; n /= 10)
    {
        k.push_back(n % 10);
    }
    REP(i, k.size())
    {
        if (k[i] != k[k.size() - 1 - i])
            return false;
    }
    return true;
}

int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    FOR(i, B + 1, A)
    {
        if (check(i))
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
//#define int long long
 

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

long long LCM(long long a, long long b){
	
	
return a/gcd(a, b) * b;  
	
	
}

 
int f(int x){
	
	
	int res = 0;
	
	while( x%2 == 0){
		
		x/=2;
		res++;
	}
	
	return res;
	
}

 
int main() {
 
 	long long a,b;
 	
 	cin >> a >> b;
 	
  
 
 	cout << a/__gcd(a,b)*b << endl;
 	
 	
 
 
  
}








Measured memory_bytes: 3632
// package arc.arc088;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long x = in.nextLong();
        long y = in.nextLong();

        int len = 1;
        while (x <= y) {
            x *= 2;
            if (x > y) {
                break;
            }
            len++;
        }
        out.println(len);
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int a,b,H,M;
    cin >> a >> b >> H >> M;
    double hd = 0,md = 0;
    bool flag = false;
    for(int i=0;i<12;i++) {
        for(int j=0;j<60;j++) {
            if(i==H && M==j){
                flag = true;
                break;
            }
            hd += 0.5;
            md += 6.0;
        }
        if(flag)break;
        md = 0;
    }
    double under = abs(hd-md);
    
    double x = under* M_PI / 180; 
    double ans = sqrt(a*a + b*b  - 2*a*b*cos(x));
    printf("%.15f\n",ans);

    return 0;
}

Measured memory_bytes: 4084
# import sys
# sys.setrecursionlimit(10 ** 6)
def cmb(n, r):
    import math
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N):
    ABs = {}
    ABs_visited = {}
    for h in range(1, 10):
        for t in range(1, 10):
            ABs.setdefault((h, t), 0)
            ABs_visited.setdefault((h, t), False)

    for n in range(1, N + 1):
        s = str(n)
        h, t = int(s[0]), int(s[-1])
        if not (h == 0 or t == 0):
            ABs[(h, t)] += 1

    ans = 0
    for k in ABs:
        if ABs_visited[k]:
            continue
        h, t = k
        ABs_visited[(h, t)] = True
        # ABs_visited[(t, h)] = True

        # if h == t:
        #     ans += ABs[(h, t)] + cmb(ABs[(h, t)], 2)
        # else:
        #     ans += ABs[(h, t)] * ABs[(t, h)]
        ans += ABs[(h, t)] * ABs[(t, h)]
        # print(k, ABs[k], ans)
        # input()
    # print(ABs)

    print(ans)


if __name__ == '__main__':
    N = int(input())
    solve(N)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (xe).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;
typedef pair<long long, long long> pll;
// scanf("%d %d %d %d", &w, &b, &d, &s); %lld
// printf("%d\n", points);
// const double PI = acos(-1);

int main() 
{
	fastIO;
	string n;
	ll ans = 0;
	cin >> n;
	
	for(int i = 0; i<n.size(); i++)
		ans += (n[i] - '0');
	
	cout << (ans % 9 == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

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

	int n;
	cin >> n;
	int a[n];
	rep(i, 0, n) cin >> a[i];
	int rsl = gcd(a[0], a[1]);
	if(n == 3) {
		rsl = gcd(rsl, a[2]);
	}
	rep(i, 1, rsl + 1) {
		if(rsl % i == 0) cout << i << endl;
	}


}



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


int main(void){
    int n; 
    cin >> n;
    string s;
    cin >> s;
    
    int ans = 1<<30;
    int num_b = 0;
    int num_w = 0;
    
    for (int i=0; i<n; i++){
        if (s[i] == '.') num_w++;
        if(s[i] == '#') num_b++;
    }
    

    int curr_w = 0, curr_b=0;
    ans = num_w - curr_w;
    for (int i=0; i<n; i++){
        // iまでを白 i+1~nまでを黒
        if(s[i] == '.') curr_w++;
        if(s[i] == '#') curr_b++;
        // cout << curr_b + num_w - curr_w  << endl;
        ans = min(ans, curr_b + num_w - curr_w);
    }
    
    cout << ans << endl;
}


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

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

int main(){
  int n;
  ll k;
  cin>>n>>k;
  ll p;
  cin>>p;
  ll mx=p;
  ll z;
  for(int i=0;i<n-1;i++){
    cin>>z;
    if(z==k){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
    mx=max(mx,z);
    p=gcd(p,z);
  }
  if(mx<k){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  if(k%p!=0){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  cout<<"POSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

bool isPrime(ll n) {
	
  for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

// TODO: write
int main() {
  int n;cin>>n;
  string a,b,c;cin>>a>>b>>c;
  int ans = 0;
  rep(i,n){
    string s = "";
    s += a[i];
    s += b[i];
    s += c[i];
    sort(all(s));
    UNIQUE(s);
    ans += s.size()-1;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	char c;
	cin >> c;
	if (c <= 'Z')
		cout << 'A' << "\n";
	else
		cout << 'a' << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  for(int i = 0; i < K; i++) {
    sum += l.at(i);
  }
  cout << sum;
}



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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 1; i <= 7; i++ ) {
			if(Math.pow(2,i)>n) {
				System.out.print((int)Math.pow(2, i-1));
				break;
			}
		}
	}

}


Measured memory_bytes: 23764
#include <climits>
#include <iostream>
#include <vector>

typedef std::vector<int> IntVector;

void Input(IntVector& Inputs)
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	long long Count;
	std::cin >> Count;
	Inputs.resize(Count);
	for(long long i=0;i<Count;i++){
		int N = 0;
		std::cin >> N;
		Inputs[i] = N;
	}
}

void Output(IntVector& Outputs)
{
	for(long long i=0;i<Outputs.size();i++){
		std::cout << Outputs[i];
		if(i + 1 < Outputs.size()){
			std::cout << " ";
		}else{
			std::cout << std::endl;
		}
	}
}

long long merge(IntVector& A,int left,int mid,int right)
{
	long long n1 = mid - left;
	long long n2 = right - mid;
	
	IntVector L(n1+1);
	for(long long i=0;i<n1;i++){
			L[i] = A[left+i];
	}
	IntVector R(n2+1);
	for(long long i=0;i<n2;i++){
		R[i] = A[mid+i];
	}
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	
	long long i = 0;
	long long j = 0;
	long long Count = 0;
	for(int k=left;k<right;k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
			Count += j;
		}else{
			A[k] = R[j];
			j++;
		}
	}
	return Count;
}

long long mergeSort(IntVector& A,int left,int right)
{
	if(left+1 >= right) return 0;
	long long mid = (left + right)/2;
	long long Count = 0;
	Count += mergeSort(A,left,mid);
	Count += mergeSort(A,mid,right);
	return Count + merge(A,left,mid,right);
}

int main()
{
	IntVector Inputs;
	Input(Inputs);
	long long CrossCount = mergeSort(Inputs,0,Inputs.size());
	std::cout << CrossCount << std::endl;
	return 0;
}

Measured memory_bytes: 2592
import math
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    A, B = map(int, input().split())
    ans = -1
    for i in range(1, 1265):
        if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
            ans = i
            break
    print(ans)

if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int n;
int widx[2000],bidx[2000];
int wcost[2010][2010],bcost[2010][2010];
int dp[4010][2010];

int main(){
  cin>>n;
  n*=2;
  rep(i,n){
    char c;
    int a;
    cin>>c>>a;
    a--;
    if(c=='W')widx[a]=i;
    else bidx[a]=i;
  }
  rep(i,n/2){
    repl(j,i+1,n/2){
      if(widx[j]<widx[i])wcost[i][0]++;
    }
    rep(j,n/2){
      if(bidx[j]<widx[i]){
        wcost[i][0]++;
        wcost[i][j+1]--;
      }
    }
    rep(j,n/2)wcost[i][j+1]+=wcost[i][j];
  }
  rep(i,n/2){
    repl(j,i+1,n/2){
      if(bidx[j]<bidx[i])bcost[i][0]++;
    }
    rep(j,n/2){
      if(widx[j]<bidx[i]){
        bcost[i][0]++;
        bcost[i][j+1]--;
      }
    }
    rep(j,n/2)bcost[i][j+1]+=bcost[i][j];
  }
  rep(i,4010)rep(j,2010)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,n){
    rep(j,n/2+1){
      if(dp[i][j]==INF)continue;
      int wnxt=i-j;
      int bnxt=j;
      if(wnxt>n/2||bnxt>n/2)continue;
      minch(dp[i+1][j],dp[i][j]+wcost[wnxt][bnxt]);
      if(j<n/2){
        minch(dp[i+1][j+1],dp[i][j]+bcost[bnxt][wnxt]);
      }
    }
  }
  cout<<dp[n][n/2]<<endl;
  return 0;
}


Measured memory_bytes: 63232
#include <iostream>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<set>
#define LL long long
#define INF 10000000000009
#define maxn 1000009
#define mod 1000000007
#include <set>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
int main()
{
    LL n,sum[201001],a,ans=INF;
    scanf("%lld",&n);
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a);
        sum[i]=sum[i-1]+a;
    }
    //printf("%d\n",sum[n]);
    for(int i=1;i<n;i++)
    {
        ans=min(ans,abs(sum[n]-2*sum[i]));
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1920
/*  ex9_1
    pptenshi  */

#include<stdio.h>
#include<stdlib.h>
#define SIZE 11

typedef struct stack {
    char elem;
    struct stack *next;
}stack;


void push(stack **first, char elem)  {
    stack *new = calloc(1, sizeof(stack));
    if (new == NULL) exit(1);

    new->elem = elem;
    new->next = *first;
    *first = new;
}


char pop(stack **first) {
    char elem;
    stack *tmp = *first;

    // 要素がない場合は'2'を返す
    if (tmp == NULL) {
        return '2'; 
    }

    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}


// 出力
void print_string(stack *first) {
    stack *stack_prt = NULL;
    char elem;

    // stack_ptrに入れなおして出力
    while ((elem = pop(&first)) != '2') {
        push(&stack_prt, elem);
    }
    while ((elem = pop(&stack_prt)) != '2') {
        putchar(elem);
    }
    putchar('\n');
}


int main(void) {
    char string[SIZE];      // s
    char *p_str;            // sのポインタ
    stack *first = NULL;    // 文字列を入れるスタック

    // input
    scanf("%s", string);
    p_str = string;

    
    while(*p_str) {
        switch (*p_str)
        {
        case '0': case '1':
            push(&first, *p_str);
            break;
        case 'B':
            pop(&first);
            break;
        }
        p_str++;
    }


    // output
    print_string(first);


    return 0;
}

Measured memory_bytes: 1624
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    if (N == 1)
    {
        cout << "Hello World" << endl;
    }
    else
    {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int X,Y;

using namespace std;
typedef unsigned  long long ll;

const ll M = 1000000007;

vector<ll> fac(800001); //n!(mod M)
vector<ll> ifac(800001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0) {
    	return 0;
    }
    ll tmp = ifac[a-b]* ifac[b] % M;

    return (long long)tmp * fac[a] % M;
}


int main()
{
	cin >> X >> Y;
	fac[0] = 1;
    ifac[0] = 1;
	for(ll i = 0; i<800001; i++){
	     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
	     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}

	if(2*X-Y<0 || (2*X-Y)%3 != 0 || 2*Y-X<0 || (2*Y-X)%3 != 0){
		cout << 0;
		return 0;
	}
	ll a = (2*X-Y)/3;
	ll b = (2*Y-X)/3;

	cout << comb(a+b,a)%M;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 99999999999999

    /*Solve*/
int main(){
    int n;
    cin >> n;
    ll a[300010];
    ll ans=-INF;
    priority_queue<ll,vector<ll>,greater<>> lqueue;
    priority_queue<ll> rqueue;
    ll sum0=0,sum1=0;
    ll maxsum0[100010];
    ll minsum1[100010];
    
    rep(i,3*n){
        cin >> a[i];
        if(i<n){lqueue.push(a[i]);sum0+=a[i];}
        if(i>=2*n){rqueue.push(a[i]);sum1+=a[i];}
        if(i==3*n-1){maxsum0[0]=sum0;minsum1[n]=sum1;}
    }
    

    ll tmp=0;
    rep(i,n){
        sum0+=a[n+i];
        lqueue.push(a[n+i]);
        sum0-=lqueue.top();
        lqueue.pop();
        maxsum0[i+1]=sum0;
        
        sum1+=a[2*n-1-i];
        rqueue.push(a[2*n-1-i]);
        sum1-=rqueue.top();
        rqueue.pop();
        minsum1[n-i-1]=sum1;
        
    }
    rep(i,n+1){
        tmp=maxsum0[i]-minsum1[i];
        if(ans<tmp)ans=tmp;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
int main(void){
    int n,r,p;
    while(cin>>n>>r,n){
        vector<int> mayor(n,0);
        p=r;
        rep(i,1000000){
            if(p==0){
                p+=mayor[i%n]; mayor[i%n]=0;
            }else{
                p--;mayor[i%n]++;
                if(mayor[i%n]==r){
                    cout<<i%n<<endl;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  string s; cin >> s;
  string alphabets; rep(i, 26) alphabets += 'a' + i;

  string result = "None";
  rep(i, 26) {
    bool flg = false;
    for(auto x: s) if (x == alphabets[i]) flg=true;
    if (!flg) { result = alphabets[i]; break; }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int n;
	cin >> n;
	int ans = pow(n, 3);
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))
div = 0
even = 0
for a in A:
    if a % 4 == 0:
        div += 1
    elif a % 2 == 0:
        even += 1

odd = n - div - even
if even:
    odd += 1
if div:
    div += 1

if div >= odd or even == n:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 85376
#include "bits/stdc++.h"
using namespace std;

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

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

    sort(S.begin(), S.end());
    int sum = 0;
    bool flag = true;
    for (int i = 0; i < N; i++) {
        sum += S[i];
        if (S[i] % 10 != 0) {
            flag = false;
        }
    }

    if (sum % 10 != 0) {
        cout << sum << endl;
    }
    else {
        if (flag) {
            cout << 0 << endl;
        }
        else {
            for (int i = 0; i < N; i++) {
                if (S[i] % 10 != 0) {
                    cout << sum - S[i] << endl;
                    break;
                }
            }
        }
    }
}

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

int parent(int key) {
	return key / 2;
}

int right(int key) {
	return (key * 2) + 1;
}

int left(int key) {
	return key * 2;
}

int main() {
	int s, T[MAX];
	cin >> s;
	for (int i = 1; i <= s; i++) {
		cin >> T[i];
	}
	for (int i = 1; i <= s; i++) {
		cout << "node " << i << ": key = " << T[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << T[parent(i)] << ", ";
		if (left(i) <= s) cout << "left key = " << T[left(i)] << ", ";
		if (right(i) <= s) cout << "right key = " << T[right(i)] << ", ";
		cout << endl;
	}
}

Measured memory_bytes: 1160
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var mn=arr.shift();
   if(mn=="0 0")break;
   mn=mn.split(" ").map(Number);
   var m=mn[0];
   var n=mn[1];
   var ary=[];
   for(var i=0;i<18;i++)ary[i]=0;
   ary[0]=m;
   for(var j=1;j<=n;j++){
      if(j==n)m=1;
      var plus=[];
      for(var i=0;i<18;i++)plus[i]=0;
      ary.forEach(function(v,i){
         var k=v*m;
         if(k>=10000){
            ary[i]=k%10000;
            plus[i+1]+=Math.floor(k/10000);
         }else{
            ary[i]=k;
         }
      });
      ary.forEach(function(v,i){
         ary[i]=ary[i]+plus[i];
      });
   }
   var us=["","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"];
   var str="";
   ary.forEach(function(v,i){
      if(v!=0)str=v+us[i]+str;
   });
   if(str=="")str=0;
   console.log(str);
}

Measured memory_bytes: 17888
#include<iostream>
#include<string>
#include<map>
#include<queue>
#define MAX 50
using namespace std;
struct Point{int x,y;};
struct P{
  Point l,r;
  int cost;
  bool operator<(const P &a)const{
    return (l.x==a.l.x?
	    (l.y==a.l.y?
	     (r.x==a.r.x?
	      (r.y<a.r.y):r.x<a.r.x)
	     :l.y<a.l.y)
	    :l.x<a.l.x);
  }
};
int main(){
  int w,h;
  while(cin>>w>>h,w||h){
    int i,j,k;
    int inf = 1<<20;
    
    bool d[MAX+1][MAX+1][MAX+1][MAX+1];
    fill(d[0][0][0],d[MAX][MAX][MAX],0);
    
    //map<P,int> m;
    string sr[60],sl[60];
    for(i=0;i<h;i++){
      cin >> sl[i] >> sr[i];
    }
    
    Point pr,pl,br,bl;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(sl[i][j]=='L'){
	  pl.x=j;pl.y=i;
	}
	if(sr[i][j]=='R'){
	  pr.x=j;pr.y=i;
	}
      }
    }
    //cout << pl.x << ":" << pl.y << endl;
    //cout << pr.x << ":" << pr.y << endl;
    //d[pl.x][pl.y][pr.x][pr.y]=
    P p,b;
    p.r=pr;
    p.l=pl;
    p.cost=0;
    //m[p]=p.cost;
    queue<P> q;
    q.push(p);
    bool f = false;
    while(!q.empty()){
      p=q.front();q.pop();
      pl=p.l;pr=p.r;
      /*
      if(m.find(p)!=m.end())
	if(p.cost>m[p]) continue;
      m[p]=p.cost;
      */
      if(d[pl.x][pl.y][pr.x][pr.y]) continue;
      d[pl.x][pl.y][pr.x][pr.y]=true;
      
      //cout << pl.x<<":"<<pl.y<<":"<<pr.x<<":"<<pr.y<<"/"<<p.cost<<endl;
      if(sl[pl.y][pl.x]=='%'&&sr[pr.y][pr.x]=='%'){
	f=true;
	break;
      }else if(sl[pl.y][pl.x]=='%') continue;
      else if(sr[pr.y][pr.x]=='%') continue;
      
      p.cost++;
      int lx[]={1,-1,0,0};int ly[]={0,0,1,-1};
      int rx[]={-1,1,0,0};int ry[]={0,0,1,-1};
      for(i=0;i<4;i++){
	bl=pl;br=pr;
	bl.x+=lx[i];bl.y+=ly[i];
	br.x+=rx[i];br.y+=ry[i];

	//cout << bl.x<<":"<<bl.y<<":"<<br.x<<":"<<br.y<<"/"<<p.cost<<endl;
	
	if(bl.x<0) bl.x=0;
	else if(bl.x>=w) bl.x=w-1;
	if(bl.y<0) bl.y=0;
	else if(bl.y>=h) bl.y=h-1;

	if(br.x<0) br.x=0;
	else if(br.x>=w) br.x=w-1;
	if(br.y<0) br.y=0;
	else if(br.y>=h) br.y=h-1;

	if(sl[bl.y][bl.x]=='#'){
	  bl.x-=lx[i];bl.y-=ly[i];
	}
	if(sr[br.y][br.x]=='#'){
	  br.x-=rx[i];br.y-=ry[i];
	}
	p.r=br;p.l=bl;
	q.push(p);
	//m[p]=p.cost;
      }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    
  }
  return 0;
}

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

long long n;
long long ans;

int main()
{
 cin >> n;
 for(int i=sqrt(n)+5;i>=1;i--)
  if(n%i==0)
  {
   ans=i+n/i-2;
   break;
  }
 cout << ans << endl;
 return 0;
}


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

/*

dp[i][j]=dp[i-1][j]+1; (j<L[i-1] or R[i-1]<j)
dp[i][j]=dp[i-1][L[i-1]-1]+1+(j-(L[i-1]-1)) (L[i-1]<=j<=R[i-1])
*/

const int M=2e5+5;
const int INF=0x3f3f3f3f;

struct SegT
{
	struct TN
	{
		int mn,fi,add;
		void app_add(int v)
		{
			add+=v;
			mn+=v;
		}
		void app_set(int v) // arthimic
		{
			add=0;
			fi=v;
			mn=v;
		}
	}tn[M*4];
	int P,L,R,V;
	void push(int o,int l,int mi,int r)
	{
		if(tn[o].fi!=-1)
		{
			tn[o<<1].app_set(tn[o].fi);
			tn[o<<1|1].app_set(tn[o].fi+mi-l+1);
			tn[o].fi=-1;
		}
		if(tn[o].add)
		{
			tn[o<<1].app_add(tn[o].add);
			tn[o<<1|1].app_add(tn[o].add);
			tn[o].add=0;
		}
	}
	void pull(int o)
	{
		tn[o].mn=min(tn[o<<1].mn,tn[o<<1|1].mn);
	}
	void build(int o,int l,int r)
	{
		tn[o].mn=tn[o].add=0;
		tn[o].fi=-1;
		if(l==r)
		{
			if(l==0) tn[o].mn=tn[o].add=INF;
			return;
		}
		int mid=(l+r)>>1;
		build(o<<1,l,mid);
		build(o<<1|1,mid+1,r);
		pull(o);
	}
	void add(int o,int l,int r)
	{
		if(L<=l&&r<=R)
		{
			tn[o].app_add(1);
			return;
		}
		int mid=(l+r)>>1;
		push(o,l,mid,r);
		if(L<=mid) add(o<<1,l,mid);
		if(mid<R) add(o<<1|1,mid+1,r);
		pull(o);
	}
	void set(int o,int l,int r)
	{
		if(L<=l&&r<=R)
		{
			tn[o].app_set(V+l-L+1);
			return;
		}
		int mid=(l+r)>>1;
		push(o,l,mid,r);
		if(L<=mid) set(o<<1,l,mid);
		if(mid<R) set(o<<1|1,mid+1,r);
		pull(o);
	}
	int query(int o,int l,int r)
	{
		if(l==r) return tn[o].mn;
		int mid=(l+r)>>1;
		push(o,l,mid,r);
		if(P<=mid) return query(o<<1,l,mid);
		else return query(o<<1|1,mid+1,r);
	}
}segt;

int main()
{
	int h,w; scanf("%d%d",&h,&w);
	segt.build(1,0,w);
	int l,r;
	for(int i=0;i<h;i++)
	{
		scanf("%d%d",&l,&r);
		if(l!=1)
		{
			segt.L=1; segt.R=l-1;
			segt.add(1,0,w);
		}
		if(r!=w)
		{
			segt.L=r+1; segt.R=w;
			segt.add(1,0,w);
		}
		segt.P=l-1;
		segt.V=segt.query(1,0,w);
		segt.L=l; segt.R=r;
		segt.set(1,0,w);
		int ans=segt.tn[1].mn;
		printf("%d\n",ans>=INF ? -1 : ans);
	}
	return 0;
}

Measured memory_bytes: 9992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll L,R;
  cin>>L>>R;
  if(R-L+1>=2019) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = ((L%2019)*((L+1)%2019))%2019LL;
  repeat(i,L,R) {
    repeat(j,i+1,R+1) {
      ans=min(ans,((i%2019LL)*(j%2019LL))%2019LL);
    }
  }
  cout << ans << endl;
  return 0;
}


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

vector<long long> used(1000050, 0);
vector<long long> wa_num(1000050, 0);


int main()
{
  long long  n, m;
  cin >> n >> m;
  vector<pair<long long , string>> taka(m);
  long long ac=0, wa=0;

  for(long long i=0; i<m; i++){
    cin >> taka[i].first >> taka[i].second;
  }


  for(long long i=0; i<m; i++){
    if(used[taka[i].first] == 0 && taka[i].second == "AC"){
      used[taka[i].first] = 1;
      ac++;
      wa +=  wa_num[taka[i].first];
    }else if(used[taka[i].first] == 0 && taka[i].second=="WA"){
      wa_num[taka[i].first]++;
    }
  }

  cout << ac << " " << wa << endl;
  return 0;
}


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

using namespace std;

set<string> ans;

void go(char c, int len, string s) {
    if (s.length() == len) {
        ans.insert(s);
        return;
    }
    for (char x = 'a'; x <= c; x++) {
        go((char)max((int)x+1, (int)c), len, s+x);
    }
}

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

    int n;
    cin >> n;

    go('a', n, "");
    for (string s : ans) {
        cout << s << "\n";
    }

    return 0;
}


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

int main(void) {
	using namespace std;
	//考察
	//色の種類の総数をcとすると，
	//iと同じ色の猫が他にいないとき，a[i] = c - 1,
	//iと同じ色の猫が他にいるとき，a[i] = c. 
	int N;
	vector<int> a;
	cin >> N;
	for(int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	int d = a.front();
	int u = a.back();
	if(u - d > 1) {//上の考察から，これはありえない
		cout << "No\n";
		return 0;
	}
	if(u == d) {
		if(u == N - 1) {//すべての猫が単独
			cout << "Yes\n";
			return 0;
		} else {//すべての猫について，他に同じ色の猫が存在する
			if(N >= 2 * u) {
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		}
	} else {//単独とそうでない猫が両方いる
		int num = 0;//単独の猫の数
		while(a[num] == d) ++num;
		if(u > num //割り当てる色がまだ残っている
			&& N - num >= 2 * (u - num)) {//単独でない N - num 匹の猫を各々2匹以上からなる u - num 個のグループに分けられるか？
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
	return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1e9

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

    string S;
    cin >> S;
    if (S.length() == 2) cout << S << endl;
    else {
        cout << S[2]<< S[1] << S[0] << endl;
    }
}

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

bool solve() {
    ll N;
    cin >> N;
    ll t0 = 0, x0 = 0, y0 = 0, t, x, y;
    bool ans = true;
    for ( int i = 0; i < N; i++ ) {
        cin >> t >> x >> y;
        if ( abs((x - x0) + (y - y0) - (t - t0)) % 2 != 0 ) ans &= false;
        if ( abs(x - x0) + abs(y - y0) > t - t0 ) ans &= false;
        t0 = t, x0 = x, y0 = y;
    }
    return ans;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main()
{
    string a;
    string b;
    int result;
    cin>>a;

    for(int i=0;i<3;i++)
    {

        if(a.compare(i,1,"1")==0){
              b+="9";
        }
        else {
        b+="1";
        }

    }

    cout<<b;
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_left

N, K = [int(i) for i in input().split()]

memo = [0] * (10 ** 5 + 10)
for _ in range(N):
    a, b = [int(i) for i in input().split()]
    memo[a] += b

print(bisect_left(list(accumulate(memo)), K))

Measured memory_bytes: 10620
n = gets.to_i
m = gets.split(" ").map(&:to_i)
count = 1
check = 0

(1..n-1).to_a.reverse.each do |i|
  (0..i-1).to_a.reverse.each do |j|
    if m[i] < m[j]
      check += 1
    end
  end
  if check == 0
    count += 1
  end
  check = 0
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) \
  it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

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

    int n;
    cin >> n;
    if(n % 2 == 0) cout << n << endl;
    else cout << 2*n << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define lli long long int
#include<vector>
int main(){
  lli n,m,sum=0,i,cost,num,u;
  cin>>n>>m;
  vector< pair<lli,lli> >p(n);
  for(i=0;i<n;i++){
    cin>>cost;
    cin>>num;
    p[i]=make_pair(cost,num);
  }
  sort(p.begin(),p.end());
  lli z=m;
  for(i=0;i<n;i++){
    u=min(z,p[i].second);
    sum=sum+u*p[i].first;
    z=z-u;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline


N = int(input())
mod=1e+9 +7
dp = [[[[0]*4 for i in range(4)] for j in range(4)] for k in range(N+1)]
dp[0][3][3][3]=1
for len in range(N):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                if dp[len][c1][c2][c3] == 0: continue
                for a in range(4):
                    if c2==0 and c3==1 and a==2: continue
                    if c2==0 and c3==2 and a==1: continue
                    if c2==1 and c3==0 and a==2: continue
                    if c1==0 and c3==1 and a==2: continue
                    if c1==0 and c2==1 and a==2: continue
                    dp[len+1][c2][c3][a]+=dp[len][c1][c2][c3]
                    dp[len+1][c2][c3][a]%=mod
ans=0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans+=dp[N][i][j][k]
            ans%=mod
print(int(ans))


Measured memory_bytes: 49648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC007 {
    class Program {
        static void Main(string[] args) {
            int[] hw = scan;
            int h = hw[0], w = hw[1];
            int min = 0,max=0;
            for (int i = 0; i < h; i++) {
                var root = Console.ReadLine();
                for(int j = 0; j < root.Length; j++) {
                    if (root[j] == '#') {
                        if (j < max) {
                            Console.WriteLine("Impossible");
                            return;
                        }
                        if (max<=j) {
                            max = j;
                        }
                        //if (min <= j) {
                        //    min = j;
                        //    break;
                        //}else {
                        //    Console.WriteLine("Impossible");
                        //    return;
                        //}
                    }
                }
            }
            Console.WriteLine("Possible");
    }
        static int[] scan {
            get {
                return Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            }
        }
    }
}


Measured memory_bytes: 2776
import java.util.Scanner;


public class Main {

    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int Ans1, Ans2;
        double Ans3;
        String str[];
        str = new String[2];
        int num[];
        num = new int[2];
        for(int i=0; i<=1; i++)
            {
            str[i] = in.next();
            num[i] = Integer.parseInt(str[i]);
            }
        Ans1 = num[0]/num[1];
        Ans2 = num[0]%num[1];
        
        Ans3 = (double)num[0]/(double)num[1];
        String Ans3after = String.format("%.5f", Ans3);
        System.out.println(Ans1+" "+Ans2+" "+Ans3after);
    }
    
}

Measured memory_bytes: 26416
S = input()


def solve(S):
    buf = [1] * len(S)

    for i in range(len(buf) - 2):
        if S[i:i+2] == "RR":
            buf[i+2] += buf[i]
            buf[i] = 0

    for i in range(len(buf) - 1, 1, -1):
        if S[i-1:i+1] == "LL":
            buf[i-2] += buf[i]
            buf[i] = 0

    return " ".join(map(str, buf))


print(solve(S))


Measured memory_bytes: 17108
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.typecons, std.math;
void main(){
    auto S = readln.chomp;
    ulong min = 0, max = 0;
    foreach (i,c; S) {
        if (c == 'A') {
            min = i;
            break;
        }
    }
    foreach_reverse (i,c; S) {
        if (c == 'Z') {
            max = i;
            break;
        }
    }
    writeln(max - min + 1);
}

Measured memory_bytes: 2684
import time
import math
N=int(input())
if N==1:
    print(1)
    exit()


d=[1]*(N+1)

ans=0
for i in range(1,N+1):
    # しょこうi こうさi
    # まっこう N-N%i
    ans+=(N//i)*(i+N-N%i)//2


print(ans)



Measured memory_bytes: 141592
#include <iostream>
#include <vector>

using namespace std;

int Q;
static const int MAX = 100001;

vector<bool> isPrime(MAX, true);
vector<int> is_like_2017(MAX, 0);
void eratos();

int main() {
    cin >> Q;
    eratos();
    for (int i = 1; i < MAX; i+= 2) {
        if (isPrime[i] and isPrime[(i+1)/2])
            is_like_2017[i] = 1;
    }
    
    for (int i = 1; i <= MAX; i++) {
        is_like_2017[i] += is_like_2017[i-1];
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        cout << is_like_2017[r] - is_like_2017[l-1] << '\n'; 
    }

}

void eratos() {

    // [0], [1] -> false
    isPrime[0] = isPrime[1] = false;
    // iを残してiの倍数を消していく
    for (int i = 2; i*i <= MAX; i++) {
        if (isPrime[i]) {
            int j = i + i;
            while (j <= MAX) {
                isPrime[j] = false;
            j = j + i;
            }
        }
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100000;
const int INF = 1e9 + 5;

LL represent(int x) {
	if (x == 0) return 0;
	LL rep;
	if (x % 2 != 0) rep = represent((x - 1) / -2) << 1 | 1;
	else rep = represent(x / -2) << 1;
	return rep;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N;
	cin >> N;
	LL rep = represent(N);
	if (rep == 0) {
		cout << 0 << "\n";
		return 0;
	}
	
	vector<int> ans;
	while (rep) ans.push_back(rep & 1), rep >>= 1;
	for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
	cout << "\n";
	
	
	/**** Note MAXN ****/
}


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

#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NH 1000000 
Node r;
 
Node Minimum(Node x);
Node Search(Node u, int x);
Node Fate(int ct, int x, Node u);
Node Successor(Node x);
void Delete(Node z);
void insert(int w);
void inorder(Node x);
void preorder(Node x);

int main(){
  int da, i, x;
  char c[20];
  scanf("%d", &da);
  
 for ( i = 0; i < da; i++ ){
   
    scanf("%s", c);
    
    if (c[0] == 'f' ){
      
      scanf("%d", &x);
      
      Node t = Search(r, x);
      
      if ( t != NIL ) {
	
	printf("yes\n");
	
      }
      
      else {printf("no\n");
	
      }
    } else if ( c[0] == 'i' ){
      
      scanf("%d", &x);
      
      insert(x);
      
    } else if ( c[0] == 'p' ){
      
      inorder(r);
      
      printf("\n");
      
      preorder(r);
      
      printf("\n");
      
    } else if ( c[0] == 'd' ){
      scanf("%d", &x);
      Delete(Search(r, x));
    }
  }
 
  return 0;
}

Node Minimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}
 
Node Search(Node u, int x){
  int ct=0;
  if(u == NIL || u->key == x) return u;
  else if(u->key > x){
    ct = 1;
  }
  return Fate(ct, x, u);
}

Node Fate(int ct, int x,Node u){
  if(ct == 1) return Search(u->left, x);
  return Search(u->right, x);
}
 
Node Successor(Node x){
  Node y;
  if(x->right != NIL) return Minimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
 
void Delete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right == NIL) y = z;
  else y = Successor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;
  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) r = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
}
 
void insert(int w){
  Node y = NIL;
  Node x = r;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = w;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) r = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
 
}
 
void inorder(Node x){
  if(x->left != NIL) inorder(x->left);
  printf(" %d", x->key);
  if(x->right != NIL) inorder(x->right);
}
void preorder(Node x){
  printf(" %d", x->key);
  if(x->left != NIL) preorder(x->left);
  if(x->right != NIL) preorder(x->right);
}



Measured memory_bytes: 20612