akhauriyash/Code-Regression huggingface dataset:
// Garg's Code
#include <bits/stdc++.h>
using namespace std;
#define set set <ll>
#define ll long long
#define ldb long double;
#define pa pair < ll, ll >
#define map map < ll, ll >
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
#define llong 1e9+7
#define lsmall -1e9+7
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
 int main() 
 
{
   fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif  
  ll n, m;
  cin >> n >> m;
  cout << max(n+m, max(n-m, m*n));
  return 0;   
}

Measured memory_bytes: 256
n, m = map(int, input().split())
MOD = 10**9 + 7

if abs(n - m) > 1:
    print(0)
elif n == m:
    ans = 1
    for i in range(2, n + 1):
        ans *= i
        ans %= MOD
    # xoxoxo... とoxoxox... 、どっちを先にするかで2種類
    print(2 * ans * ans % MOD)
else:
    ans = 1
    for i in range(2, n + 1):
        ans *= i
        ans %= MOD
    for i in range(2, m + 1):
        ans *= i
        ans %= MOD
    print(ans)


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int n;
  vector<int> a;
  cin >> n;

  REP(i, n){
      int tmp;
      cin >> tmp;
      a.pb(tmp);
    }

    sort(a.begin() , a.end());

    int s = a[1];

    REPB(i, s){
     int isDivide = 2;
      REP(j, n){
          if(a[j] % i != 0) isDivide--;
        }
        if(isDivide > 0){
            cout << i << endl;
            return 0;
          }
    }
}

Measured memory_bytes: 892
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;

int main(){

  int n;cin>>n;
  string s;cin>>s;

  int ans=1;
  rep(i,0,n-1){
    if(s[i]!=s[i+1])ans++;
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  string S;
  cin>>S;
  int N=S.size();
  if(N%2==1){
    puts("No");
    return 0;
  }
  map<char,char> A;
  A['q']='p',A['p']='q',A['b']='d',A['d']='b';
  for(int i=0;i<N/2;i++)
    if(A[S[i]]!=S[N-1-i]){
      puts("No");
      return 0;
    }
  puts("Yes");
}

Measured memory_bytes: 3760
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,K = imn()
h = iln()

dp = [INF for _ in range(N)]
dp[0] = 0

for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[N-1])

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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;
}

// 負の数にも対応した % 演算
long long mod(long long val, long long m)
{
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}

// a^n modを計算する
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    // nを2進数表示して1が埋まっている桁に関してはa^mをかけていく
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod)
{
    return modpow(a, mod - 2, mod);
}

int main()
{
    int N, M;
    cin >> N >> M;
    if (M == N)
        cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;

namespace AOJapps
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int counter = 0;
            for (int i = 0; i < N; i++)
            {
                if (IsPrime(int.Parse(Console.ReadLine())))
                {
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }

        static bool IsPrime(int n)
        {
            if ( n < 2 ) { return false; }
            else if ( n == 2) { return true; }
            else if ( n % 2 == 0 ) { return false; }
            else
            {
                double sqrtn = Math.Sqrt(n);
                for (int i=3; i<=sqrtn; i+= 2)
                {
                    if (n%i == 0) { return false; }
                }
                return true;
            }
        }
    }
}

Measured memory_bytes: 9124
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b
//区間スケジューリング問題(最大幾つの区間を取って来れるか)
//解説：https://www.pandanoir.info/entry/2016/09/05/165237
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;
 
int N;

int ans = 0;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
 
void solve(vector<pair<long,long>>& robot){
	sort(robot.begin(),robot.end(),compare_by_second);//pairのsecond要素基準でソート（昇順）
	long prev_XL = LONG_MIN;//long型で表現できる最小の負数で初期化
	for(int i=0;i<N;i++){
		if(robot[i].first>=prev_XL){
			prev_XL = robot[i].second;
			ans++;
		}
	}
}
 
int main(){
	cin>>N;
	vector<pair<long,long>> robot;
	for(int i=0;i<N;i++){
		long X,L;
		cin>>X>>L;
		robot.push_back(make_pair(X-L,X+L));//ロボットの影響範囲を格納
	}

	solve(robot);

	cout<<ans;
	return 0;
}

