akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			long n = cin.Long();
			long ans = n * (n - 1) / 2;
			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n, m; cin >> n >> m;
    vint s(m), c(m);
    rep(i,m) cin >> s[i] >> c[i];
    for (int i = (int)pow(10,n-1)-1; i <= (int)pow(10,n)-1; i++) {
        if (n != 1) {
            if (i == (int)pow(10,n-1)-1) continue;
        }
        vint x;
        int tmp = i;
        rep(j,n) {
            x.push_back(tmp%10);
            tmp /= 10;
        }
        bool ok = true;
        rep(j,m) {
            if (x[n-s[j]] != c[j]) ok = false;
        }
        if (ok) {cout << i << endl; return 0;}
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	// Code for A - αlphabet
	var a, convertA string
	fmt.Scan(&a)
	convertA = strings.ToLower(a)

	if a == convertA {
		fmt.Printf("a")
	} else {
		fmt.Printf("A")
	}
}


Measured memory_bytes: 1840
"use strict";
    
const main = arg => {
    const N   = arg.split("\n")[0];
    const sum = N.split("").map(n=>parseInt(n)).reduce((m,n)=>m+n);
    console.log(N % sum == 0 ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    std::string N;
    std::cin >> N;

    if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

double PI = 6.28318530717958623200 / 2.0;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int r;
    cin >> r;
    cout << fixed << setprecision(18) << 2 * r * PI << endl;
    return 0;
}


Measured memory_bytes: 3804
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = [0]*(h+max_a)
for i in range(1, h+max_a):
    dp[i] = min(dp[i-a] + b for a,b in ab)
print(min(dp[h:]))

Measured memory_bytes: 27488
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
        int n,i;
        ll pre,cnt1=0,cnt2=0;
        cin >> n;
        vector<ll> a(n);
        for(i=0;i<n;++i){
                cin >> a.at(i);
                cnt1 += a.at(i);
                if(i%2==1) cnt2 += 2*a.at(i);
        }
        pre = cnt1 - cnt2;
        cout << pre << " ";
        for(i=0;i<n-1;++i){
                pre = a.at(i)*2-pre;
                cout << pre << " ";
        }
        return 0;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void pre() {
}
void solve() {
	int a, b;
	cin >> a >> b;
	int sum = a + b;
	if (sum & 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << (a + b) / 2 << endl;
	}
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	//pre();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (ll i = 0;i < (a);++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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n),town(n+1,-1),junban(n);
    REP(i,n){
        ll tmp;
        cin >> tmp;
        a[i] = --tmp;

        junban[i]=-1;
    }

    ll now = 0,diff,offset;

    town[0] = 0;
    junban[0] = 0;

    REP(i,n){
        now = a[now];
        if(junban[now]!=-1){
            diff = (i+1)-junban[now];
            offset = junban[now];
            break;
        }else{
            junban[now] = i+1;
            town[i+1] = now;
        }
    }
    
    if(n > k){
        now = 0;
        REP(i,k){
            now = a[now];
        }
        cout << now + 1 << endl;
    }else{
        cout << town[((k-offset)%diff)+offset]+1 << endl;
    }
  
    return 0;
}

Measured memory_bytes: 8004
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a + b >= c)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<ld> x(n), y(n);
    rep(i, n)cin >> x[i] >> y[i];
    ld ans = 1000000;
    rep(i, n)rep(j, n)rep(k, n){
        if(i >= j || j >= k)continue;
        ld ax = x[j] - x[i];
        ld ay = y[j] - y[i];
        ld bx = x[k] - x[j];
        ld by = y[k] - y[j];
        ld cx = x[i] - x[k];
        ld cy = y[i] - y[k];
        ld s = abs(ax * by - bx * ay);
        ld a = sqrt(ax * ax + ay * ay);
        ld b = sqrt(bx * bx + by * by);
        ld c = sqrt(cx * cx + cy * cy);
        ld sina = s / b / c;
        ld sinb = s / c / a;
        ld sinc = s / a / b;
        ld sin2a = 2 * sina * sqrt(1 - sina * sina);
        ld sin2b = 2 * sinb * sqrt(1 - sinb * sinb);
        ld sin2c = 2 * sinc * sqrt(1 - sinc * sinc);
        if(sin2a+sin2b+sin2c<1e-6)continue;
        ld ox = (sin2a*x[k]+sin2b*x[i]+sin2c*x[j]) / (sin2a+sin2b+sin2c);
        ld oy = (sin2a*y[k]+sin2b*y[i]+sin2c*y[j]) / (sin2a+sin2b+sin2c);
        ld rx = x[i] - ox;
        ld ry = y[i] - oy;
        ld r = sqrt(rx * rx + ry * ry);
        bool v = true;
        rep(l, n){
            ld dx = ox - x[l];
            ld dy = oy - y[l];
            ld d = sqrt(dx * dx + dy * dy);
            if(d > r + 1e-10)v = false;
        }
        if(v)ans = min(ans, r);
    }
    rep(i, n)rep(j, n){
        ld rx = x[i] - x[j];
        ld ry = y[i] - y[j];
        ld r = sqrt(rx * rx + ry * ry) / 2;
        ld gx = (x[i] + x[j]) / 2;
        ld gy = (y[i] + y[j]) / 2;
        bool v = true;
        rep(k, n){
            ld dx = gx - x[k];
            ld dy = gy - y[k];
            ld d = sqrt(dx * dx + dy * dy);
            if(d > r + 1e-10)v = false;
        }
        if(v)ans = min(ans, r);
    }
    cout << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.io.PrintWriter
