akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>


void swap(int* X, int* Y)
{
    int Z = *X;
    *X = *Y;
    *Y = Z;
}


void AlignTwo(int* Smaller, int* Larger)
{
    if (*Smaller > *Larger){
        swap(Smaller, Larger);
    }
}

int main()
{
    int First = 0;
    scanf("%d", &First);
    int Second = 0;
    scanf("%d", &Second);
    AlignTwo(&First, &Second);
    
    int Third = 0;
    scanf("%d", &Third);
    AlignTwo(&Second, &Third);
    AlignTwo(&First, &Second);
    
    printf("%d ", First);
    printf("%d ", Second);
    printf("%d\n", Third);
    return 0;
}



Measured memory_bytes: 2052
N=int(input())
S=input()
Rd=set();Gd=set();Bd=set()
for i in range(0,N):
    if S[i]=='R':
        Rd.add(i)
    elif S[i]=='G':
        Gd.add(i)
    elif S[i]=='B':
        Bd.add(i)
RN=len(Rd);GN=len(Gd);BN=len(Bd)
s=0
for r in Rd:
    for g in Gd:
        if g>r:
            if 2*r-g in Bd:
                s+=1
                #print(r,g)
            if (r+g)%2==0 and (r+g)//2 in Bd:
                s+=1
                #print(r,g)
            if 2*g-r in Bd:
                s+=1
                #print(r,g)
        else:
            if 2*r-g in Bd:
                s+=1
                #print(r,g)
            if 2*g-r in Bd:
                s+=1
                #print(r,g)
            if (r+g)%2==0 and (r+g)//2 in Bd:
                s+=1
                #print(r, g)
print(RN*GN*BN-s)


Measured memory_bytes: 9544
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n = _i()
    x = list()
    y = list()
    for _ in range(n):
        xi, yi = _ia()
        x.append(xi - yi)
        y.append(xi + yi)
    return max(max(x) - min(x), max(y) - min(y))


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 90824
import sys
from collections import Counter

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    A = sorted(in_nl())[::-1]

    a_cnt = Counter(A)

    ans = 0
    for i in range(N):
        if a_cnt[A[i]] == 0:
            continue
        pow_two = 2 ** A[i].bit_length()
        search = pow_two - A[i]
        a_cnt[A[i]] -= 1
        if a_cnt[search] >= 1:
            ans += 1
            a_cnt[search] -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 130092
#include<bits/stdc++.h>
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
using namespace std;
char grid[2002][2002];
int L[2002][2002],R[2002][2002],U[2002][2002],D[2002][2002];
int main(){
	// read;
	// write;
	int h,w,nax=0;
	cin >> h >> w;
	for(int i=1; i<=h; ++i){
		string row;
		cin >> row;
		for(int j=1; j<=w; ++j){
			grid[i][j]=row[j-1];
		}
	}
	
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			if(grid[i][j]=='#')
				L[i][j]=0;
			else{
				if(j==1){
					L[i][j]=1;
				} else{
					L[i][j]=L[i][j-1]+1;
				}
			}
		}
	}
	for(int i=1; i<=h; ++i){
		for(int j=w; j>=1; --j){
			if(grid[i][j]=='#')
				R[i][j]=0;
			else{
				if(j==w){
					R[i][j]=1;
				} else{
					R[i][j]=R[i][j+1]+1;
				}
			}
		}
	}
	
	for(int i=1; i<=h; ++i){
		for(int j=1; j<=w; ++j){
			if(grid[i][j]=='#'){
				U[i][j]=0;
			} else{
				if(i==1){
					U[i][j]=1;
				} else{
					U[i][j]=U[i-1][j]+1;
				}
			}
		}
	}
	for(int i=h; i>=1; --i){
		for(int j=1; j<=w; ++j){
			if(grid[i][j]=='#'){
				D[i][j]=0;
			} else{
				if(i==h){
					D[i][j]=1;
				} else{
					D[i][j]=D[i+1][j]+1;
				}
			}
		}
	}
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			int cnt=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
			nax=max(nax,cnt);
		}
	}
	cout << nax << endl;
	return 0;
}

Measured memory_bytes: 66816
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from collections import deque
    K = I()
    edge = [[]for _ in range(K)]
    for i in range(K):
        edge[i].append((i * 10) % K)
        edge[i].append((i + 1)%K)
        
    zero_one_deque = deque([(1, 1)])
    node = [inf] * K
    #1から始めて、Kの倍数を見つける 01BFS
    node[1] = 1
    searched = set()
    while zero_one_deque:
        from_ , digit_sum = zero_one_deque.popleft()
        if from_ in searched:
            continue
        else:
            searched.add(from_)
            node[from_] = digit_sum
            
        for i, to in enumerate(edge[from_]):
            if i == 0:
                zero_one_deque.appendleft((to,node[from_]))
            else:   
                zero_one_deque.append((to, node[from_] + 1))
    print(node[0])
                    

