akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

## DFS

from collections import deque
N, M = mi()
memo = []
rel = [[] for i in range(N)]

for i in range(M):
    s, t = mi()
    s, t = s-1, t-1
    memo.append((s, t))
    rel[s].append(t)
    rel[t].append(s)

cnt = 0
que = deque()
for x in range(M):
    s, t = memo[x][0], memo[x][1]
    rel[s].remove(t)
    rel[t].remove(s)

    que.append(0)
    used = [0]*N
    while que != deque():
        v = que.popleft()
        for nv in rel[v]:
            if not used[nv]:
                used[nv] = 1
                que.append(nv)
    if sum(used) != N:
        cnt += 1

    rel[s].append(t)
    rel[t].append(s)

print(cnt)

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int    in_A;
    int    in_B;
    String in_S;

    String  regex;
    Pattern pattern;
    Matcher matcher;

    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_A = Integer.parseInt(in_str_split[0]);
      in_B = Integer.parseInt(in_str_split[1]);


      in_str = new String(in_stream.readLine());
      in_S   = in_str;


      regex = "[0-9]{" + in_A + "}-[0-9]{" + in_B + "}";
      pattern = Pattern.compile(regex);
      matcher = pattern.matcher(in_S);

      if(matcher.find())
      {
        UtilLog.ans_ln("Yes");
      }
      else
      {
        UtilLog.ans_ln("No");
      }
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    string s,t;
    cin>>s>>t;
    int n=s.size(), m=t.size();
    int a[n+1]={},b[m+1]={};
    for(int i=0;i<n;i++){
        a[i+1] = a[i];
        if(s[i]=='A') a[i+1]++;
        else a[i+1]--;
    }
    for(int i=0;i<m;i++){
        b[i+1] = b[i];
        if(t[i]=='A') b[i+1]++;
        else b[i+1]--;
    }
    int q;
    cin>>q;
    while(q--){
        int i,j,k,l;
        cin>>i>>j>>k>>l;
        i--,k--;
        if((a[j] - a[i] - b[l] + b[k])%3==0){
            cout << "YES\n";
        }
        else cout << "NO\n";
    }
}

Measured memory_bytes: 1744
#include<stdio.h>
int a[100][100];
typedef struct{
  int id;
  int d;
  int f;
}Visit;
void AdjMatrix(int, int);
void DFS(int, int);
int a[100][100];
Visit visit[100];
int v=0;
int main(){
  int n, u, k, A, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      a[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    visit[i].id = u;
    visit[i].d = 0;
    visit[i].f = 0;
    for(j  = 0; j < k; j++){
      scanf("%d", &A);
      AdjMatrix(u, A);
    }
  }

  for(i = 0; i < n; i++){
    DFS(i, n);
  }
  
  for(i = 0; i < n; i++){
    printf("%d %d %d\n", visit[i].id, visit[i].d, visit[i].f);
    }
  return 0;
}

void AdjMatrix(int x, int y){
  a[x-1][y-1] = 1;
}

