akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      String[] input = sc.nextLine().split(" ");
      int a = Integer.parseInt(input[0]);
      int b = Integer.parseInt(input[1]);
      
      System.out.println( ( a + b )/ 2);
   }
}


Measured memory_bytes: 26264
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}



int main()
{
        ll N;
        cin >> N;

        if (N == 0) {
                cout << 0 << endl;
                return 0;
        }

        string ans;
        while (N != 0) {
                ll r = N % 2;
                if (r < 0) r += 2;
                char tmp = r + '0';
                ans += tmp;

                N -= r;
                N /= -2;
        }

        reverse(all(ans));
        cout << ans << endl;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     
     int i = 1;
     
     while(true){
         int x = scan.nextInt();
         
             if (x == 0){
         break;
     }
         System.out.println("Case "+i+": "+x);
    i++;
     }
    }
}


Measured memory_bytes: 41664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int (i) = 0; (i) < (N); (i)++)

int main(){

    long long int N, K;
    cin >> N >> K;

    long long int ans = min(N%K, abs(N%K-K));

    cout << ans << endl;

    return 0;
}

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

int main() {
int a, b = 5;

while(1) {
cin >> a >> b;
if (a ==0 && b ==0) {
break;
}
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
if (i == 0 || j == 0 || i == a - 1 || j == b - 1) {
cout << "#";
}else {
cout << ".";
}}cout << endl;
}cout << endl;
}return 0;
}


Measured memory_bytes: 3064
from collections import deque

N,M = map(int,input().rstrip().split(" "))
A = [[] for i in range(N)]
closest = [-1 for i in range(N)]
closest[0] = 0
ans = [-1 for i in range(N)]
que = deque([[0,0]])
for i in range(M):
    q,qq = map(int,input().rstrip().split(" "))
    A[q - 1].append(qq -1)
    A[qq - 1].append(q - 1)
while len(que) != 0:
    for i in A[que[0][0]]:
        if closest[i] == -1:
            closest[i] = que[0][1] + 1
            ans[i] = que[0][0] + 1
            que.append([i,que[0][1] + 1])
    que.popleft()
print("Yes")
for i in range(N - 1):
    print(ans[i + 1])

