akhauriyash/Code-Regression huggingface dataset:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

#------------------------------------------#

BIG_NUM = 2000000000
HUGE_NUM = 9999999999999999
MOD = 1000000007
EPS = 0.000000001


def MIN(A,B):
    if A <= B:
        return A
    else:
        return B

def MAX(A,B):
    if A >= B:
        return A
    else:
        return B

#------------------------------------------#

class Point:
    def __init__(self,arg_x,arg_y):
        self.x = arg_x
        self.y = arg_y


def roll(div1,div2):
    tmp_start = Point(div2.x-div1.x,div2.y-div1.y)
    tmp_end = Point(tmp_start.x*math.cos(math.pi/3) -tmp_start.y*math.sin(math.pi/3),
                    tmp_start.x*math.sin(math.pi/3) + tmp_start.y*math.cos(math.pi/3))
    ret = Point(tmp_end.x + div1.x,tmp_end.y + div1.y)
    return ret;


def outPut(point):
    print("%.8f %.8f"%(point.x,point.y))


def calc(left,right,count):
    div1 = Point((2*left.x + right.x)/3,(2*left.y + right.y)/3)
    div2 = Point((2*right.x + left.x)/3,(2*right.y + left.y)/3)
    peek = roll(div1,div2)

    if count > 1:
        calc(left,div1,count-1)
        calc(div1,peek,count-1)
        calc(peek,div2,count-1)
        calc(div2,right,count-1)
    else:
        outPut(left);
        outPut(div1);
        outPut(peek);
        outPut(div2);


N = int(input())
left = Point(0,0)
right = Point(100,0)

if N == 0:
    outPut(left)
    outPut(right)
else:
    calc(left,right,N)
    outPut(right)



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

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            string S = cin.next();

            long count = 0;
            for (int i = 0; i < S.Length /2; i++)
            {
                if(!S[i].Equals(S[S.Length - i -1]))
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[][] s = new char[n][];
		for (int i = 0; i < n; i++) {
			s[i] = br.readLine().toCharArray();
		}
		br.close();

		Obj[] arr = new Obj[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			int cnt = 0;
			for (int j = 0; j < s[i].length; j++) {
				if (s[i][j] == '(') {
					cnt++;
				} else {
					cnt--;
					o.min = Math.min(o.min, cnt);
				}
			}
			o.cnt = cnt;
			arr[i] = o;
			total += cnt;
		}
		if (total != 0) {
			System.out.println("No");
			return;
		}

		Arrays.sort(arr, (o1, o2) -> {
			if (o1.min != o2.min) {
				return o2.min - o1.min;
			}
			return o2.cnt - o1.cnt;
		});

		int now = 0;
		List<Obj> list = new ArrayList<>();
		for (Obj o : arr) {
			if (now + o.min < 0) {
				System.out.println("No");
				return;
			}
			if (o.cnt >= 0) {
				now += o.cnt;
			} else {
				list.add(o);
			}
		}

		Collections.sort(list, (o1, o2) -> (o2.cnt - o2.min) - (o1.cnt - o1.min));
		for (Obj o : list) {
			if (now + o.min < 0) {
				System.out.println("No");
				return;
			}
			now += o.cnt;
		}
		System.out.println("Yes");
	}

	static class Obj {
		int min, cnt;
	}
}


Measured memory_bytes: 104264
N, M, Q_ = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(Q_)]

ans = 0

import itertools
l = [i for i in range(1, M+1)]

for p in (itertools.combinations_with_replacement(l, N)):
    tmp = 0
    for a, b, c, d in Q:
        if p[b-1] - p[a-1] == c:
            tmp += d
    ans = max(tmp, ans)
print(ans)









Measured memory_bytes: 67988
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const _k = stdin.split('\n')[0]
const k = Number(_k)

const arr = []
for(let i = 1; i < k; i++){
  arr.push(i)
}

arr.push(k)

let res = 0
arr.forEach((e, i) => {
  if(e % 2 === 0){
    const sliced = arr.slice(i+1)
    res += sliced.filter(e => e%2 !== 0).length
  } else {
    const sliced = arr.slice(i+1)
    res += sliced.filter(e => e%2 === 0).length
  }
})

