akhauriyash/Code-Regression huggingface dataset:
import std;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

const long mod = 998244353;
void solve(){
  
  int n = scan!int;
  X[] xs;
  foreach(_; 0 .. n){
    long x = scan!long, d = scan!long;
    xs ~= X(x, x + d, 1);
  }
  xs.sort!"a.pos<b.pos"();

  auto sta = new Stack!X;
  foreach_reverse(x; xs){
    long pos = x.pos, right = x.right, value = x.value;
    while(sta.length && sta.peek.pos < right){
      X popped = sta.pop;
      right.raiseTo(popped.right);
      value *= popped.value, value %= mod;
    }
    value += 1;
    sta.push(X(pos, right, value));
    log("x:", x, "sta:", sta);
  }
  
  long ans = 1;
  while(sta.length) ans *= sta.pop.value, ans %= mod;
  
  ans.writeln;
}

struct X{
  long pos;
  long right;
  long value;
}

/*
「このロボットを発火したらどこまで吹っ飛ぶか」を
求めると入れ子のカッコ列みたいになる

カッコ列の求め方は。
位置でソートして後ろ（右端）から見ていく。
・自分の射程より手前の奴がスタックにいたらそれを除去し、
　除去した奴の射程の方が良ければ自分の射程をそれに差し替える。
上記を繰り返し、いなくなったら自分がスタックに入る。

通り数について。
最初は通り数は１。
差し替えるとき、除去した奴が持っていた通り数を掛け算する。
自分がスタックに入るとき、通り数を＋１する。
最後にスタックに残ってる奴の通り数を掛け算したものが答え。
*/

// ----- スタック -----
class Stack(T){
	private T[] xs;
	private uint j; // j : 次に書き込む位置
	this(){	}
	this(T[] xs){ this.xs = xs; j = xs.length.to!uint; }
	uint length(){ return j; }
	bool isEmpty(){ return j == 0; }
	void push(T x){
		while(j + 1 >= xs.length) xs.length = xs.length * 2 + 1;
		xs[j ++] = x;
	}
	Stack opOpAssign(string op)(T x){
		if(op == "~"){ push(x); return this; }
		assert(0, "Operator " ~ op ~ "= not implemented");
	}
	T pop(){ assert(j > 0); return xs[-- j]; }
	T peek(){ assert(j > 0); return xs[j - 1]; }
	T opIndex(uint li){ assert(j > 0 && j - 1 >= li); return xs[j - 1 - li]; }
	static Stack!T opCall(){ return new Stack!T; }
	static Stack!T opCall(T[] xs){ return new Stack!T(xs); }
	T[] array(){ return xs[0 .. j]; }
	override string toString(){ return array.to!string; }
}


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

int main(){
	
	int n;
	int i;
	int a,b,c;
	
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a >> b >> c;
		int max =  a > b ? (a > c ? a : c) : (b > c ? b : c);
		
		if(a*a+b*b+c*c == 2*max*max)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int number,a=0,b=0,o=0,ab=0;
    char blood[3],type1[]="A",type2[]="B",type3[]="O",type4[]="AB";
    
    while(scanf("%d,%s",&number,blood)!=EOF){
        if(strcmp(blood,type1)==0)
            a++;
        else if(strcmp(blood,type2)==0)
            b++;
        else if(strcmp(blood,type3)==0)
            o++;
        else if(strcmp(blood,type4)==0)
            ab++;
        //printf("%d %d %d %d\n",a,b,o,ab);
    }
    printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
    
    
    
    return 0;
}

Measured memory_bytes: 1720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;

