akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#define MAXN 100000
#define MAXM 200000
struct node
{
	int fa,dist;
}poi[MAXN+5];
int FindSet(int x,int &dist)
{
	if(poi[poi[x].fa].fa==poi[x].fa)
	{
		dist=poi[x].dist;
		return poi[x].fa;
	}
	int d;
	int newfa=FindSet(poi[x].fa,d);
	poi[x].fa=newfa;
	dist=d+poi[x].dist;
	poi[x].dist+=d;
	return newfa;
}
bool SameSet(int x,int y)
{
	int dx,dy;
	return FindSet(x,dx)==FindSet(y,dy);
}
void UniteSet(int x,int y,int dist)
{
	int dx;
	int fx=FindSet(x,dx);
	int dy;
	int fy=FindSet(y,dy);
	poi[fx].fa=fy;
	poi[fx].dist=poi[y].dist+dist-poi[x].dist;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		poi[i].fa=i;
	for(int i=1;i<=m;i++)
	{
		int x,y,d;
		scanf("%d %d %d",&x,&y,&d);
		if(SameSet(x,y)==true)
		{
			if(poi[x].dist-poi[y].dist!=d)
			{
				printf("No\n");
				return 0;
			}
		}
		else
			UniteSet(x,y,d);
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <cstdio>

using namespace std;

int A[100000];
int V[2][100001];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i)
        scanf("%d", &A[i]);
    int B[2][2], C[2][2];
    for (int j = 0; j < 2; ++j) {
        for (int i = j; i < N; i += 2)
            ++V[j][A[i]];
        for (int i = 0; i < 2; ++i) {
            B[j][i] = (int) (max_element(V[j], V[j] + 100001) - V[j]);
            C[j][i] = V[j][B[j][i]];
            V[j][B[j][i]] = 0;
        }
    }
    if (B[0][0] != B[1][0])
        printf("%d\n", N - C[0][0] - C[1][0]);
    else
        printf("%d\n", N - max(C[0][1] + C[1][0], C[0][0] + C[1][1]));
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s; cin>>s;
    int cnt=0;
    rep(i,3){
        if(s[i]=='R') cnt++;
    }
    if(cnt==0){
        cout<<0<<endl;
    }else if(cnt==1){
        cout<<1<<endl;
    }else if(cnt==3){
        cout<<3<<endl;
    }else{
        if(s=="RSR"){
            cout<<1<<endl;
        }else{
            cout<<2<<endl;
        }
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
    cin >> a >> b;
    int x = a * b;
  
  if ( x % 2 == 1) {
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  
  }
}

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

using namespace std;

int const INF = 1<<29;

int main() {
  int N, M, S, g1, g2;
  
  while(cin >> N >> M >> S >> g1 >> g2 && N) {
    int cost[100][100]; fill(cost[0], cost[0]+10000, INF);
    for(int i=0; i<N; i++) cost[i][i] = 0;
    S--, g1--, g2--;
    for(int i=0; i<M; i++) {
      int a, b, c; cin >> a >> b >> c; a--, b--;
      cost[a][b] = c;
    }
    
    for(int k=0; k<N; k++)
      for(int i=0; i<N; i++)
	for(int j=0; j<N; j++)
	  cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
    
    int ans = INF;
    for(int k=0; k<N; k++) {
      ans = min(ans, cost[S][k] + cost[k][g1] + cost[k][g2]);
    }
    
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196
n=int(input())
A=list(map(int,input().split()))

dp=[[-10**12]*(n+1) for i in range(n+1)]
#dp[i][j]:=A[j:j+i+1]
if n%2==0:
  for i in range(n):
    dp[0][i]=-1*A[i]
  for i in range(1,n+1):
    for j in range(n-i):
      if i%2==1:
        if j+i==n:
          dp[i][j]=dp[i-1][j+1]+A[j]
        else:
          dp[i][j]=max(dp[i-1][j]+A[j+i],dp[i-1][j+1]+A[j])
      else:
        if j+i==n:
          dp[i][j]=dp[i-1][j+1]-A[j]
        else:
          dp[i][j]=min(dp[i-1][j]-A[j+i],dp[i-1][j+1]-A[j])
else:
  for i in range(n):
    dp[0][i]=A[i]
  for i in range(1,n+1):
    for j in range(n-i):
      if i%2==0:
        if j+i==n:
          dp[i][j]=dp[i-1][j+1]+A[j]
        else:
          dp[i][j]=max(dp[i-1][j]+A[j+i],dp[i-1][j+1]+A[j])
      else:
        if j+i==n:
          dp[i][j]=dp[i-1][j+1]-A[j]
        else:
          dp[i][j]=min(dp[i-1][j]-A[j+i],dp[i-1][j+1]-A[j])
print(dp[n-1][0])

Measured memory_bytes: 113244
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    s = Mint()
    for a in A:
        s += a
    ans = Mint()
    for a in A:
        ans += a * (s - a)
    print(ans // 2)

MOD = 10**9 + 7
class Mint:
    def __init__(self, value=0):
        self.value = value % MOD
        if self.value < 0: self.value += MOD

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, MOD
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        if u < 0: u += MOD
        return u

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % MOD
        return self

    def __add__(self, other):
        new_obj = Mint(self.value)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other)) % MOD
        if self.value < 0: self.value += MOD
        return self

    def __sub__(self, other):
        new_obj = Mint(self.value)
        new_obj -= other
        return new_obj

    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % MOD
        return self

    def __mul__(self, other):
        new_obj = Mint(self.value)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other)
        self *= other.inverse()
        return self

    def __floordiv__(self, other):
        new_obj = Mint(self.value)
        new_obj //= other
        return new_obj

    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj //= self
        return new_obj

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


Measured memory_bytes: 97620
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    ll N;
    io.read(N);
    map<ll, ll> primes;
    ll a = 2;
    while(a * a <= N){
        if(N % a == 0){
            ll k = 0;
            while(N % a == 0) { N /= a; k++; }
            primes[a] = k; 
        }
        a++;
    }
    if(N > 1) primes[N]++;
    ll ans = 0;
    for(auto i = primes.begin(); i != primes.end(); i++){
        ll k = 1;
        while(k * (k + 1) / 2 <= i->second) k++;
        ans += k - 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int N,K; vector<int> pl,mi;
void input()
{
    cin >> N >> K;
    for(int i=0; i<N; ++i){
        int x; cin >> x;
        if(x > 0) pl.emplace_back(x);
        else if(x < 0) mi.emplace_back(-x);
    }
    reverse(mi.begin(),mi.end());
}

void solve()
{
    if(N != pl.size() + mi.size()) --K;
    int ans, left, right;
    if(pl.empty() && mi.empty()) ans = 0;
    else if(pl.empty()) ans = mi[K-1];
    else if(mi.empty()) ans = pl[K-1];
    else {
        int mi_size = mi.size();
        int pl_size = pl.size();
        if(pl_size >= K)  {
            left = -1; right = K-1;
            ans = pl[right];
        }
        else {
            left = K - pl_size - 1; right = pl_size - 1;
            if(pl[right] > mi[left]) ans = pl[right] + 2 * mi[left];
            else ans = 2 * pl[right] + mi[left];
            // cout << mi[left] << " " << pl[right] << endl;
        }

        while(1){
            ++left; --right; 
            if(left < mi_size){ 
                if(right >= 0){
                    if(pl[right] > mi[left]) ans = min(ans, pl[right] + 2 * mi[left]);
                    else ans = min(ans, 2 * pl[right] + mi[left]);
                    // cout << mi[left] << " " << pl[right] << endl;
                }
                else if(right == -1) ans = min(ans, mi[left]);
            }
            else break;
        }
    }

    cout << ans << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3916
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int x[100001], y[100001],ballNum[100001];
bool can[100001];
signed main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 0; i <= N; i++) {
		ballNum[i] = 1;
		can[i] = false;
	}
	can[1] = true;

	for (int i = 0; i < M; i++) {
		//ボールを移動
		ballNum[x[i]]--;
		ballNum[y[i]]++;
		//移動もとに赤玉が入っていたら
		if (can[x[i]]) {
			can[y[i]] = true;
		}
		//移動もとに赤玉が入っていたが、それが最後の赤玉だったら
		if (can[x[i]] && ballNum[x[i]] == 0) {
			can[x[i]] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i <= N; i++) {
		if (can[i]) ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

const int maxk = 19, maxn = 263*1000, INF = 1*1000*1000*1000+10;
int a, n, mx[maxn][maxk][2], dp[maxn], g[maxn][maxk], h[maxn];
vector<int> tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < (1 << n); i++)
	{
		cin >> a;
		h[i] = a;
		mx[i][0][0] = a;
		mx[i][0][1] = -INF;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j + (1 << i) <= (1 << n); j++)
		{
			tmp.clear();
			tmp.push_back(mx[j][i - 1][0]);
			tmp.push_back(mx[j][i - 1][1]);
			tmp.push_back(mx[j + (1 << (i - 1))][i - 1][0]);
			tmp.push_back(mx[j + (1 << (i - 1))][i - 1][1]);
			sort(tmp.begin(), tmp.end());
			mx[j][i][0] = tmp[3];
			mx[j][i][1] = tmp[2];
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < (1 << n); j++)
		{
			if (j & (1 << i))
			{
				a = (j >> (i + 1)) << (i + 1);
				dp[j] = max(dp[j], mx[a][i][0] + mx[a][i][1]);
				dp[j] = max(dp[j], mx[a][0][0] + mx[a | (1 << i)][0][0]);
				dp[j] = max(dp[j], h[j] + h[j ^ (1 << i)]);
				h[j] = max(h[j], h[j ^ (1 << i)]);
				g[j][i] = mx[a][i][0];
				for (int k = 0; k < i; k++)
				{
					if (j & (1 << k))
					{
						dp[j] = max(dp[j], g[j][k] + g[j ^ (1 << i)][k]);
						g[j][k] = max(g[j][k], g[j ^ (1 << i)][k]);
					}
				}
			}
		}
	}
	for (int i = 1; i < (1 << n); i++)
		cout << dp[i] << endl;
	return 0;
}

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

int main() {
  
  long long H,W,K,x1,y1,x2,y2;
  
  cin >> H >> W >> K >> x1 >> y1 >> x2 >> y2;
  x1--;
  x2--;
  y1--;
  y2--;
  
  vector<vector<long long>> c(H,vector<long long> (W,10000000));
  
  
  string S;
  
  for (int i=0; i<H; i++) {
    cin >> S;
    for (int j=0; j<W; j++) {
      if (S[j] == '@') {
        c[i][j] = -1;
      }
    }
  }
  
  c[x1][y1] = 0;
  
  queue<long long> li;
  
  li.push(x1*W+y1);
  
  long long x3,y3,z3;
  
  while(!li.empty()) {
    x3 = li.front() / W;
    y3 = li.front() % W;
    z3 = c[x3][y3];
    li.pop();
    
    for (int i=1; i<=K; i++) {
      if (x3 + i >= H) break;
      if (c[x3+i][y3] <= z3) break;
      
      if (c[x3+i][y3] == 10000000) {
        li.push((x3+i) * W + y3);
      }
      
      c[x3+i][y3] = z3+1;
    }
    for (int i=1; i<=K; i++) {
      if (x3 - i < 0) break;
      if (c[x3-i][y3] <= z3) break;
      if (c[x3-i][y3] == 10000000) {
        li.push((x3-i) * W + y3);
      }
      c[x3-i][y3] = z3+1;
      
    }
    for (int i=1; i<=K; i++) {
      if (y3+i >= W) break;
      if (c[x3][y3+i] <= z3) break;
      if (c[x3][y3+i] == 10000000) {
        li.push(x3 * W + y3 + i);
      }
      c[x3][y3+i] = z3+1;
      
      
    }
    for (int i=1; i<=K; i++) {
      if (y3-i < 0) break;
      if (c[x3][y3-i] <= z3) break;
      if (c[x3][y3-i] == 10000000) {
        li.push(x3 * W + y3 - i);
      }
      c[x3][y3-i] = z3+1;
    }
    
  }
  
  
  long long ans = c[x2][y2];
  
  if (ans == 10000000) {
    ans = -1;
  }
  
  
  cout << ans << endl;
  
  
  
  
  return 0;
  
}

Measured memory_bytes: 18780
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W = mapint()
query = [list(input()) for _ in range(H)]

def check():
    for h in range(H):
        for w in range(W):
            if query[h][w]=='.':
                continue
            if h!=0 and query[h-1][w]=='#':
                continue
            if h<H-1 and query[h+1][w]=='#':
                continue
            if w!=0 and query[h][w-1]=='#':
                continue
            if w<W-1 and query[h][w+1]=='#':
                continue
            return False
    return True

if check():
    print('Yes')
else:
    print('No')

Measured memory_bytes: 64928
def comb(val):
    if(val > 0):
        return int(val*(val-1) / 2)
    else:
        return 0

def main():
    args = input().rstrip().split(' ')
    N, M = int(args[0]), int(args[1])
    print(comb(N) + comb(M))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
d={}
for i in range(n):
  d[l[i]]=i+1
ans=1
ans1=1
index=1
while index<n:
  index+=1
  if d[index]>d[index-1]:
    ans1+=1
  else:
    if ans<ans1:
      ans=ans1
    ans1=1
if ans<ans1:
  ans=ans1
print(n-ans)

Measured memory_bytes: 34976
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N,M;
    int[] A,B;

    private class Pair implements Comparable<Pair> {
        int price, num;
        public Pair(int price, int num) {
            this.price = price;
            this.num = num;
        }

        public int compareTo(Pair other) {
            return this.price - other.price;
        }
    }

    private void solve() {
        N = nextInt();
        M = nextInt();

        A = new int[N];
        B = new int[N];

        for(int i = 0;i < N;i++) {
            A[i] = nextInt();
            B[i] = nextInt();
        }

        ArrayList<Pair> pairs = new ArrayList<>();
        for(int i = 0;i < N;i++) {
            pairs.add(new Pair(A[i], B[i]));
        }

        Collections.sort(pairs);

        long ans = 0;
        for(int i = 0;i < N;i++) {
            long num = Math.min(M, pairs.get(i).num);
            ans += num * pairs.get(i).price;
            M -= num;
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 45320
#include<stdio.h>

int main(){
  int a,i,min=10,sum = 0;
  for(i = 0;i < 5;i++){
    scanf("%d",&a);
    if(a % 10 != 0&&min > a % 10){min = a % 10;}
    sum += (a+9)/10*10;
  }
  sum += min-10;
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MAX 20010
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n,m;
  int c[MAX]={};

  cin>>n>>m;
  FOR(i,0,m){
    string s;
    cin>>s;
    FOR(j,0,s.length())if(s[j]=='W')c[j]++;
  }

  int w=0,e=0;
  FOR(i,0,n)e+=c[i];
  pii ans(e,-1);
  FOR(i,0,n){
    w+=m-c[i];
    e-=c[i];
    if(w+e<ans.f)ans=mp(w+e,i);
  }
  cout<<ans.s+1<<" "<<ans.s+2<<endl;
  return 0;
}

Measured memory_bytes: 3252
<?php
fscanf(STDIN, "%d", $N);
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$ans = array_pad(array(), $N, 0);
foreach ($A as $k => $v) {
    $ans[$v - 1] = $k + 1;
}
echo implode(" ", $ans);


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

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    vector<int> d(M);
    vector<int> idx(N, -1);
    for (int i = 0; i < M; i++) {
        cin >> d[i];
        idx[d[i]-1] = i;
    }

    vector<vector<int> > v(N, vector<int>(K));
    for (auto& i : v) for (auto& j : i) cin >> j;

    vector<int> dp(1 << M, 1 << 28);
    dp[0] = 0;


    vector<vector<int> > nx(K, vector<int>(1<<M));
    for (int i = 1; i < (1<<M); i++) {
        for (int j = 0; j < K; j++) {
            int x = 0;
            for (int k = 0; k < M; k++) {
                auto t = idx[v[d[k]-1][j]-1];
                if ((i & (1<<k)) && t >= 0)
                    x |= (1<<t);
            }
            nx[j][i] = x;
            dp[i] = min(dp[i], dp[x] + 1);
        }
    }

    for (int g = 0; g < 2 * M; g++) {
        for (int i = 1; i < (1<<M); i++) {
            for (int j = 0; j < K; j++) {
                int x = nx[j][i];
                dp[i] = min(dp[i], dp[x] + 1);
            }
        }
    }

    cout << dp[(1<<M)-1] << endl;

    return 0;
}

Measured memory_bytes: 29536
#include<bits/stdc++.h>
using namespace std;
#define N 200003
#define LL long long
#define mod 998244353

int a,b;


inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

int main(){
	a=read();b=read();
	printf("%d\n",max(a+b,max(a-b,a*b)));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;


double func(int x) {
	return x * x;
}

int main() {
	for(int d; cin >> d;) {
		int sum = 0;
		for(int i = d; i < 600; i += d) {
			sum += func(i) * d;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
using namespace std;
int n,k;
long long ans;
int main()
{
	scanf("%d%d",&n,&k);
	if (k==0) {printf("%lld",1ll*n*n);return 0;} 
	for (int i=k+1;i<=n;i++)
	{
		int q=n/i;
		ans+=1ll*q*(i-k);
		ans+=max(0,n%i-k+1);
		//cout<<ans<<endl;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

var N, K int
var S string

func main() {
	fmt.Scan(&N, &K, &S)
	if N >= K {
		a := strings.Split(S, "")
		var b string

		for i := 0; i < N; i++ {
			if i == K-1 {
				b += strings.ToLower(a[K-1])
			} else {
				b += a[i]
			}
		}
		fmt.Printf("%s\n", b)
	} else {
		panic("a")
	}
}


Measured memory_bytes: 640
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
ul N,A[2][100],memo[2][100],ans,i,j;
inline void solve(){
  IN(N);
  REP(i,2)REP(j,N){
    IN(A[i][j]);
  }
  REP(j,N){
    if(j==0){
      memo[0][j]=A[0][j];
      memo[1][N-1-j]=A[1][N-1-j];
    }
    else {
      memo[0][j]+=memo[0][j-1]+A[0][j];
      memo[1][N-1-j]+=memo[1][N-j]+A[1][N-1-j];
    }
  }
  REP(j,N){
    ans=max(ans,memo[0][j]+memo[1][j]);
  }
  OUT(ans);

}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        if (a * c <= b) System.out.println(c);
        else System.out.println(b / a);
        inp.close();
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

bool add (vi &b, ll x) {
	int m = b.size();

	for (int i = m - 1; i >= 0; i--)
		if (x & (1ll << i))
			x ^= b[i];
 
	if (!x) return 0;
 
	for (int i = m - 1; i >= 0; i--)
		if (!b[i] && (x & (1ll << i))) {
			b[i] = x;
 
			for (int j = i + 1; j < m; j++)
				if (b[j] & (1ll << i))
					b[j] ^= x;
 
			break;
		}
 
	return 1;
}

const int MX = 205;
int n;
ll a[MX];
string s;
vi b, c;

void solve () {
	cin >> n;
	forn (i, n)
		cin >> a[i];
	cin >> s;

	b = vi(62); 

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '0') {
			add(b, a[i]);
		} else {
			vi c = b;
			if (add(c, a[i])) {
				cout << 1 << endl;
				return;
			}
		}
	}

	cout << 0 << endl;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int t;
	cin >> t;
	while (t--)
		solve();	

	return 0;
}


Measured memory_bytes: 3624
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
t = []
for i, j in zip(v, c):
    t.append(i - j)
t = sorted(t)[::-1]
res = 0
for i in t:
    if i > 0:
        res += i
print(res)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
int N,K;
cin>>N>>K;
int answer=1;
for(int i=0;i<N;i++){
    if(answer*2>=answer+K){
        answer=answer+K;
    }
    else{
        answer=answer*2;
    }
}
cout<<answer<<endl;
}


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
const int B = 12345;

vector<int> T, pB;
int rangeHash(int l, int r, int N) {
  return (1LL*(T[r]+MOD-(l>0?T[l-1]:0))*pB[N-l]) % MOD;
}

string f_half(string s) {
  int n = s.length();
  pB = vector<int>(n+1);
  pB[0] = 1;
  for (int i=1; i<=n; i++) pB[i] = (1LL*pB[i-1]*B)%MOD;

  T = vector<int>(n, 0);
  rep(i, n) T[i] = (1LL*pB[i]*(int)(s[i]-'a'))%MOD;
  rep(i, n-1) T[i+1] = (T[i+1]+T[i])%MOD;

  for (int d=1; d<n; d++) {
    if (rangeHash(0, n-1-d, n) == rangeHash(d, n-1, n)) {
      string o(s);
      rep(j, d) o += s[j];
      return o;
    }
  }
  return s+s;
}

string S;
long long L, R;
vector<long long> F;

vector<long long> fib(long long cur) {
  vector<long long> C(F.size(), 0);

  assert(F.size() >= 2 && F[0] == S.length()/2);
  for (int i=F.size()-1; i>=0; i--) {
    if (cur >= F[i]) {
      cur -= F[i];
      C[i]++;
    }
    if (i >= 2) C[i-2] += C[i];
    if (i >= 1) C[i-1] += C[i];
  }
  vector<long long> ret(26, 0);
  // cur
  rep(i, cur+1) ret[S[i]-'a']++;
  // C[1]
  rep(i, F[1]-F[0]) ret[S[i]-'a'] += C[1];
  // C[0]
  rep(i, S.length()/2) ret[S[i]-'a'] += C[0];
  return ret;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S >> L >> R;
  L--, R--;
  string half(S); half.resize(S.length()/2);
  vector<int> seq;
  seq.pb(half.size());
  rep(_, 3) {
    half = f_half(half);
    seq.pb(half.size());
  }
  bool repeat = true;
  rep(i, seq.size()-1) if (seq[i+1]-seq[i] != seq[1]-seq[0]) repeat = false;
  vector<long long> ans(26);
  if (repeat) {
    long long N = S.length()/2;
    rep(i, N) {
      long long l = max(0LL, (L-i+N-1)/N), r = (R-i)/N;
      ans[S[i]-'a'] += max(0LL, r-l+1);
    }
  }
  else {
    F.pb(seq[0]);
    F.pb(seq[1]);
    while (F.back() <= 1e18) F.pb(F[F.size()-1] + F[F.size()-2]);

    ans = fib(R);
    if (L > 0) {
      vector<long long> t = fib(L-1);
      rep(i, 26) ans[i] -= t[i];
    }
  }
  rep(i, 26) cout << ans[i] << " "; cout << "\n";
  return 0;
}


Measured memory_bytes: 4272
<?php
  fscanf(STDIN, "%d %d %d %d %d", $a, $b, $c, $d, $e);
  $array = array($a, $b, $c, $d, $e);
  $key = array_search('0',$array);
  $key = $key + 1;
  if ($key) {
      echo $key;
  } 
?>

Measured memory_bytes: 15964
#include <cstdio>
#include <list>
using namespace std;
int main(){
	typedef list<char> lc;
	int n;
	char c,d;
	for(scanf("%d ",&n);n--;scanf(" ")){
		lc ls;
		ls.push_back(getchar());
		lc::iterator it=ls.begin();
		for(;d=getchar(),d=='-'||d=='<';){
			getchar();
			c=getchar();
			if(d=='-'){
				if(++it==ls.end())it=ls.insert(it,c);
			}else{
				if(it==ls.begin())it=ls.insert(it,c);
				else --it;
			}
		}
		for(it=ls.begin();it!=ls.end();++it)putchar(*it);
		puts("");
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(vector<vector<T>> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}

int main() {
	int H = -1, W = -1;
	cin >> H >> W;
	auto map = getUniform('#', H + 2, W + 2);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> map[i + 1][j + 1];
		}
	}
	Show(map, "");
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]

a = [x for x in a if "#" in x]

aT = list(zip(*a))
aT = [x for x in aT if "#" in x]

a = list(zip(*aT))

for i in a:
    print("".join(i))


Measured memory_bytes: 3316
n, m = map(int, input().split())
lrs = [ list(map(int, input().split())) for _ in range(m)]

cards = [lrs[0][0], lrs[0][1]] # [min, max]

for lr in lrs[1:]:
    if (lr[1] < cards[0]) or (lr[0] > cards[1]):
        print(0)
        exit()

    cards[0] = max(cards[0], lr[0])
    cards[1] = min(cards[1], lr[1])
    

print(cards[1] - cards[0] + 1)
        
    

Measured memory_bytes: 27940
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
using namespace std;
char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
ll read(){
	char ch=gc();ll x=0;int op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
int len,ans;char op[5];
int init(){
    int k=10;
    for(int i=1;i<=9;i++){
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='N') return i;
        k=k*10;
    }
    k=9;
    for(int i=1;i<=9;i++){
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y') return i;
        k=k*10+9;
    }
    return 10;
}
int main(){
	int len=init();
    if(len==10)
    {
        printf("! %d\n",(int)1e9);
        return 0;
    }
	for(int i=1;i<len;i++)
    {
        int l=0,r=9,t=0;
        while(l<=r)
        {
            int mid=(l+r)/2;
            printf("? %d\n",ans*10+mid);
            fflush(stdout);
            scanf("%s",op);
            if(op[0]=='Y')
            {
                t=max(t,mid);
                l=mid+1;
            }
            else
                r=mid-1;
        }
        ans=ans*10+t;
    }
	for(int i=(len==1?1:0);i<=9;i++)
    {
        printf("? %lld\n",((ll)ans*10+i)*10);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y')
        {
            ans=ans*10+i;
            break;
        }
    }
    printf("! %d\n",ans);
	return 0;
}


Measured memory_bytes: 596
import java.util.Scanner;

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

        for (int i = 0; i < 10000; i++) {
            if ((input = sc.nextInt()) != 0) {
                System.out.println("Case " + (i + 1) + ": " + input);
            } else {
                break;
            }
        }
    }
}


Measured memory_bytes: 41984
#include <bits/stdc++.h> //13
//#..####...###
using namespace std;
int main(void){
    int n; cin>>n;
    if(n==0){ cout<<'0'<<endl; return 0;}
    string s; cin>>s;
    s+='0';
    vector <int> data;
    int c=0;
    if(s[0]=='#') c=1; else c=-1;
    for(int i=1;i<n+1;i++){
        if(s[i-1]!=s[i]) {data.push_back(c); c=0;}
        if(s[i]=='#') c++;
        if(s[i]=='.') c--;
    }
   // for(int i=0;i<data.size();i++) cout<<data[i]<<' ';
   // cout<<endl;
    int x=data.size();
    vector <int> kuroruikei(x,0);
    for(int i=0;i<x;i++){
        if(i!=0) kuroruikei[i]=kuroruikei[i-1];
        if(data[i]>0) kuroruikei[i]+=data[i];
   //     cout<<kuroruikei[i]<<' ';
    }
  //  cout<<endl;
    vector <int> shiro(x,0);
    for(int i=x-1;i>=0;i--){
        if(i!=x-1) shiro[i]=shiro[i+1];
        if(data[i]<0) shiro[i]+=data[i];
    }
    //for(int i=0;i<x;i++){
        //cout<<shiro[i]<<' ';
   // }
    int ans=200010;
    for(int i=0;i<x;i++){
        int tmp=0;
       // cout<<kuroruikei[i]<<'+'<<' '<<abs(shiro[i+1])<<endl;
        if(abs(kuroruikei[i])+abs(shiro[i+1])==0) {cout<<'0'<<endl; return 0;}
        if(i==0) tmp+=abs(shiro[i]);
        else
        tmp+=abs(kuroruikei[i])+abs(shiro[i+1]);
        ans=min(ans,tmp);
    }
    //cout<<ans<<endl;
    int c1=0,c3=0;
    //全部しろ
    for(int i=0;i<n;i++){
        if(s[i]=='#') c1++;
    }
  /*  //全部黒
    for(int i=0;i<n;i++){
        if(s[i]=='.') c2++;
    }*/
    //(右側)全部黒
    bool start=false;
    for(int i=0;i<n;i++){
        if(s[i]=='#') start=true;
        if(start) {
            if(s[i]=='.') c3++;
        }
    }
    //cout<<c1<<' '<<c3<<endl;
    cout<<min({c1,c3,ans})<<endl;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  int ans=0;
  if(n>=2){
    ans+=n*(n-1)/2;
  }
  if(m>=2){
    ans+=m*(m-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[14]:


a, b, c, d = map(int, input())


# In[15]:


import sys


# In[16]:


cs_a = a
for i in range(2):
    if i:
        cs_b = cs_a + b
        op1 = '+'
    else:
        cs_b = cs_a - b
        op1 = '-'
        
    for j in range(2):
        if j:
            cs_c = cs_b + c
            op2 = '+'
        else:
            cs_c = cs_b - c
            op2 = '-'
        
        for k in range(2):
            if k:
                cs_d = cs_c + d
                op3 = '+'
            else:
                cs_d = cs_c - d
                op3 = '-'
                
            if cs_d == 7:
                print('{}{}{}{}{}{}{}=7'.format(a, op1, b, op2, c, op3, d))
                sys.exit()


# In[ ]:






Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print((A+B)%24)

Measured memory_bytes: 13660
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int n,k; cin >> n >> k;
   vector<int> a(n+1),was(n+1);
   rep(i,0,n) cin >> a[i+1];
   int now = 1, tmp = 1, loop, start;
   while(1){
      if(was[now]){
         loop = tmp-was[now];
         start=now;
         break;
      }
      was[now] = tmp++;
      int next = a[now];
      now = next;
      k--;
      if(k==0){
         cout << now << "\n";
         return 0;
      }
   }
   k%=loop;
   // cout << now << '\n';
   rep(i,0,k){
      int next = a[now];
      now = next;
   }
   cout << now << "\n";
}

Measured memory_bytes: 6300
from collections import Counter

N = int(input())
S = [input() for i in range(N)]

cnt = Counter(S)

most = 0
for i in cnt.values():
    most = max(most, i)

ans = []
for i in cnt:
    if cnt[i] == most:
        ans.append(i)

ans.sort()
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 35572
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String up = s.toUpperCase();
        String down = s.toLowerCase();
        
        char x;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i) == up.charAt(i)){
                x=down.charAt(i);
            }
            else x=up.charAt(i);
            System.out.print(x);
        }
        System.out.println();
    }
}


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

