akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static int N, K;
    static string S;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        K = Input.NextInt();
        S = Input.NextString();

        var ss = S.Substring(0, K-1) + S.Substring(K - 1, 1).ToLower() + S.Substring(K);

        Console.WriteLine(ss);
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

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

def main():
    H, W, K = map(int, input().split())
    C = [list(input().rstrip()) for i in range(H)]
    ans = 0
    for i in range(1<<H):
        for j in range(1<<W):
            CNT = 0
            for s in range(H):
                for t in range(W):
                    if (i>>s) & 1:
                        continue
                    if (j >> t) & 1:
                        continue
                    if C[s][t] == '#':
                        CNT += 1
            if CNT == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
#include <iostream>
#include <stack>
using namespace std;
char rec[26] = {'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'};
void decTo26(long long dec,stack<char> q)
{
    long long temp = dec;
    while(temp){
        temp--;
        char c = rec[temp%26];
        q.push(c);
        temp = temp/26;
    }
    while(!q.empty()){
        cout<<q.top();
        q.pop();
    }
    cout<<endl;
}

int main()
{//26进制
    long long n;
    cin >> n;
    stack<char> q;
    decTo26(n,q);
    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define F first
#define S second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, res; cin >> n, n; cout << res << endl){
        res = -1;

        vector< pair<string, string> > pairs(n);
        rep(i, n){
            cin >> pairs[i].F >> pairs[i].S;
        }
        string origin, target; cin >> origin >> target;

        set<string> s;
        queue< pair<string, int> > q;
        q.push(mp(origin, 0));

        while(!q.empty()){
            string cur = q.front().F;
            int turn = q.front().S;
            q.pop();

            if(cur == target){
                res = turn;
                break;
            }
            
            rep(i, n){
                string next = cur;

                int pos = next.find(pairs[i].F);
                while(pos != -1){
                    next.replace(pos, pairs[i].F.size(), pairs[i].S);
                    pos = next.find(pairs[i].F, pos + pairs[i].S.size());
                }

                if(target.size() < next.size() || !s.insert(next).S){
                    continue;
                }
                q.push(mp(next, turn + 1));
            }
        }
    }

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A = 0, W = 0, T = 0, R = 0;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "AC") A++;
    else if (S == "WA") W++;
    else if (S == "TLE") T++;
    else R++;
  }
  cout << "AC x " << A << endl;
  cout << "WA x " << W << endl;
  cout << "TLE x " << T << endl;
  cout << "RE x " << R << endl;
}

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

int main(){
    while(1){
    int h,b;
    h=0; b=0;
    char r[10];
    char a[10];
    char x[5]="0";
    cin>>r>>a;
    if((strcmp(r,x)==0)&&(strcmp(a,x)==0)){
        break;
    }
    for(int i=0;i<4;i++){
        if(r[i]==a[i]){
            h++;
        }
        for(int j=0;j<4;j++){
            if(r[i]==a[j]){
                b++;
            }
        }
    }
    b=b-h;
    cout<<h<<' '<<b<<endl;
    }
    return 0;

}

Measured memory_bytes: 1140
//usr/bin/env swift $0 $@;exit
import CoreFoundation
func reversedArray<T>(_ a:[T]) -> [T] {
#if swift(>=3.0)
	return a.reversed()
#else
	return a.reverse()
#endif
}

let T=["dream","dreamer","erase","eraser"].map{reversedArray(Array($0.characters))}
let s=reversedArray(Array(readLine()!.characters))
var c=0
while c<s.count {
	var k:[Character]?=nil
	for e in T {
		let se=e.count
		let ss=s.count-c
		if se<=ss {
#if swift(>=4.0)
			//swift4は下でもいいんですがこちらのほうが読みやすいですよね
			if Array(s[c..<c+se])==e {
				k=e
				break
			}
#else
			var ce=0
			while ce<se {
				if s[c+ce] != e[ce] {break}
				ce+=1
			}
			if ce==se {
				k=e
				break
			}
#endif
		}
	}
	if k==nil {
		print("NO")
		exit(0)
	}
	c+=k!.count
}
print("YES")


