akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if (H%h==0 && W%w==0) {
        cout << "No" << endl;
        return 0;
    }
    else if (H%h != 0) {
        cout << "Yes" << endl;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i % h == h-1) cout << -10000*(h-1)-1;
                else cout << 10000;
                if (j < W-1) cout << " ";
                else cout << endl;
            }
        }
    }
    else if (W%w != 0) {
        cout << "Yes" << endl;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (j % w == w-1) cout << -10000*(w-1)-1;
                else cout << 10000;
                if (j < W-1) cout << " ";
                else cout << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, s, n) for(int i = s; i < n; i++)
#define rRep(i, n) for(int i = n - 1; i >= 0; i--)

double calc(pair<int, int> a, pair<int, int> b) {
	double ans = 0;
	ans += (a.first - b.first)*(a.first - b.first);
	ans += (a.second - b.second)*(a.second - b.second);
	ans = sqrt(ans);
	return ans;
}

int fac(int n){
	if (n == 1)
		return 1;
	return n*fac(n - 1);
}

int32_t main() {
	FAST
	int n;
	cin >> n;
	vector<pair<int, int>> vec(n);
	REP(i, 0, n)
	{
		int x, y;
		cin >> x >> y;
		vec[i] = mp(x, y);
	}
	double ans = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = i + 1; j < n; j++)
		{
			ans += calc(vec[i], vec[j]);
		}
	}

	int nfac = fac(n);
	int pairs = n*(n - 1);
	pairs /= 2;
	int mul = (n - 1)*nfac;
	mul /= pairs;
	ans *= mul;
	ans /= nfac;
	cout << setprecision(10) << fixed << ans << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int d, t, s;
    cin >> d >> t >> s;
    if(t * s >= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::string S)
{
    ll ans = 1;
    char prev = S[0];
    for (int i = 1; i < N; i++)
    {
        if(S[i] == prev){
            continue;
        }else{
            ans++;
            prev = S[i];
        }
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


x, y = LI()
cnt = 0


while x <= y:
    x *= 2
    cnt += 1



print(cnt)

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

int dp[2][2][5001];

int main(){
  int n;
  int t[10000];
  cin >> n;
  for(int i=0;i<n-1;i++)cin >> t[i];
  
  for(int i=0;i<=n/2;i++)dp[0][0][i] = dp[0][1][i] = 100000000;
  dp[0][0][1] = 0;

  for(int i=0;i<n-1;i++){
    int ii = i&1;
    for(int j=0;j<=n/2;j++)dp[1-ii][0][j] = dp[1-ii][1][j] = 100000000;

    for(int j=0;j<2;j++){
      for(int k=0;k<=n/2;k++){
	if(dp[ii][j][k]==100000000)continue;
	if(k<n/2)dp[1-ii][j][k+1] = min(dp[1-ii][j][k+1], dp[ii][j][k]);
	if(i+1-k<n/2 && 0<=i+1-k+1)dp[1-ii][1-j][i+1-k+1] = min(dp[1-ii][1-j][i+1-k+1],dp[ii][j][k] + t[i]);
      }
    }
  }

  cout << min(dp[1][0][n/2],dp[1][1][n/2]) << endl;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
using f32 = float;
using f64 = double;
using LL = long long;
using ULL = unsigned long long;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
signed main()
{ 
  char n;
  REP(i,3){
  cin >>n;
  if(n=='7'){
  cout << "Yes";
  return 0;
  }
  }
  cout << "No";
  
}

Measured memory_bytes: 3600
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    x = tuple(geta(int))

    for i, xi in enumerate(x):
        if xi == 0:
            print(i + 1)
            break


if __name__ == "__main__":
    main()

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		HashSet<char> ng = new HashSet<char>();
		for(int i=0;i<D.Length;i++){
			ng.Add((char)('0' + D[i]));
		}
		for(int i = N;i<=99999;i++){
			String s = i.ToString();
			bool chk = true;
			foreach(var c in s){
				if(ng.Contains(c)){
					chk = false;
					break;
				}
			}
			if(chk){
				Console.WriteLine(i);
				return;
			}
		}
		
		
		
		
		
	}
	int N,K;
	int[] D;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		D = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
int N, M;
int WA[105000];
bool AC[105000];
 
int32_t main()
{
    //int N,M;
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for(int i = 1; i <= N; i++) 
    {
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--) 
    {
        int p;
        string S;
        cin>>p>>S;
        if(AC[p])
            continue;
        else if(S=="AC")
        {
            AC[p]=true;
            ACnum++;
            WAnum+=WA[p];
        }
        else if(S=="WA")
        {
            WA[p]++;
        }
    }
    cout<<ACnum<<" "<<WAnum<<endl;
    return 0;
}

Measured memory_bytes: 768
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))