int main(){
  string s;
  cin >> s;
  int count = 0;
  bool ans = true;
  if(s[0]!= 'A') {
    ans = false;
  }

  for(int i = 2; i < s.length() -1; ++i){
    if(s.at(i) == 'C'){
      ++count;
    }
  }
  if(count != 1){
    ans = false;
  }

  count = 0;

  for(int i = 0; i < s.length(); ++i){
    if(s[i] >= 'A' && s[i] <= 'Z'){
      count++;
    }
  }
  if(count != 2){
    ans = false;
  }

  if(ans){
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a>b?b:a
#define pii pair<int, int>
#define mp make_pair
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
class Solution
{
public:
    void solve()
    {
        int n;
        cin >> n;
        deque<ll> q;
        while(n--)
        {
            int t;
            cin >> t;
            if(!t)
            {
                ll i, j;
                cin >> i >> j;
                if(!i)q.push_front(j);
                else q.push_back(j);
            }
            else if(t & 1)
            {
                int i;
                cin >> i;
                cout << q.at(i) << endl;
            }
            else
            {
                int i;
                cin >> i;
                if(!i)q.pop_front();
                else q.pop_back();
            }
        }
    }
};
int main()
{
    Solution s;
    s.solve();
    return 0;
}




Measured memory_bytes: 6208
use std::io;
use std::cmp::Ordering;

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

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

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

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

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

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

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

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

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
    }
    
    let mut vec = vec![ a, b, c ];

    vec.sort_by(|a,b| a.cmp(b));
    let length = vec.len();
    
    for (i, element) in vec.iter().enumerate() {
        print!("{:?}", element);
        if i < vec.len()-1 {
            print!(" ");
        }
    }
    println!();
}



Measured memory_bytes: 5032
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N;
char L[112345];
ll power[112345];
int mod = 1000000007;

ll f(int i) {
	if (i == N) return 1;
	if (L[i] == '0') return f(i + 1);
	return (power[N - i - 1] + f(i + 1) * 2) % mod;
}

int main() {

	scanf("%s", L);
	N = strlen(L);
	power[0] = 1;
	rep(i, N + 123) {
		power[i + 1] = power[i] * 3 % mod;
	}

	printf("%lld\n", f(0));

	return 0;
}


Measured memory_bytes: 4224
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val v = (0 until n).map { sc.next().toInt() }
    val c = (0 until n).map { sc.next().toInt() }
    println(problem125b(n, v, c))
}

fun problem125b(n: Int, v: List<Int>, c: List<Int>): Int {
    var sum = 0
    for (i in 0 until n) {
        if (v[i] > c[i]) sum += v[i] - c[i]
    }
    return sum
}

Measured memory_bytes: 29472
# 2019-11-16 21:01:15(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 


mod = 10 ** 9 + 7

def comb(n, r):
    r = min(r, n - r)
    if r == 0: return 1
    if r == 1: return n

    numerator = list(range(n-r+1, n+1))
    denominator = list(range(1, r+1))

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    
    return result

def main():
    x, y = [int(x) for x in sys.stdin.readline().split()]
    # n(+1, +2), m(+2, +1)
    n, m = (2 * y - x) / 3, (2 * x - y) / 3

    if n != abs(int(n)) or m != abs(int(m)):
        print(0)
        sys.exit()
    else:
        n, m = int(n), int(m)
        ans = comb(n+m, n) % mod
        print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 44280
a,b = input().split()
a = int(a)
b = int(b)
c = 0
for i in range(1001):
    d = c*0.08
    e = c*0.1
    d = int(d)
    e = int(e)
    if d == a and e == b:
        print(c)
        break
    elif c == 1000:
        print('-1')
        break
    else:
        c += 1

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <utility>
#include <array>
#include <algorithm>

using namespace std;

int map[16][16];

int main(){
    int a, b;
    cin >> a >> b;
    while(a){
        for(int i(0);i<16;++i)
            for(int j(0);j<16;++j)
                map[i][j] = 0;
        int n;
        cin >> n;
        vector<pair<int,int>> vec(n);
        int t1,t2;
        while(n--) {
            cin >> t1 >> t2; 
            vec.push_back(make_pair(t1-1,t2-1));
        }
        map[0][0] = 1;
        for(int i(1);i<=a+b-2;++i){
            for(int j(0);j<=i;++j){
                if(j > a - 1) continue;
                if(i-j > b - 1) continue;
                if(find(vec.begin(),vec.end(),make_pair(j,i-j)) != end(vec)){
                    map[j][i-j] = 0;
                    continue;
                }
                if(j==0) {
                    map[0][i] = map[0][i-1];
                    continue;
                }
                if(j==i){
                    map[i][0] = map[i-1][0];
                    continue;
                }
                map[j][i-j] = map[j-1][i-j] + map[j][i-j-1];
            }
        }
        cout << map[a-1][b-1] << endl;
        
        cin >> a >> b;
    }
}