void DFS(int i, int n){
  int j=0;
  if(visit[i].d == 0) {
    v++;
    visit[i].d = v;
  } else return;
  for(j = 0; j < n; j++){
    if(a[i][j] == 1 && visit[j].d == 0) {
      DFS(j, n);
    }
  }
  v++;
  visit[i].f = v;
}

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

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    int tmp = s;
    if (s == 1e9) tmp = 0;
    vector<int> ans(n, tmp + 1);
    for (int i = 0; i < k; i++) ans[i] = s;
    for (int i = 0; i < n; i++) {
        cout << ans[i] << " \n"[i == n - 1];
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	static double EPS = 0.0000000001;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Segment seg  =new Segment(new Point(sc.nextInt(),sc.nextInt()),new Point(sc.nextInt(),sc.nextInt()));

		int q=sc.nextInt();
		for (int i=0;i<q;i++) {
			Point p = reflect(seg,new Point(sc.nextInt(),sc.nextInt()));
			System.out.println(p.x+" "+p.y);
		}
	}
	static Point project(Segment s, Point p) {
		Vector base = s.p2.diff(s.p1);
		double r = p.diff(s.p1).dotProduct(base) / base.norm();
		return s.p1.sum(base.mult(r));
	}
	static Point reflect(Segment s, Point p) {
		return p.sum(project(s,p).diff(p).mult(2.0));
	}
}
class Point {
	static double EPS = 0.0000000001;
	double x; double y;
	public Point(double ax, double ay){x=ax;y=ay;}
	public Vector sum(Point p) { return new Vector(x+p.x,y+p.y); }
	public Vector diff(Point p) { return new Vector(x-p.x,y-p.y); }
	public Vector mult(double k) { return new Vector(x*k,y*k); }
	public Vector div(double k) { return new Vector(x*(1.0/k),y*(1.0/k)); }
	public boolean equals(Point p){return Math.abs(x-p.x)<EPS && Math.abs(y-p.y)<EPS;}
}
class Vector extends Point {
	public Vector(double ax, double ay) {super(ax,ay);}
	public Vector(Point p1, Point p2) {super(p1.x-p2.x,p2.x-p2.y);}
	public double norm() {return x*x+y*y;}
	public double abs() {return Math.sqrt(norm());}
	// TODO:
	public boolean isSmallerThan(Vector v) {return x!=v.x?x<v.x:y<v.y;}
	public double dotProduct(Vector v) {return x*v.x+y*v.y;}
	public double crossProduct(Vector v) {return x*v.y - y*v.x;}
}

class Segment {
	Point p1; Point p2;
	public Segment(Point ap1, Point ap2){p1=ap1;p2=ap2;}
	public double dotProduct(Segment s) {return (p1.x-p2.x)*(s.p1.x-s.p2.x)+(p1.y-p2.y)*(s.p1.y-s.p2.y);}
	public double crossProduct(Segment s) {return (p1.x-p2.x)*(s.p1.y-s.p2.y) - (p1.y-p2.y)*(s.p1.x-s.p2.x);}
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string s;
    stack<ll> st;
    ll sum;

    while(cin >> s){
        if(s=="+" || s=="*" || s=="-"){
            ll a=st.top(); st.pop();
            ll b=st.top(); st.pop();
            if(s=="+")b+=a;
            if(s=="-")b-=a;
            if(s=="*")b*=a;
            st.push(b);
        }else{
            int n=stoi(s);
            st.push(n);
        }
//        cout << st.top() << endl;
    }
    cout << st.top() << endl;
}



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

int main(){
	int dp[10010];
	int W,N;
	int v[1010],w[1010];
	int c=0;
	while(scanf("%d",&W),W!=0){
		c++;
		scanf("%d",&N);;
		for(int i=0;i<N;i++){
			scanf(" %d,%d",&v[i],&w[i]);
		}
		for(int i=0;i<W+5;i++){
			dp[i]=0;
		}
		for(int i=0;i<N;i++){
			for(int j=W;j;j--){
				if(j<w[i]){
					dp[j]=dp[j];
				}else{
					dp[j]=std::max(dp[j],dp[j-w[i]]+v[i]);
				}
			}
		}
		int ans_w=W;
		for(int i=W-1;i;i--){
			if(dp[i]==dp[i+1]){
				ans_w=i;
			}else{
				break;
			}
		}
		cout<<"Case "<<c<<":"<<endl<<dp[W]<<endl<<ans_w<<endl;
		
	}
	
	
}

Measured memory_bytes: 1224
w,h,n = map(int,input().split())
x1 = 0
x2 = w
y1 = 0
y2 = h
for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    x1 = max(x1,x)
  elif a == 2:
    x2 = min(x2,x)
  elif a == 3:
    y1 = max(y1,y)
  else:
    y2 = min(y2,y)
if x1 >= x2 or y1 >= y2:
  print(0)
else:
  print(w*h-h*(x1+w-x2)-(x2-x1)*(y1+h-y2))