val pw = PrintWriter(System.out)

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

fun func() {
    val (a, b) = listOfInt()
    println(when{
        (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) -> "Possible"
        else -> "Impossible"
    })
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36080
import sys
N = int(input())
l = []
for i in range(N):
  l.append(list(map(int,input().split())))

#Cx,Cyの探索
ansC = [0,0]
for i in range(0,100+1):
  for j in range(0,100+1):
    Cx = i
    Cy = j
    #Nこのデータから高さを決める
    for k in range(N):
      X,Y,h = l[k]
      c = 0
      if h >= 1:
        H = h + abs(X-Cx) + abs(Y-Cy)
        for k in range(N):
          X,Y,h = l[k]
          if h != max(H-abs(X-Cx)-abs(Y-Cy),0):
            break
          if k == N-1:  
            print(Cx,Cy,H)
            sys.exit()

Measured memory_bytes: 3188
import math
import itertools
Q = int(input())
query = [list(map(int,input().split())) for i in range(Q)]

def is_prime(n):
        if n <= 0:return None
        if n == 1:return False
        sup = math.floor(pow(n,1/2))
        for i in range(2,sup+1):
                if n % i == 0:
                        return False
        return True

prime = [0]*(10**5+1)
for i in range(1,10**5+1):
        if is_prime(i):
                prime[i] = 1

for i in range(10**5,-1,-1):
        if prime[i] and i % 2 == 1 and prime[(i+1)//2]:
                pass
        else:
                prime[i] = 0

acc = list(itertools.accumulate(prime))
for l,r in query:
        print(acc[r]-acc[l-1])

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

#define ll long long int
using namespace std;

void Oli(){
    int a;
    cin>>a;
    vector<int> d1(a);
    vector<int> d2(a);
    int mx = 0;
    for(int i=0;i<a;i++){
        cin>>d1[i]>>d2[i];
    }
    int h=0;
    for(int i=0;i<a;i++){
        if (d1[i] ==d2[i] && h == 0) {
            h++;
        }
        else if (d1[i] == d2[i]){
            h++;
        }else if (d1[i]!=d2[i]) {
            mx = max(mx,h);
            h = 0;
        }
    }
    mx = max(mx ,h );
    if (mx>=3) {
        cout<<"Yes"<<endl;
    }else {
    cout<<"No"<<endl;}
}

int main()
{
    int a = 1;
    //cin>>a;
    while(a--){
        Oli();
    }

}


Measured memory_bytes: 3628
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

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


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
       int m=sc.nextInt();
       int a[]=new int[n+1];
       HashMap<Integer,Integer>hm=new HashMap<>();
       for(int j=1;j<=n;j++)
           {
           a[j]=sc.nextInt();
           hm.put(j,1);
       }
       for(int j=0;j<m;j++)
       {
           int x=sc.nextInt();
           int y=sc.nextInt();
           if(a[x]>a[y])
           {
               if(hm.get(y)!=null)
                   hm.remove(y);
           }
           else if(a[x]<a[y])
           {
               if(hm.get(x)!=null)
                   hm.remove(x);
           }
           else
           {
               if(hm.get(y)!=null)
                   hm.remove(y);
               if(hm.get(x)!=null)
                   hm.remove(x);
           }
       }
       //System.out.println(hm);
       System.out.println(hm.size());


    }
}









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