console.log(res)

Measured memory_bytes: 7500
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append((b-1, i))

v_color = [0] * N
e_color = [0] * (N-1)
K = 1
for a, children in enumerate(G):
    c = 1
    for b, i in children:
        if c == v_color[a]:
            c += 1
        v_color[b] = c
        e_color[i] = c
        K = max(K, c)
        c += 1

print(K)
print('\n'.join(map(str, e_color)))


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<vi> adj(n);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vi dist(n,-1);
    dist[0] = 0;
    queue<int> que;
    que.push(0);
    while(que.size()){
        int v = que.front(); que.pop();
        for(auto u:adj[v]){
            if (dist[u]!=-1) continue;
            dist[u]=dist[v]+1;
            que.push(u);
        }
    }
    if (dist[n-1]==2){
        cout<<"POSSIBLE\n";
    }else{
        cout<<"IMPOSSIBLE\n";
    }
    return 0;
}


Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> x(N+1);
    rep(i, N) cin >> x[i];
    x[N] = X;
    sort(all(x));
    int ans = 0;
    rep(i, N) {
        ans = gcd(ans, x[i+1] - x[i]);
    }
    cout << ans << endl;
}

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

int main() {
    string s;   cin >> s;
    set<char> obj;
    for(int i=0; i<s.size(); i++)   obj.insert(s.at(i));
    ll cnt=0, res=1e+10;
    if(obj.size()==1) res=0;

    for(auto c: obj){
        string str=s;
        bool f = true;
        cnt = 1;
        while(f){
            f = false;
            string tmp;
            for(int i=0; i<str.size()-1; i++){
                if(str.at(i)==c || str.at(i+1)==c) tmp += c;
                else{
                    tmp += s.at(i); f = true;
                }
            }
            if(f){
                str = tmp; cnt += 1;
            }
            
        }
        res = min(cnt, res);
    }
    cout << res << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    char c[4];
    scanf("%s",c);
    if(c[0]<c[1]||(c[0]==c[1]&&c[1]<c[2]))c[0]++;
    printf("%c%c%c\n",c[0],c[0],c[0]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
ll kai(int n){
    if(n == 0 || n == 1)return 1;
    else if(n >= 2){
        return kai(n-1) * n;
    }else{
        return 0;
    }
}


int main(void){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> cost(N, vector<int>(N, INF));
    vector<vector<int>> d(N, vector<int>(N, INF));
    for(int i = 0; i < M; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        cost.at(a).at(b) = c;
        cost.at(b).at(a) = c;
        d.at(a).at(b) = c;
        d.at(b).at(a) = c;
    }
    for(int i = 0; i < N; i++){
        d.at(i).at(i) = 0;
    }
    
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k)+d.at(k).at(j));
            }
        }
    }
    
    
    
    int cnt = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i != j && cost.at(i).at(j) != INF){
                if(d.at(i).at(j) < cost.at(i).at(j)){
                    cnt++;
                }
            }
        }
    }
    
    cnt /= 2;
    cout << cnt << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll A=0,B=0;
  rep(i,n){
    if(a[i]==a[i+1]&&A==0){
      A=a[i];
      i++;
    }
    else if(a[i]==a[i+1]&&A!=0){
      B=a[i];
      break;
    }
  }
  cout << A*B << endl;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int r,g,b,n;

