akhauriyash/Code-Regression huggingface dataset:
#![allow(dead_code)]
use crate::scanner::Scanner;
fn main() {
    let mut scan = Scanner::new();
    let n = scan.chars();
    for i in 0..n.len() {
        if n[i] == '7' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}
mod scanner {
    use std::io::{stdin, BufReader, Bytes, Read, Stdin};
    use std::str::FromStr;
    pub struct Scanner {
        buf: Bytes<BufReader<Stdin>>,
    }
    impl Scanner {
        pub fn new() -> Scanner {
            Scanner {
                buf: BufReader::new(stdin()).bytes(),
            }
        }
        pub fn read_next<T: FromStr>(&mut self) -> Option<T> {
            let token = self
                .buf
                .by_ref()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<T>().ok()
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_next().unwrap()
        }
        pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read::<T>()).collect()
        }
        pub fn chars(&mut self) -> Vec<char> {
            self.read::<String>().chars().collect()
        }
        pub fn char(&mut self) -> char {
            self.read::<String>().chars().next().unwrap()
        }
    }
}



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

int main() {
    int N,M;
    cin>> N>>M;
    vector<vector<int>> G(N+1);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(N+1,-1);
    queue<int> que;
    vector<int> stamp(N+1);

    dist[1]=0;
    que.push(1);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int nv : G[v]){
            if(dist[nv]!=-1) continue;

            dist[nv] = dist [v] + 1;
            que.push(nv);
            stamp[nv]=v;
        }
    }
    cout << "Yes" << endl;
    rep(i,N-1){
        cout << stamp[i+2] << endl;
    }
}

Measured memory_bytes: 10528
# -*- coding: utf-8 -*-

while True:
    line = map(str, raw_input().split())
    H = int(line[0])
    W = int(line[1])
    if H+W:
        for i in range(H):
            if i == 0 or i == (H-1):
                print "#"*W
            else:
                print "#" + "."*(W-2) +"#"
        print ""
    else:
        break

Measured memory_bytes: 6380
a,b,m=(int(x) for x in input().split())
a_list=[int(x) for x in input().split()]
b_list=[int(x) for x in input().split()]

min_price=min(a_list)+min(b_list)

for count in range(m):
    x,y,c=(int(x) for x in input().split())
    discount_price=a_list[x-1]+b_list[y-1]-c
    if discount_price<min_price:
        min_price=discount_price
    else:
        continue
print(min_price)

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