(defun f(a b c)
  (if (or (and (= a b)
               (not (= b c)))
          (and (= b c)
               (not (= a b)))
          (and (= a c)
               (not (= b c)))
          )
    "Yes"
    "No"))
(let* ((line (mapcar #'parse-integer (splitat #\space (read-line nil nil)))))
  (format t "~A~%" (f (car line) (cadr line) (caddr line))))


Measured memory_bytes: 12264
# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

As.sort()
# print(As)

all_nums = [0] * (As[-1] + 1)

for A in As:
    all_nums[A] += 1

dup = 0

for i, num in enumerate(all_nums):
    if num == 0:
        continue
    if num > 1:
        dup += num
    j = 2
    while i * j <= As[-1]:
        all_nums[i*j] = 0
        j += 1
    # print(all_nums)

print(sum(all_nums)-dup)

Measured memory_bytes: 32168
a, b, x=map(int, input().split())
if a*a*b==x:
  print(0)
  exit()
import math
if 2*x/(a*b)>=a:
  ans=a/(2*b-2*x/(a**2))
else:
  ans=2*x/(a*b**2)
print(90-math.degrees(math.atan(ans)))

Measured memory_bytes: 9276
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                int h = Integer.parseInt(sc.next());
                int w = Integer.parseInt(sc.next());
                int[][] c = new int[10][10];
                for(int i = 0 ; i <= 9 ; i++){
                        for(int j = 0 ; j <= 9 ; j++){
                                c[i][j] = Integer.parseInt(sc.next());
                        }
                }
                int yono = h * w;
                int[][] a = new int[h][w];
                for(int i = 0 ; i < h ; i++){
                        for(int j = 0 ; j < w ; j++){
                                a[i][j] = Integer.parseInt(sc.next());
                                if(a[i][j] == -1) yono--;
                        }
                }
                sc.close();
                int[] q = new int[yono];
                yono = 0;
                for(int i = 0 ; i < h ; i++){
                        for(int j = 0 ; j < w ; j++){
                                if(a[i][j] != -1){
                                        q[yono] = a[i][j];
                                        yono++;
                                }
                        }
                }
                for(int i = 0 ; i <= 9 ; i++){
                        for(int j = 0 ; j <= 9 ; j++){
                                for(int k = 0 ; k <= 9 ; k++){
                                        c[j][k] = Math.min(c[j][k] , c[j][i] + c[i][k]);
                                }
                        }
                }
                long ebishu = 0;
                for(int i = 0 ; i < yono ; i++){
                        ebishu += c[q[i]][1];
                }
                ou.print(ebishu + "\n");
                ou.flush();
        }
}

Measured memory_bytes: 57332
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(a <= 8 && b <= 8)System.out.println("Yay!");
        else System.out.println(":(");
    }
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, m; scan(n, m);
      LI xs(n+1), ys(n+1);
      for(long i = 0; i < m; ++i) {
         long a, b; scan(a, b);
         if( a > b ) std::swap(a, b);
         if( a == 1 ) xs[b] = 1;
         if( b == n ) ys[a] = 1;
      }
      bool res = false;
      for(long i = 1; i <= n; ++i) {
         if( xs[i] == 1 and ys[i] == 1 ) res = true;
      }
      puts(res ? "POSSIBLE" : "IMPOSSIBLE");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 3328
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
def pow_k(x, n):

    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x