int main(){
    cin>>r>>g>>b>>n;
    int ans = 0;
    FOR(i,0,3001)FOR(j,0,3001){
        int rest = n - i*r - j*g;
        if(rest>=0 && rest%b==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def f_or_l(str, text)
  a = str.gsub(/\?/, 'a')
  z = str.gsub(/\?/, 'z')
  if z < text
    return 2
  elsif a > text
    return 1
  else
    return 0
  end
end

n = gets.to_i
s = []
for i in 0...n
  s << gets.chomp
end
t = gets.chomp

f = 0
l = 0

s.each{|str|
  res = f_or_l(str, t)
  if res == 1
    l += 1
  elsif res == 2
    f += 1
  end
}

ans = []
for i in f..(n - l)
  ans << i+1
end
puts ans.join(" ")


Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    vector<int> p(102,0);
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        p[a]=1;
    }

    int min_=100000;
    int ans=0;
    for(int i=-100; i<102; i++){
        if(i>=0 && p[i]==1)continue;
        else if(abs(X-i)<min_){
            min_=abs(X-i);
            ans=i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,K;
    cin>>N>>K;
    
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin>>x[i];
    }
    
    int tmp;
    int ans=min(abs(x[0])+abs(x[0]-x[K-1]),abs(x[K-1])+abs(x[0]-x[K-1]));
    
    for(int i=1;i<N-K+1;i++){
        tmp=min(abs(x[i])+abs(x[i]-x[i+K-1]),abs(x[i+K-1])+abs(x[i]-x[i+K-1]));
        if(tmp<ans)ans=tmp;
    }
    
    cout<<ans<<endl;
}
    

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	int N;
	cin >> N;


	cout << 3* N * N << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int c[20][1500];

int area( int px, int py, int x, int y){
	return c[y][x] - c[y][px] - c[py][x] + c[py][px];
}

int main(){
	int h, w, k;
	cin >> h >> w >> k;
	for( int i = 0; i < h; ++i ){
		string s; cin >> s;
		for( int j = 0; j < w; ++j ){
			c[i+1][j+1] = c[i][j+1] + c[i+1][j] - c[i][j];
			if( s[j] == '1' ) c[i+1][j+1] += 1;
		}
	}
	int ans = inf;
	for( int cond = 0; cond < (1<<(h-1)); ++cond ){
		int pre_x = 0;
		int columncnt = 0;
		for( int x = 1; x <= w; ++x ) {
			int pre_y = 0;
			for( int y = 1; y <= h; ++y ){
				if( cond & (1<<(y-1)) || y == h ){
					if( area( pre_x, pre_y, x, y ) > k ){
						pre_x = x-1;
						++columncnt;
						break;
					}
					pre_y = y;
				}	
			}
			// 縦線 x-1 で切ったあと，右端が条件（個数 ≤ k）を満たしているかは不明なのでチェック
			if( x == w ){
				pre_y = 0;
				for( int y = 1; y <= h; ++y ){
					if( cond & (1<<(y-1)) || y == h ){
						if( area( pre_x, pre_y, x, y ) > k ){
							columncnt = inf;
						}
						pre_y = y;
					}	
				}
			}
		}
		ans = min( ans, columncnt+__builtin_popcount(cond) );
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
N=int(input())
F=[int(input().replace(' ',''),2) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]
print(max(sum([p[bin(f&i).count('1')] for f,p in zip(F,P)]) for i in range(1,2**10)))

Measured memory_bytes: 3060
s=input()
ls=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for i in range(len(s)):
  if s[i] in ls:
    ls.remove(s[i])
    
if len(ls)>0:
  print(ls[0])
  
else:
  print("None")

Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;
 
int main(void){
  double r, v, s;
  cin >> r;
  v = r * r * M_PI;
  s = 2 * r * M_PI; 
  cout << fixed;
  cout << setprecision(6)<< v << " " << s << endl;
  return 0;
}



Measured memory_bytes: 3284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		int[] y = new int[m];
		for (int i = 0; i < m; i++) {
			y[i] = sc.nextInt();
		}
		sc.close();

		int max = X;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, x[i]);
		}
		int min = Y;
		for (int i = 0; i < m; i++) {
			min = Math.min(min, y[i]);
		}
		if (max < min) {
			System.out.println("No War");
		} else {
			System.out.println("War");
		}
	}
}


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