Measured memory_bytes: 9152
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

check s = all (uncurry (==)) $ zip s [1..] -- check' 1 s
  where
    check' _ [] = True
    check' i (x:xs)
      | x==i = check' (i+1) xs
      | otherwise = False

op s = osub 0 s
  where
    osub n [] = [n]
    osub n (1:xs) = osub (n+1) xs
    osub n (x:xs) = (x-1) : osub (n+1) xs

f s = let g i xs = if check xs then i else if i==10000 then (-1) else g (i+1) (op xs) in g 0 s


main = do
    n <- getInt
    unless (n==0) $ getInts >>= print . f >> main


Measured memory_bytes: 76808
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int v,id;
	node(int x1=0,int x2=0){v=x1,id=x2;}
};
deque<node>q1,q2;
int a[500001];
int l[500001];
signed main()
{
	int n,k;
    scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		l[i+1]=(a[i+1]>a[i])?1:0;
	a[0]=999999999;
	int flag=0,ans=0,sum=0;
	for(int i=1;i<=n;i++)
	{
		while(!q1.empty()&&q1.back().v<=a[i])
			q1.pop_back();
		while(!q2.empty()&&q2.back().v>=a[i])
			q2.pop_back();
		while(!q1.empty()&&i-q1.front().id>=k)
			q1.pop_front();
		while(!q2.empty()&&i-q2.front().id>=k)
			q2.pop_front();
		q1.push_back(node(a[i],i));
		q2.push_back(node(a[i],i));
		sum+=l[i];
		if(i>=k)
			sum-=l[i-k+1];
		if(i<k||(a[i+1]>q1.front().v&&a[i-k+1]==q2.front().v))
			continue;
		if(sum==k-1)
		{
			if(flag)
				continue;
			flag=1;
		}
		ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3456
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
const ll modP = 1000000007;


int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	vector<ll> A(n);
	vector<ll> B(m);
	rep(i,n) cin>>A[i];
	rep(i,m) cin>>B[i];
	vector<ll> cumSumA(n+1);
	cumSumA[0] = 0;
	for(int i = 0; i < n; i++){
		cumSumA[i+1] = cumSumA[i] + A[i];
	}
	vector<ll> cumSumB(m+1);
	cumSumB[0] = 0;
	for(int i = 0; i < m; i++){
		cumSumB[i+1] = cumSumB[i] + B[i];
	}
	ll ans = 0;
	for(ll i = 0; i <= n; i++){
		if( cumSumA[i] > k) break;
		ll key = k - cumSumA[i];
		auto iter = lower_bound(cumSumB.begin(),cumSumB.end(), key);
		int j = iter - cumSumB.begin();
		if( j > m) j = m;
		if( cumSumB[j] > key){
			j--;
		}
		ans = max(ans,i+j);
		//cout<<cumSumA[i] + cumSumB[j]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i;i<N;i++) cin >> V.at(i);
  sort(V.begin(),V.end());
  int max,min;
  max = V.at(N-1);
  min = V.at(0);
  int cost;
  int prop = 0;
  for(int i=min;i<max;i++){
    cost = 0;
    for(int j=0;j<N;j++) cost += (V.at(j)-i)*(V.at(j)-i);
    if(i==min||cost<prop) prop = cost;
  }
  cout << prop << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    //UG02-50-19-017
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a+b+c>=22)
    {
        printf("bust\n");
    }
    else
    {
        printf("win\n");
    }
    return 0;
}


Measured memory_bytes: 128
# 写経
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string  s;
    cin >> s;
    F0R(i,s.length()){
      if(s[i] == '1')
        s[i] = '9';
      else if(s[i] == '9') s[i] = '1';
    }
    cout << s << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double ar[n + 1], dp[n + 1][n + 1];
    for (int i = 1; i <= n; i++) cin >> ar[i];
    memset(dp, 0.0, sizeof dp);
    dp[0][0] = 1.0;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= i; j++){
            if (j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - ar[i]);
            else dp[i][j] = dp[i - 1][j - 1] * ar[i] + dp[i - 1][j] * (1.0 - ar[i]);
        }
    }
    double ans = 0.0;
    for (int i = n/2 + 1; i <= n; i++) ans += dp[n][i];
    printf("%0.10f\n", ans);
}