Measured memory_bytes: 40720
#include<stdio.h>
int main(){
  int H,W,h,w,i=1,j;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  if(H%h||W%w){
    puts("Yes");
    for(;i<=H;++i,puts(""))
      for(j=1;j<=W;++j)
        printf("%d ",(i%h||j%w)?1000:-1000*(h*w-1)-1);
  }else puts("No");
  return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
long long a[200005];
int main(){ 
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	long long fr=a[1];
	long long sum=0;
	for(int i=2;i<=n;i++){
		if(a[i]<fr){
			sum+=fr-a[i];
			a[i]+=fr-a[i];
		}
		fr=a[i];
	}
	printf("%lld",sum);
return 0;
} 

Measured memory_bytes: 5380
#include <iostream>
#include <string>

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

	int ans = 100000;
	for (int i = 0; i <= s.size() - t.size(); ++i) {
		int cnt = 0;
		for (int j = 0; j < t.size(); ++j)
			if (s[i + j] != t[j])
				++cnt;

		if (cnt < ans)
			ans = cnt;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define rev(a) reverse(all(a))
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mod 1000000007
#define inf 100000000
#define limit 200005
#define minval -100000000000000000
#define maxval 1000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 
void input()
{
    lli n, x, t;
    cin >> n >> x >> t;
    lli ans = t * ceil(1.0 * n/x);
    cout << ans << '\n';
}
int main()
{
   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   */
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
const int N = 1e5+5;
int arr[N],n;
int dp[N];
int INF=0x3f3f3f3f;
int solve (int i){
if(i>=n-1)return 0;
int &ret=dp[i];
if(~ret)return ret;
int cost1=abs(arr[i]-arr[i+1]);
int cost2=abs(arr[i]-arr[i+2]);
ret=min(solve(i+1)+cost1,solve(i+2)+cost2);
return ret;
}
int main(){
    IO;
    memset(dp,-1,sizeof(dp));
    memset(arr,INF,sizeof(arr));
    cin>>n;
    for(int i=0;i<n;++i)cin>>arr[i];
    cout<<solve(0);
}


Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(100000)

V,E = map(int, input().split())
#??£??\????????????D1??¨?????????D2???????????????
D1 = [[] for _ in range(V)]
D2 = [[] for _ in range(V)]
for _ in range(E):
    s,t = map(int, input().split())
    D1[s].append(t)
    D2[t].append(s)

stuck = []
color = [0 for _ in range(V)]
def dfs1(s):
    color[s] = 1
    for next in D1[s]:
        if color[next] == 0:
            dfs1(next)
    stuck.append(s)
    return

for i in range(V):
    if color[i] == 0:
        dfs1(i)

color = [0 for _ in range(V)]
def dfs2(s, cnt):
    color[s] = cnt
    for next in D2[s]:
        if color[next] == 0:
            dfs2(next, cnt)
    return

stuck = stuck[::-1]
cnt = 0
for i in stuck:
    if color[i] == 0:
        cnt += 1
        dfs2(i, cnt)

Q = int(input())
for _ in range(Q):
    u,v = map(int, input().split())
    if color[u] == color[v]:
        print(1)
    else: print(0)

Measured memory_bytes: 19244
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define Point pair<double, double>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<int> h(n);
  rep(i, n) {
    cin >> h[i];
  }

  int cnt = 0;
  while(true) {
    bool done = false;
    bool flag = false;
    rep(i, n) {
      if (!flag && h[i] > 0) {
        cnt++;
        done = true;
        flag = true;
        h[i]--;
      } else if (flag && h[i] > 0) {
        h[i]--;
      } else if (h[i] == 0) {
        flag = false;
      }
    }
    if (!done) {
      break;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#include <set>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

int a[22222];
int b[22222];
int main(void){
  int n,x;
  vector<int> p;
  cin>>n;
  for(int i=1;i<=n;i++){
    a[i]=i*20000;
    b[n-i+1]=i*20000;
  }
  for(int i=1;i<=n;i++){
    cin>>x;
    a[x]+=i;
  }
  for(int i=1;i<=n;i++) cout<<a[i]<<" ";
  cout<<endl;
  for(int i=1;i<=n;i++) cout<<b[i]<<" ";
  cout<<endl;

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

pair<int, int> solve(string s) {
	int tot = 0;
	int mn = 0;
	for (auto x : s) {
		if (x == '(') tot++;
		else tot--;
		mn = min(mn, tot);
	}
	return {tot, mn};
}

string rp(string s) {
	reverse(s.begin(), s.end());
	for (auto &t : s) {
		if (t == '(') t = ')';
		else t = '(';
	}
	return s;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
		
	int n;
	cin >> n;
	vector<string> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<pair<int, int>> pb;
	vector<pair<int, int>> nb;
	for (int i = 0; i < n; i++) {
		int tot, mn;
		tie(tot, mn) = solve(a[i]);
		if (tot >= 0) {
			pb.push_back({mn, i});
		} else {
			string s = rp(a[i]);
			tie(tot, mn) = solve(s);
			nb.push_back({mn, i});
		}
	}
	sort(pb.rbegin(), pb.rend());
	sort(nb.rbegin(), nb.rend());
	string res;
	for (auto t : pb) {
		res += a[t.second];
	}
	reverse(nb.begin(), nb.end());
	for (auto t : nb) {
		res += (a[t.second]);
	}
	{
		int tot, mn;
		tie(tot, mn) = solve(res);
		if (tot == 0 && mn >= 0) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;

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; }
template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}
template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}
template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}


int main()
{
	ll h,a;
	cin >> h >> a;
	ll ans = h/a;
	if(h%a > 0)ans++;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long LL;
const int MX = 10005, MP = 2005;
const int MN = 505;

bool ip[MX];
int p[MP], pc;
inline void Sieve(int N) {
	for (int i = 2; i <= N; ++i) {
		if (!ip[i]) p[++pc] = i;
		for (int j = 1, k; j <= pc; ++j) {
			if ((k = p[j] * i) > N) break;
			ip[k] = 1;
			if (i % p[j] == 0) break;
		}
	}
}

int N, A[MN], B[MN];

int main() {
	Sieve(10000);
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) A[i] = p[i & 1 ? i / 2 + 1 : N + N - i / 2 + 1];
	for (int i = 1; i <= N; ++i) B[i] = p[(i & 1 ? N - i / 2 : N + i / 2) + (N & 1)];
	A[0] = A[N + 1] = B[0] = B[N + 1] = 1;
	for (int i = 1; i <= N; ++i, puts(""))
		for (int j = 1; j <= N; ++j)
			if ((i + j) % 2) printf("%lld ", (LL)A[(i + j) / 2] * A[(i + j) / 2 + 1] * B[(N + i - j + (N & 1)) / 2] * B[(N + i - j + (N & 1)) / 2 + 1] + 1);
			else printf("%d ", A[(i + j) / 2] * B[(N + i - j + (N & 1)) / 2]);
	return 0;
}

Measured memory_bytes: 3072
import sys
from collections import Counter
sys.setrecursionlimit(10 ** 6)

def main():
    N = int(input())
    V = list(map(int, sys.stdin.readline().rstrip().split()))
    c0 = Counter([v for i, v in enumerate((V)) if i % 2 == 0])
    c1 = Counter([v for i, v in enumerate((V)) if i % 2 == 1])

    if c0.most_common()[0][0] == c1.most_common()[0][0]:
        if len(c0.most_common()) == 1:
            m = c1.most_common()[0][1]
            print(m)
        elif len(c1.most_common()) == 1:
            m = c0.most_common()[0][1]
            print(m)
        else:
            m = max(c0.most_common()[0][1] + c1.most_common()[1][1], c0.most_common()[1][1] + c1.most_common()[0][1])
            print(N - m)
    else:
        m = c0.most_common()[0][1] + c1.most_common()[0][1]
        print(N - m)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18648
#include<iostream>
using namespace std;
int main(){
int c[4][4]={};
int a[4]={};
int b[4];

for (int i = 1; i <4; i++) {
  std::cin >> c[i][1]>>c[i][2]>>c[i][3];
}

int ans=0;

for (int i = 0; i <=100 ; i++) {
  a[1]=i;
  b[1]=c[1][1]-i;
  if(b[1]<0) {continue;}
  b[2]=c[1][2]-i;
  if(b[2]<0) {continue;}
  b[3]=c[1][3]-i;
  if(b[3]<0) {continue;}

  for (a[2] = 0; a[2] <= 100; a[2]++) {
    if(c[2][1]-b[1]==a[2] && c[2][2]-b[2]==a[2] && c[2][3]-b[3]==a[2])break;
  }

  if(a[2]!=101){
    for ( a[3] = 0; a[3] <= 100; a[3]++) {
      if(c[3][1]-b[1]==a[3] && c[3][2]-b[2]==a[3] && c[3][3]-b[3]==a[3])break;
    }
    if(a[2]!=101 && a[3]!=101){ans=1;break;}
  }

}

if(ans==1)std::cout << "Yes" << '\n';
else std::cout << "No" << '\n';

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int K;
  cin >> K;
  cout << K/2 * (K-K/2) << endl;
  return 0;
}


Measured memory_bytes: 256
import Prelude ()
import Data.String
import GHC.Base
import GHC.Num
import GHC.Real
import System.IO
import Text.Read

import Data.List (sort)
--import Data.Vector.Mutable (MVector(..))
import Data.Vector.Unboxed

main :: IO ()
main = do
    l1 <- getLine
    l2 <- getLine
    let l = fmap read $ words l2 :: [Int]
        v = fromList $ sort l

    print $ f v

f v = g v n 0 1 0
    where n = length v

g v n i j ans
    | i == n = ans
    | j == n = g v n (i+1) (i+2) ans
    | otherwise = g v n i (j+1) $ ans + length (h v (a+b) 0 n) - j - 1
        where a = unsafeIndex v i
              b = unsafeIndex v j

h v x start end
    | start == end = unsafeTake start v
    | otherwise = if unsafeIndex v mid < x then h v x (mid + 1) end else h v x start mid
        where mid = (start + end) `div` 2

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int l[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << l[k-1] << endl;
    return 0;
}

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

std::vector<int> v[100005];
struct Data
{
    int parent_index, depth;
    std::string type;
};
std::map<int, Data> data;
void dfs(const int index, const int parent_index, const int depth)
{
    int size = v[index].size();
    
    Data d;
    d.parent_index = parent_index;
    d.depth = depth;
    if(d.parent_index == -1) d.type = "root";
    else if(size == 1) d.type = "leaf";  // 接点が親だけ
    else d.type = "internal node";
    data[index] = d;
    
    for(int i=0; i<size; i++){
        int child = v[index][i];
        if(child == parent_index) continue;
        dfs(child, index, depth+1);
    }
}

int main()
{
    int n;
    cin >> n;
    std::vector<int> childlist;
    for(int i=0; i<n; i++){
        int id, k, c;
        cin >> id >> k;
        for(int j=0; j<k; j++){
            cin >> c;
            v[id].push_back(c);
            v[c].push_back(id);
            childlist.push_back(c);  // root検索用
        }
    }
    int root = -1;
    for(int i=0; i<n; i++){
        std::vector<int>::iterator itr;
        itr = std::find(childlist.begin(), childlist.end(), i);
        if(itr == childlist.end()){
            root = i;
        }
    }
    if(root == -1) cout << "root not found." << endl;
    dfs(root, -1, 0);
    
    for(int index=0; index<n; index++){
        
        Data d = data[index];
        cout << "node " << index << ": parent = " << d.parent_index
            << ", depth = " << d.depth << ", " << d.type << ", [";
        
        int size = v[index].size();
        if(index != root){
            std::vector<int>::iterator itr;
            itr = find(v[index].begin(), v[index].end(), d.parent_index);
            v[index].erase(itr); size--;
        }
        for(int i=0; i<size; i++){
            int child = v[index][i];
            //if(child == d.parent_index) continue;
            cout << child;
            if(i != size-1) cout << ", ";
        }
        cout << "]" << endl;
    }
}



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

int main(){
	int p,q,r;
  	cin >> p >> q >> r;
  
  	if(p >= q && p >= r){
    cout << q+r << endl;
    }else if(q >= p && q >= r){
    cout << p+r << endl;
    }else if(r >= p && r >= q){
     cout << p+q << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(int(x) for x in input().split())
ans = 0
for i in range(N):
  x = 0
  A = list(int(x) for x in input().split())
  for j in range(M):
    x += A[j]*B[j]
  if x + C > 0:
    ans += 1
print(ans)
  

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

using namespace std;
#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  int a,b;
  cin >> a >> b;
  // int x8s, x8e;
  // int x10s, x10e;
  // x8s = ceil((double)(a * 100 / 8));
  // x8e = (a + 1) * 100 / 8;
  // x10s = ceil((double)(b * 100 / 10));
  // x10e = (b + 1) * 100 / 10;
  
  
  // // cout << x8s << x8e << x10s << x10e << endl;
  
  // if(x8e > x10s){
  //   cout << x10s << endl;
  // }else
  // {
  //   cout << -1 << endl;
  // }
  int x8;
  int x10;
  for(int i = 0; i < 1009; i++){
    x8 = i * 0.08;
    x10 = i * 0.1;
    if(x8 == a && x10 == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,m;
bool check(int x, int y){
    if(x >=0 and y >=0 and x < n and y < m) return true;
    return false;
}
signed main(){
    ios_base::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
    int a,b,n; cin>>a>>b>>n;
    //cout<<a<<" "<<b<<" "<<n<<endl;
    int x=a; 
    vector<int> v ;
    if(n >= b){
        int an=(a*(b-1))/b - (a*((b-1)/b));
         cout<<an<<endl;
    }
    else{
          int an=(a*(n))/b - (a*((n)/b));
         cout<<an<<endl;  
    }
    
    
    

    
    
}

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	string s; getline(cin, s);
	rep(i, s.size()) {
		string t = s.substr(i, 5);
		if(t == "apple") s.replace(i, 5, "peach");
		if(t == "peach") s.replace(i, 5, "apple");
	}
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <complex>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

typedef complex<double> Point;
const static double EPS = 1e-12;

class State {
public:
  int bits;
  int cost;
  State(int bits,int cost) :
    bits(bits), cost(cost) {}
  bool operator<(const State& s) const {
    return cost < s.cost;
  }
  bool operator>(const State& s) const {
    return cost > s.cost;
  }
};

int dp[1<<15];

int main(){
  int bit_length;
  int run_length;
  while(~scanf("%d %d",&bit_length,&run_length)){
    int init = 0;
    for(int i = 0; i < bit_length; i++){
      int bit;
      scanf("%d",&bit);
      if(bit > 0) init |= (1<<i);
    }
    
    vector<int> width;
    for(int i = 0; i < run_length; i++){
      int run;
      scanf("%d",&run);
      width.push_back(run);
    }

    priority_queue<State,vector<State>,greater<State> > que;
    que.push(State(init,0));
    memset(dp,0x3f,sizeof(dp));
    dp[init] = 0;

    while(!que.empty()){
      State s = que.top();
      que.pop();
      for(int i = 0; i + 1 < bit_length; i++){
        int j = i + 1;
        int next = s.bits;
        if((s.bits & (1<<i)) && !(s.bits & (1<<j))){
          next &= ~(1<<i);
          next |= (1<<j);
          if(dp[next] > s.cost + 1){
            dp[next] = s.cost + 1;
            que.push(State(next,s.cost + 1));
          }
        }
        else if(!(s.bits & (1<<i)) && (s.bits & (1<<j))){
          next &= ~(1<<j);
          next |= (1<<i);
          if(dp[next] > s.cost + 1){
            dp[next] = s.cost + 1;
            que.push(State(next,s.cost + 1));
          }
        }
      }
    }
    
    int res = INF;
    for(int S = 0; S < (1<<bit_length); S++){
      int offset = 0;
      bool isok = true;
      for(int i = 0; i < width.size(); i++){
        if(offset > 0 && ((S >> offset) & 1) == ((S >> (offset-1)) & 1)){
          isok = false;
          break;
        }
        for(int j = offset; j + 1 < offset + width[i]; j++){
          if(((S >> j) & 1) != ((S >> (j+1)) & 1)){
            isok = false;
            break;
          }
        }
        offset += width[i];
        if(!isok) break;
      }

      if(isok){
        res = min(dp[S],res);
      }
    }

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

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

int main(){
  long long N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (long long i = 0; i < N; i++){
    cin >> h[i];
  }
  
  int ans = 0;
  for (long long i = 0; i < N; i++){
    if (h[i] >= K){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int i,j,k;
  int K, N; cin >> K >> N;
  int A[N]; rep(i,N){cin >> A[i];}
  int B[N]; rep(i,N-1){B[i] = A[i+1] - A[i];} B[N-1] = K - A[N-1] + A[0];
  int max = 0;
  rep(i,N){if(max < B[i]){max = B[i];}};
  cout << K - max << "\n";

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
  char a[3];
  int i,b=0,c=0,d=0;
  
  scanf("%s",a);
  
  for(i=0;i<3;i++){
   if(a[i]=='a')  b++;
      else if (a[i]=='b')  c++;
         else if (a[i]=='c')  d++;
  }

  if(b==1&&c==1&&d==1)
       printf("Yes\n");
     else printf("No\n");           
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){
    int n,a,b,ans;
    cin>>n>>a>>b;
    if(n<a+b){
        ans=a+b-n;
    }else{
        ans=0;
    }
    
    cout<<min(a,b)<<" "<<ans<<endl;
    
    
 
return 0;
}


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

int main() {
    int W, H, N;
    cin >> W >> H >> N;

    vector<int> x, y, a;
    x = vector<int>(N, -1);
    y = vector<int>(N, -1);
    a = vector<int>(N, -1);
    rep(i,N){
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }

    int e = W, w = 0, n = H, s = 0;
    rep(i, N){
        if(a.at(i)==1){
            if(w<x.at(i)) w = x.at(i);
        }
        else if(a.at(i) == 2){
            if(e>x.at(i)) e = x.at(i);
        }
        else if(a.at(i) == 3){
            if(s<y.at(i)) s = y.at(i);
        }
        else if(a.at(i) == 4){
            if(n>y.at(i)) n = y.at(i);
        }
    }

    //cout << e << w << n << s << endl;

    if(w >= e || n <= s){
        cout << 0 << endl;
        return 0;
    }
    else{
        cout << (e-w)*(n-s) << endl;
        return 0;
    }
}


Measured memory_bytes: 256
use proconio::{fastout, input};

use std::cmp::max;

#[fastout]
fn main() {
    input! { n: usize }
    const INF: i64 = 1_000_000_000_000;
    let mut t = (-INF, -INF, -INF, 0, -INF, -INF);
    for _ in 0..n {
        input! { a: i64 }
        t = (t.3 + a, t.4 + a, t.5 + a, t.0, max(t.3, t.1), max(t.4, t.2));
    }
    if n % 2 == 1 {
        println!("{}", max(t.2, t.4));
    } else {
        println!("{}", max(t.1, t.3));
    }
}


Measured memory_bytes: 4324
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int A, B;
    cin>>A>>B;
    rep(i, 3){
        int j=i+1;
        if(j!=A && j!= B) cout<<j<<endl;
    }
    return 0;
}


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

int main(){
    int k, n;
    std::cin >> k >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }
    std::sort(a,a+n);
    int max = k - (a[n-1]-a[0]);
    for (int i = 1; i < n; ++i) {
        max = std::max(max, a[i]-a[i-1]);
    }
    std::cout << k-max;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  char b;
  cin >> b;
  if(b == 'A') {
    cout << "T" << endl;
  }
  if(b == 'T') {
    cout << "A" << endl;
  }
  if(b == 'C') {
    cout << "G" << endl;
  }
  if(b == 'G') {
    cout << "C" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
P_cum = [0] * N
P_cum[0] = P[0]
for i in range(1, len(P)):
    P_cum[i] = P_cum[i - 1] + P[i]

me = 0
for i in range(N - K + 1):
    if i >= 1:
        e = (P_cum[i + K - 1] - P_cum[i - 1] + K) / 2
    else:
        e = (P_cum[i + K - 1] + K) / 2
    me = max(e, me)

print(me)

Measured memory_bytes: 25188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
        int n, x, a;
        vector<int> va, tmp;
        long long ans = 0;
        cin >> n >> x;
        for (int i = 0; i < n; i++) {
                cin >> a;
                va.push_back(a);
                tmp.push_back(a);
        }
        if (va[0] > x)
                va[0] = x;
        for (int i = 0; i < n - 1; i++) {
                if (va[i] + va[i+1] > x)
                        va[i+1] = x - va[i];
        }
        for (int i = 0; i < n; i++)
                ans += tmp[i] - va[i];

        cout << ans << endl;

        return 0;
}



Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

const int N = 3;
const int M = 2000;
string strs[N];
bool can[N][N][2*M+1];

bool cmp(char a, char b) {
	return a == '?' || b == '?' || a == b;
}

void calc(int a, int b) {
	for (int i = 0; i <= 2*M; ++i) {
		can[a][b][i] = 1;
		for (int j = 0; j < strs[b].size() && i + j < strs[a].size(); ++j) {
			if (! cmp(strs[a][i+j], strs[b][j])) can[a][b][i] = 0;
		}
	}
}

int solve(int a, int b, int c) {
	// a starts first, then b, then c
	// Loop how much they overlap.
	int res = 3 * M;
	for (int d01 = 0; d01 <= strs[a].size(); ++d01) {
		if (! can[a][b][d01]) continue;

		for (int d12 = 0; d12 <= max(strs[a].size() - d01, strs[b].size()); ++d12) {
			if (! can[b][c][d12]) continue;

			int d02 = d01 + d12;
			if (! can[a][c][d02]) continue;

			int off = max((int)strs[a].size(), (int)max(d01 + strs[b].size(), d02 + strs[c].size()));
			res = min(res, off);
		}
	}
	return res;
}

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

	cin >> strs[0] >> strs[1] >> strs[2];
	for (int a = 0; a < 3; ++a) {
		for (int b = 0; b < 3; ++b) {
			if (a != b) calc(a, b);
		}
	}

	int res = 3 * M;
	vector<int> perm = {0, 1, 2};

	do {
		res = min(res, solve(perm[0], perm[1], perm[2]));
	} while (next_permutation(perm.begin(), perm.end()));

	cout << res << '\n';
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int min, in, out, inside, ans;
    boolean er = false;

    void run(){
	min = sc.nextInt();
	inside = sc.nextInt();
	ans = inside;
	for(int i=0; i<min; i++){
	    in = sc.nextInt();
	    out = sc.nextInt();
	    inside = inside + in - out;
	    if(inside<0){
		er = true;
		ans = 0;
	    }
	    if(!er && ans<inside)
		ans = inside;
	}
	System.out.println(ans);
    }
}

Measured memory_bytes: 40436
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
T = [INT() for i in range(N)]

def many_lcm(l):
    tmp = l[0]
    for i in range(1, len(l)):
        tmp = tmp * l[i]//gcd(tmp, l[i])
    return tmp

print(many_lcm(T))


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

#define ll long long

ll maxcoin(vector<ll> &A) {
    int n = A.size();
    vector<vector<pair<ll, ll> > > dp(n, vector<pair<ll, ll> >(n));
    for(int i=0; i<n; i++)
    {
        dp[i][i].first = A[i];
        dp[i][i].second = 0;
    }
    for(int i=1; i<n; i++)
    {
        for(int j=0; j+i<n; j++)
        {
            pair<ll, ll> &r = dp[j][j+i];
            if(A[j]+dp[j+1][j+i].second > A[j+i]+dp[j][j+i-1].second)
            {
                r.first = A[j]+dp[j+1][j+i].second;
                r.second = dp[j+1][j+i].first;
            }
            else
            {
                r.first = A[j+i]+dp[j][j+i-1].second;
                r.second = dp[j][j+i-1].first;
            }
        }
    }
    return dp[0][n-1].first - dp[0][n-1].second;
}


int main()
{
	ll n;
	cin >> n;
	vector<ll> A(n);
	for(int i=0; i<n; i++) cin >> A[i];
	cout <<  maxcoin(A);
	
	
}

Measured memory_bytes: 142848
def main():
    k=int(input())
    x,y=map(int,input().split())

    def calc(x,y,k):
        x_sign,y_sign,xy_swap=1,1,0
        if x<0:
            x_sign=-1
            x*=-1
        if y<0:
            y_sign=-1
            y*=-1
        if x<y:
            xy_swap=1
            x,y=y,x
        ans=[]
        d=x+y
        cnt=d//k
        #距離がkで割り切れるとき
        def pattern_0(x,y):
            x_now,y_now=0,0
            ans=[]
            cnt=(x+y)//k
            j=cnt
            for i in range(cnt):
                if x_now+k<x:
                    x_now+=k
                    ans.append([x_now,y_now])
                else:
                    y_now=k-x+x_now
                    x_now=x
                    ans.append([x_now,y_now])
                    j=i+1
                    break
            return ans+[[x,y_now+(i-j+1)*k] for i in range(j,cnt)]

        #cnt==0のとき
        #dが偶数のとき
        def pattern_1_even(x,y):
            return [[(x+y)//2,(x+y)//2-k],[x,y]]
        #dが奇数のとき
        def pattern_1_odd(x,y):
            if k%2==0:
                return -1
            return [[k,0]]+[[-i+k,j] for i,j in pattern_1_even(k-x,y)]

        #cnt>=1のとき
        #dが偶数のとき
        def pattern_2_even(x,y):
            cnt=(x+y)//k
            if k%2==0 or cnt%2==1:
                l=(k*(cnt+1)-(x+y))//2
            else:
                l=(k*(cnt+2)-(x+y))//2
            if cnt!=1:
                temp=[min(2*(k-l),x),max(2*(k-l)-x,0)]
                return [[k-l,-l],temp]+[[i+temp[0],j+temp[1]] for i,j in pattern_0(x-temp[0],y-temp[1])]
            else:
                return [[k-l,-l],[x,y]]
            
        #dが奇数のとき
        def pattern_2_odd(x,y):
            cnt=(x+y)//k
            if k%2==0:
                return -1
            else:
                if (x-k+y)<k:
                    if x-k<y:
                        return [[k,0]]+[[j+k,i] for i,j in pattern_1_even(y,x-k)]
                    else:
                        return [[k,0]]+[[i+k,j] for i,j in pattern_1_even(x-k,y)]
                if x-k<y:
                    return [[k,0]]+[[j+k,i] for i,j in pattern_2_even(y,x-k)]
                else:
                    return [[k,0]]+[[i+k,j] for i,j in pattern_2_even(x-k,y)]
        if d%k==0:
            temp=pattern_0(x,y)
        elif cnt==0:
            if d%2==0:
                temp=pattern_1_even(x,y)
            else:
                temp=pattern_1_odd(x,y)
        else:
            if d%2==0:
                temp=pattern_2_even(x,y)
            else:
                temp=pattern_2_odd(x,y)
        if temp==-1:
            return -1
        if xy_swap:
            temp=[[j*x_sign,i*y_sign] for i,j in temp]
        else:
            temp=[[i*x_sign,j*y_sign] for i,j in temp]
        return temp

    def out(x,y,k):
        temp=calc(x,y,k)
        if temp==-1:
            print(-1)
            return 0
        print(len(temp))
        for i in temp:
            print(*i)

    out(x,y,k)
main()

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

int main(){
	double x1,y1,x2,y2,xq,yq,x,y;
	while(0<=scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)){
		x=( (x2-x1)*(x2-x1)*xq+(x2-x1)*(y2-y1)*(yq-y1)+(y2-y1)*(y2-y1)*x1 )/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
		y=(y2-y1)*( (x2-x1)*xq+(y2-y1)*(yq-y1)-(x2-x1)*x1 )/ ((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))+y1;
		printf("%lf %lf\n",2*x-xq,2*y-yq);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000
#define PI           acos(-1.0)

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    //scan(n);
    cin>>n;
    ll A[n], B[n], C[n-1];

    f0(i,n)
    {
        cin>>A[i];
    }

    f0(i,n)
    {
        cin>>B[i];
    }

    f0(i,n-1)
    {
        cin>>C[i];
    }
    f0(i,n)
    {
        if(i>0)
        {
            if(A[i-1]==(A[i]-1))
            {
                ans+=B[A[i]-1];
                ans+=C[A[i]-2];
            }
            else
            {
                ans+=B[A[i]-1];
            }
        }
        else
        {
            ans+=B[A[i]-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <map>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    if (s[s.size()-1] == 's')
    {
          cout << s +"es" << endl;
    }else
    {
        cout << s + 's' << endl;
    }
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int a, b, c; cin >> a >> b >> c;
  if(b / a > c) cout << c << endl;
  else cout << b / a << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                  ' '
#define P_INF                1e10+17
#define N_INF               -1e10+17
#define mod                  1000000007
#define EPS                  0.000000001
#define pi                   2*acos(0.0)
#define fi(i, n)             for(int i=0; i<n; i++)
#define fj(j, n)             for(int j=0; j<n; j++)
#define rfk(k, n)            for(int k=n-1; k>=0; k--)
#define unique(a)            a.resize(unique(a.begin(), a.end()) - a.begin())

typedef double ld;
typedef long long int ll;
typedef unsigned long long int ul;
using namespace std;

class poll {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        map<string, int> m;
        while (n--) {
            string s;
            in >> s;
            m[s]++;
        }
        int maxi = N_INF;
        for (auto f:m) {
            if (f.second > maxi)
                maxi = f.second;
        }
        for (auto f:m) {
            if (f.second == maxi)
                out << f.first << endl;
        }

    }
};


int main() {
     std::ios_base::sync_with_stdio(0);
     std::cin.tie(nullptr);
     poll solver;
     std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
     return 0;
}


Measured memory_bytes: 23808
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 1000000007

#define COMMENT

int A[1<<20], B[1<<20], N;

vector<int> Zfunction(vector<int> vec) {
    vector<int> Z(vec.size());
    for(int i = 1, l = 0, r = 0;i < (int) Z.size();i++) {
      if(r >= i) {
        Z[i] = min(Z[i-l], r-i+1);
      }

      while(i+Z[i] < vec.size() && vec[i+Z[i]] == vec[Z[i]]) Z[i]++;

      if(i+Z[i]-1 > r) {
        l = i;r = i+Z[i]-1;
      }
    }

    return Z;

}

int main() {

//  freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

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

  vector<int> vec(3*N+1);
  vec[N] = -11;
  for(int i = 0;i < N;i++) {
    vec[i] = B[i] ^ B[(i+1)%N];
    vec[N+i+1] = vec[2*N+i+1] = A[i] ^ A[(i+1)%N];
  }

  vector<int> zarr = Zfunction(vec);
  // for(auto zi : zarr) debug(zi);

  for(int i = 0;i < N;i++) {
    // debug(in);
    if(zarr[i+N+1] == N) {
      cout << i << " " << (A[i] ^ B[0]) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 10968
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))
    
    S = input().strip()
    T = input().strip()

    cnt = 0
    for s, t in zip(S, T):
        if s == t:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9816
#include<cstdio>
#include<cstring>
int a[30];
int ans[30];
char s[100];
int main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<26;i++){
        ans[i]=9999;
    }
    for(i=0;i<n;i++){
        scanf("%s",s);
        int len=strlen(s);
        memset(a,0,sizeof(a));
        for(int j=0;j<len;j++){
            a[s[j]-'a']++;
        }
        for(int j=0;j<26;j++){
            if(a[j]<ans[j]){
                ans[j]=a[j];
            }
        }
    }
    char ss[2505];
    int r=0;
    for(int j=0;j<26;j++){
        if(ans[j]!=9999)
        for(i=0;i<ans[j];i++){
            ss[r++]=j+'a';
        }
    }
    ss[r]='\0';
    printf("%s\n",ss);
    return 0;
}


Measured memory_bytes: 128