int main(){
  long long a,b,x;
  cin >>a>>b>>x;
  long long adiv=a/x,bdiv=b/x;
  if (adiv < bdiv){
    if(a%x==0){
      cout<< (bdiv -adiv +1)<<endl;
      return 0;
    }
    else{
      cout<<bdiv-adiv<<endl;
      return 0;
    }
  }
  if (a%x==0){
    cout<<1<<endl;
    return 0;
  }
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>


int main(void) {
    std::string s;
    std::cin >> s;

    if (s == "Sunny") {
        std::cout << "Cloudy" << std::endl;
    } else if (s == "Cloudy") {
        std::cout << "Rainy" << std::endl;
    } else {
        std::cout << "Sunny" << std::endl;
    }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int L, R, A, B;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> L >> R >> A >> B;
  int divA = R / A - (L-1) / A;
  int divB = R / B - (L-1) / B;
  int AB = lcm(A, B);
  int divAB = R / AB - (L-1) / AB;
  cout << R - L + 1 - (divA + divB - divAB) << endl;
  return 0;
}



Measured memory_bytes: 764
x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
    print(x-k*d)
else:
    if (k-x//d)%2==0:
        print(x-d*(x//d))
    else:
 
        print(abs(d-(x-d*(x//d))))
 

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

using namespace std;

int main(){
    int n;
    cin >> n;
    map<int,int>mp;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        mp[a-1] +=1;
        mp[a] +=1;
        mp[a+1] +=1;

    }
    int ans=0;
    for(auto &x : mp){
        ans = max(ans,x.second);
    }
    cout << ans << endl;

}

Measured memory_bytes: 4736
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int d, g, ans;
void solve() {
    cin >> d >> g;
    vector<int> p(d, 0);
    vector<int> c(d, 0);
    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }
    ans = INF;
    for (int mask = 0; mask < (1 << d); ++mask) {
        int s = 0, num = 0, last_index = -1;
        for (int i = 0; i < d; ++i) {
            if (mask >> i & 1) {
                s = s + (100 * (i + 1) * p[i]) + c[i];
                num += p[i];
            } else {
                last_index = i;
            }
        }
        if (s < g) {
            int s1 = 100 * (last_index + 1);
            int need = (g - s + s1 - 1) / s1; 
            if (need >= p[last_index]) {
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();
        
        if (a<b && b<c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26364
n = int(input())
w = list(map(int, input().split()))

sum = 0

for i in range(n):
  sum += w[i]
  
#print(sum)
dif = [0]*(n)
sum_s1 = 0

for i in range(n):
  sum_s1 += w[i]
  dif[i] = abs(2 * sum_s1 - sum)
  
dif = sorted(dif)

print(dif[0])
  

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

typedef long long int llint;

int main()
{
  int n, d, x;
  int a;

  int sum;

  cin>> n >> d >> x;
  sum = x;
  d--;

  for(int i = 0; i < n; i++) {
    cin>> a;
    sum += 1 + d / a;
  }

  cout<< sum <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    vector<int> f(1e4 + 1);
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int ans = x * x + y * y + z * z + x * y + y * z + x * z;
                if (ans <= 1e4) {
                    f[ans]++;
                }
            }
        }
    }
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cout << f[i] << '\n';
    }

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> PP;

class page{
public:
  PP p;
  int n;
  page(PP p=PP(P(0,0),P(0,0)), int n=0):p(p),n(n){}
};

int main(){
  int n;
  while(cin >> n && n){
    map<string,int> m;
    map<int,string> m2;
    int h,w,aa=0;
    vector<page> v[100];
    cin >> h >> w;
    for(int i=0;i<n;i++){
      string str;
      int a;
      cin >> str >> a;
      if(m.find(str) == m.end()){
        m[str] = aa;
        m2[aa++] = str;
      }
      for(int j=0;j<a;j++){
        PP p;
        string str2;
        cin >> p.first.first >> p.first.second >> p.second.first >> p.second.second >> str2;
        if(m.find(str2) == m.end()){
          m[str2] = aa;
          m2[aa++] = str2;
        }
        v[m[str]].push_back(page(p,m[str2]));
      }
    }

    int n2, curr=0;
    vector<int> v2;
    v2.push_back(0);
    cin >> n2;
    for(int i=0;i<n2;i++){
      string str;
      cin >> str;
      if(str == "click"){
        int x,y;
        cin >> x >> y;
        int now = v2[curr];
        for(int j=0;j<v[now].size();j++){
          if(v[now][j].p.first.first <= x && x <= v[now][j].p.second.first && v[now][j].p.first.second <= y && y <= v[now][j].p.second.second){
            curr++;
            while(curr < v2.size()) v2.pop_back();
            v2.push_back(v[now][j].n);
            break;
          }
        }
      } else if(str == "back") curr = (curr <= 0) ? curr : curr-1;
      else if(str == "forward") curr = (curr >= v2.size()-1) ? curr : curr+1;
      else cout << m2[v2[curr]] << endl;
    }
  }
}

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

Measured memory_bytes: 256