Measured memory_bytes: 74084
N, M = [int(x) for x in input().split()]

def check(n, LR):
    return 1 if all(l <= n <=r for l, r in LR) else 0

L = 0
R = N
for _ in range(M):
    l, r = [int(x) for x in input().split()]
    if L < l:
        L = l
    if r < R:
        R = r

if L <= R:
    print(R - L + 1)
else:
    print(0)

Measured memory_bytes: 3064
#include <stdio.h>
#pragma warning(disable : 4996)
int N, A, B, C, X, Y[100], P;
int main() {
	while (true) {
		scanf("%d%d%d%d%d", &N, &A, &B, &C, &X);
		if (N == 0 && A == 0 && B == 0 && C == 0 && X == 0) break;
		for (int i = 0; i < N; i++) scanf("%d", &Y[i]); P = 0;
		bool flag = false;
		for (int i = 0; i <= 10000; i++) {
			if (X == Y[P]) P++;
			if (N == P) {
				printf("%d\n", i); flag = true; break;
			}
			X = (A * X + B) % C;
		}
		if (!flag) {
			printf("-1\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2704
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	// your code goes here
	ll int n,W;
	cin>>n>>W;
	vector<ll int> v(n+1),w(n+1);
	ll int dp[n+1][W+1];
	
	ll int i,j;
	for(i=0;i<=n;i++)
	for(j=0;j<=W;j++)
	dp[i][j]=0;
	for(i=1;i<=n;i++)
	cin>>w[i]>>v[i];
	for(j=1;j<=W;j++)
	{
	    for(i=1;i<=n;i++)
	    {
	        if(j>=w[i])
	        dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
	        else dp[i][j]=dp[i-1][j];
	    }
	}
	ll int maxi=dp[0][W];
	for(i=1;i<=n;i++)
	maxi=max(maxi,dp[i][W]);
	cout<<maxi<<"\n";
	return 0;
}


Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] s = new String[h];
        for (int i = 0 ; i < h ; i++) {
            s[i] = sc.next();
        }
        for (int i = 0 ; i < h ; i++) {
            System.out.println(s[i]);
            System.out.println(s[i]);
        }
    }

}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }
    