if __name__ == '__main__':
    main()

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

#define MAX_LEN 5

int main(void)
{
	int i, res = 0;
	char S[MAX_LEN];
	scanf("%s", S);

	for (i = 0; i < (int)strlen(S); i++)
		if (S[i] == '+')
			res++;
		else
			res--;

	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] A = new int[3][3];
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                A[i][j] = Integer.parseInt(sc.next());
            }
        }
        int N = Integer.parseInt(sc.next());
        int[] b = new int[N];
        for(int i = 0; i < N; i++) {
            b[i] = Integer.parseInt(sc.next());
        }

        for(int i = 0; i < N; i++) {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 3; k++) {
                    if(A[j][k] == b[i]) A[j][k] = 0;
                }
            }
        }
        int[] diagonally = {0, 0};
        for(int i = 0; i < 3; i++ ) {
            int vertical = 0;
            int horizonal = 0;
            for(int j = 0; j < 3; j++) {
                vertical += A[j][i];
                horizonal += A[i][j];
            }
            if(vertical == 0 || horizonal == 0) {
                System.out.println("Yes");
                return;
            }
            diagonally[0] += A[i][i];
            diagonally[1] += A[i][2 - i];
        }
        if(diagonally[0] == 0 || diagonally[1] == 0) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23764
function main(input) {
  const n = parseInt(input.split(" ")[0], 10);
  const k= parseInt(input.split(" ")[1], 10);
  if(n%k==0){
    console.log(0);
  }else{
    console.log(1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
N = int(input())
H = list(map(int,input().split()))

cnt =0
for i in range(N-1):
    if H[i] < H[i+1] :
        H[i+1] -= 1
    elif H[i] != H[i+1] :
        cnt += 1

if cnt != 0:
    print('No')
else :
    print('Yes')

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

int main() {
 
  int A,B,a,b,d,e,count = 0;
  cin >> A >> B;
  for (int i = A; i < B + 1; i++){
    a = i/10000;
    b = (i%10000)/1000;
    d = (i%100)/10;
    e = (i%10);
    if(a == e && b == d) ++count;
  }
  cout << count << endl;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int H, W;
  cin >> H>> W;
  queue<pii> q;
  vector<vector<int>> d(H,vector<int>(W,-1));
  char s;
  rep(row,H){
    rep(col,W){
      cin >> s;
      if (s=='#'){
        q.push(make_pair(row,col));
        d.at(row).at(col) = 0;
      }
    }
  }

  int dx[4] = {1,-1,0,0};
  int dy[4] = {0,0,1,-1};
  
  while (!q.empty()){
    pii g = q.front(); q.pop();
    for (int i=0;i<4;i++){
      int nx = g.first+dx[i];
      int ny = g.second+dy[i];
      if (nx<0 || nx>=H || ny<0 || ny>=W) continue;

      if (d[nx][ny]==-1){
        d[nx][ny] = d[g.first][g.second]+1;
        q.push(make_pair(nx,ny));
      }

    }
    
  }

  int retval = 0;
  rep(row,H){
    rep(col,W){
      retval = max(retval,d.at(row).at(col));
    }
  }

  cout << retval << endl;
  
  return 0;
}


Measured memory_bytes: 12432
s = input()

n = 3
for i in range(2**n):
    ans = s[0]
    sum = int(s[0])
    for j in range(3):
        if 1 & (i >> j):
            ans += f'+{s[j+1]}'
            sum += int(s[j+1])
        else:
            ans += f'-{s[j+1]}'
            sum -= int(s[j+1])
    if sum == 7:
        print(f'{ans}=7')
        exit()


Measured memory_bytes: 8996
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;

ll N;
ll d[50];

int main()
{
	cin >> N;
	ll ans = 0;
	rep(i, N)
	{
		cin >> d[i];
	}
	for (ll i = 0; i < N; i++)
	{
		for (ll j = i + 1; j < N; j++)
		{
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = input()
temp = X.count("1")
t = [0, 0, 0]

t[0] = int(X, 2) % (temp-1) if temp != 1 else 0
t[2] = int(X, 2) % (temp+1)
cnt = 0
for i in range(N):
    if X[i] == "1" and temp == 1:
        print(0)
        continue
    if X[i] == "1":
        # p = (1 << (N-i-1)) % (temp-1)
        p = pow(2, N-1-i, temp-1)
        a = (t[0]-p) % (temp-1)
    elif X[i] == "0":
        # m = (1 << (N-i-1)) % (temp+1)
        m = pow(2, N-1-i, temp+1)
        a = (t[2]+m) % (temp+1)
    cnt = 1
    while a > 0:
        a = a % format(a, 'b').count("1")
        cnt += 1
    print(cnt)


Measured memory_bytes: 9484
N = int(input())
A = [0 for _ in range(N)]
for i in range(N):
    A[i] = int(input())

max_A_1 = sorted(A)[-1]
max_A_2 = sorted(A)[-2]

for i in range(N):
    if A[i] != max_A_1:
        print(max_A_1)
    else:
        print(max_A_2)


Measured memory_bytes: 14668
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc071/tasks/abc071_b

int main() {
    string S; cin >> S;
    int arr[26] = {};

    REP(i, S.length()) {
        arr[S[i] - 'a']++;
    }

    REP(i, 26) {
        if (arr[i] == 0) {
            cout << char(i + 'a') << "\n";
            return 0;
        }
    }

    cout << "None" << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)
#define dec(i, l, r) for (int i = l; i >= r; i--)
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back

const int maxn = 1e3 + 5;
const int maxnum = 2e5;
const int mod = 1e9 + 7;

int add(int a, int b) { return (a + b) % mod; }
int sub(int a, int b) { return (a - b + mod) % mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

struct worm {
    int x1, y1, x2, y2;
    bool operator<(const worm &o) const {
        if (x1 != o.x1) return x1 < o.x1;
        return y1 < o.y1;
    }
} w[maxn];

int dp[maxn], n, m, k;

inline ll ksm(ll _a, ll _n) {
    ll _r = 1;
    while (_n) {
        if (_n & 1) _r = _r * _a % mod;
        _a = _a * _a % mod;
        _n >>= 1;
    }
    return _r;
}

int fac[maxnum + 5];
int C(int _n, int _m) {
    return mul(mul(fac[_n], ksm(fac[_n - _m], mod - 2)), ksm(fac[_m], mod - 2));
}

int cal(int x1, int y1, int x2, int y2) {
    if (x1 > x2 || y1 > y2) return 0;
    return C(x2 - x1 + y2 - y1, x2 - x1);
}

int main() {
    fac[0] = 1;
    inc(i, 1, maxnum) fac[i] = mul(fac[i - 1], i);
    while (scanf("%d %d %d", &n, &m, &k) != EOF && n) {
        inc(i, 0, k - 1)
            scanf("%d %d %d %d", &w[i].x1, &w[i].y1, &w[i].x2, &w[i].y2);

        sort(w, w + k);
        w[k] = {n, m, n, m};
        for (int i = 0; i <= k; i++) {
            dp[i] = cal(1, 1, w[i].x1, w[i].y1);
            for (int j = 0; j < i; j++) {
                dp[i] = sub(
                    dp[i], mul(dp[j], cal(w[j].x1, w[j].y1, w[i].x1, w[i].y1)));
                dp[i] = add(
                    dp[i], mul(dp[j], cal(w[j].x2, w[j].y2, w[i].x1, w[i].y1)));
            }
        }
        printf("%d\n", dp[k]);
    }
}


Measured memory_bytes: 4036
fun main(args: Array<String>) {
    val args = readLine()!!.split(" ").map { it.toInt()}
    val r = args[0]
    val g = args[1]
    val b = args[2]

    val n = 100 * r + 10 * g + b

    val result = if (n % 4 == 0) "YES" else "NO"
    print(result)
}


Measured memory_bytes: 37876
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list( map(int, input().split()) )

uf = UnionFind(N)
A = [0]*M
B = [0]*M
for i in range(M):
    a,b = list( map(int, input().split()) )
    A[i]=a-1
    B[i]=b-1

#print(A)
#print(B)

cmax = int(N*(N-1)/2)
FD = [cmax]*(M+1)
#print(FD)
for i in range(M):
    #print(uf)
    if uf.same(A[M-i-1],B[M-i-1]):
        FD[M-i-1] = FD[M-i]
    else:
        cless = uf.size(A[M-i-1])*uf.size(B[M-i-1])
        FD[M-i-1] = FD[M-i] - cless
        if FD[M-i-1]<0: FD[M-i-1]=0
    uf.union(A[M-1-i],B[M-1-i])

#print(uf)
#print(FD[1:])
for fd in FD[1:]:
    print(fd)




Measured memory_bytes: 85268
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>

typedef long long int64;

int main(void) {
  int n;
  std::cin >> n;
  std::vector<int> as;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    as.push_back(a);
  }

  std::vector<int> evens;
  for (auto a : as) {
    if (a % 2 == 0) {
      evens.push_back(a);
    }
  }

  bool ans = true;
  for (auto even : evens) {
    if (even % 3 != 0 && even % 5 != 0) {
      ans = false;
    }
  }

  std::cout << (ans ? "APPROVED" : "DENIED") << std::endl;
  return 0;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 998244353;

console.log(main());
function main(){
  var n = o.a();
  var x = o.a(1).split("").map(a=>+a);
  var ans = 0;
  for(var i = 0; i < n; i++){
    ans = ans*2 + x[i];
    ans %= mod;
  }
  ans++;
  ans *= n*2;
  var a = odd(n);
  var al = a.length;
  var map = new Map();
  for(var j = 0; j < al; j++){
    var b = 0, m = n/a[j];
    for(var i = 0; i < m; i++){
      b = b*2 + x[i];
      b %= mod;
    }
    var xor = 0;
    for(;i < n; i++){
      if(i%m === 0)xor ^= 1;
      if((x[i%m]^xor) === x[i])continue;
      if(x[i] === 1)b++;
      break;
    }
    if(i === n)b++;
    for(k of map){
      if(m % k[0])continue;
      b -= k[1];
    }
    map.set(m,b);
    ans -= (n-m)*2*b;
  }
  ans %= mod;
  return ans<0?ans+mod:ans;
}

function odd(n){
  var r = [];
  while(n%2 === 0)n >>= 1;
  for(var i = 3; i*i < n; i++){
    if(n%i)continue;
    r.push(i,n/i);
  }
  if(i*i === n)r.push(i);
  if(n > 1)r.push(n);
  return r.sort((a,b)=>b-a);
}

Measured memory_bytes: 27592
#include <stdio.h>
#include <stdlib.h>
 
struct Node{
  int key;
  struct Node *parent;
  struct Node *left;
  struct Node *right;
};
 
#define NIL NULL
typedef struct Node* NodePointer;
NodePointer root;
 
void inOrder(NodePointer);
void preOrder(NodePointer);
void print(void);
void insert(int);
NodePointer makeNode(int);
void init(void);
 
int main(){
  int Q,i,x;
  char order[7];
  scanf("%d",&Q);
  for(i = 0 ; i < Q ; i++){
    scanf("%s",order);
    if(order[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }else{
      print();
    }
  }
  return 0;
}
 
void inOrder(NodePointer x){
  if(x == NIL){ return; }
  inOrder(x->left);
  printf(" %d",x->key);
  inOrder(x->right);
}
 
void preOrder(NodePointer x){
  if(x == NIL){ return; }
  printf(" %d",x->key);
  preOrder(x->left);
  preOrder(x->right);
}
 
void print(){
  inOrder(root); printf("\n");
  preOrder(root); printf("\n");
}
 
void insert(int key){
  NodePointer x = root,y = NIL;
  NodePointer z = makeNode(key);
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}
 
NodePointer makeNode(int key){
  NodePointer newNode = malloc(sizeof(struct Node));
  newNode->key = key;
  newNode->left = newNode->right = NIL;
  return newNode;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,A,B,ans;
  cin >> N>>A>>B;
  if(A*N>B){
    cout << B<<endl;
  }else{
    cout << N*A<< endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter
input = sys.stdin.readline


def compress_coordinate(x: list, key=None, reverse=False):
    zipped = {}
    unzipped = {}
    for i, xi in enumerate(sorted(set(x), key=None, reverse=reverse)):
        zipped[xi] = i + 1
        unzipped[i + 1] = xi
    return zipped, unzipped


class BIT1():
    """
    Binary Indexed Tree (1-indexed)
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)

    def add(self, idx, x):
        # add x to idx-th element
        # idx: 1-indexed
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        # get sum of [1, idx]
        # idx: 1-indexed
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s

    def bisect_left(self, w):
        # condition : always all element is not minus
        # return minimum idx where bit.sum(idx) >= w
        if w <= 0:
            return 0
        idx = 0  # self.bit[idx] < w
        k = 1 << ((self.n).bit_length() - 1)
        while k > 0:
            if idx + k <= self.n and self.bit[idx + k] < w:
                w -= self.bit[idx + k]
                idx += k
            k = k >> 1
        return idx + 1


MOD = 998244353
n = int(input())
x_list = []
y_list = []
for i in range(n):
    x, y = map(int, input().split())
    x_list.append(x)
    y_list.append(y)
x_zipped, x_unzipped = compress_coordinate(x_list)
y_zipped, y_unzipped = compress_coordinate(y_list)

p = []
for i, (x, y) in enumerate(zip(x_list, y_list)):
    p.append((x_zipped[x], y_zipped[y], i))

info = [[0] * 5 for _ in range(n)]
p.sort(key=itemgetter(0))
# print(*p)
bit1 = BIT1(n)
for m, (px, py, idx) in enumerate(p):
    bit1.add(py, 1)
    s_left = bit1.sum(py) - 1
    s_right = (m + 1) - s_left - 1
    info[idx][2] = s_right
    info[idx][3] = s_left

p.sort(key=itemgetter(0), reverse=True)
# print(*p)

bit2 = BIT1(n)
for m, (px, py, idx) in enumerate(p):
    bit2.add(py, 1)
    s_left = bit2.sum(py) - 1
    s_right = (m + 1) - s_left - 1
    info[idx][1] = s_right
    info[idx][4] = s_left

ans = 0
for _, c1, c2, c3, c4 in info:
    c1 = pow(2, c1, MOD) - 1
    c2 = pow(2, c2, MOD) - 1
    c3 = pow(2, c3, MOD) - 1
    c4 = pow(2, c4, MOD) - 1
    ans += 1
    ans += c1 + c2 + c3 + c4
    ans += c1 * c3 * 2 + c2 * c4 * 2
    ans += c1 * c2 + c2 * c3 + c3 * c4 + c4 * c1
    ans += (c2 * c3 * c4 + c1 * c3 * c4 + c1 * c2 * c4 + c1 * c2 * c3) * 2
    ans += c1 * c2 * c3 * c4 * 2
    ans %= MOD

# print(*info, sep='\n')
print(ans)


Measured memory_bytes: 151388
#include <stdio.h>
int main(void) {
    int hin,min,sin,hout,mout,sout,i,time;
    for (i=0; i<3; i++) {
        scanf("%d%d%d%d%d%d",&hin,&min,&sin,&hout,&mout,&sout);
        time = (hout-hin)*3600+(mout-min)*60+(sout-sin);
        printf("%d %d %d\n",time/3600,(time%3600)/60,(time%3600)%60);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

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

	if (a < b) {
		if (b < c) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 3084
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int sx = Integer.parseInt(S[0]);
    int sy = Integer.parseInt(S[1]);
    int tx = Integer.parseInt(S[2]);
    int ty = Integer.parseInt(S[3]);
    
    String ans1 = "";
    String ans2 = "";
    String ans3 = "D";
    String ans4 = "U";
    
    for(int i = 0; i < tx - sx; i++){
      ans1 = ans1 + "R";
      ans2 = ans2 + "L";
      ans3 = ans3 + "R";
      ans4 = ans4 + "L";
      if(i+1 == tx-sx){
        ans3 = ans3 + "R";
        ans4 = ans4 + "L";
      }
    }
    
    for(int i = 0; i < ty - sy; i++){
      ans1 = ans1 + "U";
      ans2 = ans2 + "D";
      ans3 = ans3 + "U";
      ans4 = ans4 + "D";
      if(i+1 == ty-sy){
        ans3 = ans3 + "UL";
        ans4 = ans4 + "DR";
      }
    }
    System.out.println(ans1 + ans2 + ans3 + ans4);
  }
}

Measured memory_bytes: 89684
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;
vector<ll> a,b,c;

int search_upper(int i, int j, ll v){
    int k = (i+j)/2;
    if(c[k] <= v){
        if(k == j) return j+1; 
        return search_upper(k+1,j,v);
    } else {
        if(k == 0) return 0;
        return search_upper(i,k-1,v);
    }
}


int search_lower(int i, int j, ll v){
    int k = (i+j)/2;
    if(a[k] >= v){
        if(k == 0) return -1;
        return search_lower(i,k-1,v);
    } else {
        if(k == j) return j; 
        return search_lower(k+1,j,v);
    }
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        ll t;
        cin >> t;
        a.push_back(t);
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        ll t;
        cin >> t;
        b.push_back(t);
    }
    sort(b.begin(), b.end());
    for(int i = 0; i < n; i++){
        ll t;
        cin >> t;
        c.push_back(t);
    }
    sort(c.begin(), c.end());

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll nc = n-search_upper(0,n-1,b[i]);
        ll na = search_lower(0,n-1,b[i])+1;

        ans += na*nc;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

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


int dp[100100];
void solve()
{
	int num;
	cin>>num;
	vector<int>cand;
	cand.push_back(1);
	int t=1;
	int ma=100000;
	while(t<=ma){
		t*=6;
		if(t<=ma)
		cand.push_back(t);
	}
	t=1;
	while(t<=ma){
		t*=9;
		if(t<=ma)
		cand.push_back(t);
	}
	rep(i,num+1){
		dp[i]=1e9;
	}
	dp[0]=0;
	rep(i,num+1){
		rep(j,cand.size()){
			if(i+cand[j]<=num)
			dp[i+cand[j]]=min(dp[i+cand[j]],dp[i]+1);
		}
	}
	cout<<dp[num]<<endl;
	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 640
import numpy as np
import itertools

N, M = [int(n) for n in input().split()]

config = np.zeros((M, N)).astype(int)

for i in range(M):
    switches = [int(n) for n in input().split()]
    for switch in switches[1:]:
        config[i][switch - 1] = 1

P = np.asarray([int(n) for n in input().split()], dtype=int).reshape((M, 1))

bits = itertools.product((0,1), repeat=N)

count = 0

for bit in bits:
    bit_vect = np.asarray(bit, dtype=int).reshape((N, 1))
    if np.array_equal(np.dot(config, bit_vect) % 2, P):
        count += 1

print(count)

Measured memory_bytes: 27296
using System;
using System.Collections.Generic;
public class ABC127C {
    public static void Main() {
        int N, M, L, R, maxL, minR;
        string[] str = System.Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        M = int.Parse(str[1]);
        maxL = 1;
        minR = N;
        for(int i = 0; i < M; i++) {
            str = System.Console.ReadLine().Split(' ');
            L = int.Parse(str[0]);
            R = int.Parse(str[1]);
            if (L > maxL) maxL = L;
            if (R < minR) minR = R;
        }
        if (maxL > minR) System.Console.WriteLine(0);
        else System.Console.WriteLine(minR - maxL + 1);
    }
}


Measured memory_bytes: 15292
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
   ll x,k,d;
   cin>>x>>k>>d;
   ll q=x/d;
   if(abs(q)<=k)
   {
      q=abs(q);
    if(x<0)
    {
      //q=abs(q);
      x+=(q*d);
    }
    else
    {
      //q=abs(q);
      x-=(q*d);
    }
    k-=q;
    //cerr<<"where"<<endl;
    if(k>0&&k%2==1)
    {
      if(x<0)
      {
        x+=d;
      }
      else
      {
        x-=d;
      }

      }
      cout<<abs(x)<<endl;

   }
   else
   {
    if(x>0)
    {
      x-=(k*d);
    }
    else
    {
      x+=(k*d);
    }
    cout<<abs(x)<<endl;
   }
}
return 0;
}

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

int main(){
    string N;
    int n = 0;
    cin >> N;
    for(int i = 0; i < N.size(); ++i){
        n += (N[i]-'0');
    }
    if(n % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

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

    ll l, r, d;
    cin >> l >> r >> d;

    cout << r/d - (l-1)/d << endl;


    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 1000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

long N;
long X;
long ans = 0;

void solve(long n, long x, int f) {
	long d = n / x;
	long m = n % x;
	if(m > 0) {
		ans += (d-f) * 2 * x;
		solve(x, m, 0);
	} else {
		ans += d * 2 * x - x;
		return;
	}
}

int main() {
	long i, j;
	
	scanf("%ld %ld", &N, &X);
	
	if(N % 2 == 0 && N/2 == X) {
		ans = N/2 * 3;
	} else if(N % X == 0) {
		ans = (N/X - 1) * 2 * X + N - X;
	} else {
		solve(N, X, 1);
		ans += N;
	}
	
	printf("%ld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
def ATGC(i):
    if i == 'A' or i == 'T' or i == 'G' or i == 'C':
        return True

s = input()
a = 0
streak = 0
for i in s:
    if ATGC(i):
        streak += 1
    else :
        if a < streak :
            a = streak
            streak = 0
if streak > a:
    a = streak 
print(a)


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

public class S
{

    private const long DP_INIT_MINUS1 = -1;
    private const double DP_INIT_DOUBLE_MINUS1 = -1.0;
	private const long MOD = 1000000007;


    //s
    private const int FIRST_WIN = 1;
    private const int SECOND_WIN = 0;

    private static long[,] dp;
    private static long[] cSum;


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];

        solver(N,Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse));
    }

    public static void solver(long N, long[] input){

        /*
            ABC 139 C "Lower"
            含まれる広義単調減少（だっけ？）の最大長っぽい（それっぽい言い方）
			
        
         */

        int cnt = 0;
        int max = 0;
        long parent = input[0];

        for(int i = 1; i < N; i++){
            if(parent >= input[i]){
                cnt++;
            }else{
                cnt = 0;
            }
			max = Math.Max(max, cnt);
			parent = input[i];
        }
        Console.WriteLine(max);
    }

}

Measured memory_bytes: 25436
# input
N = int(input())
A = list(map(int, input().split()))

# check
app_fl = True
for Ai in [a for a in A if a % 2 == 0]:
    if Ai % 3 != 0 and Ai % 5 != 0:
        app_fl = False
        break

if app_fl is True:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 2940
from itertools import *
h,w,k=map(int,input().split())
c=[]
s=[]
H=[i for i in range(h)]
W=[i for i in range(w)]
ans=0
for i in range(h):
    c.append(list(input()))
for i in range(2**h):
    for j in range(2**w):
        tmp=0
        for ii in range(h):
            for jj in range(w):
                if ((i>>ii)&1) and ((j>>jj)&1):
                    if c[ii][jj]=="#":
                        tmp+=1
        if tmp==k:
            ans+=1
                        
print(ans)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

ll fact(ll n){
    if(n ==1) return 1;
    return n * fact(n-1);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    // グラフ
    Graph G(N);

    REP(i, M){
        ll a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    vector<ll> nums(N);
    REP(i, N){
        nums[i] = i;
    }

    ll p = fact(N);

    ll ans = 0;
    REP(i, p){
        if(nums[0] != 0) continue; 
        bool flag = true;
        REP(j, N-1){
            // cout << nums[j];
            bool check = false;
            for(auto v: G[nums[j]]){
                if(v == nums[j+1]) check = true;
            }
            if(check == false){
                flag = false;
                break;
            }
        }
        if(flag == true) ans++;
        // cout << endl;
        // 順列の遷移処理
        next_permutation(nums.begin(), nums.end());
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (W - x >= r&&H - y >= r&&x >= r&&y >= r){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*; 

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

		Long a = sc.nextLong();
		Long v = sc.nextLong();
		Long b = sc.nextLong();
		Long w = sc.nextLong();
		Long t = sc.nextLong();
		
	    Long d = Math.abs(a - b);
		v = (v - w) * t;
		
		if(d<=v){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	  }
	}		  

Measured memory_bytes: 35600
n = int(input())
a = list(map(int, input().split()))

mx = 10**5
table = [0] * (mx + 1)
for i in a:
    table[i] += 1

q = int(input())
total = sum(a)
for i in range(q):
    b, c, = map(int, input().split())
    total -= table[c] * c + table[b] * b
    table[c] += table[b]
    table[b] = 0
    total += table[c] * c
    print(total)

Measured memory_bytes: 20876
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>j;
		// n=s.length();
		// ll a[n];
		k=0;c=1;
		rep(i,n)
		{
			cin>>m;
			k+=m;
			if(k<=j)
				c++;
		}
		
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<27;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int NPrime=1000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	vi c=EnumeratePrime();
	while(1){
		int n,a,b;
		cin>>n>>a>>b;
		if(n==0) break;
		int mx=0,p,q;
		for(int i=0;2*c[i]<=n;i++){
			for(int j=0;j<=i&&c[j]*c[i]<=n;j++){
				if(a*c[i]<=b*c[j]){
				if(mx<c[j]*c[i]){
					mx=c[j]*c[i];
					p=c[j],q=c[i];
				}
				}
			}
		}
		cout<<p<<' '<<q<<endl;
	}
}


Measured memory_bytes: 4308
#include <bits/stdc++.h>
using namespace std;
int N, p;
string s;
int f() {
	if (s[p]=='[') {
		p++;
		vector<int> t;
		while (s[p]!=']') t.push_back(f());
		p++;
		sort(t.rbegin(), t.rend());
		return accumulate(t.begin()+t.size()/2, t.end(), 0);
	}
	int t = 0;
	while (isdigit(s[p])) {
		t = t*10+(s[p++]-'0');
	}
	return (t+1)/2;
}
int main() {
	cin >> N;
	while (N--) {
		cin >> s;
		p = 0;
		cout << f() << endl;
	}
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;


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

	int num = n;
	string s ;

	while (num) {
		
		int is1 = !(num %2 ==0);
		s += ('0' + is1);
		num = (num - is1) / 2 * -1;
		
	}
	int len = s.length();

	for (int i = 0; i < len / 2; i++) {
		char tmp = s[i];
		s[i] = s[len - 1 - i];
		s[len - 1 - i] = tmp;
	}
	if (!len) {
		s = '0';
	}

	cout << s << endl;
}

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

int main() {
  vector<int>vec(5);
  cin >> vec[0] >> vec[1] >> vec[2] >> vec[3] >> vec[4];
  int k;
  cin >> k;
  bool x = true;
  for(int i=0; i<4; i++){
    for(int j=i+1; j<5; j++){
      if(vec[j]-vec[i] > k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
}


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

using namespace std;

const int maxn=1e5+5;

int s[maxn],n;

int binarysearch(int key)
{
    int left=0,right=n;
    int mid;
    while(left<right){
        mid=(left+right)>>1;
        if(key==s[mid]){
            return 1;
        }else if(key<s[mid]){
            right=mid;
        }else if(key>s[mid]){
            left=mid+1;
        }
    }
    return 0;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    int p,key,sum=0;
    scanf("%d",&p);
    for(int i=0;i<p;i++){
        scanf("%d",&key);
        if(binarysearch(key)){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}
/*
5
1 2 3 4 5
3
3 4 1
3
1 2 3
1
5

*/



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

using namespace std;

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

const int inf = 1e9;

int32_t main(){
	cin.tie(0); ios::sync_with_stdio(0);
	
	int n;
	cin >> n;
	int a[n+1][3];
	int dp[n+1][3];
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 3; j++)
			cin >> a[i][j];
	}
	
	memset(dp, 0, sizeof dp);
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int at = 0; at < 3; at++){
			for(int pas = 0; pas < 3; pas++){
				if(pas == at)
					continue;
				dp[i][at] = max(dp[i][at], dp[i-1][pas] + a[i][at]);
				ans = max(ans, dp[i][at]);
			}
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >>n;
    int *a= new int[n],*b = new int[n],*c = new int[n-1];
    int sum = 0;
    for (int i= 0;i < n; ++i){
        cin >> a[i];
        a[i]--;
    }
    for (int i= 0;i< n; ++i){
        cin >> b[i];
    }
    for (int i = 0; i<n-1;++i)
    {
        cin >>c[i];
    }
    sum +=b[a[0]];
    for (int i = 1;i < n;++i){
        sum +=b[a[i]];
        if ((a[i-1] + 1) == a[i]){
            sum+=c[a[i-1]];
        }
    }
    cout << sum<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size()){
        if(s[i]<='Z'-n){
            s[i] += n;
        }else{
            s[i] -= 26 - n;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = Integer.MAX_VALUE;
		for (char c = 'a'; c <= 'z'; c = (char)(c + 1)) {
			int max = 0;
			int current = 0;
			String t = String.valueOf(c);
			int idx = s.indexOf(t);
			while (idx != -1) {
				if (max < idx - current) {
					max = idx - current;
				}
				current = idx + 1;
				idx = s.indexOf(t, current);
			}
			if (max < s.length() - current + 1) {
				max = s.length() - current;
			}
			if (min > max) {
				min = max;
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef long long ll;
int n,ans,x[501],y[501],pw[501];
int main(){
    scanf("%d",&n);
    pw[0]=1;
    for(int i=1;i<=n;i++)pw[i]=(ll)pw[i-1]*2%mod;
    for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
    ans=(pw[n]-n-1-n*(n-1)/2+mod)%mod;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int tmp=0;
            for(int k=j+1;k<=n;k++){
                if((y[j]-y[i])*(x[k]-x[j])==(y[k]-y[j])*(x[j]-x[i]))tmp++;
            }
            ans=(ans+mod+1-pw[tmp])%mod;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int INF = 1e9;
int main() {
    int N; cin >> N;
    vector<string> A(N);
    for (auto &a : A) cin >> a;
    vector<int> B(N);
    int t = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            B[j] |= A[i][j] == '#';
            t |= B[j];
        }
    }
    if (t == 0) {
        cout << -1 << '\n';
        return 0;
    }
    int col = 0;
    int ans = INF;
    for (int j = 0; j < N; j++) {
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            cnt += A[i][j] == '#';
        }
        if (cnt == N) col++;
    }
    for (int i = 0; i < N; i++) {
        int k = 0;
        for (int j = 0; j < N; j++) if (A[i][j] != '#') k++;
        k += !B[i];
        k += N - col;
        ans = min(ans, k);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 512