Measured memory_bytes: 3868
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A9x9 solver = new A9x9();
        solver.solve(1, in, out);
        out.close();
    }

    static class A9x9 {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int a = in.scanInt();
            int b = in.scanInt();
            if (a < 1 || a > 9 || b < 1 || b > 9) out.println(-1);
            else out.println(a * b);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 25044
#include<iostream>
using namespace std;
int main(){
	int x,y,a;
	for(a=0;a<3000;a++){
	cin>>x>>y;
	if(x==0 && y==0){
	break;
	}
	else if(x>=y){
	cout<<y<<" "<<x<<endl;
	}
	else if(x<=y){
	cout<<x<<" "<<y<<endl;
	}
	}
return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

map<char, int> character_count(string s){
    map<char, int> counter;
    rep(i, s.size()){
        ++counter[s[i]];
    }

    return counter;
}

string nchar(char c, int n){
    string s = "";
    rep(i, n){
        s.push_back(c);
    }

    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    string s[n];
    rep(i, n){
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        s[i] = tmp;

    }



    map<char,int> snuke;
    string alp = "abcdefghijklmnopqrstuvwxyz";
    rep(i, n){
        dpp(s[i]);

        auto cnt = character_count(s[i]);
        rep(j, 26){

            cerr << "{" << alp[j] << ":" << cnt[alp[j]] << "}"<< endl;
            if(i == 0)
                snuke[alp[j]] = cnt[alp[j]];
            else
                snuke[alp[j]] = min(cnt[alp[j]], snuke[alp[j]]);
        }

        cerr << endl;
        for(auto itr = snuke.begin(); itr != snuke.end(); ++itr)
            cerr << "{" << itr->first << ":" << itr->second << "}"<< endl;

        cerr << endl;
    }

    for(auto itr = snuke.begin(); itr != snuke.end(); ++itr)
        cout << nchar(itr->first, itr->second);

    cout << endl;    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll P = 998244353;
ll fact[200000];

// Extended Euclid's greatest common divisor algorithm
// Find (x, y, g)
// where $a*x + b*y = g$ and g is the greatest common divisor of (a, b)
ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	ll nx, ny;
	ll g = ext_gcd(b, a%b, nx, ny);
	x = ny;
	y = nx - a/b *ny;
	return g;
}

// Modular inverse of x given modulo p, y
// x*y = 1 mod p
// <=> x*y + z*p = 1
ll inv_mod(ll x, ll p){
	ll y,z;
	ext_gcd(x, p, y, z);
	return y>=0 ? y : p+(y%p);
}


// Modular factorial of n, also counting p's appearance e
// n! = a * p^e
// return: a % p
// n! = n * (n-1) * ... * (k*p+1) *
//      (k*p) * (k*p-1) * ... ((k-1)*p+1) *
//      ...
//      p * (p-1) * ... * 2 * 1   (k = floor(n/p))
//    = (n%p) * ... * 1 *
//      (k*p) * (p-1) * ... * 1 *
//      p * (p-1) * ... * 1       (mod p, preserving p's multiples)
//    = (n%p)! * p^k * k! * (p-1)^k
//    = (n%p)! * p^k * k! * (p-1)^(k%2)
//
// From the facts:
//   (p-1)! = p-1 (mod p) (c.f. Willson's theorem)
//   (p-2)**2 = 1 (mod p)
ll fact_mod(ll n, ll p, ll &e){
	if(n == 0){
		e = 0;
		return 1;
	}

	ll na = fact_mod(n/p, p, e);

	e += n/p;
	ll a = na * fact[n%p] % p;

	if((n/p)%2) a = a * (p-1)%p;
	return a;
}


// Modular combination (n, m) given module p
// (n, m) = n!/(n-m)!m!
//        = (a_n * p^(e_n)) / ((a_{n-m} * p^(e_{n-m}) * (a_m * p^e_m))
//        = a_n / (a_{n-m} * a_m) * p^(e_n - e_{n-m} - e_m)
ll comb_mod(ll n, ll m, ll p){
	ll e1,e2,e3;
	ll a1 = fact_mod(n, p, e1);
	ll a2 = fact_mod(m, p, e2);
	ll a3 = fact_mod(n-m, p, e3);

	if(e1 > e2+e3) return 0;
	else return a1*inv_mod(a2*a3%p, p)%p;
}

int main(){
	fact[0] = fact[1] = 1;
	for(int i=2; i<200000; i++) fact[i] = fact[i-1]*i%P;
	int N, K;
	cin >> K >> N;

	ll all = comb_mod(N+K-1, K-1, P);
	vector<ll> f(N+K);
	for(int i=K-1; i<N+K; i++) f[i] = comb_mod(i, K-1, P);
	for(int t=2; t<=2*K; t++){
		ll ans = all;
		int m = t/2+1-max(1, t-K);
		int sign = 1;
		for(int l=1; l<=min(N/2, m); l++){
			// cout << N+K-1-2*l << " " << K-1 << " " <<m<<" "<<l << endl;
			// cout << comb_mod(N+K-1-2*l, K-1, P) << endl;
			// cout << comb_mod(m, l, P) << endl;
			ans -= sign * f[N+K-1-2*l] * comb_mod(m, l, P) % P;
			sign *= -1;
			ans += P;
			ans %= P;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long int sum=0;
    for(int i=1;i<n;i++)
    {
        if(a[i-1]>a[i])
        {
            int d=a[i-1]-a[i];
            a[i]=a[i]+d;
            sum+=d;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4380
import java.util.Arrays;
import java.util.Scanner;
   
   
public class Main {
	static int INF = 2 << 27;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int[][] map = new int[h][w];
		boolean[][] ok = new boolean[h][w];
		for(int i = 0 ; i < h; i++) {
			for(int j = 0; j < w; j++) {
				map[i][j] = sc.nextInt();
				ok[i][j] = (map[i][j] == 1)?false:true;
			}
		}
		for(int i = 0; i < h; i++) {
			dfs(0,i,ok);
			dfs(w-1,i,ok);
		}
		for(int i = 0; i < w; i++) {
			dfs(i,0,ok);
			dfs(i,h-1,ok);
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				ok[i][j] = (map[i][j] == 1)?true:ok[i][j];
			}
		}
		int sum = 0;
		
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(map[i][j] == 1) {
					int count = 0;
					if(i % 2 == 0) {
						for(int k = 0; k < 6; k++) {
							int ty = i + vy[k];
							int tx = j + vx1[k];
							if(tx < 0 || ty < 0 || ty >= ok.length || tx >= ok[ty].length || !ok[ty][tx]) continue;
							count++;
						}
					}
					else {
						for(int k = 0; k < 6; k++) {
							int ty = i + vy[k];
							int tx = j + vx2[k];
							if(tx < 0 || ty < 0 || ty >= ok.length || tx >= ok[ty].length || !ok[ty][tx]) continue;
							count++;
						}
					}
					sum += 6 - count;
				}
			}
		}
		System.out.println(sum);
		
		
		
	}
	
	static int[] vx1 = {0 ,1 ,-1,1 ,0 ,1 };
	static int[] vx2 = {-1,0 ,-1,1 ,-1,0 };
	static int[] vy  = {-1,-1,0 ,0 ,1 ,1 };
	
	static void dfs(int x, int y, boolean[][] c) {
		if(x < 0 || y < 0 || y >= c.length || x >= c[y].length || !c[y][x]) return;
		c[y][x] = false;
		if(y % 2 == 0) {
			for(int i = 0; i < 6; i++) {
				dfs(x + vx1[i], y + vy[i],c);
			}
		}
		else {
			for(int i = 0; i < 6; i++) {
				dfs(x + vx2[i], y + vy[i],c);
			}
		}
	}
	
}

Measured memory_bytes: 40228
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for(int i = k-1;i >= 0;i--){
            System.out.print(x-i + " ");
        }
        for(int i = 1;i < k;i++){
            System.out.print(x+i+" ");
        }
    }
    
}


Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

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

    ll sumleft[n], sumright[n];
    sumleft[0] = a[0];
    for(int i=1; i<n; i++){
        sumleft[i] = sumleft[i-1] + a[i];
        // cout << sumleft[0] << endl;
    }

    sumright[n-1] = 0;
    for(int i=n-2; i>=0; i--){
        sumright[i] = sumright[i+1] + a[i+1];
        // cout << sumright[0] << endl;
    } 

    ll vmin = 1e18;
    for(int i=0; i<n-1; i++){
        vmin = min(vmin, abs(sumleft[i] - sumright[i]));
    }

    cout << vmin;

    return 0;
}

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