Measured memory_bytes: 1200
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans = 0;
    int n;cin>>n;
    vector<int> v(n),c(n);
    rep(i,0,n){
        int k;cin>>k;
        v[i] = k;
    }
    rep(i,0,n){
        int k;cin>>k;
        c[i] = k;
    }
    rep(i,0,n){
        if (v[i]>c[i]) ans+= v[i]-c[i];
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    int q;
    cin >> s >> q;
    deque<char> dq;
    rep (i, s.size()) dq.push_back(s[i]);
    int cnt = 0;
    rep (i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            cnt++;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (cnt % 2) f++;
            if (f % 2) dq.push_front(c);
            else dq.push_back(c);
        }
    }
    string res = "";
    while (!dq.empty()) {
        res += dq.front();
        dq.pop_front();
    }
    if (cnt % 2) reverse(res.begin(), res.end());
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 1368
n = int(input())
s = [input() for i in range(n)]
m= int(input())
t = [input() for i in range(m)]

c = 0

for i in range(n):
    a = 0
    b = 0
    for j in range(n):
        if s[i] == s[j]:
            a += 1

    for j in range(m):
        if s[i] == t[j]:
            b += 1

    if c < a-b:
        c = a-b

print(c)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define int long long

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

    double in;
    string kind;
    
    int x;
    
    cin >> x;
    
    int ysum = 0;
    double bsum = 0;
    
    for(int i = 0; i < x; ++i)
    {
        cin >> in >> kind;
        
        if(kind == "JPY")
        {
            ysum += in;
        }
        else
        {
            bsum += in;
        }
    }

    cout << ysum + bsum * 380000.0 << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b, c, d;
	scanf("%d %d %d", &a, &b, &c);
	while ((a> b) || (b>c)||(a>c))
	{

		if (a > b)
		{
			d = a;
			a = b;
			b = d;
		}
		if (b > c)
		{
			d = b;
			b = c;
			c = d;
		}
		if (a > c)
		{
			d = a;
			a = c;
			c = d;
		}
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2052
m,d=map(int,input().split())
ans=0
for i in range(1,m+1):
    for j in range(1,d+1):
        d10=j//10
        d1=j-(j//10*10)
        if i==d10*d1 and d1>=2 and d10>=2:
            ans+=1
print(ans)
            
        

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

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

    int N;
    cin >> N;

    string s;
    cin >> s;

    cout << (N % 2 ? "No" : (s.substr(0, N/2) == s.substr(N/2) ? "Yes": "No")) << '\n';

    return 0;
}


Measured memory_bytes: 256
n = int(input())

an = list(map(int, input().split()))

if min(an) == 0:
    print(0)
else:
    calc = 1
    is_ok = True
    for i in sorted(an, reverse=True):
        calc *= i
        if calc >10 ** 18:
            is_ok = False
            break
    if is_ok:
        print(calc)        
    else:
        print(-1)

Measured memory_bytes: 84748
#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

#include <iomanip>

using namespace std;

typedef pair<int, int> pint;
typedef vector<int> vint;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))

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

#define NEXTP(c) next_permutation(ALL(c))
#define SUM(c) accumulate(ALL(c),0)
#define MP( a, b ) make_pair( ( a ), ( b ) )

#define ANS(x)  cout << (x) << endl;
#define DUMP(x)  cerr << #x << " = " << (x) << endl;

#define INF 1000000000 // 10^9
const double EPS = 1e-10;

struct data{
    vint board;
    int cost;
};