Measured memory_bytes: 2420
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x;
        if(b >= 100) x = 1000 * a + b;
        else if(b >= 10) x = 100 * a + b; 
        else x = 10 * a + b;
        String ans = "No";
        for(int i = 1; i < 1000; i++)
            if(i * i == x)  ans = "Yes";
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
nums = [int(input()) for _ in range(5)]
l = list(map(int,filter(lambda x:x !="0",[str(n)[-1] for n in nums])))
r = [(n+9) // 10 for n in nums]
print(sum(r)*10-(10-min(l))) if len(l) != 0 else print(sum(r)*10)

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

int main(){
  int K,N;
  cin>>K>>N;
  vector<int>A(N);
  
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int cnt=0;
  int high=0;
  for(int i=0;i<N-1;i++){
    cnt +=(A.at(i+1)-A.at(i));
    if(A.at(i+1)-A.at(i)>=high)high=A.at(i+1)-A.at(i);
  }
  cnt+=(K-A.at(N-1)+A.at(0));
  int highest=max(high,K-A.at(N-1)+A.at(0));
  int ans=cnt-highest;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
a=nl()
cnt=0
for i in range(n):
  if (i+1)%2==1 and a[i]%2==1:
    cnt+=1

print(cnt)


Measured memory_bytes: 61724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}

int main(){
  ll n = getll(), A = getll(), B = getll();
  if((B - A) & 1){
    printf("%lld\n",min(A - 1 + B - 1,n - A + n - B) / 2 + 1);
  }else{
    printf("%lld\n",(B - A) / 2);
  }
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin >> a.at(i);
  sort(a.begin(),a.end());
  cout << a.at(n-1)-a.at(0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int yyyy, mm, dd;
	scanf("%d/%d/%d", &yyyy, &mm, &dd);

	if (yyyy >= 2019 && mm >= 5) {
		printf("TBD"); 
	}
	else {
		printf("Heisei");
	}

	return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAC solver = new AAC();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();

            if (str.equals("ABC")) {
                out.println("ARC");
            } else {
                out.println("ABC");
            }

        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.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 byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 25568
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int64_t h, w;
    cin >> h >> w;
    vector<vector<char>> vec(h, vector<char>(w));
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> vec.at(i).at(j);
        }
    }
    rep(i, h)
    {
        rep(k, 2)
        {
            rep(j, w)
            {
                cout << vec.at(i).at(j);
            }
            cout << endl;
        }
    }
    return 0;
}

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

int main(){
  
  string S;
  cin >> S;
  int x = S.size(), ans=0;
  
  for(int i=0; i<x/2; i++) {
    if(S.at(i) != S.at(x-1-i)) ans++;
  }

  cout << ans << endl;
  
}

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

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


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AizuOnlineJudgement.ITP1_2_D
{
	public static class Program
	{
		public static void Main (string[] args)
		{
			var WHxyr = Console.ReadLine ().Split (' ').Select (s => int.Parse (s)).ToArray ();
			var W = WHxyr[0];
			var H = WHxyr[1];
			var x = WHxyr[2];
			var y = WHxyr[3];
			var r = WHxyr[4];
			Console.WriteLine (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H ? "Yes" : "No");
		}
	}
}



Measured memory_bytes: 9400
N,M,K=map(int, input().split())
A = [0]
B = [0]
A += list(map(int, input().split()))
B += list(map(int, input().split()))
for i in range(N):
  A[i+1] += A[i]
for i in range(M):
  B[i+1] += B[i]
j = 0
ans = 0
for i in range(N,-1,-1):
  while (j <= M) and (A[i] + B[j] <= K):
    ans = max(ans, i+j)
#    print(i,j,A[i],B[j], A[i] + B[j], ans)
    j += 1
print(ans)



Measured memory_bytes: 40144
N, M = (int(i) for i in input().split())
uf = [-1]*N
def parent(v):
    if uf[v] < 0:
        return v
    else:
        uf[v] = parent(uf[v])
        return uf[v]

def size(v):
    return -uf[parent(v)]

def union(u, v):
    pu = parent(u)
    pv = parent(v)
    if pu != pv:
        res = uf[pv] * uf[pu] #適当な返り値
        uf[pv] += uf[pu]
        uf[pu] = pv
    else:
        res = 0
    return res

for i in range(M):
    X, Y, Z = (int(i) for i in input().split())
    union(X-1, Y-1)
ans = 0
for i in range(N):
    if uf[i] < 0:
        ans += 1
print(ans)