int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 0; i <= b*100; i++){
        int x = (int)((double)i*0.08);
        int y = (int)((double)i*0.10);
        if(x == a && y == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    if b+c-a > 0{
	println!("{}",b+c-a);
    }else{
	println!("0");
    }
}


Measured memory_bytes: 4352
//by Top
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 4e6 + 111;
     
using namespace std;

int n, q, dp[5][maxn], a[25][25];
vector <int> g[maxn];
bool was[maxn];

int dfs(int v){
	was[v] = true;
	bool ch = false;
	dp[0][v] = 1;
	dp[1][v] = 1;
	for (auto to : g[v]){
		if (!was[to]){
			ch = true;
			dfs(to);
			dp[0][v] *= (dp[0][to] + dp[1][to]);
			dp[1][v] *= dp[0][to];
			dp[0][v] %= mod;
			dp[1][v] %= mod;
		}
	}
}

void solve(){
	cin >> n;

	int x, y;

	for (int i = 1; i < n; i++){
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}

	dfs(1);

	cout << (dp[0][1] + dp[1][1]) % mod;
}

main(){
    boost;
	    
	q = 1;

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

Measured memory_bytes: 111488
M, D = map(int, input().split())
cnt = 0
for i in range(1, M+1):
    for j in range(10, D+1):
        d10 = int(j /10)
        d1 = j % 10
        if i == (d10*d1) and d10 >= 2 and d1 >= 2:
            cnt += 1
print(cnt)

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll A, B;
    cin >> A >> B;
    if((A-B)%2==0){
        if(A==B){
            cout << 0 << endl;
        }
        else{
            ll k = (A+B) / 2;
            cout << k << endl;
        }
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=1e5+5;
#define mst(a) memset(a,0,sizeof a) 
typedef long long ll;
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m){
	int ans=0;
	ans=n*(n-1)/2+m*(m-1)/2;
	cout<<ans<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int n,k;
    string s[105];
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>s[i];
        sort(s,s+n);
        for(int i=0;i<n;i++)
            cout<<s[i];
        cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 100000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int N, K;
	scanf("%d %d", &N, &K);

	ll c1 = 0, c2 = 0;
	for (int i = 1; i <= N; i++) {
		if (i%K == K / 2) c2++;
		if (i%K == 0) c1++;
	}

	ll ans = c1 * c1*c1;
	if (K % 2 == 0) ans += c2 * c2*c2;
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL H, W;
	in >> H >> W;
	std::vector<std::string>A(H);
	rep(i, H) in >> A[i];

	std::vector<std::vector<LL>>dist(H, std::vector<LL>(W, -1));
	std::queue<std::pair<LL, LL>>que;
	rep(i, H)
	{
		rep(j, W)
		{
			if (A[i][j] == '#')
			{
				dist[i][j] = 0;
				que.push(std::make_pair(i, j));
			}
		}
	}

	LL dx[] = { -1,0,0,1 }, dy[] = { 0,-1,1,0 };
	while (!que.empty())
	{
		auto p = que.front(); que.pop();
		rep(k, 4)
		{
			LL x = p.first + dx[k], y = p.second + dy[k];
			if (0 <= x && x < H && 0 <= y && y < W)
			{
				if (dist[x][y] == -1)
				{
					dist[x][y] = dist[p.first][p.second] + 1;
					que.push(std::make_pair(x, y));
				}
			}
		}
	}

	LL ans = 0;
	rep(i, H) rep(j, W) ans = std::max(ans, dist[i][j]);
	out << ans << std::endl;
}


Measured memory_bytes: 25524
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int dp[4];
int l[4];

int main() {
    scanf("%d %d %d %d", &l[0], &l[1], &l[2], &l[3]);
    dp[0] = l[0];
    dp[1] = l[1];
    dp[2] = l[2];
    dp[3] = l[3];
    dp[1] = min(dp[1], 2 * dp[0]);
    dp[2] = min(dp[2], 4 * dp[0]);
    dp[2] = min(dp[2], 2 * dp[1]);
    dp[3] = min(dp[3], 8 * dp[0]);
    dp[3] = min(dp[3], 4 * dp[1]);
    dp[3] = min(dp[3], 2 * dp[2]);
    ll n;
    scanf("%lld", &n);
    n *= 4;
    ll ret = 0;
    for(int i = 3; i >= 0; i--) {
        ret += dp[i] * (n >> i);
        n &= (1<<i)-1;
    }
    printf("%lld\n", ret);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
int main()
{
    init();
    int N, ans = 0;
    cin >> N;
    vector<string> str(N);
    vector<vector<vector<string>>>data(11,vector<vector<string>>(128));
    rep(i, N){
        cin >> str[i];
        int flag = 1;
        rep(j, data[str[i].size()][int(str[i][0])].size()){
            rep(k,str[i].size()){
                if (data[str[i].size()][int(str[i][0])][j][k]!=str[i][k]){
                    break;
                }
                if(k==(str[i].size()-1)){
                    flag = 0;
                    break;
                }
            }
            if(flag==0)break;
        }
        if (flag == 1){
            data[str[i].size()][int(str[i][0])].push_back(str[i]);
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 16764
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int h,w,m;
  cin >> h >> w >> m;
  vp vh(h,P(0,0)),vw(w,P(0,0));
  vector<ll> vhw(m,0);
  rep(i,m) {
    ll a,b;
    cin >> a >> b;
    a--;b--;
    vh.at(a).fi++;
    vh.at(a).se = a;
    vw.at(b).fi++;
    vw.at(b).se = b;
    ll c = (a << 20) + b;
    vhw.at(i) = c;
  }
  sort(rng(vhw));
  sort(rrng(vh));
  sort(rrng(vw));

  int mxh = vh.at(0).fi,mxw=vw.at(0).fi;
  int isz = 0;
  vh.push_back(P(-1,-1));
  rep(k,vh.size()) {
    if(mxh!=vh.at(k).fi) {
      isz = k;
      break;
    }
  }
  int jsz = 0;
  vw.push_back(P(-1,-1));
  rep(k,vw.size()) {
    if(mxw!=vw.at(k).fi) {
      jsz = k;
      break;
    }
  }

  rep(i,isz) rep(j,jsz) {
    ll oi = vh.at(i).se;
    ll t = (oi << 20) + vw.at(j).se;
    auto low = lower_bound(rng(vhw),t);
    auto up = upper_bound(rng(vhw),t);
    if(!(up - low == 1)) {
      cout << vh.at(i).fi + vw.at(j).fi << endl;
      return 0;
    }
  }

  cout << vh.at(0).fi + vw.at(0).fi -1 << endl;

  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<int>> grid(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> grid[i][j];
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 2; j > -1; j--) {
      grid[i][j] -= grid[i][0];
    }
  }
  for (int j = 0; j < 3; j++) {
    for (int i = 2; i > -1; i--) {
      grid[i][j] -= grid[0][j];
    }
  }
  string ans = "Yes";
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (grid[i][j]) {
        ans = "No";
        break;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// Convex Hull Trick
typedef ll LT;
typedef pair<LT,LT> LP;
struct CHT {
  deque<LP> d;
  LT get(LT x) {
    while (sz(d) >= 2) {
      LT a = d[0].fi*x + d[0].se;
      LT b = d[1].fi*x + d[1].se;
      if (a <= b) break; // get min
      d.pop_front();
    }
    return d[0].fi*x + d[0].se;
  }
  void add(LP x) { // decreasing order of x.fi
    while (sz(d) >= 2) {
      LP y = d[sz(d) - 1];
      LP z = d[sz(d) - 2];
      if ((x.se-y.se)*(z.fi-y.fi) >= (y.fi-x.fi)*(y.se-z.se)) break; // both
      d.pop_back();
    }
    d.pb(x);
  }
};
//



int main() {
  int n;
  scanf("%d",&n);
  ll c;
  scanf("%lld",&c);
  vl a(n);
  cin>>a;
  CHT d;
  d.add(LP(-a[0]*2,a[0]*a[0]));
  ll ans;
  rrep(i,n-1) {
    ans = d.get(a[i]);
    ans += c+a[i]*a[i];
    d.add(LP(-a[i]*2,ans+a[i]*a[i]));
  }
  cout<<ans<<endl;
  return 0;
}






















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

namespace ABC_158b
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long count = 0;

            count += input[0] / (input[1] + input[2]) * input[1];
            if (input[0] % (input[1]+input[2]) >= input[1])
            {
                count += input[1];
            }
            else
            {
                count += input[0] % (input[1]+input[2]);
            }
            Console.WriteLine(count);

            Console.Read();
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int cm = 1 << 18;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int N=1e6+10;
ll a[N];
int sum[11];
main(){
    ios
    int h,w,n;
    h=getint();w=getint();n=getint();
    if(w==1000000000 && h==1000000000){
        h-=2,w-=2;
    int x,y;
    int cnt=0;
    ll m=(ll)h*w;
    rep(iii,n){
        x=getint();y=getint();
        rep(i,3)if(x-i>=1 && x-i<=h){
            rep(j,3)if(y-j<=w){
            a[cnt++]=((ll)(x-i)<<32)+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<" ";
    rep2(i,1,9)cout<<sum[i]<<" ";
    }
    else{
    h-=2,w-=2;
    int x,y;
    int cnt=0;
    ll m=(ll)h*w;
    rep(iii,n){
        x=getint();y=getint();
        rep(i,3)if( x-i>=1 && x-i<=h){
            rep(j,3)if(y-j>=1 && y-j<=w){
            a[cnt++]=((ll)(x-i)<<32)+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<" ";
    rep2(i,1,9)cout<<sum[i]<<" ";
    }
}



Measured memory_bytes: 7552
N, L = map(int, input().split())

apples = []
for i in range(1, N+1):
    apples.append(L+i-1)

tast = sum(apples)
for i in range(500):
    if i in apples:
        tast -= i
        break
    elif -i in apples:
        tast += i
        break
print(tast)



Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int a[200],sum[200];
	int inf=0x3f3f3f3f;
	memset(sum,0,sizeof(sum));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(inf>abs(sum[n]-sum[i]-sum[i]))
		{
			inf=abs(sum[n]-sum[i]-sum[i]);
		}
	}
	printf("%d\n",inf);
	return 0;
}

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 sum,i;
		int pasta[] = new int[3];
		int juice[] = new int[2];
		for(i=0;i<3;i++){
			pasta[i]=sc.nextInt();
		}
		for(i=0;i<2;i++){
			juice[i]=sc.nextInt();
		}
		sum=pasta[0]+juice[0]-50;
		for(i=0;i<3;i++){
			for(int j=0;j<2;j++){
				if(sum>pasta[i]+juice[j]-50){
					sum=pasta[i]+juice[j]-50;
				}
			}
		}
		System.out.println(sum);
	}

}

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

int main(){
    int n;
    cin>>n;
    vector<long long>A(n);
    for(int i=0; i<n; ++i) cin>>A[i];
    sort(A.begin(),A.end());
    int num=0;
    for(int i=0; i<n-2; ++i){
        long long l1=A[i];
        for(int j=i+1; j<n-1; ++j){
            long long l2 = A[j];
            if(l1!=l2){
                int pos1 = lower_bound(A.begin()+j+1, A.end(), l1+l2) - A.begin();
                int pos2 = upper_bound(A.begin()+j+1, A.end(), l2) - A.begin();
                num+=(pos1-pos2);
            }
        }
    }
    cout<<num<<"\n";
}

Measured memory_bytes: 3612
#include <vector>
#include <cstdio>
using namespace std;

struct FenwickTree {
	typedef int T;
	vector<T> v;
	void init(int n) { v.assign(n, 0); }
	void add(int i, T x) {
		for(; i < (int)v.size(); i |= i + 1) v[i] += x;
	}
	T sum(int i) const { //[0, i)
		T r = 0;
		for(-- i; i >= 0; i = (i & (i + 1)) - 1) r += v[i];
		return r;
	}
	T sum(int left, int right) const { //[left, right)
		return sum(right) - sum(left);
	}
};

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> p(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &p[i]), -- p[i];
		int BlockSize = 200, NumBlocks = N / BlockSize + 1;
		vector<vector<long long> > memo(NumBlocks, vector<long long>(N));
		FenwickTree ft;
		for(int bi = 0; bi < NumBlocks; ++ bi) {
			vector<long long> &v = memo[bi];
			int i = bi * BlockSize;
			{
				ft.init(N);
				long long sum = 0;
				for(int j = i; j < N; ++ j) {
					sum += (j - i) - ft.sum(p[j]);
					v[j] = sum;
					ft.add(p[j], 1);
				}
			}
			{
				ft.init(N);
				long long sum = 0;
				for(int j = i - 1; j >= 0; -- j) {
					sum += ft.sum(p[j]);
					v[j] = sum;
					ft.add(p[j], 1);
				}
			}
		}
		ft.init(N);
		int Q;
		scanf("%d", &Q);
		for(int ii = 0; ii < Q; ++ ii) {
			int l; int r;
			scanf("%d%d", &l, &r), -- l, -- r;
			int bl = (l + BlockSize - 1) / BlockSize, br = (r - 1) / BlockSize;
			long long ans = 0;
			if(bl > br) {
				for(int i = r; i >= l; -- i) {
					ans += ft.sum(p[i]);
					ft.add(p[i], 1);
				}
				for(int i = l; i <= r; ++ i)
					ft.add(p[i], -1);
			} else {
				int L = bl * BlockSize, R = br * BlockSize;
				ans += memo[bl][r];
				ans += memo[br][l];
				if(bl < br)
					ans -= memo[bl][R - 1];
				for(int i = R; i <= r; ++ i)
					ft.add(p[i], 1);
				for(int i = l; i < L; ++ i)
					ans += ft.sum(p[i]);
				for(int i = R; i <= r; ++ i)
					ft.add(p[i], -1);
			}
			printf("%lld\n", ans); fflush(stdout);
		}
	}
	return 0;
}

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

x = [0]
y = [0]
for i in range(N):
    if S[i] == "W":
        x.append(x[-1]+1)
    else:
        x.append(x[-1])
    if S[N-i-1] == "E":
        y.append(y[-1]+1)
    else:
        y.append(y[-1])


res = N
for i in range(N):
    res = min(x[i]+y[N-i-1], res)

print(res)

Measured memory_bytes: 23464
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

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

 
int main(){
	int n;
	while(cin>>n,n){
		vector<int> a;
		vector<ll> x;
		for (int i = 0; i < n; i++){
			int d; ll b,c; cin>>d>>b>>c;
			int id = find(a.begin(),a.end(),d) - a.begin();
			if(id == (int)a.size()){
				a.push_back(d);
				x.push_back(0L);
			}
			x[id] += b*c;
		}

		vector<int> ans;
		for (int i = 0; i < (int)a.size(); i++){
			if(x[i] >= 1000000L) ans.push_back(a[i]);
		}
		
		if(ans.size() == 0){ cout << "NA" << endl; continue; }

		for (int i = 0; i < (int)ans.size(); i++)
			cout << ans[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &p : a) cin >> p;
  int q;
  cin >> q;
  while (q--) {
    int b, e, t;
    cin >> b >> e >> t;
    for (int k = 0; k < e - b; k++) swap(a[b + k], a[t + k]);
  }
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
long long half(long long n){
    long long p=0,r=0;
    if(n==1)
    return n;
    else
    return ((2*half(n/2))+1);
}
int main(){
    long long t,n;
    cin>>n;
    t=half(n);
    cout<<t;
    return 0;
  
}


Measured memory_bytes: 256
@c=($%=<>,2,5,5,4,5,6,3,7,6);@a=sort{$b-$a}glob<>;map{//;($p[$_])=sort{$b-$a}map$'<$_?-1:$p[$'-$_]+1,@c[@a]}1..$%;$%-=$c[$~=(grep$p[$#_=$%-$c[$_]]+1==$p[$%],@a)[0]],print$~while$%

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;


int H, W;

int main() {
	cin >> H >> W;
	
	ll ans = LINF;
	if(H >= 3) {
		if(H % 3 == 0) ans = 0;
		else ans = min(ans, 1ll*W);
	}
	if(W >= 3) {
		if(W % 3 == 0) ans = 0;
		else ans = min(ans, 1ll*H);
	}
	for(int k=0; k<2; k++) {
		for(int h=1; h<H; h++) {
			ll ch[3] = {1ll * h * W, 1ll * W/2 * (H-h), 1ll * (W - W/2) * (H-h)};
			sort(ch, ch+3);
			ans = min(ans, abs(ch[2] - ch[0]));
		}
		swap(H, W);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < b && b < c){
        printf("Yes\n");
    }
    
    else{
        printf("No\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main() {
  int N;
  cin >> N;
  ll ans = 0;
  rep(i,N) {
    ll a;
    cin >> a;
    while(a%2==0) {
      ans++;
      a/=2;
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

char c[60][60];
int n,m;

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>c[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if (c[i][j]=='#'&&c[i-1][j]=='.'&&c[i+1][j]=='.'&&c[i][j-1]=='.'&&c[i][j+1]=='.')
			{
				puts("No");
				return 0;
			 } 
		}
	}
	puts("Yes");
 } 

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

using namespace std;

bool hasNoMark(string s, int left, int right, const char mark = '*'){
	for(int i = left; i <= right; i++){
		if(s[i] == '*') return false;
	}
	return true;
}

int main(){
	int h, w;
	while(cin >> h >> w){
		if( !h && !w ) break;

		vector<string> data;

		string padding(w+1, '*');
		data.push_back(padding);
		for(int i = 0; i < h; i++){
			string line;
			cin >> line;
			line += '*';
			data.push_back(line);
		}
		data.push_back(padding);

		int recmax = 0;

		for(int i = 1; i < h+1; i++){
			for(int j = 0; j < w; j++){
				if(data[i][j] == '*') continue;
				int k = j;
				while(data[i][j] != '*') j++;
				for(int left = k; left < j; left++){
					int up = 0, down = 1;
					while(hasNoMark(data[i-1-up], left, j-1)) up++;
					while(hasNoMark(data[i+down], left, j-1)) down++;
//					cout << "left=" << left << "  right=" << j-1 << "  up=" << i-up-1 << "  down="  << i+down-2 << "  rec=" << (j-left)*(up+down) << endl;
					recmax = max((j-left)*(up+down), recmax);
				}
			}
		}

//		p(data);
		cout << recmax << endl;
	}

	return 0;
}

Measured memory_bytes: 1492
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  h,w = map(int,readline().split())
  a = []
  for i in range(h):
    s = list(map(int,readline().split()))
    a.append(s)
  b = []
  for i in range(h):
    t = list(map(int,readline().split()))
    b.append(t)
  C = [[0]*w for _ in range(h)]
  for i in range(h):
      for j in range(w):
          C[i][j] = abs(a[i][j] - b[i][j])

  dp = [[[0]*6321 for i in range(w)] for _ in range(h)]
  dp[0][0][C[0][0]] = 1

  for i in range(h):
    for j in range(w):
      for k in range(6321):
        if dp[i][j][k]:
          if i < h-1:
            c = C[i+1][j]
            if k+c < 6321:
              dp[i+1][j][k+c] = 1
            dp[i+1][j][abs(k-c)] = 1
          if j < w-1:
            d = C[i][j+1]
            if k+d < 6321:
              dp[i][j+1][k+d] = 1
            dp[i][j+1][abs(k-d)] = 1

  for i in range(6321):
    if dp[h-1][w-1][i]:
      print(i)
      break
      
if __name__ == "__main__":
    main()

Measured memory_bytes: 354568
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
pass_list = []	#条件を満たした合計料金のリスト.最後に最小値を取得する。

for i in range(2**n):
  l_pic = [0]*(m+1)	#ピックアップしたbookによる効果（値段、スキルアップ量）の総和を見る。
  for j in range(n):
    if ((i >> j) & 1):	#ピックアップしたj番目について
      l_pic = [x+y for (x, y) in zip(l_pic, l[j])]
  if min(l_pic[1:]) >= x:
    pass_list.append(l_pic[0])

if len(pass_list) == 0:
  print(-1)
else:
  print(min(pass_list))

Measured memory_bytes: 9296
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S,T;
  int count = 0;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++){
    if(S.at(i) != T.at(i)){
      count = 1;
      break;
    }
  }
  if(count == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

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

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  bool ok=true;
  int n=s.size();
  for(int i=0;i<n;++i){
    if(s[i]!=t[i])ok=false;
  }
  if(ok){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

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

    int a = N;
    int dig = 0;
    while(a) {
        dig += a % 10;
        a /= 10;
    }

    if(N % dig == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
  string S;
  cin >> S;
  if(S.at(0)==S.at(1) && S.at(1)==S.at(2)) cout << "No" << endl;
  else 
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, D;
	cin >> N >> D;
	int sum=0;
	for (int i=0; i<N; i++) {
		long long int x, y;
		cin >> x >> y;
		x*=x;
		y*=y;
		if (sqrt(x+y)<=D) {
			sum++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3672