int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int a,p;
    while (cin >> a >> p) {
        const int x = a*3 + p;
        cout << x/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool func(int X){
  for(int i=2;i*i<=X;i++){
    if(X%i==0){
      return false;
    }
  }
  return true;
}
  
int main(){
  int X;
  cin >> X;
  while(true){
    if(func(X)){
      cout << X << endl;
      break;
    }
    X++;
  }
}
  

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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;

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

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MAXN = 1e5 + 5;

// states are [day][activity]
int dp[MAXN][4];
int arr[MAXN][4];

void solve() {
    int n; cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
        dp[i][1] = arr[i][1];
        dp[i][2] = arr[i][2];
        dp[i][3] = arr[i][3];
    }
    
    for(int i=1; i<=n; i++) {
        dp[i][1] += max(dp[i-1][2], dp[i-1][3]);
        dp[i][2] += max(dp[i-1][1], dp[i-1][3]);
        dp[i][3] += max(dp[i-1][1], dp[i-1][2]);
    }

    cout << max(dp[n][1], max(dp[n][2], dp[n][3])) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    int sum=0;
    for(int i=0; i<M; i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    if(sum>N) cout << -1 << endl;
    else cout << N-sum << endl;
    return 0;
}

Measured memory_bytes: 3640
stdin.ReadLine().Split(" ")
|> Array.map int
|> fun [| _; k |] ->
    stdin.ReadLine().ToCharArray()
    |> Array.indexed
    |> Array.map (fun (i, c) -> if i = (k - 1) then System.Char.ToLower c else c)
    |> System.String
    |> printfn "%s"


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

int main()
{
    string s;
    cin>>s;
    int l = s.length();
    for(int i = 0 ;i<l;i++) 
    {
        if(i%2==0)
        {
            if(s[i]=='L')
            {
                cout<<"No"<<endl;
                return 0;
            }
            
        }
        else
        {
            if(s[i]=='R')
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

fn main() {
    let (s, w) = read!(usize, usize);
    if w >= s {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


Measured memory_bytes: 2164
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace Test
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // new Program().abc127_b(new ConsoleInput(Console.In, ' '));
            new Program().abc69_a();
        }

        // public void abc127_b(ConsoleInput cin)
        // {
        //     var r = cin.ReadInt;
        //     var D = cin.ReadInt;
        //     var x = cin.ReadInt;

        //     var xi = new List<int> {x};

        //     for(int i = 1; i < 11; i++){
        //         xi.Add(r * xi[i-1] - D);
        //         WriteLine(xi[i]);
        //     }
        // }

        public void abc69_a(){
            var CinTemp = ReadLine().Split(' ');
            int n = int.Parse(CinTemp[0]);
            int m = int.Parse(CinTemp[1]);
            
            WriteLine((n-1)*(m-1));
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234][1234];
signed main() {
	ll n = 0, a, cnt = 1, ans = 0; cin >> n;
	vector<ll> v(n + 1);
	for (int h = 1; h <= n; h++) {
		cin >> v[h];
	}
	for (int h = 1; h <= n; h++) {
		if (v[v[h]] == h) { ans++; }
	}
	cout << ans / 2 << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

const int N = 1e6 + 100;
vector<int> from[N], res;
int val[N];
queue<int> que;
int deg[N], ans[N];

void updatewin(int u) {
	for(auto v : from[u]) {
		if(ans[v] != -1) continue;
		if(val[v] > val[u]) {
			deg[v] --;
			if(deg[v] == 0) que.push(v);
		}
	}
}

void updatefail(int u) {
	for(auto v : from[u]) {
		if(ans[v] != -1) continue;
		if(val[v] > val[u]) {
			ans[v] = 1; 
			updatewin(v);	
		}
	}
}

int main() {
	memset(ans, -1, sizeof(ans));
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) scanf("%d", &val[i]);	
	for(int i = 1; i < n; i ++) {
		int u, v;
		scanf("%d %d", &u, &v);
		if(val[u] < val[v]) {
			from[u].push_back(v);
		    deg[v] ++;
        }
		if(val[u] > val[v]) {
			from[v].push_back(u);
            deg[u] ++;
		}	
	}
	for(int u = 1; u <= n; u ++) {
		if(deg[u] == 0) que.push(u);
    }

    while(! que.empty() ) {
		int u = que.front();
		que.pop();
		ans[u] = 0;
		updatefail(u);
	}

	for(int i = 1; i <= n; i ++) 
		if(ans[i] == 1) res.push_back(i);
	for(int i = 0; i < SZ(res); i ++) 
		printf("%d%c", res[i], i == SZ(res) - 1 ? '\n' : ' ');

}


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

const long double CHANGE = 1e-8;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int parz, nparz;
int main() {
	int n;
	scanf("%d", &n);
	while(n--) {
		int x;
		scanf("%d", &x);
		if(x % 2) nparz++;
		else parz++;
	}
	while(nparz > 1) {
		parz++;
		nparz -= 2;
	}
	parz = min(parz, 1);
	if(nparz + parz <= 1) puts("YES");
	else puts("NO");
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=1,f=0;
  cin >>a;
  for(int n=1;n<=a;n++) d+=n;
  cout <<d<<'\n';
  return (0);
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n * 3);
  for (int i = 0; i < n * 3; ++i) {
    scanf("%d", &a[i]);
  }
  vector<int64> L(n * 3), R(n * 3);
  multiset<int> A;
  int64 cur = 0;
  for (int i = 0; i < n * 3; ++i) {
    A.insert(a[i]);
    cur += a[i];
    if (A.size() > n) {
      auto it = A.begin();
      cur -= *it;
      A.erase(it);
    }
    L[i] = cur;
  }
  cur = 0;
  A.clear();
  for (int i = n * 3 - 1; i >= 0; --i) {
    A.insert(a[i]);
    cur += a[i];
    if (A.size() > n) {
      auto it = std::prev(A.end());
      cur -= *it;
      A.erase(it);
    }
    R[i] = cur;
  }
  int64 ret = -(1LL << 60);
  for (int i = n; i + n <= 3 * n; ++i) {
    ret = max(ret, L[i - 1] - R[i]);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 10752
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		(new Main()).execute();
	}
	public void execute() { ;
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int X = sc.nextInt();
		int A = sc.nextInt();

		if(X < A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}


	}

}


Measured memory_bytes: 25172
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    if(n>=m)
    {
        for(i=0;i<n;i++)
            printf("%d",m);
        printf("\n");
    }
    else
    {
        for(i=0;i<m;i++)
            printf("%d",n);
        printf("\n");
    }
    return 0;
}


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

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);


int main()
{
  LL q,h,s,d,n;
  cin>>q>>h>>s>>d;
  cin>>n;
  h=min(2*q,h);
  s=min(2*h,s);
  d=min(2*s,d);
  LL ans=0;
  ans=(n/2)*d;
  if(n%2)
    ans+=s;
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())

n = b - a + 1
x0 = (a - 1)// c
y0 = b // c
x1 = (a - 1) // d
y1 = b // d
x2 = (a - 1) // (c * d // gcd(c, d))
y2 = b // (c * d // gcd(c, d))

print(n - ((y0 - x0) + (y1 - x1) - (y2 - x2)))

Measured memory_bytes: 5076
#include <stdio.h>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int ll;
const int m = 300;
const int ox = m/2, oy = m/2;	//??????
int r[7][7];
int f[301][301];				//?????¢?????°???
int height[301][301];			//????????????
int d[4][2] = {{0,-1}, {1,0}, {0,1}, {-1,0}};
int solve();

struct st {
	int id, num;
	bool operator<( const st& right ) const {
		return num > right.num;
	}
};

void rot( int &tp, int &fr, int dir ) {
	//?????¢
	/*
		dir = 0	????????´
		dir = 1 ?????´
		dir = 2 ?\\??´
		dir = 3 ?????´
	*/

	int ri = r[tp][fr];
	int pt = tp, pf = fr;
	if( dir == 0 ) {
		tp = 7-pf;
		fr = pt;
	} else if( dir == 1 ) {
		tp = 7-ri;
	} else if( dir == 2 ) {
		tp = pf;
		fr = 7-pt;
	} else {
		tp = ri;
	}

}

int main(void) {

	r[1][2] = 3;
	r[1][3] = 5;
	r[1][4] = 2;
	r[1][5] = 4;

	r[2][1] = 4;
	r[2][3] = 1;
	r[2][4] = 6;
	r[2][6] = 3;

	r[3][1] = 2;
	r[3][2] = 6;
	r[3][5] = 1;
	r[3][6] = 5;

	r[4][1] = 5;
	r[4][2] = 1;
	r[4][5] = 6;
	r[4][6] = 2;

	r[5][1] = 3;
	r[5][3] = 6;
	r[5][4] = 1;
	r[5][6] = 4;

	r[6][2] = 4;
	r[6][3] = 2;
	r[6][4] = 5;
	r[6][5] = 3;

	while(solve()) {}

	return 0;
}

int solve() {

	int n;

	cin >> n;

	if( n == 0 ) { return 0; }

	for( int i = 0; i < m; i++ ) {
		for( int j = 0; j < m; j++ ) {
			f[i][j] = 0;
			height[i][j] = 0;
		}
	}

	//????????\??¬??????
	for( int i = 0; i < n; i++ ) {

		int front, top;
		int px = ox, py = oy;
		int h = height[ox][oy];

		cin >> top >> front;
		
		bool isAbleToFall = true;

		//????????????
		while( isAbleToFall ) {

			isAbleToFall = false;

			//??´??¢?????????????????????
			vector<st> side(4);
			vector<st> pside;
			for( int j = 0; j < 4; j++ )
				side[j].id = j;
				side[0].num = front;
				side[1].num = r[top][front];
				side[2].num = 7-side[0].num;
				side[3].num = 7-side[1].num;
			pside = side;
			sort(side.begin(),side.end());
			
			//????????????
			for( int j = 0; j < 4; j++ ) {

				if( height[px + d[side[j].id][0]][py + d[side[j].id][1]] >= h ) { continue; }
				if( pside[side[j].id].num <= 3 ) { continue; }
				
				//????????????????????????????????£?????¨???
				isAbleToFall = true;
				rot(top,front,side[j].id);

				px += d[side[j].id][0];
				py += d[side[j].id][1];

				h=height[px][py];
				break;
				
			}

			if( !isAbleToFall ) {
				f[px][py] = top;
				height[px][py] ++;

			}
			
		}
		
	}

	//????¨?
	int ans[7];
	for( int i = 0; i < 7; i++ )
		ans[i] = 0;

	for( int i = 0; i < m; i++ )
		for( int j = 0; j < m; j++ )
			ans[f[i][j]]++;

	cout << ans[1];
	for( int i = 2; i < 7; i++ )
		cout << " " << ans[i];
	cout << endl;

	return 1;

}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a;
  cin >> a;

  string b;
  cin >> b;

  ll len = b.length();
  ll in = stoi(b.substr(0, len - 3));

  ll fr = stoi(b.substr(len - 2, 2));

  ll val = a * in + (a * fr) / 100;

  cout << val << en;
  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define min(a, b) ((a > b) ?  (b):(a))
#define rep(a, b) for(int a=0; a<b; ++a)
#define rep1(a, b) for(int a=1; a<b; ++a)


int main () {
    int k, n;
    scanf("%d%d", &k, &n);
    int house[n];
    rep(i, n)
        scanf("%d", &house[i]);
    int mini = k;
    rep1(i, n) {
        mini = min(mini, k-house[i]+house[i-1]);
    }
    mini = min(mini, house[n-1]-house[0]);
    printf("%d\n", mini);
    return 0;
}


Measured memory_bytes: 896
a, b = map(int, input().split())
count = 0
for i in range(a, b+1):
    s = str(i)
    if(len(s) == 1):
        count += 1
        break
    for j in range(len(s) // 2):
        if(s[j] != s[len(s)-1-j]):
            break
    else:
        count += 1
print(count)  

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

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

const long long INF = 1LL << 60;

int N;
long long h[100010];

long long dp[100010];

long long rec(int i) {
	if (dp[i] < INF) return dp[i];
	
	if (i == 0) return 0;
	
	long long res = INF;
	chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
	if (i > 1) chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));
	
	return dp[i] = res;
}

int main() {
	cin >> N;
	
	for (int i = 0; i < N; ++i) cin >> h[i];
	
	for (int i = 0; i < 100010; ++i) dp[i] = INF;
	
	cout << rec(N - 1) << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N,A,B);
  out((B-A)&1 ? "Borys" : "Alice");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		// ?¨??????\???????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();

		int[] values = new int[w];

		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}

		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			// a??¨b????????£???values??????????????????
			int c;
			c = values[a];
			values[a] = values[b];
			values[b] = c;
		}
	// values??????????????????
		for(int i=0;i < values.length; i++){
			System.out.println(values[i]);
		}
	}
}

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