Measured memory_bytes: 6248
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string S;
  cin >> S;
  int len = S.length();
  for(int i = 0; i < len; i++){
    cout << 'x';
  }
  cout << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

int main() {
    for(;;){
        int e;
        int ans=1000000;
        cin >> e;
        if (e==0) {
            break;
        }
        for (int z=0;e-z*z*z>=0 ; z++) {
            for (int y=0; e-z*z*z-y*y>=0; y++) {
                ans=min(ans,e-z*z*z-y*y +y+z);
            }
        }
        cout<<ans<<"\n";
    }
}

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

int main(){
	int h,w;
	cin >> h >> w;
	int a,b;
	cin >> a >> b;
	int ans[1005][1005];
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
    		int t = (i<b)^(j<a);
    		ans[i][j] = t;
		}
	}
	
for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
    return 0;
}



Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  cin >> n;
  vector<int> a(n), g_wo_i(n, 1);
  vector<queue<int>> factor(n);
  vector<pair<int, int>> prime;
  for (auto &x : a) {
    cin >> x;
  }

  // g1は全要素の最大公約数
  int g1 = a.at(0);
  for (auto &x : a) {
    g1 = __gcd(g1, x);
  }
  for (auto &x : a) {
    x /= g1;
  }

  //√max(a)までの素数を生成
  int check_num = (int)sqrt(*max_element(ALL(a)));
  vector<bool> is_prime(check_num + 1, true);
  for (int i = 0; i <= check_num; i++) {
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (int j = i + 1; j <= check_num; j++) {
        if (j % i == 0) is_prime.at(j) = false;
      }
    }
  }
  REP(i, check_num + 1) {
    if (is_prime.at(i)) prime.push_back(make_pair(i, 0));
  }

  // aを素因数分解,素因数をfactorに格納
  REP(i, n) {
    for (auto &y : prime) {
      int cnt = 0;
      while (a.at(i) % y.first == 0) {
        cnt++;
        factor.at(i).push(y.first);
        a.at(i) /= y.first;
      }
      y.second = max(y.second, cnt);
      if (a.at(i) == 1) break;
    }
    if (a.at(i) != 1) {
      factor.at(i).push(a.at(i));
      prime.push_back(make_pair(a.at(i), 0));
    }
  }
  sort(ALL(prime));

  //一つを除いた最大公約数を求める
  for (auto y : prime) {
    int p = y.first;
    int p_n = y.second;
    REP(i, p_n) {
      int cnt = 0;
      int tmp;
      REP(j, n) {
        if (factor.at(j).empty()) {
          cnt++;
          tmp = j;
        } else {
          if (factor.at(j).front() == p) {
            factor.at(j).pop();
          } else {
            cnt++;
            tmp = j;
          }
        }
      }
      if (cnt == 1) {
        g_wo_i.at(tmp) *= p;
      }
    }
  }

  cout << g1 * *max_element(ALL(g_wo_i)) << "\n";
  return 0;
}