int main(){
  int a,b;
  cin >> a >> b;
  for(int i=0;i<max(a,b);i++){
    if(abs(a-i) == abs(b-i)){
      cout << i << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var s = ReadLines(N);

            var sum = s.Sum();
            if (sum % 10 != 0)
            {
                Println(sum);
                return;
            }

            s = s.OrderBy(x => x).ToList();
            for (int i = 0; i < N; i++)
            {
                sum -= s[i];
                if (sum % 10 != 0)
                {
                    Println(sum);
                    return;
                }
                sum += s[i];
            }

            Println(0);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = max(0, min(b, d) - max(a, c));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long K;
  scanf("%lld", &K);
  ll sum = 0;
  if (A >= K)
  {
    sum += K;
  }
  else
  {
    sum += A;
    K -= A;
    if (B >= K)
    {
      sum += 0;
    }
    else
    {
      K -= B;
      if (C >= K)
      {
        sum -= K;
      }
      else
      {
        sum -= C;
        K -= C;
      }
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		long a = fs.nextLong();
		long b = fs.nextLong();
		long c = fs.nextLong();
		
		long right  = (c - a) - b;
		
		if(right < 0) {
			System.out.println("No");
			return;
		}
		
		right = right * right;
		
		long left = (4 * a) * b;
		
		if(left < right) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

const int maxn = 1e6+10;

int a[maxn];
int c[maxn];
char s[maxn];

int cnt2(int x) {
    int res = 0;
    while(x%2==0) {
        x >>= 1;
        res++;
    }
    return res;
}

int main() {
    int n;
    scanf("%d%s", &n, s+1);
    for(int i=1; i<=n; i++)
        a[i] = s[i]-'1';
    c[0] = 0;
    for(int i=1; i<=n-1; i++)
        c[i] = c[i-1]+cnt2(n-i)-cnt2(i);
    for(int i=0; i<=n-1; i++) {
        if(c[i])
            c[i] = 0;
        else
            c[i] = 1;
    }
    int ans = 0;
    for(int i=1; i<=n; i++)
        ans ^= a[i]*c[i-1]%2;
    if(ans&1) {
        printf("1\n");
        return 0;
    }
    bool flag = false;
    for(int i=1; i<=n; i++) {
        if(a[i]==1) {
            flag = true;
            break;
        }
    }
    if(flag)
        printf("0\n");
    else {
        ans = 0;
        for(int i=1; i<=n; i++)
            ans ^= a[i]/2*c[i-1]%2;
        if(ans&1)
            printf("2\n");
        else
            printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 9088
#include <cstdio>
#include <cmath>
#include <algorithm>

const int MAXN = 16;

int n, a[MAXN][MAXN];
bool calced[1 << MAXN];
long long f[1 << MAXN], _sum[1 << MAXN], sum[1 << MAXN];

long long dfs(int s) {
    if (calced[s]) return f[s];
    calced[s] = true;
    f[s] = sum[s];
    for (int i = s; i; i = (i - 1) & s) f[s] = std::max(f[s], dfs(i) + dfs(s ^ i));
    return f[s];
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
        _sum[0] = 0;
        for (int j = 1; j < (1 << n); j++) {
            int k = (j - 1) & j;
            _sum[j] = _sum[k] + a[i][(int) log2(j & -j)];
            if (j & (1 << i)) sum[j] += _sum[j];
        }
    }
    for (int i = 0; i < (1 << n); i++) sum[i] >>= 1;

    std::fill(calced, calced + (1 << n), false);
    printf("%lld\n", dfs((1 << n) - 1));
    
    return 0;
}

Measured memory_bytes: 1792
import sys
import collections

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
S = list(rs())
MOD = 10 ** 9 + 7
answer = 1
c = collections.Counter(S)
for k, v in c.items():
    answer = (answer * (v + 1)) % MOD

print(answer-1 if answer != 0 else MOD - 1)

Measured memory_bytes: 4340
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
      String s[]=new String[n];
      int x[]=new int[4];
      for(int i=0;i<4;i++)
      {x[i]=0;}
      sc.nextLine();
      for(int i=0;i<n;i++)
      {s[i]=sc.nextLine();
      }
      for(int i=0;i<n;i++)
      { if(s[i].equals("AC"))
        ++x[0];
       if(s[i].equals("WA"))
        ++x[1];
       if(s[i].equals("TLE"))
        ++x[2];
       if(s[i].equals("RE"))
        ++x[3];
      }
      for(int i=0;i<4;i++)
      {
        if(i==0)
        System.out.println("AC x "+x[i]);
        if(i==1)
        System.out.println("WA x "+x[i]);
        if(i==2)
        System.out.println("TLE x "+x[i]);
        if(i==3)
        System.out.println("RE x "+x[i]);
      }
    }
}

Measured memory_bytes: 66372
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int n,m,x,a,ans1,ans2,k[100];
int main() 
{cin>>n>>m>>x;
 for (int i=0;i<m;i++){
 cin>>a;
 k[a]=a;} 
 for (int i=x;i<n;i++)
 if (k[i]>x)
 ans1++; 
 for (int i=x;i>=0;i--)
 if (k[i]>0)
 ans2++;
 cout<<min(ans1,ans2); 
 system("pause");
 return 0;
}        


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

#define MOD (1000000007)

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n; cin >> n;
	vector<int> ns{};
	while (n) {
		ns.push_back(n % 2);
		n >>= 1;
	}
	// n>>iと (a>>i)+(b>>i)の差が0,1,2の場合の場合の数をc[0],c[1],c[2]とする。
	// n,a,bの上からi+1桁目の数をn',a',b'と書くことにすると、
	// n'=0,1, a'+b'=0,1,2のときの遷移を考えればよい。
	// 結果は
	// c[2] = 3*c[2]+(1+n')*c[1]
	// c[n']+=c[1-n']
	// となる

	long long c0{ 1 };
	long long c1{ 0 };
	long long c2{ 0 };
	while (ns.size()) {
		int ni = ns.back(); ns.pop_back();
		c2 *= 3;
		c2 += (1 + ni)*c1;
		c2 %= MOD;
		if (ni) {
			c1 += c0;
			c1 %= MOD;
		}
		else {
			c0 += c1;
			c1 %= MOD;
		}
	}
	long long ans = (c0 + c1 + c2) % MOD;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n, t[102], m, p, x, i, j, ans=0, tmp;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &t[i]);
  scanf("%d", &m);

  for(i = 0; i < m; i++)
    {
      scanf("%d %d", &p, &x);
      tmp = t[p-1];
      t[p-1] = x;

      for(j = 0; j < n; j++)
	ans += t[j];

      printf("%d\n", ans);
      t[p-1] = tmp;
      ans = 0;
    }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc079/tasks/abc079_c

string abcd;
string OP;

static bool dfs(int sum, string op) {
    if (op.length() == 3) {
        OP = op;
        return sum == 7;
    }

    if (dfs(sum + (abcd[op.length()+1] - '0'), op+"+")) return true;
    if (dfs(sum - (abcd[op.length()+1] - '0'), op+"-")) return true;
    return false;
}

int main() {
    cin >> abcd;
    if (dfs(abcd[0] - '0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", abcd[0], OP[0], abcd[1], OP[1], abcd[2], OP[2], abcd[3]);
    }

    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if (a >= 13){
        cout << b << endl;
        return 0;
    }
    if (a >= 6){
        cout << b / 2 << endl;
        return 0;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	nfs_mw;
	ll n,a,b;
	cin>>n>>a>>b; if(a>b) swap(a,b);
	if((b-a)&1){
		ll save = (b-a)/2;
		cout<<(min(b - 1, n - a) - save);
	}
	else cout<<((b-a)>>1);
}

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

int main() {
  int N;
  cin >> N;
  int64_t SOUSA = 0;
  vector<int64_t> a(N);
   for (int i = 0; i < N; i++) {
    cin >> a.at(i);
     while(a.at(i)%2 == 0){
       a.at(i) /= 2;
       SOUSA++;
     }
   }
  cout << SOUSA << endl;
}

Measured memory_bytes: 384
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

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

    int h, w;
    cin >> h >> w;
    vector<vector<PII>> mat(h, vector<PII>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat[i][j].first;
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat[i][j].second;
        }
    }

    bitset<25700> dp[h][w];
    dp[h-1][w-1].set(12850 + mat[h-1][w-1].first - mat[h-1][w-1].second);
    dp[h-1][w-1].set(12850 + mat[h-1][w-1].second - mat[h-1][w-1].first);
    int val;

    for (int i = h-1; i >= 0; i--) {
        for (int j = w-1; j >= 0; j--) {
            val = abs(mat[i][j].first - mat[i][j].second);
            if (i < h-1) {
                dp[i][j] |= (dp[i+1][j] << val);
                dp[i][j] |= (dp[i+1][j] >> val);
            }
            if (j < w-1) {
                dp[i][j] |= (dp[i][j+1] << val);
                dp[i][j] |= (dp[i][j+1] >> val);
            }
        }
    }

    for (int i = 0; i < dp[0][0].size(); i++) {
        if (dp[0][0][12850+i] or dp[0][0][12850-i]) {
            cout << i << "\n";
            return 0;
        }
    }
}



Measured memory_bytes: 20480
package main

import (
	"fmt"
	"sort"
)

func main() {
	var b [3]int
	fmt.Scan(&b[0], &b[1], &b[2])
	a := b[:]
	sort.Ints(a)

	for k, v := range []int{5, 5, 7} {
		if a[k] != v {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


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

int main(){
	const int MAX_H = 10;
	int H, board[MAX_H][5];
	int l, res, sub;
	bool deleted;
	
	while(true){
		scanf("%d", &H);
		if(H == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < 5; j++){
				scanf("%d", &board[i][j]);
			}
		}
		
		deleted = true;
		res = 0;
		while(deleted){
			deleted = false;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < 5;){
					l = j;
					while(j < 5 && board[i][l] == board[i][j]) j++;
					if(j - l >= 3 && board[i][l] != 0){
						res += board[i][l] * (j - l);
						for(int k = l; k < j; k++) board[i][k] = 0;
						deleted = true;
					}
				}
			}
			
			for(int j = 0; j < 5; j++){
				for(int i = 0; i < H; i++){
					if(board[i][j] == 0){
						for(int k = i; k - 1 >= 0; k--){
							sub = board[k][j];
							board[k][j] = board[k - 1][j];
							board[k - 1][j] = sub;
						}
					}
				}
			}
		}
		printf("%d\n", res);
	}
	
	return 0;
}

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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  long long a[5];
  long long n,fa[10],fd[10],la[10],ld[10];

  cin >> n;
  fa[0] = la[0] = 0;
  for (int i=0; i<5; i++){
    cin >> a[i];
    fd[i] = fa[i];
    ld[i] = MAX(la[i],fa[i]+(n-1)/a[i]);
//    cout << fd[i] << " " << ld[i] << endl;
    fa[i+1] = fd[i]+1;
    la[i+1] = ld[i]+1;
  }
  cout << la[5] << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int q = 0; q < n; q++){
        cin >> a[q];
    }
    sort(a.rbegin(), a.rend());
    int ans = a[0];
    for (int q = 2; q < n; q++){
        ans += a[q/2];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4784
<?php
// From https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
// From https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
list($N,$M)=sscanf(trim(fgets(STDIN)),"%d %d");
$total = 0;
$sc = new Scanner();
for ($i=0; $i < $M; $i++) { 
    # code...
    $n = $sc->nextInt();
    $total += $n;
}

if($total <= $N){
    print($N-= $total);
}else{
    print(-1);
}
//

Measured memory_bytes: 16788
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    S = list(input().rstrip().split())
    if len(set(S))==4:
        print('Four')
    else:
        print('Three')

if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	vector<mint> sum(n+1);
	rep(i,n) sum[i+1]=sum[i]+inverse(mint(i+1));

	mint ans=0;
	rep(i,n){
		ans+=(sum[i+1]+sum[n-i]-sum[1])*fact(n)*a[i];
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;

int L[100005], R[100005];
priority_queue<pair<int, int>> pq[2];
int used[100005];

long long trial(int state){
    int cur = 0;
    long long res = 0;
    while(!pq[state].empty()){
        int x = pq[state].top().first;
        int ind = pq[state].top().second;
        if(state == 0) x = -x;
        pq[state].pop();
        if(used[ind]) continue;
        used[ind] = 1;
        state = !state;
        if(state == 1 && x > cur) continue;
        else if(state == 0 && x < cur) continue;
        res += abs(cur-x);
        cur = x;
    }
    res += abs(cur);
    return res;
}

int main(){
    int N;
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%d%d", &L[i], &R[i]);
        pq[0].push({-R[i], i});
        pq[1].push({L[i], i});
    }
    long long res = trial(0);
    for(int i=0; i<N; i++){
        used[i] = 0;
        pq[0].push({-R[i], i});
        pq[1].push({L[i], i});
    }
    res = max(res, trial(1));
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int n;
    cin>>n;
    if(n%1000==0){
        cout<<0<<endl;
    }else{
        cout<<1000-n%1000<<endl;
    }
    
}


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

int main(){
	int x; cin>>x;
  	int n; cin>>n;
  	if(n==0){cout<<x<<endl; return 0;}
  	vector<int> arr(n);
 	cout<<endl;
  	for(int i=0;i<n;i++) cin>>arr[i];
  	pair<int,int> p1 = {INT_MAX, -1};
  	for(int i=0;i<=101;i++){
    	if(find(arr.begin(),arr.end(),i)!=arr.end()) continue;
      	else{
        	int currDiff = abs(x-i);
          	if(currDiff < p1.first){p1.first = currDiff; p1.second=i;}
        }
    }
  cout<<p1.second<<endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e2;
struct f{
	ll a,b,c,d;
}d[mm];
ll num[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t,s,ss,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10; s=0;ss=0;ll q;
	cin>>n>>m>>q;
	for(i=0;i<q;i++)
	scanf("%lld %lld %lld %lld",&d[i].a,&d[i].b,&d[i].c,&d[i].d);
	for(i1=1;i1<=m;i1++)
	{
		num[1]=i1;
	for(i2=i1;i2<=m;i2++)	
	{
		num[2]=i2;
	for(i3=i2;i3<=m;i3++)
	{
	    num[3]=i3;
	for(i4=i3;i4<=m;i4++)
	{
	    num[4]=i4;
	for(i5=i4;i5<=m;i5++)
	{
	    num[5]=i5;
	for(i6=i5;i6<=m;i6++)
	{
	    num[6]=i6;
	for(i7=i6;i7<=m;i7++)
	{
	    num[7]=i7;
	for(i8=i7;i8<=m;i8++)
	{
	    num[8]=i8;
	for(i9=i8;i9<=m;i9++)
	{
	    num[9]=i9;
	for(i10=i9;i10<=m;i10++)
	{
	    num[10]=i10;
	    s=0;
		for(i=0;i<q;i++)
		{
			if(num[d[i].b]-num[d[i].a]==d[i].c)
			s+=d[i].d;
		}
		ss=max(ss,s);	
	}		
	}		
	}		
	}		
	}		
	}			
	}	
	}
    }
    }
   cout<<ss<<endl; 
}

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

int main()
{
	string w;
	cin >> w;
	transform(w.begin(), w.end(), w.begin(), ::tolower);
	int ans = 0;
	string t;
	while (1){
		cin >> t;
		if (t == "END_OF_TEXT") break;
		transform(t.begin(), t.end(), t.begin(), ::tolower);
		if (t == w) ans++;
	}

	cout << ans << endl;
}





Measured memory_bytes: 3172
#include <stdio.h>

int main(void)
{
  int x = 0;
  int ans = 0;
  
  int N;
  scanf("%d", &N);
  
  char S[110];
  scanf("%s", S);
  
  int i;
  for( i = 0; i < N; i++ ){
    if( S[i] == 'I' ) x++;
    if( S[i] == 'D' ) x--;
    if( ans < x ) ans = x;
  }
  
  printf("%d\n", ans);
  
  
  return 0;
}       
       

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,q;
    long long int sum=0;
    int d[100001];
    for(int i=0;i<=100000;i++)
    d[i]=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	d[a[i]]++;
    	sum+=a[i];
	}
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		sum=sum+(c-b)*d[b];
		d[c]+=d[b];
		d[b]=0;
		cout<<sum<<"\n";
	}
}


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

const int N = 2e5 + 5;

int A[N] , n , m;

int main(void) {
	scanf("%d" , &n);
	for(int i = 1;i <= n;++ i) scanf("%d" , &A[i]);
	for(int i = 1;i <= n;++ i)
	if(A[i] > i - 1) {
		puts("-1");
		return 0;
	}
	long long ans = 0;
	int now = n - A[n];
	ans += A[n];
	for(int i = n - 1;i >= 1;-- i) {
		int it = i - A[i];
		if(it == now)
		continue;
		else {
			if(it > now) {
				puts("-1");
				return 0;
			}
			else {
				now = it;
				ans += A[i];
			}
		}
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

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

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3584
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

s = iinp()
z = 10**9+7
ans = 0

dp =[0]*2001

dp[0] = 0
dp[1] = 0
dp[2] = 0
dp[3] = 1
dp[4] = 1
dp[5] = 1
dp[6] = dp[3]+1

for i in range(7,s+1):
    dp[i] = dp[i-1]+dp[i-3]

ans = dp[s] % z
print(ans)

Measured memory_bytes: 9240
#include <iostream>
#include<string>
#include<math.h>
using namespace std;
int retmax(int a,int b,int c){//enum
    if(a>b){
        if(a>c){
            return 0;
        }else{
            return 2;
        }
    }else if(b>c){
        return 1;
    }else{
        return 2;
    }
}

int main(){
    int A,B,C;

    cin>>A >> B >> C;
    int s[3]={A,B,C};
    int K;
    cin >>K;
    int tmp=retmax(A,B,C);
    for(int i=0;i<K;i++){
        s[tmp]*=2;
    }   
    cout << s[0]+s[1]+s[2];
    return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::{input, fastout};

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

#[fastout]
fn main() {
    input! {
        mut a: usize,
        mut b: usize,
        mut c: usize,
        k: usize,
    }

    for i in 1..=k {
        if a >= b {
            b *= 2;
        } else if b >= c {
            c *= 2;
        } else {
            println!("Yes");
            return;
        }
    }
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2168
fn main() {
	loop {
		let v = read_vec::<i32>();
		if v == [0, 0] { return; }
		let (n, x) = (v[0], v[1]);
		if 3 * n - 3 < x {
			// 取り得る最大値がxより小さい場合
			println!("0");
			continue;
		}
		
		let mut count = 0;
		for min in 1..std::cmp::min(x / 3, n - 2) + 1 {
			if min + 2 * n - 1 < x { 
				continue; // 取り得る最大値がxより小さい場合
			}
			for mid in min + 1..n {
				if min + mid + n < x { 
					continue; // 取り得る最大値がxより小さい場合
				} else if min + mid * 2 + 1 > x {
					break;   // 取り得る最小値がxより大きい場合
				} else { 
					count += 1; // 範囲内に解あり
				}
			}
		}
		println!("{}", count);
	}
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5036
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int A, B;
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
        return 0;
    }else if(N == 2){
        cin >> A >> B;
        cout << A + B << endl;
    }
    return 0;
    
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair
#define r0 return 0

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    string s;
    cin>>s;
    string front, end;
    front = s.substr(0, 2);
    end = s.substr(2, 2);
    int n, m;
    n= stoi(front);
    m = stoi(end);
    if(((n<13)&&(n>0))&&((m<13)&&(m>0))){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    else if((n<13)&&(n>0)){
        cout << "MMYY" << endl;
        return 0;
    }
    else if((m<13)&&(m>0)){
        cout << "YYMM" << endl;
        return 0;
    }
    else{
        cout << "NA" << endl;
        return 0;
    }
    return 0;
}


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

int main() {
  int K, N;
  cin >> K >> N;
  int Max;
  
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for(int i = 1; i < N; i++) {
    if(Max < vec.at(i) - vec.at(i - 1)) Max = vec.at(i) - vec.at(i - 1);
  }
  if(Max < vec.at(0) + K - vec.at(N - 1)) Max = vec.at(0) + K - vec.at(N - 1);
  cout << K - Max << endl;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll X;
    ll A, B;
    cin >> X;
    for(A = -119;A <= 120;A++) {
        for(B = -119;B <= 120;B++) {
            if(pow(A, 5) - pow(B, 5) == X) goto aaa;
        }
    }
    aaa:
    cout << A << ' ' << B << endl;
    return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int n;
    cin >> n;

    vi p(n);
    REP(i,n) cin >> p[i];

    int ans = 0;
    REP(i,n-2){
        int f = p[i];
        int s = p[i+1];
        int t = p[i+2];
        vi tmp {f,s,t};
        sort(ALL(tmp));

        if (tmp[1] == s) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);

  int n;
  while(cin>>n) {
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> c(10);
    rep(i, n) {
      if (a[i] <= 399) {
        c[0] = 1;
      } else if (a[i] <= 799) {
        c[1] = 1;
      } else if (a[i] <= 1199) {
        c[2] = 1;
      } else if (a[i] <= 1599) {
        c[3] = 1;
      } else if (a[i] <= 1999) {
        c[4] = 1;
      } else if (a[i] <= 2399) {
        c[5] = 1;
      } else if (a[i] <= 2799) {
        c[6] = 1;
      } else if (a[i] <= 3199) {
        c[7] = 1;
      } else {
        c[8]++;
      }
    }

    int num = 0;
    rep(i,8) if (c[i]) num++;
    if (num == 0) {
      cout << 1 << " " << c[8] << endl;
    } else {
      cout << num << " " << num + c[8] << 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++)
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    cout << vec.at(n/2)-vec.at(n/2-1) << endl;
}


Measured memory_bytes: 640
na, nb, a, b, c = map(int, input().split())
ab_list = [0 for i in range(na + nb)]
ab_list[:na] = sorted(list(map(int, input().split())), reverse=True)[:na]
ab_list[na:] = sorted(list(map(int, input().split())), reverse=True)[:nb]
ab_list += sorted(list(map(int, input().split())), reverse=True)[:min(na + nb, c)]

ab_list.sort(reverse=True)

print(sum(ab_list[:na + nb]))

Measured memory_bytes: 22212
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;



int main() {
    
    int N,left=0,right=0;
    string S;
    cin>>N>>S;
    rep(i,N){
        if(S[i]=='('){
            left++;
        }
        else if(left>0){
            left--;
            
        }
        else{
            right++;
        }
    }
    
        rep(i,right){
            S='('+S;
        }
    
    
        rep(i,left){
            S=S+')';
        }
    
    cout<<S<<endl;
   
return 0;
}



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

using namespace std;

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  for (int i = 0; (int)(i * 0.08) <= a && (int)(i * 0.1) <= b; ++i) {
    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      printf("%d\n", i);
      return 0;
    }
  }
  puts("-1");
}


Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    ll a,b;
    cin>>a>>b;
    cout<<min(b-a%b,a%b);
}

int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())

number = abs(B - A)
if number % 2 == 0:
    print(number // 2)

else:
    answer_1 = ((N - A) + (N - B) + 1) // 2
    answer_2 = ((A - 1) + (B - 1) + 1) // 2

    print(min(answer_1, answer_2))


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

int main() {
	int n,m,i,j;
	cin >> n >> m;
	vector<vector<pair<int,int>>> a(n+1,vector<pair<int,int>>(0));
	
	int p,y;
	for(i=0; i<m; i++){
		cin >> p >> y;
		a[p].push_back({y,i});
	}
	
	for(i=1; i<=n; i++){
		sort(a[i].begin(),a[i].end());
	}
	
	vector<pair<int,int>> ans(m);
	
	for(i=1; i<=n; i++){
		for(j=0; j<a[i].size(); j++){
			ans[a[i][j].second].first=i;
			ans[a[i][j].second].second=j+1;
		}
	}
	
	for(i=0; i<m; i++){
		printf("%06d%06d\n",ans[i].first,ans[i].second);
	}
	return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;
int n;
long a[100];
void input()
{
    cin>> n;
    a[0]= 2; a[1]= 1;
    up(i,2,n) a[i]= a[i-1]+ a[i-2];
    cout<<a[n];
}
void solve()
{

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	  #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 256
from collections import deque
def main():
    S = input()
    S = deque([c for c in S])
    Q = int(input())
    rvCt = 0

    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            rvCt += 1
        else:
            doReverse = False
            if rvCt % 2 == 1:
                doReverse = True

            if query[1] == '1':
                if doReverse:
                    S.append(query[2])
                else:
                    S.appendleft(query[2])
            else:
                if doReverse:
                    S.appendleft(query[2])
                else:
                    S.append(query[2])

    if rvCt % 2 == 1:
        S.reverse()
    
    print(''.join(S))

main()

Measured memory_bytes: 8420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int n,x,t; cin >> n >> x >> t;
    if(n % x == 0) {
        cout << (n/x) * t << endl;
    }else{
        cout << (1+n/x) * t << endl;
    }
}

Measured memory_bytes: 3620
N = input()
A = list(map(int,input().split()))
if 0 in A:
  result = 0
else:
  result = 1
for a in A:
  if len(str(result)) > 19:
    exit
  else:
    result *= a
if result > 10 ** 18:
    result = -1
print(result)

Measured memory_bytes: 21584
using System;
using System.Collections;
using System.Collections.Generic;

namespace ABC126 {
  class ProblemA {
    static void Main(string[] args) {
      int[] input = Input.nums;
      int k = input[1] - 1;
      char[] str = Input.charArr;
      str[k] = Char.ToLower(str[k]);
      System.Console.WriteLine(str);
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}

Measured memory_bytes: 13012
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////


//////////////////////////////////////

int main() {
    
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    
    ll ans = b * d;
    ans = std::max(ans, a*c);
    ans = std::max(ans, b*c);
    ans = std::max(ans, a*d);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3592