#define i64 long long int

int n, lim;

i64 gcd(i64 a, i64 b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	scanf("%d%d", &n, &lim);
	
	i64 x = 0;
	int o = -1;
	for(int i=0;i<n;i++) {
		int y = 0;
		scanf("%d", &y);
		y/=2;
		
		if(i==0) x = y;
		else 
		if(x<=lim) {
			i64 g = gcd(x, y);
			x = x/g*y;
		}
		
		int pw = 0;
		while(y%2==0) {
			pw++; y/=2;
		}
		if(o>=0 && o!=pw) {
			puts("0");
			return 0;
		}
		o = pw;
	}
	
	int ans = lim / x;
	printf("%d\n", (ans+1)/2);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
# define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main(){
    ll s;
    cin >> s;
    const ll tenq = pow(10,9);
    ll q = s/tenq;
    ll r = s%tenq;
    ll a,b,c,d;
    if(q==pow(10,9)){
        a = tenq;
        b = 0;
        c = 0;
        d = tenq;
    }else{
        a = q+1;
        d = tenq;
        b = 1;
        c = tenq-r;
    }
    cout << 0 << " " << 0 << " ";
    cout << a << " " << b << " ";
    cout << c << " " << d << " ";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

vector<vector<int> > vec;
vector<int> num;
vector<pair<int, int> > memo;
int ss;

bool check(int from, int d, int depth){
  if(num[d]!=-INF){
    memo[d].fi = memo[d].se = num[d];
  }
  else if(from !=-1){
    memo[d].fi = memo[from].fi-1;
    memo[d].se = memo[from].se+1;
  }

  for(int to : vec[d]) if(to!=from){
    if( ! check(d, to, depth+1) ) return false;
    memo[d].fi = max(memo[d].fi, memo[to].fi-1);
    memo[d].se = min(memo[d].se, memo[to].se+1);
    if(memo[d].fi > memo[d].se) return false;
  }
  if(memo[d].fi == memo[d].se){
    num[d] = memo[d].fi;
    if( (num[d] + depth)%2 != num[ss]%2 ) return false;
  }
  return true;
}

bool build(int from, int d){
  int lw, up;
  if(from==-1 || memo[d].fi==memo[d].se) lw = memo[d].fi, up=memo[d].se;
  else lw = max(num[from]-1, memo[d].fi), up=min(num[from]+1, memo[d].se);
  for(int i=lw; i<=up; i++){
    num[d] = i;
    if(from!=-1 && abs(num[d]- num[from]) != 1){
      continue;
    }
    bool flg=true;
    for(int to : vec[d]) if(to != from){
      if( ! build(d, to)){
        flg=false;
        continue;
      }
    }
    if(flg){
      return true;
    }
  }
  return false;
}

int main(){
  int n;
  cin>>n;
  vec = vector<vector<int> >(n, vector<int>());
  num = vector<int>(n, -INF);
  memo = vector<pair<int, int> >(n, pair<int, int>(-INF, INF));
  rep(i,n-1){
    int a,b;
    scanf("%d %d", &a, &b);
    a--; b--;
    vec[a].pb(b);
    vec[b].pb(a);
  }
  int k; cin>>k;
  rep(i,k){
    int a,b;
    scanf("%d %d", &a, &b);
    a--;
    num[a]=b;
    memo[a]=mp(b,b);
    ss=a;
  }

  if(check(-1, ss, 0) && build(-1,ss)){
    cout<<"Yes"<<endl;
    rep(i,n) printf("%d\n", num[i]);
  } else{
    cout<<"No"<<endl;
  }

  return 0;
}


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

int main() {
  int n; cin >> n;
  int data[n+1][3];
  for (int j = 0; j < 3; j++)
    data[0][j] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      cin >> data[i+1][j];
  bool count = true;
  for (int i = 0; i < n; i++){
    int dt = data[i+1][0] -data[i][0];
    int dl = abs(data[i+1][1] -data[i][1]) + abs(data[i+1][2] -data[i][2]); 
    if (dt < dl) count = false;
    if ((dt-dl)%2 != 0) count = false;
    if(!count) break;
  }
  if (count) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int a=fsc.nextInt(), b=fsc.nextInt();
        fsc.close();
        System.out.println(a<10&&b<10?a*b:-1);
        
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Measured memory_bytes: 21204