int main(){
    map<vint, int>ret;
    data fd;
    REP(i, 8)fd.board.push_back(i);
    fd.cost=0;
    
    queue<data>que;
    que.push(fd);
    ret[fd.board]=0;
    
    int def[4] = {-4,-1,+1,+4};
    
    while (que.size()) {
        data d = que.front();
        que.pop();
        //0の位置をさがす
        int pos;
        for (pos = 0; pos <= 7; pos++) {
            if (d.board[pos]==0) break;
        }
        //交換
        REP(i, 4){
            int tar = pos + def[i];
            //範囲チェック
            if (!(0<=tar&&tar<=7)) continue;
            if ((pos==3&&tar==4)||(pos==4&&tar==3)) continue;
            
            vint search = d.board;
            search[pos]=d.board[tar];
            search[tar]=d.board[pos];
            
            //被りチェック
            map<vint, int>::iterator itr;
            itr = ret.find(search);
            if(itr!=ret.end()) continue;
            
            //キューに追加
            data nd;
            nd.board = search;
            nd.cost=d.cost+1;
            que.push(nd);
            
            ret[search]=nd.cost;
        }
    }
    
    vint b(8);
    while (cin>>b[0]) {
        FOR(i, 1, 8)cin>>b[i];
        cout<<ret[b]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3772
# コンビネーション
mod = 10**9+7
def cmb(n, r, mod=mod):
    if ( n<0 or r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 10**6 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N = int(input())

ans = 0
for n in range(1, N//3+1):
    ans = (ans + cmb(N-2*n-1, n-1)) % mod

print(ans)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};




int main(){
  
  int n;
  ll res = 0;
  cin >> n;
  vector<ll> v(n);
  REP(i,n)cin >> v[i];
  vector<ll> digit(60,0);
  REP(i,n){
    for(int j = 0;j < 60;j++){
      if(v[i] % 2 == 1)digit[j]++;
      v[i] /= 2;
    }
  }
  ll two = 1;
  for(int i = 0;i < 60;i++){
    ll many = (digit[i]*(n-digit[i]))%MOD;
    many = (many*(two%MOD))%MOD;
    res = (res+many)%MOD;
    two = (two*2)%MOD;
  }
  cout << res << endl;


  return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int max = Integer.MIN_VALUE;
			int number = -1;
			for(int i = 0; i < n; i++){
				final int p = sc.nextInt();
				final int sum = sc.nextInt() + sc.nextInt();

				if(max < sum){
					max = sum;
					number = p;
				}
			}
			
			System.out.println(number + " " + max);
			
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <limits>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    bool allneg = true;
    vector<int64_t> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
        if(a[i] > 0) allneg = false; 
    }

    if(allneg) {
        auto m = max_element(a.begin(), a.end());
        cout << *m << endl;
        cout << N-1 << endl;
        int d = distance(a.begin(), m);
        for(int i=N-1; i>=0; i--) {
            if(i > d) {
                cout << i+1 << endl;
            } else if(i == d) {
                break;
            }
        }
        for(int i=0; i<d; i++) {
            cout << 1 << endl;
        }
        return 0;
    }

    vector<int> odd, even;
    int64_t odd_ans = 0, even_ans = 0;
    for(int i=0; i<N; i++) {
        if(a[i] < 0) continue;
        if(i%2) {
            odd.emplace_back(i);
            odd_ans += a[i];
        } else {
            even.emplace_back(i);
            even_ans += a[i];
        }
    }

    vector<int> ans;
    if(odd_ans > even_ans) {
        cout << odd_ans << endl;
        for(int i=N-1; i>=0; i--) {
            if(i > odd.back()) ans.emplace_back(i);
            else if (i == odd.back()) break;
        }
        for(int i=0; i<N; i++) {
            if(i < odd.front()) ans.emplace_back(0);
            else if(i == odd.front()) break;
        }
        for(int i=N-1; i>=0; i--) {
            if(odd.front() < i && i < odd.back() && i%2 && a[i] < 0) ans.emplace_back(i - odd.front());
        }
        for(int j=0; j<odd.size()-1; j++) {
            ans.emplace_back(1);
        }
    } else {
        cout << even_ans << endl;
        for(int i=N-1; i>=0; i--) {
            if(i > even.back()) ans.emplace_back(i);
            else if (i == even.back()) break;
        }
        for(int i=0; i<N; i++) {
            if(i < even.front()) ans.emplace_back(0);
            else if(i == even.front()) break;
        }
        for(int i=N-1; i>=0; i--) {
            if(even.front() < i && i < even.back() && i%2 == 0 && a[i] < 0) ans.emplace_back(i - even.front());
        }
        for(int j=0; j<even.size()-1; j++) {
            ans.emplace_back(1);
        }
    }

    cout << ans.size() << endl;
    for(auto e: ans) {
        cout << e+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = 0;
		result = a+b;
		if(result >= 24) result -= 24;
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
    
using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;
vector< pll > v(50);
int ans = 50;
int N;

int main(){
    
    cin >> N;
    
    for(ll i = 0; i < N; i++){
        cin >> v[i].first >> v[i].second;
    }
    if(DEBAG){
        for(int i = 0; i < N; i++){
            cout << v[i].first << v[i].second << endl;
        }
    }
    
    v.resize(N);
    sort(all(v));
    
    if(DEBAG){
        cout << "sort" << endl;
        for(int i = 0; i < N; i++){
            cout << v[i].first << v[i].second << endl;
        }
    }
    
    ans = N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){

            if(i != j){
                ll dx = v[j].first - v[i].first;
                ll dy = v[j].second - v[i].second;

                int cnt = 0;
                for(int k = 0; k < N; k++){
                    for(int l = 0; l < N; l++){
                        if( k != l){
                            ll dx2 = v[l].first - v[k].first;
                            ll dy2 = v[l].second - v[k].second;
                            if(dx == dx2 && dy == dy2){
                                cnt ++;   
                            } 

                        }
                    }
                }
                ans = min(ans, (N - cnt) );
            }
        }
    }

    cout << ans << endl;    
    
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  int data[10];
  int max;
  int i, j, p;

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

  for(i=0;i<3;i++){
    p=0;
    max=-1;
    for(j=0;j<10;j++){
      if(data[j]>max){
	p=j;
	max=data[j];
      }
    }
    printf("%d\n", data[p]);
    data[p]=0;
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Food
    {
        internal string name;
        internal int wt, cap;

        public override string ToString()
        {
            return name;
        }
    }

    class Problem
    {
        readonly int n;

        Food[] foods;
        bool[] used;
        double minBal;
        string minPath;

        public Problem(int n)
        {
            this.n = n;
            foods = new Food[n];
            used = new bool[n];
            minBal = double.MaxValue;
            minPath = "";
        }

        public void Solve()
        {
            Food temp;
            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                temp.name = input[0];
                temp.wt = int.Parse(input[1]);
                temp.cap = int.Parse(input[2]);
                foods[i] = temp;
            }

            DFS(0, 0, 0, "");

            StringBuilder sb = new StringBuilder();
            string[] ans = minPath.Split(' ');

            for (int i = n - 1; i >= 0; i--)
            {
                sb.AppendLine(ans[i].ToString());
            }
            Console.Write(sb);
        }

        private void DFS(int depth, int sumWt, int sumB, string path)
        {
            if (depth == n)
            {
                double bal = (double)sumB / sumWt;

                if (minBal > bal)
                {
                    minBal = bal;
                    minPath = path;
                }
                return;
            }

            for (int i = 0; i < n; i++)
            {
                if (used[i] || sumWt > foods[i].cap) continue;

                used[i] = true;

                DFS(depth + 1, sumWt + foods[i].wt, sumB + foods[i].wt * (n - depth), path + foods[i].name + " ");

                used[i] = false;
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Problem p = new Problem(n);
                p.Solve();
            }
        }
    }
}

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

int n,m,x;
int flag[12];
int c[12];
int a[12][12];
int min1=INF;

void rec(int i){
  if(i==n){
    int sum=0;
    int aa[12];
    rep(i,m)aa[i]=0;
    rep(i,n){
      if(flag[i]==1){
        sum+=c[i];
        rep(j,m){
          aa[j]+=a[i][j];
        }
      }
    }
    int flag1=1;
    rep(i,m){
      if(aa[i]<x)flag1=0;
    }
    if(sum < min1 && flag1==1)min1=sum;
    return;
  }
  flag[i]=1;
  rec(i+1);
  flag[i]=0;
  rec(i+1);
}

int main(){
  cin >> n >> m >> x;
  
  rep(i,n){
    cin >> c[i];
    rep(j,m)cin >> a[i][j];
  }
  rec(0);
  if(min1==INF)cout << "-1" << endl;
  else cout << min1 << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    ans+=a[i]/2;
    if(i+1<n&&a[i]%2==1&&a[i+1]>0){
      a[i+1]--;
      ans++;
    }
  }
  COUT(ans);
}

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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

ll N;
static ll a[131072], b[131072];
int main(void){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i];
	}
	ll cnt = 0;
	for(int i=N-1;i>=0;i--){
		ll d = (b[i] - (a[i] + cnt) % b[i]) % b[i];
		cnt += d;
	}
	cout << cnt << endl;
	
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(min(a,b) < c && c < max(a,b)) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//
// Weighted Union Find Tree
//
// verified:
//   ABC 087 D - People on a Line
//     https://beta.atcoder.jp/contests/abc087/tasks/arc090_b
//