Measured memory_bytes: 68224
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    while (true) {
    int n1,n2; cin >> n1>>n2; int sum1 =0 ,sum2 = 0;
        if(!(n1+n2)) break;
        bool check = true;
    vi v1(n1,0); vi v2(n2,0);
    rep(i,n1) {cin >>v1[i];sum1+=v1[i];}
    rep(i,n2) {cin >>v2[i];sum2+=v2[i];}
    int bigger = max(sum1,sum2);
    int mini  = min(sum1,sum2); int ans1 = INF,ans2 = INF;
    rep(i,n1){
        rep(k,n2){
            int temp = abs(v1[i]-v2[k]);
            if(sum1+v2[k]-v1[i] == sum2+v1[i]-v2[k]){
                check = false;
                if(v1[i]+v2[k] < ans1+ans2){ans1 = i; ans2 = k;}
            }
        }
    }
        if(check) cout << -1 << endl;
        else cout << v1[ans1] << " " << v2[ans2] << endl;
        check = true;
    
}

  }

Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
long long d[100005];
int n,m;
bool vis[100005],use[100005];
vector<int>v[100005];
vector<int>e[100005];
void read(int& x)
{
	char c=getchar();
	x=0;
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
}
bool dfs(int fa)
{
	vis[fa]=1;
	use[fa]=1;
	for(int i=0;i<v[fa].size();i++)
	{
		int y=v[fa][i];
		int z=e[fa][i];
		if(d[y]>d[fa]+z)
		{
			if(vis[y])return 1;
			d[y]=d[fa]+z;
			if(dfs(y))return 1;
		}
	}
	vis[fa]=0;
	return 0;
}
int main()
{
	read(n);
	read(m);
	for(int i=1;i<=n;i++)
	{
		d[i]=200000000000ll;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		read(x);
		read(y);
		read(z);
		v[x].push_back(y);
		e[x].push_back(z);
		v[y].push_back(x);
		e[y].push_back(-z);
	}
	bool ok=0;
	for(int i=1;i<=n;i++)
	{
		if(!use[i])
		{
			d[i]=0;
			if(dfs(i))
			{
				ok=1;
			}
		}
	}
	if(ok)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 17024
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    int d[N];
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }
    
    sort(d, d + N);
    
    cout << d[N/2] - d[N/2-1] << endl;

    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#ifndef rd
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
const int mod=998244353;
//const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int a[1000005];
void solve() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	fr(i,1,n) {
		a[i]=s[i-1]-'0';
	}
	int noone=1;
	rep(i,1,n) {
		a[i]=abs(a[i]-a[i+1]);
		if(a[i]==1)
			noone=0;
	}
	n--;
	if(noone) {
		int lol=n-1;
		int temp=0;
		while(lol>0) {
			temp+=(lol>>1);
			lol>>=1;
		}
		int ans=0;
		fr(i,1,n) {
			if(a[i]==2) {
				int tol=i-1,tol2=n-i;
				int col=temp;
				while(tol>0) {
					tol>>=1;
					col-=tol;
				}
				while(tol2>0) {
					tol2>>=1;
					col-=tol2;
				}
				if(col==0) {
					ans^=2;
				}
			}
		}
		cout<<ans<<endl;
	} else {
		trace(1);
		int lol=n-1;
		int temp=0;
		while(lol>0) {
			temp+=(lol>>1);
			lol>>=1;
		}
		int ans=0;
		fr(i,1,n) {
			if(a[i]==1) {
				int tol=i-1,tol2=n-i;
				int col=temp;
				while(tol>0) {
					tol>>=1;
					col-=tol;
				}
				while(tol2>0) {
					tol2>>=1;
					col-=tol2;
				}
				if(col==0) {
					ans^=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(8);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


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

int main() {
  int N, x, sweets[100], counter = 0;
  cin >> N >> x;
  for (int i = 0; i < N; i++) cin >> sweets[i];
  sort(sweets, sweets + N);

  for (int i = 0; i < N; i++) {
    if ((x - sweets[i] < 0) || (i == N - 1 && x != sweets[i])) {
      break;
    }

    x -= sweets[i];
    counter++;
  }

  cout << counter << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
const ll mod = pow(10, 9) + 7;  
 
ll modpow(ll n, ll k) {
  ll value = 1;
  for(ll i = 0; i < k; i++) {
    value = value * (n % mod) % mod; 
  }
  return value;
}
 
int main() {
  ll N, ans;
  cin >> N;
  ans = (modpow(10, N) - 2 * modpow(9, N) + modpow(8, N)) % mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 3632
from itertools import combinations

N, K = map(int, input().split())
K_max = (N-1)*(N-2)//2
if K not in range(K_max + 1):
    print(-1)
else:
    edges = list(combinations(range(1, N+1), 2))[:N*(N-1)//2 - K]
    print(len(edges))
    for a, b in edges:
        print(a, b)

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

using namespace std;

int main()
{
    int a,b,x[900],i,k,m,n,sum,temp,flag=0;
    cin >> a >> b;
    for(i=0; ;)
    {
        for(k=1; k<10; k++)
        {
            sum=k;
            for(m=0; m<10; m++)
            {
                sum*=10;
                sum+=m;
                temp=sum;
                for(n=0; n<10; n++)
                {
                   sum*=10;
                   sum+=n;
                   sum*=10;
                   sum+=m;
                   sum*=10;
                   sum+=k;
                   x[i]=sum;
                   sum=temp;
                   i++;
                }
                sum/=10;
            }
        }
        break;
    }
    for(i=0;i<900;i++)
    {
        if(x[i]>=a && x[i]<=b)
            flag++;
    }
    cout << flag;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
	int N;
	std::vector<int> A, S, B;
	int result = 0;
	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		int t;
		std::cin >> t;
		A.push_back(t);
		B.push_back(t);
		if(i % 2 == 1) {
			S.push_back(t);
		}
	}
	if(N == 1) {
		std::cout << "0\n";
		return 0;
	}
	if(N == 2) {
		if(A[0] <= A[1]) {
			std::cout << "0\n";
		} else {
			std::cout << "1\n";
		}
		return 0;
	}
	std::sort(B.begin(), B.end());
	std::sort(S.begin(), S.end());
	int j = 0;
	for(int i = 0; i < S.size(); ++i) {
		while(S[i] != B[j]) {
			++j;
		}
		if(j % 2 == 0) {
			++result;
		}
	}
	std::cout << result << '\n';
	return 0;
}



Measured memory_bytes: 1472
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <random>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <bitset>

#pragma comment(linker, "/STACK:36777216")
using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

typedef long double ptype;

long long mod = /*27449*//*998244353*/ 1e9 + 7 /*1e9 + 9*/;
int inf = 1e9;
double eps = 1e-7;
long double pi = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ifstream in("input.txt");
ofstream out("output.txt");

void solve()
{
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i < n; i++)
	{
		ans += (n - 1) / i;
	}
	cout << ans;
}

int main()
{
	cout << setprecision(20) << fixed;
	cin.tie();
	cout.tie();
	clock_t t1 = clock();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
		//test();
	}
	//cout << (clock() - t1) * 1.0 / CLOCKS_PER_SEC;
	gg;
}

Measured memory_bytes: 3632
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
char buf[20];
void mypr(int n)
{
    int i;
    if (!n) { pc('0'); return; }
    i = 0; while (n) buf[i++] = n%10 + '0', n/=10;
    while (i--) pc(buf[i]); 
}
 
typedef struct { char c; int a; int id; } DATA;
 
int partition(DATA *a, int lo, int hi)
{
    int i, j;
    int key;
    DATA t;
     
    key = a[hi].a, i = lo-1;
    for (j = lo; j < hi; j++) {
        if (a[j].a <= key) i++, t = a[i], a[i] = a[j], a[j] = t;
    }
    t = a[++i], a[i] = a[hi], a[hi] = t;
    return i;
}
 
void quick_sort(DATA *a, int lo, int hi)
{
    int mi;
 
    if (lo < hi) {
        mi = partition(a, lo, hi);
        quick_sort(a, lo, mi-1);
        quick_sort(a, mi+1, hi);
    }
}
 
DATA a[100002];
 
int main()
{
    int N, i, f;
 
    N = in();
    for (i = 0; i < N; i++) {
        a[i].c = gc(), gc();
        a[i].a = in(), a[i].id = i;
    }
    quick_sort(a, 0, N-1);
    f = 0; for (i = 1; i < N; i++) {
        if (a[i-1].a == a[i].a && a[i-1].id > a[i].id) { f = 1; break; }
    }
    puts(f? "Not stable": "Stable");
    for (i = 0; i < N; i++) {
        pc(a[i].c), pc(' '), mypr(a[i].a), pc('\n');
    }
    return 0;
}



Measured memory_bytes: 2700
#include <stdio.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
int main(void){
	char c[2];
	int fr[2][1000],n,i,j,x,ans;
	while(scanf("%d",&n)){
		if(n==0)break;
		ans=0;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%1s",&c);
				if(c[0]=='.'){
					if(i==0 || j==0)fr[1][j]=1;
					else {
						x=MIN(MIN(fr[1][j-1],fr[0][j]),fr[0][j-1])+1;
						if(ans<x)ans=x;
						fr[1][j]=x;
					}
				}
				else fr[1][j]=0;
			}
			for(j=0;j<n;j++){fr[0][j]=fr[1][j];}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c=0;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
        if(s[i]==t[i])
            c++;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	long N, K;

	cin >> N >> K;

	long cnt = 0;
	for (long b = K + 1; b <= N; b++) {
		cnt += (N / b) * (b - K);
		if (N % b > 0 && N % b >= K) {
			if (K == 0) cnt += N % b - K;
			else cnt += N % b - K + 1;
		}
	}

	cout << cnt << endl;

	return 0;
}


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

int data[1000001];

int main(){
	int n;

	while (std::cin >> n, n){
		memset(data, 0, sizeof(data));

		int m;
		std::string str;
		std::cin >> m >> str;

		int res = 0;

		for (int i = m - 3; i >= 0; i--){
			if (str[i] == 'I'&&str[i + 1] == 'O'&&str[i + 2] == 'I')data[i] = data[i + 2] + 1;
		}

		for (int i = 0; i < m; i++){
			if (data[i] >= n)res++;
		}
		
		std::cout << res << std::endl;
	}

	return 0;
}

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

int n,m,dp[1001][1001];
char a[1001][1001];

int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        cin>>a[i][j];
    }
}
dp[1][1]=1;
for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        if(a[i][j]=='.')dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%1000000007;
    }
}
cout<<dp[n][m];
}