def main():  #startline-------------------------------------------
    n = int(input())
    a = list(map(int, input().split()))
    accum = sum(a)
    ans = 1
    b = [0] * (n + 1)
    b[0] = 1
    for i in range(1, n + 1):
        accum -= a[i]
        b[i] = min(2 * b[i - 1] - a[i], accum)
        if b[i] < 0:
            ans = -1
            break
        ans += b[i] + a[i]
    if a[0] == 1:
        ans = -1
    if n == 0:
        if a[0] == 1:
            ans = 1
        else:
            ans = -1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 32708
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }
std::vector<int> adj[100004];
int mod = 1e9 + 7;

pair<int, int> dfs(int u, int p) {
	std::vector<pair<int, int> > vec;
	for (int v : adj[u]) 
		if (v != p)
			vec.pb(dfs(v, u));
	pair<int, int> pl; pl.fi = 1; pl.se = 1;
	for (auto pp : vec) {
		pl.fi = pl.fi * ((pp.fi + pp.se) % mod) % mod;
		pl.se = pl.se * (pp.fi) % mod;
	}
	return pl;
}


int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	for (int o = 0; o < n - 1; o++) { int x, y; cin >> x >> y; x--; y--; adj[x].pb(y); adj[y].pb(x); }
	auto p = dfs(0, 0);
	cout << (p.first + p.second) % mod;
}

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