#include <iostream>
#include <vector>
#include <map>
using namespace std;


template<class Abel> struct UnionFind {
    const Abel UNITY_SUM = 0;      // to be set
    vector<int> par, rank;
    vector<Abel> diff_weight;
    
    UnionFind(int n) : par(n), rank(n, 0), diff_weight(n, UNITY_SUM) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    void init(int n) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = UNITY_SUM;
    }
    
    int root(int x) {
        if (par[x] == x) return x;
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
    
    Abel calc_weight(int x) {
        root(x);
        return diff_weight[x];
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y, Abel w = 0) {
        w += calc_weight(x); w -= calc_weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
    
    Abel diff(int x, int y) {
        return calc_weight(y) - calc_weight(x);
    }
};



/* debug */
template<class Abel> ostream& operator << (ostream& s, UnionFind<Abel> uf) {
    map<int, vector<int> > res;
    for (int i = 0; i < uf.par.size(); ++i) {
        int r = uf.root(i);
        res[r].push_back(i);
    }
    for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
        s << endl;
        for (int j = 0; j < (int)it->second.size(); ++j) {
            s << it->second[j] << "(" << uf.calc_weight(it->second[j]) << "), ";
        }
    }
    return s << endl;
}




int main() {
	int N, M;
	cin >> N >> M;
    UnionFind<long long> uf(N);
	for (int i = 0; i < M; ++i) {
		int l, r, d; cin >> l >> r >> d; --l, --r;
		if (uf.issame(l, r)) {
			long long diff = uf.diff(l, r);
			if (diff != d) {
				puts("No");
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}
	puts("Yes");
}

Measured memory_bytes: 1792
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any) = pw.print(s)
fun println(s: Any) = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, X) = nextIntList()
    val x = nextIntList()
    val d = (x + X).sorted().distinct().windowed(2) { it[1] - it[0] }
    val ans = d.reduce { n, m -> gcd(n, m) }
    println(ans)
}