bool pal(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();
  cout << (pal(S) && pal(S.substr(0, N / 2)) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;

void main()
{
  auto input = readln.chomp.split.map!(to!int);
  auto n = input[0];
  auto m = input[1];
  int[] as;
  int[] bs;
  foreach (i; 0..m) {
    auto ab = readln.chomp.split.map!(to!int);
    as ~= ab.front;
    bs ~= ab.back;
  }
  int cnt = 0;
  foreach (i; 0..m) { // skip i
    bool[] done = new bool[n + 1];
    int[] queue = [1];
    while (queue.length) {
      int node = queue.front;
      queue.popFront;
      if (done[node]) {
        continue;
      }
      done[node] |= true;
      foreach (j; 0..m) {
        if (i == j) {
          continue;
        }
        if (as[j] == node) {
          queue ~= bs[j];
        }
        if (bs[j] == node) {
          queue ~= as[j];
        }
      }
    }
    bool flag = true;
    for (int j = 1; j <= n; ++j) {
      flag &= done[j];
    }
    cnt += !flag;
  }
  cnt.writeln;
}


Measured memory_bytes: 380
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N; cin >> N;
	vector<pair<int, int>> p(N);
	rep(i, N) {
		cin >> p[i].first;
		p[i].second = i;
	}

	sort(p.begin(), p.end());
	
	rep(i, N) {
		cout << p[i].second + 1 << " " << flush;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3864
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <cstdio>
    #include <bits/stdc++.h>
    #include <unordered_map>
    #include <unordered_set>
    #include <queue>
     
    using namespace std;
    typedef long long ll;
     
     
    bool debug = false;
     
     
     
    int main()
    {
    	std::ios::sync_with_stdio(false);
     
    	
    	string s;

        cin >> s;

        if (s == "ABC")
            cout <<  "ARC" << endl;
        else
    	   cout <<  "ABC" << endl;
     
    	return 0;
    }

Measured memory_bytes: 3652
n=int(input())
line=input().split()
line2=input().split()

a=[]
asum=0
b=[]
bsum=0
extraa=0
for i in range(n):
    a.append(int(line[i]))
    b.append(int(line2[i]))
    asum+=a[-1]
    bsum+=b[-1]

for i in range(n):
    if a[i]<b[i]:
        extraa+=(b[i]-a[i])//2
    if a[i]>b[i]:
        extraa-=a[i]-b[i]
if extraa>=0 and asum<=bsum:
    print ("Yes")
else:
    print("No")
    



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

using namespace std;

char ch, v[53][53];
int n, m;
int dl[4] = {1, -1, 0, 0};
int dc[4] = {0, 0, -1, 1};

int main ()
{
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> ch;
      v[i][j] = (ch == '#');
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      bool ok = 0;
      for (int k = 0; k < 4; k++) {
        int l = i + dl[k];
        int c = j + dc[k];
        if (v[l][c] == 1)
          ok = 1;
      }
      if (ok == 0 && v[i][j] == 1){cout << "No"; return 0;}
    }
  cout << "Yes";
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int sum = 0;
  int max = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (max <= a) {
      sum++;
      //cout << a << ' ' << sum << ' ' << max << endl;
      max = a;
    }
  }
  cout << sum << endl;
  return 0;
}

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



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

    vector<int> a(3);
    int ev=0;
    rep(i,3) {
        cin >> a[i];
        if (a[i]%2==0) ++ev;
    }
    sort(a.begin(),a.end());
    int d=0;
    rep(i,3) d+=a[2]-a[i];
    if (d%2==0) cout << d/2 << endl;
    else cout << (d+3)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    for i in range(g,n):
        v = A[i]
        j = i - g
        while (j>=0) and (A[j] > v):
            A[j + g] = A[j]
            j -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])