const int N=105;
const int MOD=1000000007;
int n,f[N][N],a[N],w[N],m;

int ksm(int x,int y){
    if (y<0) return 1;
    int ans=1;
    while (y){
        if (y&1) ans=(LL)ans*x%MOD;
        x=(LL)x*x%MOD;y>>=1;
    }
    return ans;
}

int solution(){
  for(int i=1;i<=n;i++){
    w[++m] = a[i];
  }
  sort(w+1,w+m+1);
  m = unique(w+1,w+m+1)-w-1;
  for (int i=1;i<=n;i++) a[i]=lower_bound(w+1,w+m+1,a[i])-w;
  f[0][0]=1;
  for (int i=1;i<=n;i++)
  {
      for (int j=a[i]+1;j<=a[i-1];j++) (f[i][0]+=f[i-1][j]*2%MOD)%=MOD;
      (f[i][0]+=f[i-1][0]*2%MOD)%=MOD;
      for (int j=1;j<=a[i];j++)
      {
          f[i][j]=(LL)f[i-1][j]*ksm(2,w[a[i]]-w[a[i-1]])%MOD;
          if (a[i-1]>=j) continue;
          if (j>1) (f[i][j]+=(LL)f[i-1][0]*(ksm(2,w[j]-w[j-1])-1)%MOD*2%MOD*ksm(2,w[a[i]]-w[j])%MOD)%=MOD;
          else (f[i][j]+=(LL)f[i-1][0]*(ksm(2,w[j])-2)%MOD*ksm(2,w[a[i]]-w[j])%MOD)%=MOD;
      }
  }
  int ans=0;
  for (int i=0;i<=m;i++) (ans+=f[n][i])%=MOD;
  return ans;
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    int res = solution();
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define max(a, b) (a) < (b) ? (b) : (a)

int main() {
    int A, B, C;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    int ans = max(C - (A - B), 0);
    printf("%d\n", ans);
    return 0;
}


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

bool isPrime(int a){
  for(int i=2;i*i<=a;i++){
    if(a%i==0)return false;
  }
  return true;
}

int main(){
  int n;
  vector<int> v;
  for(int i=2;i<=10000;i++){
    if(isPrime(i))v.push_back(i);
  }

  while(cin >> n,n){
    int sum = 0, prv = 0, ans = 0;
    for(int i=0;i<v.size();i++){
      sum += v[i];
      while(sum > n){
	sum -= v[prv++];
      }
      if(sum==n){
	ans++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1232
unittest
{
	assert( [ "2 5" ].parse.expand.solve == 10 );
	assert( [ "100 100" ].parse.expand.solve == 10000 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return a * b;
}


Measured memory_bytes: 2820
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int Min(int a, int b) { if (a < b) { return a; }return b; }
int ups(const void*a, const void*b) { return strcmp((char*)a, (char*)b); }
char S[5002];
char a[25002][6];
int main() {
	int K;
	scanf("%s%d", S, &K);
	int n = strlen(S);
	int i = 0;//S[]における抽出開始位置
	int j;//指定文字数
	int cnt = 0;//各文字の文字列内イテレータ　兼　S[]における抽出文字数カウント数
	int num = 0;//抽出した文字列の通し番号

	for (i = 0; i < n; i++)//S[]における抽出開始位置
	{
		for (j = 0; j < 5; j++)//文字数の指定
		{
			for (cnt = 0; cnt < j + 1; cnt++)//各文字の文字列内イテレータの指定
			{
				a[num][cnt] = S[i + cnt];
				//printf("a[%d][%d]=%c\n",num,cnt, a[num][cnt]);
			}
			//puts("");
			//puts(a[num]);
			//puts("");
			num++;
		}
	}

	//for (int i = 0; i < num; i++)
	//{
	//	printf("a[%d]:%s\n", i, a[i]);
	//}
	qsort(a, num, 6, ups);
	//for (int i = 0; i < num; i++)
	//{
	//	printf("q a[%d]:%s\n", i, a[i]);
	//}

	if (K==1)
	{
		puts(a[0]);
		return 0;
	}else
	{
		int nmb = 1;
		for (int i = 1; i < num; i++)
		{
			if (strcmp(a[i], a[i - 1]) != 0) 
			{
				nmb++;
			}
			if (nmb == K) 
			{
				puts(a[i]);
				return 0;
			}
		}
	}
	return 0;
}

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

int N;
double pw;
double vw[100000];
double pf[100000];
double vf[100000];
double th[100000];

double sim(double W) {
	double sum = W * pw;
	for(int i = 0; i < N; i++) {
		double rem = th[i] - W * vw[i];
		if(rem < 0) continue;
		sum += rem / vf[i] * pf[i];
	}
	return sum;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> N, N) {
		cin >> pw;
		for(int i = 0; i < N; i++) {
			cin >> vw[i] >> pf[i] >> vf[i] >> th[i];
		}

		/*for(int i = 0; i < 100; i++) {
			cout << sim(0.5 * i) << endl;
			}
			break;*/

		double l = 0, r = 1e9;
		for(int loop = 0; loop < 1000; loop++) {
			double ll = (l + l + r) / 3.0, rr = (l + r + r) / 3.0;
			if(sim(ll) > sim(rr)) {
				l = ll;
			}
			else {
				r = rr;
			}
		}
		cout << sim(l) << endl;
	}
}

Measured memory_bytes: 6388
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define max 100000
vector<int> vn[max];
int grp[max];
int n;

void grouping(int g,int cnt){
  if(grp[g]!=0)return;
  grp[g]=cnt;
  for(int i=0;i<(int)vn[g].size();i++)
    grouping(vn[g][i],cnt);
}

int main(){
  int m,t,u,cnt;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>t>>u;
    vn[t].push_back(u);
    vn[u].push_back(t);
  }
  cnt=1;
  for(int i=0;i<n;i++){
    if(grp[i]!=0)continue;
    grouping(i,cnt);
    cnt++;
  }
  //for(int i=0;i<n;i++)cout<<"i: "<<i<<"grp "<<grp[i]<<endl;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>t>>u;
    if(grp[t]==grp[u]&&grp[t]!=0)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 13648
s = input()


def palindrome(s1: str) -> bool:
    n = len(s1)
    for i in range(n // 2):
        if s1[i] != s1[-(i + 1)]:
            return False
    return True


half = len(s) // 2
if palindrome(s):
    if palindrome(s[:half]):
        if palindrome(s[half + 1:]):
            print('Yes')
            exit()
print('No')


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

int main()
{
	int y,l;
	cin >> y >> l;
	
	if(y>l)
	{
		cout << "safe" << endl;
		return 0;
	}
	else if(l>y)
	{
		cout << "unsafe" << endl;
		return 0;
	}
	else if(l=y)
	{
		cout << "unsafe" << endl;
		return 0;
	}
} 

Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace::std;
string S;
int main(){
    cin>>S;
    if(S[0]!='2')S[0]='2';
    if(S[1]!='0')S[1]='0';
    if(S[2]!='1')S[2]='1';
    if(S[3]!='8')S[3]='8';
    
    cout<<S;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
t=s
l=str()
r=str()
while '()' in t:
  t=t.replace('()','')
if len(t)==0:
  print(s)
else:
  for i in range(len(t)):
    if t[i]=='(':
      r+=')'
    else:
      l+='('
  print(l+s+r)

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

int main(){
    vector<int> a(9);
    rep(i,9) cin >> a[i];
    int n; cin >> n;
    vector<int> b(n);
    rep(i,n) cin >> b[i];
    vector<bool> A(9,false);
    rep(i,9){
        rep(j,n){
            if(a[i] == b[j]) A[i] = true; 
        }
    }
    vector<vector<int>> bingo = {{0,3,6},{1,4,7},{2,5,8},{0,1,2},{3,4,5},{6,7,8},{0,4,8},{2,4,6}};
    bool flag = false;
    rep(i,8){
        if(A[bingo[i][0]] && A[bingo[i][1]] && A[bingo[i][2]]) flag = true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int H,A;cin>>H>>A;
	cout<<(H+A-1)/A<<endl;
}

Measured memory_bytes: 764
#include <vector>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
typedef long long ll;
using namespace std;
typedef vector<ll> vll; typedef set<ll> sll; typedef map<ll,ll> mll;
int bitct(long long r) {int c=0; for(; r; r&=r-1) c++; return c;}
long long gcd(long long x, long long y) {return x ? gcd(y%x,x) : y;}
long long choose(long long n, long long q) { if(n==0 || q==0) return 1;
  if (q==1) return n; else return ( choose(n, q-1) * (n-q+1 ) /q); }
template<typename T> ostream& operator << (ostream &o,vector<T> v) {o<<"[";
  int i=0,s=v.size();for(;i+1<s;i++)o<<v[i]<<", ";if(s)o<<v[i];o<<"]";return o;}
template<typename K, typename V> ostream& operator << (ostream &o,
  unordered_map<K, V> m) {o<<"{";for(auto i:m)o<<i.first<<" -> "<< i.second <<
  ", "; o<<"}";return o;}
template<typename K, typename V> ostream& operator << (ostream &o, map<K, V> m)
  {o<<"{";for(auto i:m)o<<i.first<<" -> "<< i.second << ", "; o<<"}";return o;}
template<typename K> ostream& operator << (ostream &o, set<K> m)
  {o<<"{";for(auto i:m)o<<i<< ", "; o<<"}";return o;}
template<typename K> ostream& operator << (ostream &o, unordered_set<K> m)
  {o<<"{";for(auto i:m)o<<i<< ", "; o<<"}";return o;}
template<typename T> ostream& printv(vector<T> v) {int i=0,s=v.size();
  for(;i+1<s;i++)cout<<v[i]<<" ";if(s)cout<<v[i];return cout;}

int main() {
  ios_base::sync_with_stdio(false);
  string x;
  cin >> x;
  cout << x.substr(0, x.size()-8) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;++i)
#define repe(i,k,n) for(int i=k;i<=n;++i)

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    cin >> a >> b;
    int c = stoi(a+b);
    
    repe(i,1,1000)
    {
        if (pow(i,2) == c){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


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

int main(){
	double r, s, e;
	
	cin >> r;
	
	s = r * r * 3.141592653589;
	e = r * 2 * 3.141592653589;
	printf("%f %f\n", s , e);
	
	return 0;

}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> r, w;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') r.push_back(i);
    else w.push_back(i);
  }
  reverse(r.begin(), r.end());
  if (min(r.size(), w.size()) == 0) {
    cout << 0 << endl;
    return 0;
  }
  int cnt;
  for (cnt = 0; w[cnt] < r[cnt]; cnt++);
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4652
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

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


// todo: inf = 1e18
const ll N = 1e5 + 5, MOD = 1e9 + 7, inf = 1000000LL * 1000000LL * 100LL + 10;
int n, m, s, t, ans;
ll dis[2][N];
int cnt[2][N];
vector <pii> G[N];
priority_queue <pii, vector <pii>, greater <pii> > PQ;
bool mark[N];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;
	return c;
}

int _sub (int a, int b) {
	int c = a - b;
	if (c < 0)
		c += MOD;
	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

void input() {
	scanf("%d %d", &n, &m);
	scanf("%d %d", &s, &t);
	s--, t--;

	for (int i = 0; i < m; i++) {
		int v, u, w;
		scanf("%d %d %d", &v, &u, &w);
		v--, u--;

		G[v].push_back({u, w});
		G[u].push_back({v, w});
	}
}

void dijkstra (int id, int v) {
	for (int i = 0; i < n; i++) {
		dis[id][i] = inf;
		mark[i] = false;
	}
	dis[id][v] = 0;
	cnt[id][v] = 1;
	PQ.push({0, v});

	while (PQ.size()) {
		int ver = PQ.top().second;
		PQ.pop();

		if (mark[ver])
			continue;
		mark[ver] = true;

		for (pii u: G[ver]) {
			if (dis[id][ver] + u.second < dis[id][u.first]) {
				dis[id][u.first] = dis[id][ver] + u.second;
				PQ.push({dis[id][u.first], u.first});
				cnt[id][u.first] = 0;
			}
			if (dis[id][ver] + u.second == dis[id][u.first])
				cnt[id][u.first] = _sum(cnt[id][u.first], cnt[id][ver]);	
		}
	}
}

int main() {
	input();
	dijkstra(0, s);
	dijkstra(1, t);
	ans = _mul(cnt[0][t], cnt[0][t]);
	for (int i = 0; i < n; i++)
		if (dis[0][i] + dis[1][i] == dis[0][t] && dis[0][i] == dis[1][i])
			ans = _sub(ans, _mul(_mul(cnt[0][i], cnt[1][i]), _mul(cnt[0][i], cnt[1][i])));
		
	for (int v = 0; v < n; v++)
		for (pii u: G[v])
			if (dis[0][v] + u.second + dis[1][u.first] == dis[0][t]) {
				if (dis[0][v] >= u.second + dis[1][u.first])
					continue;
				if (dis[0][v] + u.second <= dis[1][u.first])
					continue;
				ans = _sub(ans, _mul(_mul(cnt[0][v], cnt[1][u.first]), _mul(cnt[0][v], cnt[1][u.first])));
			}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 16880
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int n,A[55];
bool ok() {
	For(i,1,n) if(A[i]!=i) return 0;
	return 1;
}
void beng() {
	puts("YES");
	exit(0);
}
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&A[i]);
	if(ok()) beng();
	For(i,1,n)
		For(j,i+1,n) {
			swap(A[i],A[j]);
			if(ok()) beng();
			swap(A[i],A[j]);
		}
	puts("NO");
	return 0;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2")

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define up(x, v) upper_bound(all(x), v)
#define low(x, v) lower_bound(all(x), v)
#define bin(x, v) binary_search(all(x), v)
#define FOR(k, a, b) for(int k = (a); k < (b); ++k)
#define ROF(k, a, b) for(int k = (a); k > (b); --k)
#define fn(k, n) for(int k = 0; k < n; ++k)

#define EPS 1.0e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n, h, s = 0;

	cin >> h >> n;

	FOR(k, 0, n) {

		int a;

		cin >> a;

		s += a;
	}

	if(s >= h) cout << "Yes\n";
	else cout << "No\n";

    return 0;
}


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

#define ll long long

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++) cin>>A[i];
    int a=1,b=1e9;
    while(a<b){
        // cout<<a<<" "<<b<<endl;
        int mid = (a+b)/2;
        int times=0;
        for(int i=0;i<n;i++){
            int y=A[i]/mid;
            if(A[i]%mid==0) y--;
            times+=y;
        }
        if(times>k) a = mid+1;
        else b = mid;
    }
    cout<<a;
}

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

int main()
{
    vector<string> S(3);
    cin >> S[0];
    cin >> S[1];
    cin >> S[2];

    int next = 0;
    while (1)
    {
        if (S[next].size() == 0)
        {
            if (next == 0)
            {
                cout << 'A' << endl;
                return 0;
            }
            else if (next == 1)
            {
                cout << 'B' << endl;
                return 0;
            }
            else
            {
                cout << 'C' << endl;
                return 0;
            }
        }
        else
        {
            if (S[next][0] == 'a')
            {
                S[next].erase(S[next].begin());
                next = 0;
            }
            else if (S[next][0] == 'b')
            {
                S[next].erase(S[next].begin());
                next = 1;
            }
            else
            {
                S[next].erase(S[next].begin());
                next = 2;
            }
        }
    }

    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;


int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

ll pow5(ll c) {
    ll d = c;
    rep(i, 4) {
        d *= c;
    }
    return d;
}

int main() {
    ll X, A, B; cin >> X;

    for (ll a = 1; a <= 5000; a++) {
        for (ll b = -2000; b < a; b++) {
            if (pow5(a) - pow5(b) == X) {
                A = a;
                B = b;
                break;
            }
        }
    }
    cout <<  A << " " << B << endl;


}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;


int main(){

    int n;
    cin >> n;

    cout << n * n * n << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N)]
for ai, bi in ab:
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)

color = {}    
from collections import deque
q = deque([(0, 0)])
while len(q) > 0:
    src, c_prev = q.popleft()
    c = 1
    for dst in graph[src]:
        if c == c_prev: c += 1
        key = '{0}-{1}'.format(min(src, dst), max(src, dst))
        if color.setdefault(key, 0) == 0:
            color[key] = c
            q.append((dst, c))
            c += 1

print(max(color.values()))
for ai, bi in ab:
    key = '{0}-{1}'.format(min(ai, bi) - 1, max(ai, bi) - 1)
    print(color[key])

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    vector<int> length = {5, 7, 5, 7, 7};

    int N;
    while (cin >> N || N) {
        vector<string> S(N);
        rep(i, N) cin >> S[i];

        for (int i=0; i<N; i++) {
            int current = 0;
            int step = 0;
            bool ok = false;

            for (int j=i; j<N; j++) {
                if (current < length[step]) {
                    current += S[j].size();
                }

                if (current > length[step]) {
                    break;
                }

                if (current == length[step]) {
                    step++;
                    current = 0;
                }
                
                if (step == length.size()) {
                    ok = true;
                    cout << i+1 << endl;
                    break;
                }
            }
            if (ok) break;
        }
    }
}


Measured memory_bytes: 3184
import sys
import math
from collections import defaultdict, deque
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def main():
    N = I()
    mylist = [[] for i in range(N)]
    for i in range(N):
        temp = LI()
        temp2 = temp[1]
        for j in range(temp2):
            mylist[temp[0]-1].append(temp[2+j]-1)
    #初期化,距離、訪れたか。
    d = [-1] * N
    d[0] = 0
    dq = deque()
    dq.append(0)
    while dq:
        now = dq.popleft()
        for next_p in mylist[now]:
            if d[next_p] == -1:
                d[next_p] = d[now]+1
                dq.append(next_p)
    for index, num in enumerate(d):
            print(index+1, num)
            
        
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 6084
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

int main()
{
	// 入力
	ll n, c, k;
	cin >> n >> c >> k;
	vec t(n);
	REP(i, n) {
		cin >> t[i];
	}

	SORT(t);

	ll ans = 0;
	ll nextcust = 0;
	REP(i, n) {
		ans++;
		ll tnow = t[i];
		ll itemp = i;
		// cout<<"tnow"<<tnow<<endl;
		FOR(j, itemp + 1, min(itemp + c , n)) {
			if (t[j] > tnow + k) {
				// cout << j << " " << t[j] << " " << tnow << endl;
				break;
			}
			else {
				// cout << i << j << endl;
				i++;
			}
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll unsigned long long int 
using namespace std;


int main()
{
  ll h,w;
  cin>>h>>w;

  ll mid=h*w;
  if(h==1||w==1)
    cout<<"1"<<endl;

  else if(mid%2==0)
    cout<<mid/2<<endl;
  else
    cout<<(mid/2)+1<<endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
	static void Main(string[] args)
	{
		List<int> ValueList = new List<int>();

		int readnum = Convert.ToInt32(Console.ReadLine());

		while(readnum != 0)
		{
			ValueList.Add(readnum);
			readnum = Convert.ToInt32(Console.ReadLine());
		}

		for (int i = 0; i < ValueList.Count; i++)
		{
			Console.WriteLine(string.Format("Case {0}: {1}", i + 1, ValueList[i]));
		}
	}
}






Measured memory_bytes: 9544
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    }


}

Measured memory_bytes: 23252
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
using namespace std;
int main(){ 
  int N,M;
  int ans=0;
  cin >>N;
  cin >>M;
  ans =N*(N-1)/2+M*(M-1)/2;
  cout <<ans<<endl;
}

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

using namespace std;

int n,a[110],m,x,y,ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d%d",&x,&y);
		printf("%d\n",ans+y-a[x]);
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  ll A;
  map<ll, int> a;
  rep(i, N) {
    cin >> A;
    a[A-1]++;
  }
  int ans = 0;
  for (auto e : a) {
    if (e.second % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){

  string s;

  cin >> s;

  reverse(s.begin(), s.end());

  //abcd
  //int len = s.length();
  // len = 4

  //for(int i = len; i >= 0; i--){
  //cout << s[i];
    //}

  cout << s << endl;

}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        char[] S = scanner.next().toCharArray();

        boolean isBad = S[0] == S[1] || S[1] == S[2] || S[2] == S[3];

        System.out.println(isBad ? "Bad" : "Good");
    }
}

Measured memory_bytes: 22612
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const int MAXN = 345678;
int r[MAXN], c[MAXN];
vector<int> cand[MAXN];

int main() {
    int H, W, M;
    scanf("%d %d %d", &H, &W, &M);
    for (int i = 0; i < M; i++) {
        int tx, ty;
        scanf("%d %d", &tx, &ty);
        r[tx]++, c[ty]++;
        cand[tx].push_back(ty);
    }
    priority_queue<pii, vector<pii>> pq;
    for (int i = 1; i <= W; i++)
        pq.push(make_pair(c[i], i));
    int ans = 0;
    for (int i = 1; i <= H; i++) {
        set<int> st;
        int bst = 0;
        for (auto j : cand[i])
            st.insert(j);
        vector<pii> buff;
        while (!pq.empty()) {
            auto cur = pq.top();
            if (!st.count(cur.second)) {
                bst = max(bst, cur.first);
                break;
            }
            pq.pop();
            buff.push_back(make_pair(cur.first, cur.second));
            bst = max(bst, cur.first - 1);
        }
        for (auto i : buff)
            pq.push(i);
        ans = max(ans, r[i] + bst);
    }
    printf("%d\n", ans);

    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


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

    int i = (c + b - 1) / b;
    int j = (a + d - 1) / d;

    if (i <= j) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}



Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl L;
    L.push_back(a[0]);
    for(ll i=1; i<n; i++){
        if(a[i] > L[L.size()-1]){
            L.push_back(a[i]);
        }else{
            *lower_bound(all(L),a[i]) = a[i];
        }
    }
    cout << L.size() << endl;
}


Measured memory_bytes: 4716
#include<algorithm>
#include<iostream>
using namespace std;
int n[4];
int main(){
    cin >> n[0] >> n[1] >> n[2] >> n[3];
    int a=0;
    sort(n,n+4);
    if(n[0]==1){
        if(n[1]==4){
            if(n[2]==7){
                if(n[3]==9) cout <<"YES" <<endl,a=1;
            }
        }
    }
    if(a==0) cout << "NO" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define MAX 100005
using namespace std;

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

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int k, x;

    cin>>k>>x;

    k--;
    for(int i = x - k; i <= x + k; i++){
        cout<<i<<" ";
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 256