Measured memory_bytes: 5120
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
		if (abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
            printf("Yes\n");
		}
	else{
		printf("No\n");
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int k,R,L;
double p,e,t;

double dfs(double l,double r,int d){
	if(d==k){
		if(abs((l+r)/2-t)<e)return 1.0;
		else return 0.0;
	}else{
		double mid=(l+r)/2;
		double res;
		if(t<=mid){
			res=dfs(l,(l+r)/2,d+1)*p+dfs((l+r)/2,r,d+1)*(1-p);
		}else{
			res=dfs(l,(l+r)/2,d+1)*(1-p)+dfs((l+r)/2,r,d+1)*p;
		}
		return res;
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin>>k>>R>>L;
	cin>>p>>e>>t;
	double res=dfs(L,R,0);
	printf("%.10f\n", res);
	return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key, typename val>
using ordered_tree = 
  tree<key, val, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'001;

int n, m, k;

void solve(int test)
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << b + min(c, a + b + 1) << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
      solve(i);
  //cerr << endl << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <complex>
#include <cmath>
using namespace std;

typedef complex<double> xy_t;
xy_t P[110];

double cross_product(xy_t a, xy_t b)
{
    return (conj(a)*b).imag();
}

int main()
{
    int N=0;
    double x, y;
    while(scanf("%lf,%lf",&x, &y) != EOF)
        P[N++] = xy_t(x,y);
    double sum = 0.0;
    for(int i=0;i+2<N;i++)
    {
        xy_t a=P[0], b=P[i+1], c=P[i+2];
        sum += cross_product(b-a,c-a)/2;
    }
    printf("%.6f\n",abs(sum));
    return 0;
}


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

using namespace std;


int main() {
    long x,y,p;
    cin >> x >>y;
    if(x < y) swap(x,y);

    while(1){
        p = x % y;
        if (p == 0)break;

        swap (x,y);
        y = p;
    }
    cout << y << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int a, b, c, d;

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y, x%y);
}

int lcm(int x,int y){
    return x*y/gcd(x,y);
}

inline int can_div(int n){
    return n/c + n/d - n/lcm(c,d);
}

signed main(){
    cin >> a >> b >> c >> d;
    int ans = b - a + 1;
    ans -= can_div(b) - can_div(a-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

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

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

using namespace std;

int n;
int a[5];


int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = res * 1ll * x % mod;
		x = x * 1ll * x % mod, y >>= 1;
	}
	return res;
}

int b[N];

int Asum;


int sum_mask(int mask) {
	int res = 0, last = -1;
	rep(i, 0, 26) {
		if (mask & (1 << i)) res += i - last, last = i;
	}
	return res;
}

int sz;
pair <int, int> bits[30];

int mem[1 << 17];
int good(int mask) {
	if (~mem[mask]) return mem[mask];
	int last = -1, sve = mask;
	vector <int> bts;
	rep(i, 0, 26) {
		if (mask & (1 << i)) {
			bts.pb(i - last);
			last = i;
		}
	}
	int id = 1, sum = 0;
	while (sz(bts)) {
		sum += bts.back();
		bts.pp();
		if (sum > a[id]) return mem[sve] = -1;
		if (sum == a[id]) sum = 0, id++;
	}
	return mem[sve] = id;
}

int mem2[1 << 17];
void fix(int &mask) {
	mask &= (1 << 17) - 1;
	if (~mem2[mask]) {
		mask = mem2[mask];
		return;
	}


	int last = -1, sum = 0, sve = mask;
	sz = 0;
	rep(i, 0, 16) {
		if (mask & (1 << i)) {
			bits[++sz] = {i, i - last};
			sum += i - last;
			last = i;
		}
	}
	//reverse(bits + 1, bits + 1 + sz);
	while (good(mask) == -1 && sz > 0) {
		sum -= bits[sz].s;
		mask ^= (1 << bits[sz].f); 
		--sz;
	}
	mem2[sve] = mask;
	return;
	int now = mask;
	while (sum_mask(mask) > Asum) {
		per(i, 26, 0) {
			if (mask & (1 << i)) {
				mask ^= (1 << i);
				break;
			}
		}
	}
}

int dp[41][1 << 18][2];
int pw[41];
inline int calc(int v = 1, int mask = 0, bool f = 0) {
	fix(mask);
	if (!f && good(mask) == 4) f = 1;
	if (f) return pw[n - v + 1];
	if (v > n) {
		return f;
	}	
	if (~dp[v][mask][f]) return dp[v][mask][f];
	int res = 0;
	rep(i, 1, 10) {
		int nmask = (mask << i) ^ (1 << (i - 1));
		if (i > 7) nmask = 0;
		res += calc(v + 1, nmask, f);
		if (res >= mod) res -= mod;
	}
	return dp[v][mask][f] = res;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
		freopen ("E.out", "w", stdout);
	#endif
	Kazakhstan
	cin >> n;
	rep(i, 1, 3) cin >> a[i], Asum += a[i];
	a[4] = a[0] = inf;
	memset(dp, -1, sizeof(dp));
	memset(mem, -1, sizeof(mem));
	memset(mem2, -1, sizeof(mem2));
	pw[0] = 1;
	rep(i, 1, n) {
		pw[i] = pw[i - 1] * 1ll * 10 % mod;
	}
	int ans = calc();
	cout << ans << nl;
	cerr << ans << nl;
	//cout << (calc(1, 0, 0, 0) + calc(1, 1, 10, 0)) % mod;
	ioi
}


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

namespace ConsoleApplication1
{   
    class Program
    {
           static void Main(string[] args) {
            while(true)
            {

                string sss = Console.ReadLine();
                if (sss== null)
                    return;
                int[] sss2 = sss.Split().Select(int.Parse).ToArray();
                int  a = sss2[0]+sss2[1];  string b = a.ToString();      Console.WriteLine("{0}",b.Length);

            }
        }
    }
    }

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

const int maxn = 100005;
int sex[maxn], n, l, r, mid;
char s[maxn];

void ask(int x) {	
	printf("%d\n", x);
	fflush(stdout);
	scanf("%s", s);
	if (s[0] == 'V') exit(0);
	if (s[0] == 'M') sex[x] = 1;
	else sex[x] = 0;
}

bool check(int l, int m, int r) {
	ask(m);
	if (((m - l) & 1) ^ sex[l] ^ sex[m]) return 1;
	if (((r - m) & 1) ^ sex[r] ^ sex[m]) return 0;
	return 1;
}

int main() {
	scanf("%d", &n);
	ask(l = 0); ask(r = n - 1);
	while (l + 1 < r) {
		mid = (l + r) >> 1;
		if (check(l, mid, r)) r = mid;
		else l = mid;
	}
	return 0;
}


Measured memory_bytes: 976
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
#define inf 1145141919ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d,e,f,g;
int dx[]={0,-1,0,1,0};
int i,j,k,n;
struct A{

};
int q[100][100];
bool pri(int u){
	int x;
	for(x=2;x*x<=u;x++)
		if(u%x==0)
			return false;
	return true;
}
signed main(){
	int u,v;
	cin>>a>>b>>c;
	cin>>u;
	for(i=1;i<a;i++){
		cin>>v;
		n+=min((v-u)*b,c);
		u=v;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        /* code */
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n -1; i++)
    {
        /* code */
        if(p[i-1] < p[i] &&  p[i] < p[i+1]){
            ans++;
        }else if(p[i+1] < p[i] &&  p[i] < p[i-1]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int cnt[100005];
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		cnt[a-1]++;
		cnt[a]++;
		cnt[a+1]++;
	}
	int ans=-1;
	for(int i=0;i<=1e5;i++) ans=max(ans,cnt[i]);
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3940
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        String answer = null;
        if (S.equals("Sunny")) {
            answer = "Cloudy";
        } else if (S.equals("Cloudy")) {
            answer = "Rainy";
        } else if (S.equals("Rainy")) {
            answer = "Sunny";
        }
        System.out.println(answer);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  ll k = N / (A+B);
  ll n = N-k*(A+B);
  cout << k*A+min(n,A) << endl;
  return 0;
}

Measured memory_bytes: 256