Measured memory_bytes: 45480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)

int main(){
    char a;
    cin >>a;
    if (a=='a'||a=='i'||a=='u'||a=='e'||a=='o') cout << "vowel"<<endl;
else cout << "consonant"<<endl;
}


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

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t x = 1;
    int64_t y = 1;
    int64_t i = 1;
    for (int64_t n = 0; n < N; ++n)
    {
        i *= 8;
        i %= 1000000007;
        x *= 9;
        x %= 1000000007;
        y *= 10;
        y %= 1000000007;
    }

    int64_t ans = (y - x * 2 + i) % 1000000007;
    if (ans < 0) {
        ans += 1000000007;
    }
    std::cout << ans << std::endl;

    return 0;
}


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

int main() {
  ll n, m, d;
  cin >> n >> m >> d;
  if(d == 0) cout << setprecision(20) << (double)(m-1) / n << endl;
  else cout << setprecision(20) << (double)(2*n-2*d) / (n * n) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n,t;
  cin >> n >> t;

  std::vector<pair<int,int> > v;

  rep(i,n) {
    int a,b;
    cin >> a >> b;
    v.pb(make_pair(b,a));
  }

  sorti(v);

  int ans = 1001;
  for (auto itr : v) {
    if (itr.first <= t) {
      ans = min(ans, itr.second);
    } else {
      if (ans == 1001) {
        cout << "TLE" << endl;
        return 0;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  vector<ll> costs(n+1); // i 番目に到達するためのコスト
  costs[0] = abs(a[0]);
  rep(i, n-1) {
    costs[i+ 1] = abs(a[i+1] - a[i]);
  }
  costs[n] = abs(a[n-1]);

  ll sum = SUM(costs);

  rep(i, n) {
    ll tmp = sum;
    tmp -= (costs[i] + costs[i+1]);  // i に来るためのコストとiから次に行くためのコスト
    if (i == 0) {
      tmp += abs(a[i+1]);  // 0 から a[1] へ
    } else if (i == n - 1) {
      tmp += abs(a[i-1]);  // a[-2] から 0 へ
    } else {
      tmp += abs(a[i-1] - a[i+1]);
    }
    cout << tmp << endl;
  }

  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	ll n, W;
	cin >> n >> W;
	vector<ll> v(n+1), w(n+1);
	for(ll i=1; i<=n; i++) {
		cin >> w[i] >> v[i];
	}
	vector<ll> dp(W+1, 0); 
	for(int i=1; i<=n; i++) {
		for(ll j=W; j>=w[i]; j--) {
			if (dp[j] < dp[j - w[i]] + v[i]) dp[j] = dp[j - w[i]] + v[i];
		}
	}
	/*cout << "dp: " << endl;
	for(ll j=0; j<=W; j++) {
		cout << dp[j] << " ";
	}*/

	ll ans = 0;
	for(ll j=1; j<=W; j++) {
		if (dp[j] > ans) ans = dp[j]; 
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
int r,c,dp[105][105][5];
char arr[105][105];
int f(int n, int m, int con){
    if(n==r+1&&m==c)return 0;
    if(n==r&&m==c+1)return 0;
    if(n>r||m>c)return 1e9;
    if(dp[n][m][con]!=-1)return dp[n][m][con];
    if(arr[n][m]=='#'){
        if(con==1){
            return dp[n][m][con]= min(f(n+1,m,con),f(n,m+1,con));

        }
        else return dp[n][m][con] = min(f(n+1,m,1)+1,f(n,m+1,1)+1);
    }
    else{
        return dp[n][m][con]=min(f(n+1,m,0),f(n,m+1,0));
    }
}
int main(){
    cin>>r>>c;
    memset(dp,-1,sizeof(dp));
    for(int i =1;i<=r;i++){
        for(int j =1;j<=c;j++)cin>>arr[i][j];
    }
    cout<<f(1,1,0)<<endl;
    // for(int i =1;i<=r;i++){
    //     for(int j =1;j<=c;j++){
    //         cout<<dp[i][j][0]<<' '<<dp[i][j][1]<<' ';
    //     }
    //     cout<<endl;
    // }
}

Measured memory_bytes: 1020
# -*- coding: utf-8 -*-
"""
Created on Fri May 10 23:15:55 2019

@author: Yamazaki Kenichi
"""

n = int(input())
A = list(map(int,input().split()))

T = [[0 for i in range(10**5+1)], [0 for i in range(10**5+1)]]
counta = 0
for c in A:
    T[counta%2][c] += 1
    counta += 1

tmp = [[0]*4, [0]*4]
for i in range(10**5+1):
#for i in range(6):
    for k in range(2):
        if T[k][i] > tmp[k][0]:
            tmp[k][2], tmp[k][3] = tmp[k][0], tmp[k][1]
            tmp[k][0], tmp[k][1] = T[k][i], i
        elif T[k][i] > tmp[k][2]:
            tmp[k][2], tmp[k][3] = T[k][i], i
#        print(tmp)
if tmp[0][1] != tmp[1][1]:
    print(n-tmp[0][0]-tmp[1][0])
else:
    print(min(n-tmp[0][0]-tmp[1][2], n-tmp[0][2]-tmp[1][0]))
    
    

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

int top, stack[1000];

void push(int x) {
  stack[++top] = x;
}

int pop() {
  --top;
  return stack[top + 1];
}

int main() {
  int a, b;
  top = 0;
  string s;

  while (cin >> s) {
    if (s == "+") {
      a = pop();
      b = pop();
      push(a + b);
    } else if (s == "-") {
      b = pop();
      a = pop();
      push(a - b);
    } else if (s == "*") {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(stoi(s));
    }
  }

  cout << pop() << endl;

  return 0;
}



Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;

int main(){

    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    ll smallest = min({a, b, c, d, e});

    ll ans = (n + smallest - 1) / smallest + 4;

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


Measured memory_bytes: 256
n = int(input())
judge = list(input() for _ in range(n))
ac = wa = tle = re = 0
for i in judge:
  if i == 'AC':
    ac = ac + 1
  elif i == 'WA':
    wa = wa + 1
  elif i == 'TLE':
    tle = tle + 1
  elif i == 'RE':
    re = re + 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine() + '\0';
        int cnt=0;
        boolean b=false;
        while (true) {
            if (cnt + 1 == s.length()) {
                b = true;
                break;
            }
            if (cnt + 11 <= s.length() && s.substring(cnt, cnt + 11).equals("dreameraser")) {
                cnt += 11;
            }
            else if (cnt + 10 <= s.length() && s.substring(cnt, cnt + 10).equals("dreamerase")) {
                cnt += 10;
            }
            else if (cnt + 7 <= s.length() && s.substring(cnt, cnt + 7).equals("dreamer")) {
                cnt += 7;
            }
            else if (cnt + 5 <= s.length() && s.substring(cnt, cnt + 5).equals("dream")) {
                cnt += 5;
            }
            else if (cnt + 6 <= s.length() && s.substring(cnt, cnt + 6).equals("eraser")) {
                cnt += 6;
            }
            else if (cnt + 5 <= s.length() && s.substring(cnt, cnt + 5).equals("erase")) {
                cnt += 5;
            }
            else {
                break;
            }
        }
        System.out.println(b?"YES":"NO");
    }
}

Measured memory_bytes: 27860
N = int(input())
S = list(input())
x = 0
max = 0

for i in range(N):
  if(S[i] == 'I'):
    x += 1
    if(max < x):
      max = x
  else:
    x -= 1
    if(max < x):
      max = x

print(max)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

void insertionSort(int A[], int n, int g);
void ShellSort(int A[], int n);

int count;

int main(){
  int n;
  int i;
  int *A = NULL;

  scanf("%d", &n);
  A = (int*)malloc(sizeof(int) * n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  ShellSort(A, n);
  for(i = 0; i < n; i++){
    printf("%d\n", A[i]);
  }

  return 0;
}

void insertionSort(int A[], int n, int g){
  int i, j;
  int tmp = 0;

  for(i = g; i < n; i++){
    tmp = A[i];
    j = i - g;
    while(j >= 0 && A[j] > tmp){
      A[j+g] = A[j];
      j = j - g;
      count++;
    }
    A[j+g] = tmp;
  }
}

void ShellSort(int A[], int n){
  int i, j, m;
  int G[100];
  count = 0;

  m = 0;
  for(i = 0, j = 1; ; i++){
    if(j > n){break;}
    G[i] = j;
    j = 3*j+1;
    m++;
  }

  for(i = m-1; i >= 0; i--){
    insertionSort(A, n, G[i]);
  }

  printf("%d\n", m);
  for(i = m-1; i >= 0; i--){
    if(i == 0){
      printf("%d\n", G[i]);
    }else{
      printf("%d ", G[i]);
    }
  }
  printf("%d\n", count);
}



Measured memory_bytes: 5660
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    int count = 0;
    while (true)
    {
        if (a <= 0)
        {
            cout << "No" << endl;
            break;
        }
        if (c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }

        if (count % 2 == 0)
        {
            c = c - b;
        }
        else
        {
            a = a - d;
        }
        count++;
    }

    return 0;
}

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

using namespace 	std;
int main(void){
  string str;
  
  cin >> str;
  
  if(str.size()==6 && str[2]==str[3] && str[4]==str[5]){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }

  return 0;  
}



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

int calc(vector<string>&str, vector<int>&level, int n, int max){
  int lev= level[n];
  if(str[n][lev]>='0' && str[n][lev] <= '9'){
    return str[n][lev]-'0';
  }
  if(str[n][lev]=='+'){
    int ans=0;
    for(int i=n+1; i<max; i++){
      if(level[i]<=level[n]) break;
      if(level[i]==level[n]+1){
        ans += calc(str, level, i, max);
      }
    }
    return ans;
  }
  if(str[n][lev]=='*'){
    int ans=1;
    for(int i=n+1; i<max; i++){
      if(level[i]<=level[n]) break;
      if(level[i]==level[n]+1){
        ans *= calc(str, level, i, max);
      }
    }
    return ans;
  }
  return -1;
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    
    vector<string> str(n);
    vector<int> l(n,0);
    for(int i=0; i<n; i++){
      cin >> str[i];
      for(int j=0; str[i][j]=='.'; j++){ l[i]++; }
    }
    
    cout << calc(str, l, 0, n) << endl;
  }
  return 0;
}

Measured memory_bytes: 3060
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

A, B, C = 'Sunny', 'Cloudy', 'Rainy'
def solve(S):
    if S == A: return B
    if S == B: return C
    return A
    

print solve(rr())


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

  //  入力された整数の, 各桁の数の総和を求める
int sum_of_digits(int n){
  int sum  = 0;
  while(n > 0){
     sum += n % 10;
     n /= 10;
   }
   return sum;
}


int main()
{
  int n, a, b;
  cin >> n >> a >> b;

  int total_sum = 0;
  for(int i = 1; i <=n; ++i){
    if(sum_of_digits(i) >= a && sum_of_digits(i) <= b){
      total_sum += i;
    }else continue;
  }

  cout << total_sum << endl;

  return 0;
  
}

 
  


Measured memory_bytes: 256
N,a,b=map(int,input().split())
mod=10**9+7

def C(n,k,mod):
  k=min(k,n-k)
  x=1
  for i in range(k):
    y=(n-i)*pow(i+1,mod-2,mod)
    x=x*y%mod
    
  return x

ans=pow(2,N,mod)-1-C(N,a,mod)-C(N,b,mod)
print(ans%mod)

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, D; cin >> N >> D;
    vector<vector<int> > x( N, vector<int>( D ) );
    REP( i, N ){
        REP( j, D ){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    REP( i, N - 1 ){
        FOR( j, i + 1, N ){
            int sum = 0;
            REP( k, D ){
                sum += ( x[i][k] - x[j][k] ) * ( x[i][k] - x[j][k] );
            }

            double t = sqrt( sum );

            if( ceil( t ) == floor( t ) ) ans++;
        }
    }

    cout << ans << endl;

}


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

using namespace std;

int main(void){
	int Mo,Do,Mt,Dt;
	cin >> Mo>>Do>>Mt>>Dt;
	int ans;
	if(Dt == 1){
		ans = 1;
	}
	else ans = 0;
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	
	if((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[0] != a[1])) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, A, B;
	cin >> n >> A >> B;
	string s;
	cin >> s;
	s = ' ' + s;
	int nowa = 0, nowb = 0;
	for (int i = 1; i < s.size(); ++i)
	{
		if (s[i] == 'a')
		{
			if(nowa + nowb < A + B)
			{
				cout << "Yes" << endl;
				nowa++;
			}
			else
			{
				cout << "No" << endl;
			}
		}
		else if(s[i] == 'b')
		{
			if(nowa + nowb < A + B && nowb < B)
			{
				cout << "Yes" << endl;
				nowb++;
			}
			else
			{
				cout << "No" << endl;
			}
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 892
h, w = map(int, input().split())
s = [input() for _ in range(h)]

news = []
for y in range(h):
    tmp = ''
    for x in range(w):
        cnt = 0
        if s[y][x] == '#':
            tmp += '#'
            continue
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx == 0 and dy == 0:
                    continue
                nx = dx + x
                ny = dy + y
                if not (0 <= nx < w and 0 <= ny < h):
                    continue
                if s[ny][nx] == '#':
                    cnt += 1
        tmp += str(cnt)
    news.append(tmp)
for i in range(h):
    print(news[i])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; ll k;
    cin >> n >> k;
    V<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    drep(i, 50) {
        int cnt = 0;
        rep(j, n) if(1 & a[j] >> i) cnt++;
        if(cnt <= (n-1)/2) {
            ll tmp = ans + (1LL << i);
            if(tmp <= k) ans += (1LL << i);
            else continue;
        }
    }
    ll res = 0;
    rep(i, n) res += (a[i] ^ ans);
    cout << res << endl;
}

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

int main(){
    long long H, W;
    cin>>H>>W;
    long long a=(W+1)/2;
    long long ans=((H+1)/2)*a+(H/2)*(W/2);
    if(H==1||W==1){
        cout<<1<<endl;
    }
    else{
        cout<<ans<<endl;
    }
}

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    A, B = map(int, readline().split())
    print(max(A + B, A - B, A * B))


if __name__ == '__main__':
    main()


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

using namespace std;

void test()
{
    int p,n;
    cin>>p>>n;

    set<int>s;

    for(int i=0;i<n;i++)
    {
        int y;
        cin>>y;

        s.insert(y);
    }

    bool res=true;
    int i=0;
    int res1=INT_MAX,res2=INT_MAX;
    while(true)
    {
        if(s.find(p+i)==s.end())
        {
            res1=p+i;
        }

        if(s.find(p-i)==s.end())
        {
            res2=p-i;
        }

        if(res1!=INT_MAX || res2!=INT_MAX)
        break;

        i++;
    }

    int ans=min(res1,res2);

    cout<<ans<<endl;
}

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

    test();

    return 0;
}


Measured memory_bytes: 3624
#coding:utf-8

L = []
x = 1
y = 2
while x < y:
    a = input()
    if a == 0:      #0?????\?????????????????§??°?????????
        break
    else:
        L.append(a)

for i in xrange(len(L)):
    print("Case " + str(i + 1) + ": " + str(L[i]))

Measured memory_bytes: 6528
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int h,w,c[10][10],a;
signed main(){
	cin>>h>>w;
	rep(i,10){
		rep(j,10)cin>>c[i][j];
	}
	rep(i,10)c[i][i]=0;
	rep(k,10){
		rep(i,10){
			rep(j,10)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
		}
	}
	int ans=0;
	rep(i,h*w){
		cin>>a;
		if(a!=-1)ans+=c[a][1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
l, r = 0, 10 ** 5 + 1
for i in range(M):
    L, R = map(int, input().split())
    if L > l:
        l = L
    if R < r:
        r = R
print(max(0, r - l + 1))

Measured memory_bytes: 3060
H, W, A, B = map(int, input().split())

# if H//2 < B or W//2 < A:
#     print("No")
#     exit()
for _ in range(H-B):
    print("0" * (W-A) + "1" * A)
for _ in range(B):
    print("1" * (W-A) + "0" * A)


Measured memory_bytes: 3956
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if X == 500 * a + 100 * b + 50 * c:
                cnt += 1
print(cnt)

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

int main() {
	int n, a[100];
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (a[i] % 10 != 0) {
			cout << sum - a[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/****************temporary declaration & definitoins*******************/

/**************************define functions****************************/

/****************************main function*****************************/
int main(void) {
	ll H, W, N; cin >> H >> W >> N;
	ll sr, sc; cin >> sr >> sc;
	string S, T; cin >> S >> T;
	ll x, y;

	sr--; sc--;

	 y = sc;
	/*右端に出ることがあり得るか？*/
	for (ll i = 0; i < N; i++) {
		if (S[i] == 'R') {
			y++;
			if (y >= W) {
				cout << "NO" << endl; return 0;
			}
		}
		if (y > 0 && T[i] == 'L') {
			y--;
		}
	}

	 y = sc;
	for (ll i = 0; i < N; i++) {
		if (S[i] == 'L') {
			y--;
			if (y < 0) {
				cout << "NO" << endl; return 0;
			}
		}
		if (y < W-1 && T[i] == 'R') {
			y++;
		}
	}

	 x = sr;
	for (ll i = 0; i < N; i++) {
		if (S[i] == 'U') {
			x--;
			if (x < 0) {
				cout << "NO" << endl; return 0;
			}
		}
		if (x < H - 1 && T[i] == 'D') {
			x++;
		}
	}
	 x = sr;
	for (ll i = 0; i < N; i++) {
		if (S[i] == 'D') {
			x++;
			if (x >= H) {
				cout << "NO" << endl; return 0;
			}
		}
		if (x > 0 && T[i] == 'U') {
			x--;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 776
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int d=sc.nextInt(),g=sc.nextInt();
        int[] p = new int[d];
        int[] c = new int[d];
        int ans=Integer.MAX_VALUE;

        for(int i=0;i<d;i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        for(int i=0;i<Math.pow(2,d);i++){
            int temp = i;
            int point=0;
            int problems=0;
            boolean[] bit = new boolean[d];
            for(int j=0;j<d;j++){
                bit[j]=temp%2==1;
                temp = temp>>1;
            }
            for(int j=0;j<d;j++){
                if(bit[j]){
                    point+=c[j]+p[j]*100*(j+1);
                    problems+=p[j];
                }
            }
            if(point<g){
                int k;
                for(int j=d-1;j>=0;j--){
                    if(!bit[j]){
                        int dif=g-point;
                        if(dif%(100*(j+1))==0)k=dif/(100*(j+1));
                        else k=dif/(100*(j+1))+1;
                        problems+=k;
                        point+=k*100*(j+1);
                        if(k>p[j]){
                            problems=Integer.MAX_VALUE;
                        }
                        break;
                    }
                }

            }

            ans = Math.min(ans,problems);

        }
        System.out.println(ans);




    }

}


Measured memory_bytes: 22740