akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e6;

int n;

bool check(vector<string> data, int b) {
    bool ok = true;
    rep(i,n)rep(j,n) {
        if (data[i][(j-b)<0?j-b+n:j-b] != data[j][(i-b)<0?i-b+n:i-b]) {
            ok = false;
        }
    }
    return ok;
}

int main() {
    cin >> n;
    vector<string> data(n);
    rep(i,n) cin >> data[i];
    int ans = 0;
    rep(i,n) if (check(data,i)) ans++;
    ans *= n;
    cout << ans << endl;
}

Measured memory_bytes: 512
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut ab: Vec<(usize,usize)> = (0..n).map(|_| (sc.read(), sc.read())).collect();
    ab.sort();

    use std::collections::BinaryHeap;
    let mut heap = BinaryHeap::new();
    let mut ans = 0;
    let mut i = 0;
    let mut j = 1;
    while j <= m {
        while i<n && ab[i].0 == j {
            heap.push(ab[i].1);
            i += 1;
        }
        if let Some(b) = heap.pop() {
            ans += b;
        }
        j += 1;
    }

    format!("{}\n", ans)
}
#[test]
fn test_solve() {
   assert_eq!(solve("3 4\n4 3\n4 1\n2 2\n"), "5\n");
   assert_eq!(solve("5 3\n1 2\n1 3\n1 4\n2 1\n2 3\n"), "10\n");
   assert_eq!(solve("1 1\n2 1\n"), "0\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
#[allow(dead_code)]
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

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

class Main{
    public static void main(String[] args){
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String line;
	int i=0,j=0;//int[] flag = new int['Z'];
	int oi = 0;
	try{
	    while(null!=(line = br.readLine())){
		line = 'A' + line;
		while((oi = line.indexOf("OI")) != -1){
		    //flag[line.charAt(oi-1)]++;
		    if(line.charAt(oi-1)=='J')j++;
		    if(line.charAt(oi-1)=='I')i++;
		    line = line.substring(oi + 1);
		}
		System.out.println(Integer.toString(j));//flag['J']));
		System.out.println(Integer.toString(i));//flag['I']));
		//flag['J'] = flag['I'] = 0;
		i=j=0;
	    }
	}
	catch(Exception e){
	    System.out.println(e.getMessage() + oi);
	}
    }
}

Measured memory_bytes: 17912
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    ml m;
    ll a[1000000];
    cin>>a[0];m[a[0]]++;
    for(int i=1;i<1000000;i++){
        if(a[i-1]%2)a[i]=a[i-1]*3+1;
        else a[i]=a[i-1]/2;
        if(m.count(a[i])){
            cout<<i+1;return 0;
        }
        m[a[i]]++;
    }
    return 0;
}


Measured memory_bytes: 256
N, L = list(map(int, input().split()))

total = sum([L+i for i in range(N)])
diff = float('inf')
for i in range(N):
    a = total - (L+i)
    diff = min(abs(total - a), diff)
if total > 0:
    print(total-diff)
else:
    print(diff+total)

Measured memory_bytes: 38384
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char z;
  scanf("%c", &z);
  printf("%c\n", (char)(z + 1));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

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

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

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

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 15
int N;
double x[Max];
string u[Max];

int main(int argc, const char * argv[]) {
    N = inputValue();
    rep(i, N) {
        cin >> x[i];
        cin >> u[i];
    }

    double ans  = 0;

    rep(i, N){ 
        if (u[i] == "JPY") {
            ans += x[i];
        } else {
            ans += x[i] * 380000;
        }
    }

    output(ans, 10);

    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(cnt) begin(cnt), end(cnt)

int N, M;
int x[100010], y[100010];

int cnt[100010];
int exist[100010];

int main() {
    while (cin >> N >> M) {
        for (int i = 0; i < M; i++) {
            cin >> x[i] >> y[i];
            --x[i], --y[i];
        }
        for (int i = 0; i < N; i++) {
            cnt[i] = 1;
            exist[1] = false;
        }
        exist[0] = true;

        for (int i = 0; i < M; i++) {
            int x = ::x[i], y = ::y[i];
            // x->y
            cnt[x]--;
            cnt[y]++;
            exist[y] |= exist[x];
            if (cnt[x] == 0) {
                exist[x] = false;
            }
            //for (int i = 0; i < N; i++) {
            //    cout << exist[i];
            //}
            //cout << endl;
        }
        cout << count(exist, exist + N, true) << endl;
    }

}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define ll long long


int main(void){
	int n;
	scanf("%d",&n);
	char s[n+1],t[n+1];
	scanf("%s%s",s,t);
	int yobunn=0;
	bool ok;
	for(int i=0;i<n;i++){
		ok=true;
		if(s[i]==t[0]){
			for(int j=0;i+j<n;j++){
				if(s[i+j]==t[j]);
				else ok=false;
			}
			if(ok)yobunn=yobunn>(n-i)?yobunn:n-i;
		}
		
	}
	printf("%d",2*n-yobunn);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <stdio.h>

int main(){
  int n,flg[3];char str[5];
  scanf("%s",str);
  std::sort(str,str+3);
   if(str[0] == 'a'){
     if(str[1] == 'b') {
       if(str[2] == 'c') {printf("Yes\n");return 0;}}}

  printf("No\n");
  return 0;
}





Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

struct place{
	int cnt;
	int num;
};

int cmp(const void* a,const void* b){
	struct place *p1 = (struct place *)a;
	struct place *p2 = (struct place *)b;
	if(p2->cnt == p1->cnt)
		return p1->num - p2->num;
	return p2->cnt - p1->cnt;
}

int main(void){
	int n, m, i, j;
	struct place p[100];
	while(1){
		scanf("%d%d%*c",&n,&m);
		if(n == 0 && m == 0)
			break;
		for(i = 0;i < m;i++){
			p[i].cnt = 0;
			p[i].num = i + 1;
		}
		for(i = 0;i < n;i++){
			for(j = 0;j < m;j++){
				if(getchar() == '1')
					p[j].cnt++;
				getchar();
			}
		}
		qsort(p,m,sizeof(p[0]),cmp);
		for(i = 0;i < m;i++){
			printf("%d",p[i].num);
			if(i != m - 1)
				printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1040
#include<iostream>
using namespace std;
int main(){

	int a[101][101], r, c, d, e, f=0;
	cin >> r >> c;
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < r; i++){
		d = 0;
		for (int j = 0; j < c; j++){
			cout << a[i][j] << " ";
			d += a[i][j];
		}
		cout << d << endl;
	}
	for (int j = 0; j < c; j++){
		e = 0;
		for (int i = 0; i < r; i++){
			e += a[i][j];
		}
		cout << e << " ";
		f += e;
	}
	cout << f << endl;
}


Measured memory_bytes: 3124
n = int(input())
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)

for ss in s:
    dp[ss] += 1

A = max(s)
pairwise = True
setwise = True

for i in range(2, A + 1):
    cnt = 0
    for j in range(i, A + 1, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False
    if cnt >= n:
        setwise = False
        break

if pairwise:
    print("pairwise coprime")
elif setwise:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 194644
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(i64);

    let mut ok = false;
    for x in 1..10 {
        for y in 1..10 {
            ok = ok || x * y == N;
        }
    }

    println!("{}", if ok { "Yes" } else { "No" })
}


Measured memory_bytes: 4352
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;

int main()
{
	int W, H;
	int dx[] = {0,1,0,-1};
	int dy[] = {1,0,-1,0};
	while (cin >> W >> H && W != 0 && H != 0)
	{
		bool path[20 + 1][20 + 1];
		for (int i = 1; i <= H; i++)
		{
			for (int j = 1; j <= W; j++)
			{
				path[i][j] = false;
			}
		}
		char field[20 + 1][20 + 1];
		int startx, starty;
		for (int i = 1; i <= H; i++)
		{
			char buf[21];
			cin >> buf;
			string str = buf;
			for (int j = 0; j < W; j++)
			{
				field[i][j + 1] = str.at(j);
				if (str.at(j) == '@')
				{
					startx = j + 1;
					starty = i;
				}
			}
		}
		int tiles = 0;
		queue< pair<int,int> > q;
		q.push(make_pair(startx, starty));
		path[starty][startx] = true;
		while(q.size() > 0)
		{
			pair<int,int> p = q.front();
			q.pop();
			int x = p.first;
			int y = p.second;
			tiles++;
			for (int i = 0; i < 4; i++)
			{
				int nx = x + dx[i];
				int ny = y + dy[i];
				if (nx > W || ny > H || nx < 1 || ny < 1)continue;
				if (path[ny][nx])continue;
				if (field[ny][nx] == '#')continue;
				path[ny][nx] = true;
				q.push(make_pair(nx, ny));
			}
		}
		cout << tiles << endl;

	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s, ans = "";
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != 'B') {
            ans += s[i];
        }else if(ans.length() > 0){
            ans.erase(ans.length()-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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



Measured memory_bytes: 26196
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	string S,T,U;
	int A,B;
	cin >> S >> T >> A >> B >> U;
	if(S==U)A-=1;else B-=1;
	cout << A << " " <<B;
    return 0;
}


Measured memory_bytes: 256
N, M, Q = [int(n) for n in input().split()]
a, b, c, d = [list(x) for x in zip(*[[int(n) for n in input().split()] for _ in range(Q)])]
ans = 0

def dfs(A):
    global ans
    if len(A) == N:
        now = 0
        for i in range(Q):
            if A[b[i]-1] - A[a[i]-1] == c[i]: now += d[i]
        ans = max(ans, now)
        return

    for v in range(A[-1], M+1):
        A.append(v)
        dfs(A)
        A.pop()

dfs([1])
print(ans)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main() {
    int n,m,q;
    cin>>n>>m>>q;

    vector<vector<int>> a(n,vector<int>(n,0));
    rep(i,m){
        int l,r;
        cin>>l>>r;
        l--,r--;
        a[l][r]++;
    }

    vector<vector<int>> s(n+1,vector<int>(n+1,0));
    rep(i,n){
        rep(j,n){
            s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+a[i][j];
        }
    }

    while(q--){
        int p,q;
        cin>>p>>q;
        p--,q;
        int x2=q,y2=q,x1=p,y1=p;
        cout << s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1] << endl;
    }
}

Measured memory_bytes: 5600
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
d=b-a
if d%2==0:
    ans=d//2
    print(ans)
else:
    if b-1<=n-a:
        ans=(a+b-1)//2
    else:
        ans=(2*n-a-b+1)//2
    print(ans)
    


Measured memory_bytes: 38460
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

void Main()
{
	int R, G, B, N;
	std::cin >> R >> G >> B >> N;
	int count = 0;
	for (int r = 0; r * R <= N; ++r)
	{
		auto a = r * R;
		for (int g = 0; a + g * G <= N; ++g)
		{
			auto b = g * G;
			auto v = N - (a + b);
			if (v % B == 0)
			{
				++count;
			}
		}
	}
	std::cout << count << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int a,b;
cin >> a >> b;
int i = 0;
if (b == 1) i = 0;
else {
for (i = 1;i < INF;i++) {
    if (i*a -(i-1) >= b) break; 
}
}
cout << i << endl;

return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    string s, t; cin >> s >> t;
    int sn = s.size();   
    int tn = t.size();

    int dp[sn+1][tn+1];
    rep(i,sn+1) dp[i][0] = 0;
    rep(i,tn+1) dp[0][i] = 0;

    rep(i,sn){
        rep(j,tn){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j]+1;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    string ans = "";

    int len = dp[sn][tn];
    int i = sn;
    int j = tn;
    while(len>0){
        if(s[i-1] == t[j-1]){
            ans += s[i-1];
            --i;
            --j;
            --len;
        }else if(dp[i][j] == dp[i-1][j]){
            --i;
        }else{
            --j;
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i = 0;i < n;++i) {
        cin>>a[i];
    }

    map<int,int> mp;
    ll ans=0;
    for(int i = 0;i < n;++i) {
        ans+=mp[-a[i]+i];
        ++mp[a[i]+i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 21116
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val s = readLine()

    if (s.length % 2 != 0) {
      println("No")
    } else {

      var ans = true
      for (i <- 0 until s.length) {
        if (i % 2 == 0 && s(i) != 'h') ans = false
        if (i % 2 != 0 && s(i) != 'i') ans = false
      }
      println(if (ans) "Yes" else "No")
    }
  }
}


Measured memory_bytes: 27456
//AUTHOR:: MOHAMMAD FAISAL
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// ATCODER Beginner Problems
#include<bits/stdc++.h>
#include<iostream>
#include<tuple>
#include<bitset>
#include<string>
#include<algorithm>
#include <cctype>
#include<unordered_map>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<iterator>
using namespace std;
//string password;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool isVowel(char c)
{
    return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}
bool isPrime(long long n)
{
  if (n == 1)
  {
    return false;
  }
  long long int i = 2;
  while (i*i <= n)
  {
      if (n % i == 0)
      {
          return false;
      }
      i += 1;
  }
  return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
    int n;
    cin >>n;
    vector<tuple<string,int,int> > lis;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin >> s;
        int sc;
        cin >> sc;
        lis.push_back(make_tuple(s,-sc,i));
    }
    sort(lis.begin(),lis.end());
    for(int i=0;i<(int)lis.size();i++)
        cout<<get<2>(lis[i])<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10 , OO = 0x3f3f3f3f ;
const int mod = 1e9 + 7;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

ll n;

ll fastPower(ll b , ll p){
    if(p == 0)
        return 1;
    
    ll ret = fastPower(b,p/2);
    return (p&1 ? ret*ret*b : ret*ret);

}


int main()
{
   // startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    scanf("%lld",  &n);
    
    string ans = "";
    for(int len = 1 ; len <= 11 ; ++len){ // 26^11 > maxinput

        ll pow = fastPower(26 , len);
        if(n <= pow){
            n--;
            for(int j = 1 ; j <= len ; ++j)
            {
                ans += char('a' + (n % 26));
                n /= 26; 
            }
            break;        
        }
        else
            n -= pow;
    }

    reverse(ALL(ans));
    cout << ans << "\n";

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  string s;
  cin >> s;
  int aa = stoi(s.substr(0, 2));
  int bb = stoi(s.substr(2, 2));

  if (min(aa, bb) >= 13 || (aa == 0 && bb == 0)) {
    cout << "NA\n";
    return;
  }

  if (min(aa, bb) == 0) {
    if (max(aa, bb) <= 12) {
      cout << (aa > bb ? "MMYY\n" : "YYMM\n");
      return;
    } else {
      cout << "NA\n";
      return;
    }
  }

  if (aa <= 12 && bb <= 12) {
    cout << "AMBIGUOUS\n";
    return;
  }

  if (aa >= bb) {
    cout << "YYMM\n";
  } else {
    cout << "MMYY\n";
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define dump(x)  cerr << #x << " => " << (x) << endl
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
typedef long long LL;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
// LONG_MAX,LLONG_MAX
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class Key,class Value> ostream& operator << (ostream &s, map<Key,Value> M)
{ for ( auto itr = begin(M); itr != end(M); ++itr) { s << itr->first << ":" << itr->second; } return s;}

int N;
vector<vector<vector<double>>> memo;

double dfs(int one,int two,int three) {
    if (memo[one][two][three] != -1.0) {
        return memo[one][two][three];
    }
    double ret = 0;
    if (one > 0) ret += (dfs(one-1,two,three) * (double) one);
    if (two > 0) ret += (dfs(one+1,two-1,three) * (double) two);
    if (three > 0) ret += (dfs(one,two+1,three-1) * (double) three);
    return memo[one][two][three] = (ret + (double)N) / (one+two+three);
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    memo = vector<vector<vector<double>>>(N+1,vector<vector<double>>(N+1,vector<double>(N+1,-1.0)));
    memo[0][0][0] = 0;
    int one = 0,two = 0,three = 0;
    int a;
    REP(i,N) {
        cin >> a;
        if (a == 1) one++;
        else if (a == 2) two++;
        else three++;
    }
    cout << setprecision(15) << dfs(one,two,three) <<  endl;
}



Measured memory_bytes: 217088
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
vector<int> alf[26]; string s; int n;
int le[26];
int cc = 0;
int app(char x) {
	int res = cc;
	int t = x - 'a';
	int ri = lower_bound(alf[t].begin(), alf[t].end(), cc) - alf[t].begin();
	if (ri == le[t])return n;
	res = alf[t][ri];
	return res;
}
void upd(int x) {
	int ri = lower_bound(alf[x].begin(), alf[x].end(), cc) - alf[x].begin();
	if (ri == le[x])cc = n;
	else cc = alf[x][ri] + 1;
}
int main() {
	cin >> s; n = s.length();
	vector<int> v; v.push_back(n);
	rep(i, n) {
		int t = s[i] - 'a';
		alf[t].push_back(i);
	}
	per(i, n) {
		int cnt = 0; int used[26] = {};
		while (i>=0&&cnt < 26) {
			int t = s[i] - 'a';
			if (!used[t]) {
				used[t] = 1; cnt++;
			}
			i--;
		}
		i++;
		if (cnt == 26)v.push_back(i);
	}
	rep(i, 26) {
		le[i] = alf[i].size();
	}
	reverse(v.begin(), v.end());
	int len = v.size();
	string out; int memo = -1;
	int used[26] = {};
	rep(i, v[0]) {
		used[s[i] - 'a'] = 1;
	}
	per(i, 26) {
		if (!used[i])memo = i;
	}
	out.push_back('a' + memo);
	upd(memo);
	Rep(i,1, len) {
		rep(j, 26) {
			char nex = 'a' + j;
			int chk = app(nex);
			if (chk >= v[i]) {
				out.push_back(nex);
				upd(j);
				break;
			}
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 1412
A = [input(),input(),input()]
b = ['a','b','c']
c = list(map(len,A))
d = [0]*3
w = 'a'
while True:
    ind = b.index(w)
    if d[ind] == c[ind]:
        print(b[ind].upper())
        break
    w = A[ind][d[ind]]
    d[ind] += 1

Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var s = input[0];
  
  var ans = "No";
  if(s[2] == s[3] && s[4] == s[5]) ans = "Yes";

	//出力
	console.log('%s', ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int N, K, M, c[200010], a[200010], Ans, b[200010];
void Read(int &x) {
	scanf("%d", &x);
}
int Max(int a, int b) {
	return a > b ? a : b;
}
int main() {
	int i, j, x;
	//freopen("in.txt", "r", stdin);
	Read(N); Read(K);
	for (i = 1; i <= N; i++) Read(a[i]);
	sort(a + 1, a + 1 + N);
	for (i = 1; i <= N; i++) {
		if (!c[a[i]]) c[a[i]] = ++M;
		b[c[a[i]]]++;
	}
	sort(b + 1, b + 1 + M);
	for (i = 1; i <= M - K; i++) Ans += b[i];
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=LINF,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k,sy,sx,gx=1000,gy=1000,ri,le,up,down;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[1000][1000];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>h>>w>>k;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
            if(s[i][j]=='S')sy=i,sx=j;
        }
    }

    int min_cost[h+10][w+10];
	rep(i,h) rep(j,w) min_cost[i][j] = INF;
	queue<pair<ll,ll>> qu; qu.push({sy, sx}); min_cost[sy][sx] = 0;
	while(!qu.empty()){
		auto p = qu.front(); qu.pop();
		rep(i,4){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if(nx<0||ny<0||nx>=h||ny>=w) continue;
			if(s[nx][ny] == '#') continue;
			if(min_cost[p.first][p.second] + 1 >= min_cost[nx][ny]) continue;
			min_cost[nx][ny] = min_cost[p.first][p.second] + 1;
			qu.push({nx, ny});
		}
	}
    rep(i,h){
        rep(j,w){
            if(min_cost[i][j]<=k){
                ri=w-j-1;
                le=j;
                up=i;
                down=h-i-1;
                d=min({ri,le,up,down});
                if(d%k!=0)d=d/k+1;
                else d/=k;
                ans=min(ans,d);
            }
        }
    }
    Cout(ans+1);
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAXN = 1e5 + 5;
const ll INF = 1e15;

int ar[MAXN];
ll dp[MAXN][2];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n;
    scanf("%d", &n);
    dp[0][1] = -INF;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &ar[i]);
        for (int sub = 0; sub <= 1; sub++) {
            if (ar[i] - sub < 0)
                dp[i][sub] = -INF;
            else {
                dp[i][sub] = dp[i - 1][0] + (ar[i] - sub) / 2;
                if (ar[i] - sub - 1 >= 0)
                    dp[i][sub] = max(dp[i][sub], dp[i - 1][1] + (ar[i] - sub - 1) / 2 + 1);
            }
        }
    }
    printf("%lld\n", dp[n][0]);
    return 0;
}



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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll modul(ll x) { return (x + mod) % mod; }
ll pow(ll a, ll x) {
	if (x == 0) return 1;
	if (x == 1) return modul(a);
	ll tmp = pow(a, x / 2);
	return (x % 2 == 0 ? modul(tmp*tmp) : modul(tmp*modul(tmp*a)));
}
ll inv(ll x) { return pow(x, mod - 2); }
ll c(ll n, ll k) {
	ll ans = 1;
	for (ll i = 1; i <= k; ++i) {
		ans = (ans*(n - i + 1)) % mod;
		ans = (ans*inv(i)) % mod;
	}
	return ans;
}
int main() {
	ll x, y; cin >> x >> y;
	if ((x + y) % 3 != 0) cout << 0 << endl;
	else {
		ll sum = (x + y) / 3, diff = y - x;
		if ((sum + diff) % 2 != 0) cout << 0 << endl;
		else {
			ll i = (sum + diff) / 2, j = (sum - diff) / 2;
			if (i < 0 || j < 0) cout << 0 << endl;
			else {
				cout << c(i + j, min(i, j)) << endl;
			}
		}
	}
}

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

#上下左右のマスを黒くしていく
#BFS
from collections import deque
def bfs():
    dx=[0,1,0,-1]
    dy=[1,0,-1,0]
    log=[[-1]*w for i in range(h)]

    que=deque()
    for i in range(h):
        for j in range(w):
            if a[i][j]=='#':
                que.append((i,j))
                log[i][j]=0

    while que:
        #queの先頭を取り出す
        p=que.popleft()
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]

            if not(0<=nx<h and 0<=ny<w):continue
            if log[nx][ny]!=-1:continue
            que.append((nx,ny))
            log[nx][ny]=log[p[0]][p[1]]+1

    return log

G=bfs()
ans=0
for i in range(h):
    for j in range(w):
        if ans<G[i][j]:
            ans=G[i][j]
print(ans)
#print(*G,sep='\n')

Measured memory_bytes: 121692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int i;
  for(i=0; i<N; i++){
    string s;
    cin>>s;
    if(s=="Y"){
      cout<<"Four"<<endl;
      break;
    }
    else if(i==N-1&&s!="Y"){
      cout<<"Three"<<endl;
    }
    else if(s!="Y"){
      continue;
    }
  }
}



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


def main():
    """Function."""
    n = int(input())
    s = list(map(str, input().split()))

    check = set()
    for i in range(n):
        check.add(s[i])

    if len(check) == 3:
        print("Three")
    else:
        print("Four")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
n = int(input())
S = []
for i in range(n):
    S.append(input())
cnt_ac = 0
cnt_tle = 0
cnt_wa = 0
cnt_re = 0


for i in range(n):
    if S[i] == "AC":
        cnt_ac += 1
    elif S[i] == "TLE":
        cnt_tle += 1
    elif S[i] == "WA":
        cnt_wa += 1
    elif S[i] == "RE":
        cnt_re += 1

print("AC x " + str(cnt_ac))
print("WA x " + str(cnt_wa))
print("TLE x " + str(cnt_tle))
print("RE x " + str(cnt_re))

Measured memory_bytes: 16328
/*  chuckie   */
#include <bits/stdc++.h>
//#define CHUCKIE
 
#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
 
#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
 
const long long MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODR(d) ((d)>=MOD?(d)%MOD:(d))
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;
 
#define foreach(it,c) for(__typeof((c).begin()) it = (c).begin(); it!=(c).end(); it++) 
#define MAX 1000000
#define ll long long
#define mp make_pair
#define pb push_back
 
using namespace std;

ll negmod(ll number, ll mod)
{
    if(number >= 0) return number % mod;
    return (mod + (number % mod)) % mod;
}



// To compute (a * b) % mod
ll mulmod(ll a, ll b, ll mod)
{
    ll res = 0; // Initialize result
    a = a % mod;
    while (b > 0)
    {
        // If b is odd, add 'a' to result
        if (b % 2 == 1)
            res = (res + a) % mod;
 
        // Multiply 'a' with 2
        a = (a * 2) % mod;
 
        // Divide b by 2
        b /= 2;
    }
 
    // Return result
    return res % mod;
}
 
 ll diffy[100005],diffx[100005],mulx[100005],muly[100005];
 
int main()
{
	#ifdef CHUCKIE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	
	ll n,m;
	cin>>n>>m;
	ll temp,prev;
	cin>>prev;
	for(int i=1;i<n;i++)
	{
		cin>>temp;
		diffx[i-1]=temp-prev;
		prev=temp;
	}
	
	cin>>prev;
	for(ll i=1;i<m;i++)
	{
		cin>>temp;
		diffy[i-1]=temp-prev;
		prev=temp;
	}
	
	
	ll xans=0,yans=0,inc=n-2-1;
	
	
	mulx[0]=n-1;
	mulx[n-2]=n-1;
	for(ll i=1;i<n/2;i++)
	{
		mulx[i]=mulx[i-1]+inc;
		inc-=2;
	}
	inc=n-2-1;
	
	for(ll i=n-3;i>=n/2;i--)
	{
		mulx[i]=mulx[i+1]+inc;
		inc-=2;
	}
	
	
	muly[0]=m-1;
	muly[m-2]=m-1;
	inc=m-2-1;
	for(ll i=1;i<m/2;i++)
	{
		muly[i]=muly[i-1]+inc;
		inc-=2;
	}
	inc=m-2-1;
	
	for(ll i=m-3;i>=m/2;i--)
	{
		muly[i]=muly[i+1]+inc;
		inc-=2;
	}
	
	
	
	xans=0;yans=0;
	
	for(ll i=0;i<n-1;i++)
	{
		xans+= mulmod(diffx[i],mulx[i],MOD);
		//cout<<xans<<" ";
		xans=MODR(xans);
	}
	//cout<<xans<<endl;
	
	for(ll i=0;i<m-1;i++)
	{
		yans+= mulmod(diffy[i],muly[i],MOD);
		//cout<<yans<<" ";
		yans=MODR(yans);
	}
	
	//cout<<yans<<endl;
	
	ll ans=(mulmod(xans,yans,MOD));
	//cout<<ans<<endl;
	ans=ans%MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3456
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define endl "\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
int f[N];
int e[N];
inline ll pp(ll a)
{
    ll start = -500, end = 500, mid;
    while (start <= end)
    {
       
        mid = (start + end) / 2;
        if (mid * mid * mid * mid * mid == a)
            return mid;
        else if (mid * mid * mid * mid * mid > a)
        {
            end = mid - 1;
        }
        else if (mid * mid * mid * mid * mid < a)
        {
            start = mid + 1;
        }
    }
    return 0;
}
int main()
{
    Run();
    int n; cin >> n;
    for (int i = -1000; i <= 1000; i++)
    {
        ll a = pow(i, 5) - n;
        ll b = pp(a);
        if (pow(i, 5) - pow(b, 5) == n)
        {
            cout << i << " " << b;
            return 0;
        }
        
    }
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int p[N];
  for (int i = 0; i < N; i++) cin >> p[i];

  int a[N], b[N];
  for (int i = 0; i < N; i++) {
    a[i] = (i + 1) * N;
    b[i] = (N - i) * N;
  }

  for (int i = 0; i < N; i++) {
    a[p[i]-1] += i;
  }

  // 解答
  for (int i = 0; i < N; i++) cout << a[i] << " ";
  cout << endl;
  for (int i = 0; i < N; i++) cout << b[i] << " ";
  cout << endl;

  return 0;
}


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

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

    int K, N; cin >> K >> N;
    int A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];

    vector<int> d;
    for (int i = 1; i < N; ++i) d.push_back(A[i] - A[i - 1]);
    d.push_back(K - A[N - 1] + A[0]);
    sort(d.begin(), d.end());

    int ans = accumulate(d.begin(), d.end() - 1, 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>///http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_B
using namespace std;

int main(){

    int a, b, c;

    cin >> a >> b >> c;

    if(a < b && a < c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 3080
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H1, M1, H2, M2, K):
    d = (H2-H1) * 60
    d += (M2-M1)
    return d - K


def main():
    H1, M1, H2, M2, K = read_int_n()
    print(slv(H1, M1, H2, M2, K))


if __name__ == '__main__':
    main()


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

int main()
{
    int n;
    cin >> n ;
    string a;
    cin >> a;
    int c = 0;
    for(int i=0;i<n-2;i++)
    {
        if(a[i]=='A' and a[i+1]=='B' and a[i+2]=='C')
            c++;
    }
    cout << c << endl;
}

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

using namespace std;

string s;

int main() {
    cin >> s;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0, len = s.length(); i < len; ++i) {
        if (s[i] == 'o') {
            cnt1++;
        } else {
            cnt2++;
        }
    }
    if (cnt2 >= 8) {
        puts("NO");
    } else {
        puts("YES");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	float a,b,c,d;
	cin>>a>>b>>c>>d;
	//cout<<(float)ceil(c/b)<<" "<<ceil(a/d);

	if(ceil(c/b) <= ceil(a/d))
		cout<<"Yes";
	else 
		cout<<"No";
	
}

Measured memory_bytes: 3724
a=[int(i) for i in input().split()] 
l=min(a[0],a[3],a[4])
a0=(a[0]-l)//2
a3=(a[3]-l)//2
a4=(a[4]-l)//2

if l>0:
  l1=l-1
else:
  l1=0
a10=(a[0]-l1)//2
a13=(a[3]-l1)//2
a14=(a[4]-l1)//2


print(a[1]+max(l*3+a0*2+a3*2+a4*2, l1*3 + a10*2 + a13*2 + a14*2))

Measured memory_bytes: 3064