void YYMM(int s){
    int x=s/100;
    int y=s%100;
    if(x>0 && x<13){
        if(y>0 && y<13){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "MMYY" << endl;
        }
    }
    else{
        if(y>0 && y<13){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
}

int main(){
    int s; cin >> s;
    YYMM(s);
    return 0;
}

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

int main(){
    map<string, int> table;
    string word,frequent, longest;
    int N = 0;
    while(cin >> word){
        table[word]++;
        if(table[word] > N){
            N = table[word];
            frequent = word;
        }
        if(word.size() > longest.size())
            longest = word;
    }
    cout << frequent << " " << longest << endl;
}

Measured memory_bytes: 3048
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
 
const int N = 100 * 1000 + 5, A = 15;
int ans;
 
 
vector <pair <int, int> > adj[N];
bool mark[N];
int dp[N][A + 5];
int bp[(1 << A) + 5];
int get(int x, int y) {
	return (x >> y) & 1;
}
void dfs(int v) {
	mark[v] = true;
	for (auto p : adj[v]) {
		int u = p.first, w = p.second;
		if (!mark[u]) {
			dfs(u);
			for (int i = 0; i <= A; i++) {
				dp[v][i] += dp[u][i];
				if (dp[u][i] % 2 == 1) {
					w ^= i;
				}
			}
			dp[v][w]++;
		}
 
	}
/*	for (int i = 1; i <= A; i++) {
		for (int j = 1; j < i; j++) {
			if (dp[v][i] && dp[v][j] && dp[v][i ^ j]) {
				ans += 2;
				dp[v][i] = 0;
				dp[v][j] = 0;
				dp[v][i ^ j] = 0;
			}
		}
	}*/
/*	for (int i = 1; i <= A; i++) {
		ans += dp[v][i] / 2;
		dp[v][i] %= 2;
	}*/
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		adj[u].push_back({v, w});
		adj[v].push_back({u, w});
	}
	dfs(1);
	for (int i = 1; i <= A; i++) {
		ans += dp[1][i] / 2;
		dp[1][i] %= 2;
	//	cout << i << " " << dp[1][i] << endl;
	}
/*	for (int i = 1; i <= A; i++) {
		for (int j = 1; j < i; j++) {
			if (dp[1][i] && dp[1][j] && dp[1][i ^ j]) {
				ans += 2;
				dp[1][i] = 0;
				dp[1][j] = 0;
				dp[1][i ^ j] = 0;
			}
		}
	}
	for (int i = 1; i <= A; i++) {
		ans += dp[1][i];
	}*/
	for (int mask = 0; mask < 1 << A; mask++) {
		bp[mask] = __builtin_popcount(mask);
	}
	for (int k = 0; k < A; k++) {
		for (int mask = 0; mask < 1 << A; mask++) {
			for (int i = 0; i < A; i++) {
				for (int j = 0; j < i; j++) {
					int mask2 = mask;
					int x = 0;
					int y = 0;
					if (get(mask, i)) {
						x++;
					}
					if (get(mask, j)) {
						x++;
					}
					if (get(mask, ((i + 1) ^ (j + 1)) - 1)) {
						x++;
					}
					if (x == 3) {
						y = 2;
					}
					else{
						y = 1;
					}
					mask2 ^= 1 << i;
					mask2 ^= 1 << j;
					mask2 ^= 1 << (((i + 1) ^ (j + 1)) - 1);
				//	if (mask == 19) {
				//		cout << "48 " << mask << " " << mask2 << " " << i << " " << j << " " << bp[mask2] << endl;
				//	}
					bp[mask] = min(bp[mask], bp[mask2] + y);
				}
			}
		}
	}
//	for (int mask = 0; mask < 1 << A; mask++) {
//		
//		cout << mask << " " << bp[mask] << endl;
//	}
	int mask = 0;
	for (int i = 1; i <= A; i++) {
		if (dp[1][i]) {
			mask += 1 << (i - 1);
		}
	}
	cout << ans + bp[mask] << endl;
	return 0;
}


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

int main() {
  int n; cin >> n;
  map<string, int> red;
  while (n--) {
    string key; cin >> key;
    if (red.count(key)) red.at(key)++;
    else red.insert(make_pair(key, 1));
  }
  int m; cin >> m;
  map<string, int> blue;
  while (m--) {
    string key; cin >> key;
    if (blue.count(key)) blue.at(key)++;
    else blue.insert(make_pair(key, 1));
  }
  
  int answer = 0;
  for (pair<string, int> word : red) {
    if (blue.count(word.first)) answer = max(answer, word.second - blue.at(word.first));
    else answer = max(answer, word.second);
  }
  
  cout << answer << endl;
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> used(1000000, 0), same(M, 0), num(M, 0);
	for (int i = 0, X; i < N; i++) {
		cin >> X;
		num[X % M]++;
		used[X]++;
		if (used[X] % 2 == 0) {
			same[X % M]++;
		}
	}
	long long res = 0;
	vector<bool> Used(M, false);
	for (int i = 0; i < M; i++) {
		if (i == (M - i) % M) {
			if (Used[i]) continue;
			res += num[i] / 2;
			num[i] %= 2;
			Used[i] = true;
		}
		else {
			if (Used[i] && Used[(M - i) % M]) continue;
			int val = min(num[i], num[(M - i) % M]);
			if ((num[i] - val) % 2 && (num[(M - i) % M] - val) % 2 && same[i] * 2 > val && same[(M - i) % M] * 2 > val) val--;
			res += val;
			num[i] -= val;
			num[(M - i) % M] -= val;
			res += min(num[i], same[i] * 2) / 2;
			num[i] -= min(num[i], same[i] * 2) / 2 * 2;
			res += min(num[(M - i) % M], same[(M - i) % M] * 2) / 2;
			num[(M - i) % M] -= min(num[(M - i) % M], same[(M - i) % M] * 2) / 2 * 2;
			Used[i] = Used[(M - i) % M] = true;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                     \
  ifstream in("atcoder-problems/abc061_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  vector<vector<int>> g(N, vector<int>(0));
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  rep(i, N) { cout << g[i].size() << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 100123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define oo 1000000123
#define sz(x) ((int)((x).size()))
#define pi acos(-1)

using namespace std;

double n;

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    cin >> n;
    cout << fixed << setprecision(10);
    n = 2.0*pi*n;
    cout << n << '\n';
    return 0;
}

Measured memory_bytes: 3768
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=505;
struct node{
    int go[2];
    node(){go[0]=go[1]=0;}
};
vector<node> trie(2);
char num[256];
void add(const string&s){
    int v=1;
    for(char c:s){
        if(!trie[v].go[c-'0']){
            trie[v].go[c-'0']=sz(trie); 
            trie.pb();
        }
        v=trie[v].go[c-'0'];
    }
    // trie[v].term=1;
}
int g(int v,int d){
    int s=0,c=0;
    forn(i,2){
        int to=trie[v].go[i];
        if(to)c++,s^=g(to,d-1);
    }
    if(c&1){
        int x=__builtin_ctzll(d);
        s^=(1ll<<x);
    }
    return s;
}
int32_t main(){
    int n,len;
    cin>>n>>len;
    string s;
    forn(i,n){
        cin>>s;
        add(s);
    }
    int k=g(1,len);
    if(k)cout<<"Alice\n";
    else cout<<"Bob\n";
    return 0;
}

Measured memory_bytes: 9696
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll a, b, c; cin >> a >> b >> c;
    (a+b >= c) ? Yes() : No();
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		System.out.println(Integer.toString(N, K).length());
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static int n;
	public static int k;
	public static int []w;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		k = scan.nextInt();
		w = new int[n];
		for(int i = 0; i < n; i++) {
			w[i] = scan.nextInt();
		}
		scan.close();
		long ans = solve();
		System.out.println(ans);
	}
	
	/*
	 * トラックに詰め込めるかどうかのチェック
	 */
	public static int check(long p) {
		int i = 0;
		for(int j = 0; j < k; j++) {
			long s = 0;
			while(s + w[i] <= p) {
				s += w[i];
				i++;
				if(i == n) {
					return n;
				}
			}
		}
		return i;
	}
	/**
	 * 二分探索木でトラックに乗せる最大積載量Pを求める
	 * @return
	 */
	public static long solve() {     
		long left = 0;
	// 荷物の個数×1個当たりの最大重量
	long right = 100000 * 10000;
	long mid;
	while(right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if(v >= n) {
			right = mid;
		}else{
			left = mid;
		}
	}
	return right;
	}
}



Measured memory_bytes: 71380
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll ans = 0,N,T;
  cin >> N >> T;
  ll t[N+1];
  FOR(i,0,N)cin >> t[i];
  t[N] = LINF;
  FOR(i,0,N){
    if(t[i+1] - t[i] >= T)ans += T;
    else ans += t[i+1] - t[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
from sys import stdin
from itertools import accumulate

def solve():
    file_input = stdin
    
    N = int(file_input.readline())
    img = tuple(tuple(map(int, line.split())) for line in file_input)
    
    acc_row = (tuple(accumulate(line)) + (0,) for line in img)
    
    acc_col = (tuple(accumulate(line)) + (0,) for line in zip(*img))
    acc_col_1 = next(acc_col)
    acc_col = tuple(zip(*acc_col))
    
    ans = 0
    for i, tpl_1 in enumerate(zip(img, acc_row)):
        img_i, acc_row_i = tpl_1
        for j, img_j in enumerate(img[i:], start=i):
            if acc_row_i[j] - acc_row_i[i - 1] > ans:
                ans = acc_row_i[j] - acc_row_i[i - 1]
                
            if i == j:
                continue
            
            col_max = acc_col_1[j] - acc_col_1[i - 1]
            
            for acc_col_j_k, acc_col_i_k, img_i_k, img_j_k in zip(acc_col[j], acc_col[i - 1], img_i[1:], img_j[1:]):
                col = acc_col_j_k - acc_col_i_k
                
                if col_max > 0:
                    c_ans = col_max + col
                    if c_ans > ans:
                        ans = c_ans
                else:
                    if col > ans:
                        ans = col
                
                t_col_max = col_max + img_i_k + img_j_k
                if t_col_max > col:
                    col_max = t_col_max
                else:
                    col_max = col
    print(ans)

solve()


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

int f(int n)
{
    int ret = 0;
    for (; n; ret += n % 10, n /= 10);
    return ret;
}
int main()
{
    int n;
    cin >> n;

    cout << (n % f(n) ? "No" : "Yes") << endl;

    return 0;
}


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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int cnt = 0;
  for(int i = 0; i <= 999; i++){
    int c[3] = {i/100, (i%100)/10, i%10};
    int k = 0;
    for(int j = 0; j < n; j++){
      if('0' + c[k] == s.at(j)){
        k++;
      }
      if(k == 3){
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = list(STR())
l = len(s)
k = INT()
for i in range(l):
    tmp = (ord('z') - ord(s[i]) + 1) % 26
    if tmp <= k:
        s[i] = 'a'
        k -= tmp
    #print(k, tmp)
s[l - 1] = chr((ord(s[l - 1]) - ord('a') + k) % 26 + ord('a'))
print(''.join(s))


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

const int MAX = 10000000 ;
// UFTクラスを宣言するときはグローバル変数か、staticをつけて静的変数にすること
class UFT{
public :
	int par[MAX] ;
	int rank[MAX] ;
	int size[MAX] ;
	bool root[MAX] ;
	int tree ;
	int group ;

	void init(int n){
		for(int i=0;i<n;i++){
			par[i] = i ;
			rank[i] = 0 ;
			size[i] = 1 ;
			root[i] = true ;
		}
		tree = n ;
		group = n ;
	}

	int find(int x){
		if(par[x]==x) return x ;
		return par[x] = find(par[x]) ;
	}

	void unite(int x,int y){
		x = find(x) ;
		y = find(y) ;
		if(x==y){
			if(root[x]){
				root[x] = false ;
				tree-- ;
			}
			return ;
		}
		if(rank[x]<rank[y]){
			par[x] = y ;
			size[y] += size[x] ;
			if(root[x]){
				root[x] = false ;
				tree-- ;
			}
			group-- ;
		}else{
			par[y] = x ;
			size[x] += size[y] ;
			if(rank[x]==rank[y]) rank[x]++ ;
			if(root[y]){
				root[y] = false ;
				tree-- ;
			}
			group-- ;
		}
	}

	bool same(int x,int y){
		return find(x)==find(y) ;
	}
};

int main(){
	int n,m ;
	cin >> n >> m ;
	static UFT uft ;
	uft.init(n) ;
	for(int i=0;i<m;i++){
		int a,b,c ;
		cin >> a >> b >> c ;
		a-- ; b-- ;
		uft.unite(a,b) ;
	}
	cout << uft.group << endl ;
}


Measured memory_bytes: 6784
while True:
    m,f,r = map(int,input().split())
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7720
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    s += string(n, ' ');
    // vector<char> s(n); cin >> s;
    int q; cin >> q;
    for(int h = 0; h < q; h++){
        int k; cin >> k;
        int ms = 0, cs = 0;
        ll num = 0, ans = 0;
        for(int i = 0; i < k - 1; i++){
            if(s[i] == 'M'){
                ms++;
            }else if(s[i] == 'C'){
                cs++;
                num += ms;
            }
        }
        for(int i = 0; i < n; i++){
            // if(i + k - 1 < n){
                if(s[i + k - 1] == 'M'){
                    ms++;
                }else if(s[i + k - 1] == 'C'){
                    cs++;
                    num += ms;
                }
            // }
            if(s[i] == 'D'){
                ans += num;
                // printde(i, ans, num);
            }else if(s[i] == 'M'){
                ms--;
                num -= cs;
            }else if(s[i] == 'C'){
                cs--;
            }
        }
        if(num){
            return 1;
        }
        cout << ans << '\n';
    }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

#define MAX_N 100
#define MAX_M 100

int main() {
    string s;
    cin >> s;
    string miru = "KIHBR";

    if(s.size() > 9) {
        cout << "NO" << endl;
        return 0;
    }
    int idx = 0;
    REP(i, s.size()) {
        if(s[i] != miru[idx]) {
            if(s[i] != 'A') {
                cout << "NO" << endl;
                return 0;
            }
        } else {
            idx++;
        }
    }

    if(idx != 5) {
        cout << "NO" << endl;
        return 0;
    }

    REP(i, s.size()-1) {
        if(s[i+1] == 'A') {
            if(s[i] != 'H' && s[i] != 'B' && s[i] != 'R') {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program {
    static void Main( string[] args )
    {
        string[] size = Console.ReadLine().Split();

        int n = int.Parse( size[ 0 ] );
        int m = int.Parse( size[ 1 ] );

        int[,] matrix = new int[ n, m ];

        for ( int i = 0; i < n; ++i ) {
            string[] row = Console.ReadLine().Split();

            for ( int j = 0; j < m; ++j ) {
                matrix[ i, j ] = int.Parse( row[ j ] );
            }
        }

        int[] vector = new int[ m ];

        for ( int i = 0; i < m; ++i ) {
            vector[ i ] = int.Parse( Console.ReadLine() );
        }

        for ( int i = 0; i < n; ++i ) {
            int dot = 0;

            for ( int j = 0; j < m; ++j ) {
                dot += vector[ j ] * matrix[ i, j ];
            }

            Console.WriteLine( dot );
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    string s;
    cin >> s;
    stack<char> stk;

    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(!stk.empty() && stk.top()!=s[i]){
            stk.pop();
            ans += 2;
        }else{
            stk.push(s[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

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

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,k;
    cin>>n>>k;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    vi w;
    for(int i=0;i<n;++i)
    {
        int x=0;
        for(int j=i;j<n;++j)
        {
            x+=v[j];
            w.pb(x);
        }
    }

    vi tmp;
    int ans=0;
    for(int i=60;i>=0;--i)
    {
        int val=1ll<<i,cnt=0;
        for(auto c:w)
        {
            if(c&val)
                ++cnt;
        }

        if(cnt<k)
            continue;

        ans^=val;
        for(auto c:w)
        {
            if(c&val)
                tmp.pb(c);
        }

        w=tmp;
        tmp.clear();
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 6512
n, m = map(int, input().split(' '))
ab = []
for _ in range(n):
    a, b = map(int, input().split(' '))
    ab.append((a, b))

sorted_ab = sorted(ab)
collected = 0
cost = 0
for i in range(n):
    a, b = sorted_ab[i]
    if b > m - collected:
        cost += (m - collected) * a
        break
    else:
        cost += a * b
        collected += b

print("{:d}".format(cost))


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

using namespace std;

int main()
{
  long long K, A, B;
  cin >> K >> A >> B;
  long long ans;
  if (B - A <= 2)
    ans = K + 1;
  else
    ans = A + max(0LL, (K - A + 1)) / 2 * (B - A) + max(0LL, (K - A + 1)) % 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a, b, c;

int main()
{
	cin >> a >> b >> c;
	if (a + b >= c)
	{
		cout << b + c << endl;
	}
	else
	{
		cout << a + 2 * b + 1 << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        double w = scanner.nextDouble();
        double h = scanner.nextDouble();
        double x = scanner.nextDouble();
        double y = scanner.nextDouble();

        int count = 0;
        if(w/2 == x && h/2 == y){count++;}
        System.out.println((w*h/2.0) + " " + count);
        
    }
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,i;
    cin>>a>>b>>c;
    for(i=1;i<=1000;i++)
    {
        d=i*a;
        if(d>=b&&d<=c)
        {
            cout<<"OK";
            return 0;
        }
        if(d>c)
        {
            cout<<"NG";
            return 0;
        }
    }

}


Measured memory_bytes: 3640
#include <cstdio>

int main(){
	int n;
	while(scanf("%d", &n), n){
		int p[10] = {0}, t;
		for(;n;n--)
			scanf("%d", &t), p[t]++;

		for(t=0;t<10;t++){
			if(p[t])
				for(n=p[t];n;n--)
					printf("*");
			else printf("-");
			puts("");
		}
	}
}

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

using namespace std;

int main()
{
	int x, t;
	cin >> x >> t;
	if (x < t) {
		cout << "0" << endl;
	}
	else {
		cout << x - t << endl;
	}
	return 0;
}



Measured memory_bytes: 256
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
if a1 < b1:
  a1, b1 = b1, a1
  a2, b2 = b2, a2
f = (a1-b1)*t1
l = (b2-a2)*t2
if f > l:
  print(0)
elif f == l:
  print("infinity")
else:
   print(2 * (f//(l-f)) + int(f%(f-l)!=0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;

int main (void) {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++)
    cin >> S[i];

  vector<vector<int>> tbl1(H, vector<int>(W));
  vector<vector<int>> tbl2(H, vector<int>(W));
  vector<vector<int>> tbl3(H, vector<int>(W));
  vector<vector<int>> tbl4(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') {
        tbl1[i][j] = 1;
        tbl2[i][j] = 1;
        tbl3[i][j] = 1;
        tbl4[i][j] = 1;
      }
    }
  }

  // 右向きに伸びる光をとる
  for (int i = 0; i < H; i++) {
    for (int j = 1; j < W; j++) {
      if (S[i][j] == '.') {
        if (S[i][j - 1] == '.') {
          tbl1[i][j] = tbl1[i][j - 1] + 1;
        } else {
          tbl1[i][j] = 1;
        }
      } else {
        tbl1[i][j] = 0;
      }
    }
  }

  // 下向きに伸びる光をとる
  for (int i = 1; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') {
        if (S[i - 1][j] == '.') {
          tbl2[i][j] = tbl2[i - 1][j] + 1;
        } else {
          tbl2[i][j] = 1;
        }
      } else {
        tbl2[i][j] = 0;
      }
    }
  }

  // 左向きに伸びる光をとる
  for (int i = 0; i < H; i++) {
    for (int j = W - 2; j >= 0; j--) {
      if (S[i][j] == '.') {
        if (S[i][j + 1] == '.') {
          tbl3[i][j] = tbl3[i][j + 1] + 1;
        } else {
          tbl3[i][j] = 1;
        }
      } else {
        tbl3[i][j] = 0;
      }
    }
  }

  // 上向きに伸びる光をとる
  for (int i = H - 2; i >= 0; i--) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') {
        if (S[i + 1][j] == '.') {
          tbl4[i][j] = tbl4[i + 1][j] + 1;
        } else {
          tbl4[i][j] = 1;
        }
      } else {
        tbl4[i][j] = 0;
      }
    }
  }

  int ans = -1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      const int s = tbl1[i][j] + tbl2[i][j] + tbl3[i][j] + tbl4[i][j] - 3;
      ans = max(ans, s);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 67200
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n;
    cin >> n;
    int a[n];
    F(i,0,n) cin >> a[i];
    bool f=1;
    F(i,0,n){
        if(a[i]%2==0){
            if(a[i]%3==0 || a[i]%5==0){
                continue;
            }
            else{
                f=0;
                break;
            }
        }
    }
    if(f){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

struct edge {
    int to;
    ll cap;
    int rev;
};
// 0 to S
// 1~100 to H
// 101~200 to W
// 201 to T
vector<edge> G[202];
bool used[202];

void add_edge(int from, int to, ll cap) {
    G[from].push_back(edge{to, cap, (int)G[to].size()});
    G[to].push_back(edge{from, 0LL, (int)G[from].size() - 1});
}

ll dfs(int v, int t, ll f) {
    if(v == t) return f;
    used[v] = true;
    for(auto &e : G[v]) {
        if(!used[e.to] && e.cap > 0) {
            ll d = dfs(e.to, t, min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(int s, int t) {
    ll flow = 0;
    while(true) {
        memset(used, 0, sizeof(used));
        ll f = dfs(s, t, INT64_MAX);
        if(f == 0) return flow;
        flow += f;
        if(flow >= ~0U) return ~0U;
    }
}

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

    int H, W;
    const int S = 0, T = 201;

    cin >> H >> W;

    FOR(i, 1, H + 1) {
        FOR(j, 101, W + 101) {
            char c;
            cin >> c;
            if(c == 'S') {
                add_edge(S, i, ~0U);
                add_edge(S, j, ~0U);
            }
            if(c == 'T') {
                add_edge(i, T, ~0U);
                add_edge(j, T, ~0U);
            }
            if(c == 'o') {
                add_edge(i, j, 1);
                add_edge(j, i, 1);
            }
        }
    }

    cout << (int)max_flow(S, T) << endl;

    return 0;
}

Measured memory_bytes: 1536