fun <T, R> List<T>.windowed(size: Int, transform: (List<T>) -> R): List<R> {
    return (0..this.size - size step 1).map { i ->
        transform(this.slice(i until i + size))
    }
}

tailrec fun gcd(a: Int, b: Int): Int {
    if (a < b) return gcd(b, a)
    if (b == 0) return a
    if (a <= 0) throw IllegalArgumentException()
    return gcd(b, a % b)
}

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

int main(){
	int n;
	cin >> n;
	int a[n];
	REP(i,n) cin >> a[i];
	sort(a,a + n);
	cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 256
//
// Created by 永徳泰明 on 2019-01-20.
//

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;
#define dump(x)  cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define fill(x, y) memset(x,y,sizeof(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 999999999;

void readFromInputFile() {
#ifdef LOCAL
    static std::ifstream in("/Users/hoo/CLionProjects/for_atcoder/input");
    std::cin.rdbuf(in.rdbuf());
#endif
}

int nexta(int a){
    return (a % 2) ? 3*a+1 : a/2;
}

int main() {
    readFromInputFile();
    int s;
    cin>>s;
    set<int> l;

    l.insert(s);
    rep(i,1000005){
        s = nexta(s);
        if (l.count(s)) {
            cout<<i+2<<endl;
            return 0;
        }
        l.insert(s);
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>

using namespace std;
int n, m;
string a[55], b[55];
int main(void) {
	int i, j, k;
	cin >> n >> m;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < m; i++) cin >> b[i];
	for (i = 0; i <= n - m; i++) for (j = 0; j <= n - m; j++) {
		for (k = 0; k < m; k++) if (a[i + k].substr(j, m) != b[k]) break;
		if (k == m) { cout << "Yes"; return 0; }
	}
	cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  int x;
  int exist[100000];
  int duplicate = 0;
  cin >> N;


  for(int i = 0; i < 100000; i++) exist[i] = 0;
  for(int i = 0; i < N; i++){
    cin >> x;
    if(exist[x] == 1){
      duplicate++;
    }
    else{
      exist[x] = 1;
    }
  }

  if(duplicate % 2 == 0){
    cout << N - duplicate << endl;
  }
  else{
    cout << N - duplicate - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
#define mod 1000000007
#define nos ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int dp[3005][3005];
int n,t;
int happy(vector<pair<int,int>>&a,int pidx,int time)
{
    if(time>=t||pidx>=n)
    return 0;
    if(dp[pidx][time]!=-1)
    return dp[pidx][time];
    return dp[pidx][time]=max(a[pidx].s+happy(a,pidx+1,time+a[pidx].f),happy(a,pidx+1,time));
}
int32_t main() {
    nos;
    cin>>n>>t;
    vector<pair<int,int>>a(n);
    for(int i=0;i<n;i++)
    cin>>a[i].f>>a[i].s;
    sort(a.begin(),a.end());
    memset(dp,-1,sizeof(dp));
    cout<<max(a[0].s+happy(a,1,a[0].f),happy(a,1,0));
    return 0;
}


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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a >= k) cout << k << endl;
    if (a < k && a + b >= k) cout << a << endl;
    if (a + b < k && a + b + c >= k) cout << a - (k -a - b) << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) v.begin(), v.end()
//bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
//bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll N, ans=0;

ll input() {
  ll x;
  cin >> x;
  return x;
}

int main() {
  cin >> N;
  sl S;
  rep(i, N) S.insert(input());
  cout << S.size() << endl;
  return 0;
}

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

struct rw{
	int t,x,e;
	rw(){};
	rw(int t_,int x_,int e_){
		t=t_,x=x_,e=e_;
	};
	bool operator<(const rw& o)const {return t<o.t;}
};

signed main(){
	int n,q;cin>>n>>q;
	vector<int> d(q),ans;
	vector<rw> r;
	rep(i,n){
		int s,t,x;cin>>s>>t>>x;
		r.push_back(rw(s-x,x,1));
		r.push_back(rw(t-x,x,-1));} 
	for(auto&& u:d)cin>>u;
	sort(begin(r),end(r));

		int idx=0;
		multiset<int>s; 
	for(auto&& u:d){
		while(idx<r.size()&&r[idx].t<=u){
			if(r[idx].e==1)s.insert(r[idx].x);
			else s.erase(s.find(r[idx].x));
			idx++;
		}
		if(s.empty())ans.push_back(-1);
		else ans.push_back(*begin(s));
	}	
	for(auto&& u:ans)cout<<u<<endl;
}


Measured memory_bytes: 27240
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int dp[51][51][51][51]={};
const int MIN=INT_MIN/10;
int dfs(int live,int lv0,int lv1,int lv2,vi &a,vi &b,vi &c){
	if(dp[live][lv0][lv1][lv2]!=MIN){
		return dp[live][lv0][lv1][lv2];
	}
	if(live==a.size()){
		return 0;
	}
	int ret=MIN;
	REP(k,lv2+1){
		REP(i,min(8,k)+1){
			REP(j,8-i+1){
				if(lv1>=j){
					int plus=0;
					if(i==0&&j==0){
						plus=c[live];
					}else{
						plus=a[live]*i+b[live]*j;
					}
					ret=max(ret,dfs(live+1,lv0+lv1,k,lv2-k,a,b,c)+plus);
				}
			}
		}
	}
	return dp[live][lv0][lv1][lv2]=ret;
}
int main(){
	int n,m;
	cin>>n>>m;
	vi a(n),b(n),c(n);
	REP(i,51)REP(j,51)REP(k,51)REP(l,51)dp[i][j][k][l]=MIN;
	REP(i,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	cout<<dfs(0,0,0,m,a,b,c)<<endl;

	//REP(i,51){
	//	int aa=0;
	//	REP(j,51)REP(k,51)REP(l,51){
	//		aa=max(aa,dp[i][j][k][l]);
	//	}
	//	cout<<i<<" "<<aa<<endl;
	//}
}

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

int main() {
  int n;
  std::cin >> n;
  std::vector<double> a(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  double ans = 0;
  for (int i = 0; i < n; ++i) ans += 1 / a[i];
  ans = 1 / ans;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    Rep(i, 1, 10){
        Rep(j, i, 10){
            if(i*j == N){
                pr("Yes");
                return 0;
            }
        }
    }
    pr("No");
}

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

using namespace std ;

typedef long long LL ; 

int main() { 
		int n, a ,b ; 
		scanf("%d%d%d", &n, &a, &b) ; 
		if (a > b) puts("0") ;
		else if (n == 1) printf("%d\n", a == b) ; 
		else  cout << 1LL * (b - a) * (n - 2) + 1 << endl ; 
}




Measured memory_bytes: 256
N=int(input())
x=[list(map(int,input().split(" "))) for i in range(N)]

x=sorted(x, key=lambda x:x[1],reverse=False)

T=0
for e in x:
    T+=e[0]
    if e[1]<T:
        print("No")
        exit()
print("Yes")

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

using namespace std;

const int MAX_N = 305;

char grid [MAX_N][MAX_N];
int forb [MAX_N];

int n;
void process (int i, int j, int k, int l) {
  if (grid[i][j] == grid[k][l]) return;
  forb[(j + n - k) % n] = 1;
}

vector<pair<int, int>> bucket [MAX_N];

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

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      bucket[(i + j) % n].push_back({i, j});
    }
  }

  for (int i = 0; i < n; i++) {
    for (auto p : bucket[i]) {
      for (auto q : bucket[i]) {
        process(p.first, p.second, q.first, q.second);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!forb[i]) {
      ans += n;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1536
#include<stdio.h>

int main (void){
	
	int i,j;
	char c[30]={};
	
	for(i=0;;i++){
	scanf("%c",&c[i]);
	if(c[i]=='\n')break;
	}
	
	for(j=i-1;j>=0;j--){
		printf("%c",c[j]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

ll func(int n){
    if(n == 0) return 1;
    return n*func(n-1)%1000000007;
}

int main()
{
    int N,M;
    cin >> N >> M;
    if(abs(N-M) > 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    if(N==M){
        ans = func(N)*func(M)*2%1000000007;
    }else{
        ans = func(N)*func(M)%1000000007;
    }
    cout << ans << endl;


    return 0;
}


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

def main():
    N = int(input())
    upper_list = list(map(int, input().split()))
    lower_list = list(map(int, input().split()))
    sum_list = []
    for v in range(N):
        sum_list.append(sum(upper_list[0:v+1]) + sum(lower_list[v:]))
    print(max(sum_list))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
using Base.Collections
function main()
	lines=readlines()
	shift!(lines)
	B=0
	L=PriorityQueue(Int,Int)
	R=PriorityQueue(Int,Int)
	id=0
	for s=lines
		if s[1]=='1'
			_,a,b=map(x->parse(Int,x),split(s))
			B+=b
			if length(L)>length(R)
				B-=a
				L[id+=1]=-a
				a=-peek(L).second
				dequeue!(L)
				B+=2a
				R[id+=1]=a
			else
				B+=a
				R[id+=1]=a
				a=peek(R).second
				dequeue!(R)
				B-=2a
				L[id+=1]=-a
			end
		else
			w=-peek(L).second
			println("$w $(B+(length(L)>length(R) ? w : 0))")
		end
	end
end
main()


Measured memory_bytes: 196852
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

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

signed main(){
	IOS;
	ll t;
	cin >> t;
	REP(i,t){
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		if(d < b || a < b){
			dump("No");
			continue;
		}
		else if(c >= b){
			dump("Yes");
			continue;
		}
		ll g = gcd(b, d);
		if(c >= b - g + a % g)dump("Yes");
		else dump("No");
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
import cmath

def main():
    a, b, h, m = map(int, input().split())
    h_ang = 2 * cmath.pi * (h / 12 + m / 12 / 60)
    m_ang = 2 * cmath.pi * m / 60

    h_cpl = cmath.rect(a, -h_ang)
    m_cpl = cmath.rect(b, -m_ang)
    ret = abs(h_cpl - m_cpl)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9504