akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int n;
	cin >> n;
	map<string, int> mp;
	int mx = 0;
	while(n--) {
		string s;
		cin >> s;
		mp[s]++;
		mx = max(mx, mp[s]);
	}
	for(auto x: mp) {
		if(x.second == mx) {
			cout << x.first << "\n";
		}
	}
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 19244
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define MAX_N 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1
typedef pair<ll, ll> P;

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

int R, C, sy, sx, gy, gx;
vector<string> c(50);
vector<vector<int>> cnt(50, vector<int>(50, -1));

void print(vector<ll> &v) {
    rep(i, v.size()) {
        if(i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

void bfs(int sy, int sx) {
    queue<P> q;
    q.push(P(sy, sx));
    cnt[sy][sx] = 0;

    while(q.size()) {
        P v = q.front();
        int pre_y = v.first;
        int pre_x = v.second;
        q.pop();

        // for(int i = 0; i < 4; i++) {
        //     int y = pre_y + dy[i];
        //     int x = pre_x + dx[i];

        //     if(c[y][x] == '#')
        //         continue;
        //     if(c[y][x] == '.') {
        //         q.push(P(y, x));
        //         cnt[y][x] = cnt[pre_y][pre_x] + 1;
        //     }
        // }
    }
}

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    if(A >= K) {
        A -= K;
    } else {
        B -= K - A;
        A = 0;
        if(B < 0) {
            B = 0;
        }
    }

    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
#AB=[list(map(int,input().split()) for _ n range(N))]
p=[[] for _ in range(N+1)]
for _ in range(M):
    a,b=map(int,input().split())
    p[a].append(b)
    p[b].append(a)
#print(p)
sirube=[-1]*N
visited=[True]+[False]*(N-1)
def bfs():
    global visited,sirube
    queue=[1]
    while queue:
        now=queue.pop(0)
        #print(now)
        for n in p[now]:
            if not visited[n-1]:
                queue.append(n)
                visited[n-1]=True
                sirube[n-1]=now
    return
bfs()
if -1 in sirube[1:]:
    print("No")
    exit()

print("Yes")
for sir in sirube[1:]:
    print(sir)


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

int main() {
  string n;
  cin >> n;

  if ((n.at(0) == n.at(1) && n.at(1) == n.at(2)) || (n.at(1) == n.at(2) && n.at(2) == n.at(3))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){

    
    string s;
    cin >> s;
    //cout << s << endl;

    ll s_length = s.length()-1;
    //cout << s_length << endl;

    ll ans = 0;

    REP(i, (1<<s_length)){
        //cout << i << endl;
        ll tmp = 0;
        ll sum = 0;
        tmp = s[0]-'0';


        REP(j,s_length){

            if((i>>j) &1){
                sum += tmp;
                tmp = s[j+1]-'0';
            }else{
                tmp = tmp*10 + s[j+1]-'0';
            }

        }
        sum += tmp;
        ans += sum;
        //cout << sum << endl;
    }
    
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let h = get!([usize]);
    let mut before = std::usize::MAX;
    let mut count = 0;
    let mut mx = 0;
    for e in h {
        if before >= e {
            count += 1;
        } else {
            mx = max!(mx, count);
            count = 1;
        }
        before = e;
    }
    mx = max!(mx, count);
    println!("{}", mx-1);
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

class UnionFind {
public:
  // 親の番号を格納する。親だった場合は-(その集合のサイズ)
  vector<int> Parent;

  // 作るときは Parent の値を全て -1 にする
  // こうすると全てバラバラになる
  UnionFind(int N) {
    Parent = vector<int>(N, -1);
  }

  // A がどのグループに属しているか調べる
  int root(int A) {
    if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }

  // 自分のいるグループの頂点数を調べる
  int size(int A) {
    return -Parent[root(A)];
  }

  // A と B をくっつける
  bool connect(int A, int B) {
    // A と B を直接くっつけるのではなく，root(A) に root(B) をくっつける
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;  // すでにくっついているからくっつけない
    }

    // 大きい方(A) に小さい方をくっつけたい
    // 大小が逆だったらひっくり返す
    if (size(A) < size(B)) swap(A, B);

    // A のサイズを更新する
    Parent[A] += Parent[B];
    // B の親を A に変更する
    Parent[B] = A;
    return true;
  }
};

int main() {
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind road(n);
  UnionFind rail(n);
  rep(i, k) {
    int p, q;
    cin >> p >> q;
    road.connect(p-1, q-1);
  }
  rep(i, l) {
    int r, s;
    cin >> r >> s;
    rail.connect(r-1, s-1);
  }

  map<pair<int, int>, int> mp;
  rep(i, n) {
    pair<int, int> tmp = make_pair(road.root(i), rail.root(i));
    if (mp.count(tmp) == 0) {
      mp[tmp] = 1;
    } else {
      mp[tmp]++;
    }
  }

  rep(i, n) {
    pair<int, int> tmp = make_pair(road.root(i), rail.root(i));
    cout << mp[tmp] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ALL(v)   v.begin(),v.end()
ll mod = 1e9 + 7;
ll power(ll a, ll b)
{
	ll re = 1;
	while(b)
	{
		while(!(b &1)){a = (a*a)%mod ; b>>=1;}
		re = (re*a)%mod;
		--b;
	}
	return re;
}
ll solve(ll a, ll b)
{
	if(a < b)
		return 0;
	ll re = 1, re1 = 1;
	for(ll x =0; x<b; x++)
	{
		re = (re * (a-x)) % mod;
		re1 = (re1 * (x+1)) % mod;
	}
	return (re * power(re1, mod- 2)) % mod;
}
int main()
	{
		speed
		ll n, k;
		cin >> n >> k;
		for(ll x =1; x<=k ; x++)
		{
			cout << (solve(n-k+1, x) * solve(k -1, x-1))%mod << "\n";
		}
	}	


Measured memory_bytes: 256
def Recording():
    n, c = map(int, input().split())
    num = 2*10**5+1 

    # チャンネルごとにimos配列
    imos = [[0]*num for _ in range(c)]
    
    # imos
    for _ in range(n):
        s, t, c0 = map(int, input().split())
        if imos[c0-1][s*2] < 0 and imos[c0-1][t*2-1] > 0:
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2-1] = 0
        elif imos[c0-1][s*2] < 0:            
            imos[c0-1][s*2] = 0
            imos[c0-1][t*2] -= 1
        elif imos[c0-1][t*2-1] > 0:    
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2-1] = 0
        else:
            imos[c0-1][s*2-1] += 1
            imos[c0-1][t*2] -= 1
    ans = [0 for _ in range(num)]
    for i in range(c):
        for j in range(1, num):
            imos[i][j] += imos[i][j-1]
            ans[j] += imos[i][j]
    print(max(ans))
    
if __name__ == '__main__':
    Recording()
    


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

using namespace std;

#define ll long long
#define sz(x) (int) ((x).size())

int main() {
	int n;
	cin >> n;
	map<string, int> mp;
	int mx = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mx = max(mx, ++mp[s]);
	}
	for (auto x : mp) {
		if (x.second == mx) {
			cout << x.first << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 25216
N=int(input())
a = []
for i in range(N):
  a.append(int(input()))
  
a.sort()
ans = sum(a)
for i in range(N):
  if ans % 10 == 0:
    ans -= a[0]
    for j in range(1,N):
      if ans % 10 == 0:
        ans += a[j-1]
        ans -= a[j]
      else:
        print(ans)
        exit(0)
    ans += a[N-1]
  else:
    print(ans)
    exit(0)
  ans -= a[i]
print(0)

Measured memory_bytes: 3064
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

string a, b="CODEFESTIVAL2016";

int main()
{
	int i, j, k, l;
	cin>>a;
	int ans=0;
	for(i=0;i<16;i++) ans+=a[i]!=b[i];
	cout<<ans<<endl;
	return 0;
}
//*/

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

using namespace std;

#define  N 200200

const double PI = 3.14159265359;
typedef long long ll;

int a[N];

void solve() {
    ll n;
    cin >> n;
    if (n & 1) {
        cout << 0 << endl;

    } else {
        ll ans = 0;
        for (ll x = 10; x <= n; x *= 5) {
            ans += n / x;
        }


        cout << ans << endl;
    }

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef qwerty
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif


    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<pair<int,int>>p(5);
	for(int i=0;i<5;++i){
		int a;
		cin >> a;
		p[i]=make_pair((a-1)%10,a);
	}
	int ans=0;
	sort(p.begin(),p.end());
	for(int i=1;i<5;++i){
		ans+=p[i].second+10-p[i].first-1;
	}
	ans+=p[0].second;
	cout <<ans;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

length = len(a)
b = [0] * length
center = length // 2

if len(a) % 2 != 0:
    before = center
    for i in range(len(a)):
        if i == 0:
            b[center] = a[i]
        else:
            if i % 2 != 0:
                before = before + i
            else:
                before = before - i
            b[before] = a[i]
else:
    before = center
    for i in range(len(a)):
        if i == 0:
            b[center] = a[i]
        else:
            if i % 2 != 0:
                before = before - i
            else:
                before = before + i
            b[before] = a[i]


L = [str(v) for v in b]
L = ' '.join(L)
print(L)


Measured memory_bytes: 29460
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
#define C


#ifdef C
int main(void)
{
	int H, W;
	vector<pair<int, int> > arr;
	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		arr.push_back(pair<int, int>(H, W));

	}
	for (auto a : arr) {
		for (size_t i = 0; i < a.first; i++)
		{
			bool f = (i % 2 == 0) ? true : false;
			for (size_t j = 0; j < a.second; j++)
			{
				if (f)
					cout << "#";
				else
					cout << ".";
				f = !f;
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}
#endif // C

Measured memory_bytes: 3068
def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    cal=0
    time=[0]*N
    town=[]
    roop=[]

    while time[cal]!=2:
        if time[cal]==0:
            town.append(cal)

        else :
            roop.append(cal)

        time[cal]+=1
        cal=A[cal]-1

    if len(town)>K:
        print(town[K]+1)
        return

    else :
        print(roop[(K-(len(town)-len(roop)))%len(roop)]+1)
        return
main()


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var NR = IO_ShortCut.ReadSplitLong;
            var N = NR[0];
            var R = NR[1];

            var ans = R + (N < 10 ? (10 - N) * 100 : 0);
            WriteLine(ans);
        }
    }

    public class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

        #endregion
    }

    /// <summary>
    /// 正の数の四則演算のみ対応
    /// </summary>
    public class Mod
    {
        // 割る数の定義
        private readonly static long M = 1000000007;

        // 足し算
        public static long Add(long a, long b) => (a * b) % M;
        // 引き算
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        // 掛け算
        public static long Multi(long a, long b) => (a * b) % M;
    }

    public class MathLib
    {
    }
}

Measured memory_bytes: 11220
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int main()
{
	int h, w, n;
	scanf("%d%d%d", &h, &w, &n);
	int limit = h;
	if (limit < w) limit = w;
	
	int ans = n / limit;
	if (n % limit != 0) {
		ans++;		
	}
		
	printf("%d\n", ans);
	
	return 0;
}



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

int main(){
	while(1){
		int a,b,c,ans=0;
		cin>>a>>b>>c;
		if(a==0&&b==0&&c==0) break;
		for(int i=1;i<1000;i++){
			for(int j=1;j+i<1000;j++){
				if(i*(a+100)/100+j*(a+100)/100==c){
					ans=max(ans,(i*(b+100)/100+j*(b+100)/100));
				}
			}
		}
		cout<<ans<<endl;
	}		
	return 0;
}


Measured memory_bytes: 3064
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

void solve(){
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d;
	a=a-1;
	e=(c*d)/__gcd(c,d);
	cout<<b-a-b/c+a/c-b/d+a/d+b/e-a/e<<endl;
}
int main()
{
	waste;
	int t;
//	cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200100


int main(void){
map<long long,long long>m;
set<long long>ss;
long long s,ans;
int n;
long long x;
scanf("%d",&n);
s=0;
ans=0;
ss.insert(s);
m[s]=0;
f(i,n){
scanf("%lld",&x);
s+=x;
if(ss.count(s)==1){
ans=max(ans,i+1-m[s]);
}
else{
ss.insert(s);
m[s]=i+1;
}
}
printf("%lld\n",ans);

return 0;
}


Measured memory_bytes: 24500
N = int(input())
P = list(map(int, input().split()))

ans = 0
# print(P)

for i in range(N - 1):
    if P[i] != int(i + 1):
        continue
    else:
        P[i], P[i + 1] = P[i + 1], P[i]
        # print(i + 1, P)
        ans += 1


# 最後を見てなかった！！！！
if P[-1] == N:
    ans += 1

print(ans)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;


int main() {
    ll k, n, m,ans1 = 0, ans2 = 0, min = 10000000000;
    
    cin>>k>>n;
    vector<ll> a(n);
    rep(i, n) cin>>a[i];
    
    ans1 = (a[n-1] - a[0]);
    
    m= k/2;
    for(int i = 0; i<n;i++){
        if(i==0) ans2 = a[n-1] - a[0];
        
        else{
            if(a[i-1]==0) ans2 = k - a[i];
            else ans2 = k - a[i] + a[i-1];
        }
        if(min>= ans2) min = ans2;
        
    }
    if(ans1>min) cout<<min<<endl;
    else cout<<ans1<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI p(n);
  REP(i, 0, n) {
    cin >> p[i];
    p[i]--;
  }
  VI inv(n);
  REP(i, 0, n) inv[p[i]] = i;
  int len = 0;
  int cur = 0;
  REP(i, 1, n) {
    if (inv[i - 1] > inv[i]) {
      len = max(len, i - cur);
      cur = i;
    }
  }
  len = max(len, n - cur);
  cout << n - len << endl;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
    	//AtCoder Beginner Contest 053
    	//a
    	Scanner sc = new Scanner(System.in);
    	int x = Integer.parseInt(sc.next());
    	if( x < 1200 ) System.out.println("ABC");
    	else System.out.println("ARC");    	
    }
}

Measured memory_bytes: 21588
<?php

$is_honban = 1;

if ($is_honban) {
  //----------------------------------------------------------------------------------
  // Input for honban
  //----------------------------------------------------------------------------------
  $sc = new Scanner();
  $s = $sc->next();

//  $a = array();
//  for ($i = 0; $i < $n; $i++) {
//    $a[] = $sc->nextInt();
//  }


} else {
  //----------------------------------------------------------------------------------
  // Input for test
  //----------------------------------------------------------------------------------
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  $s = 'dreameras';



}
//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

$pieces = array('dream','dreamer','erase','eraser');

$ng_count = 0;
$ans = 'YES';
while (strlen($s) > 0) {
  foreach ($pieces as $piece) {
    if (substr($s, -strlen($piece)) == $piece) {
      $s = substr($s, 0, strlen($s) - strlen($piece));
      $ng_count = 0;
    } else {
      $ng_count++;
      if ($ng_count == 10) { $ans = 'NO'; break 2; }
    }
  }
}


//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
out::println($ans);



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  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();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


Measured memory_bytes: 3980
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c = (int(_) for _ in input().split())
    if b-a == c-b:
        print('YES')
    else:
        print('NO')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  string s, t;
  rep(i, n) {
    cin >> s >> t;
    vector <vector <ll>> dp(s.size()+1, vector <ll> (t.size()+1));
    rep(i, s.size()) dp.at(i).at(0) = 0;
    rep(i, t.size()) dp.at(0).at(i) = 0;
    rep(i, s.size()) {
      rep(j, t.size()) {
        if (s.at(i) == t.at(j)) {
          dp.at(i+1).at(j+1) = dp.at(i).at(j) + 1;
        } else {
          dp.at(i+1).at(j+1) = max(dp.at(i+1).at(j), dp.at(i).at(j+1));
        }
      }
    }
    cout << dp.at(s.size()).at(t.size()) << endl;
  }
}


Measured memory_bytes: 10736
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int cnt = 0;
	while (a > 0 && c > 0) {
		if (cnt % 2 == 0) {
			c -= b;
			if (c <= 0) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		else {
			a -= d;
			if (a <= 0) {
				cout << "No" << endl;
				return 0;
			}
		}
        cnt++;
	}
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, cnt = 0; cin >> N;
    int M = N;
    while (N > 0) {
        N -= 1000;
        cnt++;
    }
    if (N % 1000 == 0) printf("%d\n", 0);
    else {
        printf("%d\n", 1000 * cnt - M);
    }
}


Measured memory_bytes: 3692
#include<stdio.h>
#include<stdlib.h>
#define MAX 100

main()
{
  int S[MAX], i=0, x, a;
  char input[MAX];

  while(scanf("%s", input) != EOF)
    {
      if(input[0] == '+')
	{
	  S[i-2] = S[i-1] + S[i-2];
	  i--;
	}
      else if(input[0] == '-')
	{
	  S[i-2] = S[i-2] - S[i-1];
	  i--;
	}
      else if(input[0] == '*')
	{
	  S[i-2] = S[i-2] * S[i-1];
	  i--;
	}
      else
	{
	  x = atoi(input);
	  S[i] = x;
	  i++;
	}

    }

  printf("%d\n", S[i-1]);

  return 0;
}

Measured memory_bytes: 548
#include "bits/stdc++.h"
using namespace std;
const int INF = 1001001001;
int main() {
	int N,M;
	cin >> N >> M; 
	vector<int>A(M);
	vector<int>C(M);
	for (int m = 0;m<M; ++m) {
		int B;
		cin >> A[m] >> B;
		int bit = 0;
		for (int b = 0;b<B;++b) {
			int c;
			cin >> c;
			bit |= 1 << (c-1);
		}
		C[m] = bit;
	}
	/*for (int m = 0; m < M; ++m) {
		cout << C[m]<<  endl;
	}*/
	int nMax = 1 << N;
	vector<vector<int>> dp(M + 1, vector<int>(nMax, INF));	
	dp[0][0] = 0;
	for (int m = 0; m < M; ++m) {
		for (int n = 0; n < nMax; ++n) {
			if (INF != dp[m][n]) {
				dp[m + 1][n] = min(dp[m + 1][n], dp[m][n]);
				int num = n | C[m];
				dp[m + 1][num] = min(dp[m + 1][num], dp[m][n] + A[m]);
			}
		}
		/*for (int n = 0; n < nMax; ++n) {
			cout << dp[m + 1][n] <<  endl;
		}*/
	}

	if (INF == dp[M][nMax - 1]) {
		cout << -1 << endl;
	}
	else{
		cout << dp[M][nMax - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 19364
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	constexpr long long MOD = 1000000007;
	constexpr long long inv_2_MOD = 500000004;

	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	long long sum = 0;
	long long sum_sqr = 0;
	for (long long val : a)
	{
		sum += val;
		sum_sqr += (val * val) % MOD;
	}
	sum %= MOD;
	sum_sqr %= MOD;
	cout << (((sum * sum - sum_sqr) % MOD) * inv_2_MOD) % MOD << endl;
}

Measured memory_bytes: 4840
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();
		int n2 = 'z' - 'a';
		int cnt[][] = new int[n][n2 + 1];
		for(int i = 0; i < n; ++i) {
			if(i != 0) {
				for(int j = 0; j < n2 + 1; ++j) {
					cnt[i][j] = cnt[i - 1][j];
				}
			}
			int tmp = s.charAt(i) - 'a';
			cnt[i][tmp]++;
		}
		int ans = 0, a = 0;
		for(int i = 0; i < n; ++i) {
			a = 0;
			for(int j = 0; j < cnt[i].length; ++j) {
				int tmp = cnt[n - 1][j] - cnt[i][j];
				if(Math.min(tmp,  cnt[i][j]) > 0)++a;
			}
			ans = Math.max(ans, a);
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 22740
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;


const ll inf = 1e14;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<PI> > edges(n);
  vector<vector<int> > mat(n, VI(n, 0));
  REP(i, 0, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edges[a].push_back(PI(b, c));
    edges[b].push_back(PI(a, c));
    mat[a][b] = c;
    mat[b][a] = c;
  }
  VL conn(1 << n);
  REP(bits, 0, 1 << n) {
    ll sum = 0;
    REP(u, 0, n) {
      if ((bits & 1 << u) == 0) { continue; }
      REP(v, u + 1, n) {
	int c = mat[u][v];
	if (bits & 1 << v) {
	  sum += c;
	}
      }
    }
    conn[bits] = sum; // All edges are counted once
  }
  vector<VL> dp(1 << n, VL(n, -inf));
  REP(bits, 1, 1 << n) {
    REP(i, 0, n) {
      if ((bits & 1 << i) == 0) { continue; }
      ll ma = -inf;
      REP(u, 0, n) {
	if (u == i || (bits & 1 << u) == 0) { continue; }
	if (mat[u][i] == 0) { continue; }
	int iex = bits ^ 1 << i ^ 1 << u;
	for (int sub = iex; true; sub = (sub - 1) & iex) {
	  ll tmp = dp[sub ^ 1 << u][u] + conn[bits - sub - (1 << u)] + mat[u][i];
	  ma = max(ma, tmp);
	  if (sub == 0) {
	    break;
	  }
	}
      }
      if (i == 0) {
	ma = max(ma, conn[bits]);
      }
      // cerr << "dp[" << bits << "][" << i << "]=" << ma << "\n";
      dp[bits][i] = ma;
    }
  }
  int ma = dp[(1 << n) - 1][n - 1];
  cout << conn[(1 << n) - 1] - ma << "\n";
}


Measured memory_bytes: 5376
#include<iostream>
#include<vector>

using namespace std;

vector<long long> L;

int main(void){
    int N,ans = 0;
    cin >> N;
    L = vector<long long>(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
    }

    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                int a=L[i],b=L[j],c=L[k];
                if(a!=b && b!=c && a!=c){
                    if((a+b>c)&&(a+c>b)&&(c+b>a)){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using T = tuple<int, int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;

    vector<T> v;
    for (int i = 0; i < n; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        v.emplace_back(s - x, 1, x);
        v.emplace_back(t - x, -1, x);
    }
    sort(v.begin(), v.end());

    set<int> se;
    int idx = 0;
    for (int i = 0; i < q; i++) {
        int d;
        cin >> d;
        while (idx < v.size()) {
            int t, com, x;
            tie(t, com, x) = v[idx];
            if (t > d) break;
            if (com == 1) se.insert(x);
            else se.erase(x);
            idx++;
        }
        cout << (se.empty() ? -1 : *se.begin()) << "\n";
    }
    return 0;
}

Measured memory_bytes: 16236
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

const double PI = acos(-1);

int main(){

    int X;

    cin >> X;
    if (X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
using namespace std;

template<typename T>
vector<T>divisor(T n){//約数列挙
    vector<T>v;
    for(T i=1;i*i<=n;++i){
        if(n%i==0){
            v.push_back(i);
        if(i*i!=n)v.push_back(n/i);
        }
    }
    sort(v.begin(),v.end());
    return v;
}

void solve()
{
    ll n, m;
    cin >> n >> m;
    if(m%n!=0){
        ll ans = 1;
        for (auto x : divisor<ll>(m))
        {
            if(x*n<=m){
                chmax(ans, x);
            }
        }
        cout << ans;
    }
    else
        cout << m / n;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		for (var k = 1; ; k++)
		{
			var N2 = k * (k - 1) / 2;
			if (N2 > N) { WriteLine("No"); break; }
			if (N2 == N)
			{
				WriteLine("Yes");
				WriteLine(k);
				var s = new List<int>[k];
				for (var i = 0; i < k; i++) s[i] = new List<int>();
				var n = 1;
				for (var i = 0; i < k; i++)
				{
					for (var j = i + 1; j < k; j++)
					{
						s[i].Add(n);
						s[j].Add(n++);
					}
				}
				for (var i = 0; i < k; i++) WriteLine($"{k - 1} {string.Join(" ", s[i])}");
				break;
			}
		}
	}
}


Measured memory_bytes: 18384
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<iostream>
#define ll long long
using namespace std;
const int N = 20;
int n,ans,a[N],u[N],x[N][N],y[N][N];
void dfs(int d){
	if(d>n){
		for(int i=1;i<=n;i++) 
			if(u[i]){
				for(int j=1;j<=a[i];j++)
					if(u[x[i][j]]!=y[i][j])return;
			}
		int sum=0;
		for(int i=1;i<=n;i++) 	
			if(u[i]) sum++;
		ans=max(ans,sum);
		return;
	}
	u[d]=1;
	dfs(d+1);
	u[d]=0;
	dfs(d+1);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		for(int j=1;j<=a[i];j++)
			scanf("%d%d",&x[i][j],&y[i][j]);
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
N = int(input())

abc = [111, 222, 333, 444, 555, 666, 777, 888, 999]

ans = 0

if N <= 111:
    ans = 111

for i in range(len(abc)-1):
    if abc[i] < N <= abc[i+1]:
        ans = abc[i+1]
        break

print(ans)


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n+1)
	bs := make([]int, n)
	for i := 0; i < n+1; i++ {
		fmt.Scan(&as[i])
	}

	c := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&bs[i])

		m := 0
		if as[i] < bs[i] {
			m = as[i]
		} else {
			m = bs[i]
		}
		as[i] -= m
		bs[i] -= m
		c += m

		if as[i+1] < bs[i] {
			m = as[i+1]
		} else {
			m = bs[i]
		}
		as[i+1] -= m
		c += m
	}
	fmt.Println(c)
}


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

int euler(int num){
    int abc=num;
    for(int i=2;i*i<=num;i++){
        if(abc%i==0){
            num=num/i*(i-1);
            while(abc%i==0) abc/=i;
        }
    }
    if(abc!=1) num=num/abc*(abc-1);
    return num;
}

int main(){
    ll n;
    cin >> n;
    cout << euler(n) << endl;

    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m, l, g[N][N], a[N * N];

void Next(int &x, int &y){
	if(x & 1){
		if(y + 1 <= m) y ++;
		else x ++;
	}
	else{
		if(y - 1 >= 1) y --;
		else x ++; 
	}
	return;
}

int main(){
	scanf("%d%d%d", &n, &m, &l);
	for(int i = 1; i <= l; i ++) scanf("%d", &a[i]);
	int sx = 1, sy = 1;
	for(int i = 1; i <= l; i ++){
		while(a[i]){
			g[sx][sy] = i;
			a[i] --;
			Next(sx, sy);
		}
	}
	
	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++)	
			printf("%d ", g[i][j]);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ABK = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];
            for (var i = A; i <= Math.Min(A + K - 1, B); i++)
            {
                Console.WriteLine(i);
            }
            for (var i = Math.Max(B - K + 1, A + K); i <= B; i++)
            {
                Console.WriteLine(i);
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i<n; i++)
#define ll long long
#define MOD 1000000007
using namespace std;;
 
ll calc(ll a, ll b) {
  if (b ==0) return 1;
  if (b % 2 ==0) {
    ll d = calc(a,b/2);
    return(d*d) % MOD;
  }
  if (b % 2 ==1) return (a*calc(a,b-1)) % MOD;
}

ll combi(ll a, ll b) {
  ll ans=1, M = min(b,a-b);
  rep(i,0,M) {
    ans *= a - i; ans %= MOD;
  }
  rep(i,1,M+1) {
    ans *= calc(i,MOD-2) % MOD;
    ans %= MOD;
  }
  return ans;
}

int main() {
  ll X,Y,a,b; cin >> X >> Y;
  if (2 * Y - X >=0 && (2 * Y - X) % 3 ==0) {
    a = (2 * Y - X) / 3;
  } else {
    cout << 0 << endl; return 0;
  }
  if (2 * X - Y >=0 && (2 * X - Y) % 3 ==0) {
    b = (2 * X - Y) / 3;
  } else {
    cout << 0 << endl; return 0;
  }
  
  ll ans = combi(a+b,b);
  cout << ans << endl;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	vector<llong> a;

	cin >> N;
	a.resize(N);
	for(int i = 0; i < N; i++)
		cin >> a[i];

	llong ans = 0, col = -1;
	for(auto x : a)
		if(x == col)
			ans++, col = -1;
		else
			col = x;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;int main(){int c[6];for(int i=0;i<6;i++)cin>>c[i];if(c[0]+c[1]*5+c[2]*10+c[3]*50+c[4]*100+c[5]*500>=1000)cout<<"1"<<endl;else cout<<"0"<<endl;return 0;}

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

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> cnt(M);
  for (int x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < M; i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, t, a; cin >> n >> t >> a;
  vector<int> h(n); for(int i = 0; i < n; i++) cin >> h[i];
  vector<int> x(n); for(int i = 0; i < n; i++) x[i] = (int)abs(t * 1000 - h[i]*6 - a * 1000);
  int cc = 1<<30;
  int ans=1;
  for(int i = 0; i < n; i++) {
    if(x[i] < cc) cc = x[i], ans=i+1;
  }
  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

	vector<LL> T(N + 1);
	vector<LL> X(N+1);
	vector<LL> Y(N+1);

	T[0] = 0;
	X[0] = 0;
	Y[0] = 0;

	bool flag = true;

	FOR(i,1,N+1) {
		cin>>T[i] >> X[i] >> Y[i];

		if (abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]) <= (T[i] - T[i - 1]) &&
			(abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]) )% 2 == (T[i] - T[i - 1]) % 2) {

		}
		else {
			flag = false;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int sz = 550;

int c[500], f[500], s[500];
int res[550];

int findNext(int tm, int s, int f){

    int cur = s;
    while(cur<tm){
        cur += f;
    }

    return cur;

}
int main() {

    int n;
    cin>>n;

    for(int i = 1; i<n; i++) cin>>c[i]>>s[i]>>f[i];

    for(int i = 1; i<n; i++){

        int tm = 0;
        int cur = i;

        for(int j = i; j<n; j++){


            if(tm<=s[j])

            tm = s[j];

            else {


                int x = findNext(tm, s[j], f[j]);

                tm = x;
            }

            tm += c[j];

          //  cout<<j<<" -> "<<tm<<endl;
        }

        res[i] = tm;



    }

    for(int i = 1; i<=n; i++) cout<<res[i]<<endl;
    puts("");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void){
    int N,M;
    cin >> N;
    cin >> M;

    multiset<int> points;
    int num;

    for(int i=0;i<N;i++){
        cin >> num;
        points.insert(num);
    }

    for(int i=0;i<M;i++){
    auto p_i = points.end();
      --p_i;
    int max =  *p_i;
    max = max/2;
    points.erase(p_i);
    points.insert(max);
    }
  

    long long result = 0;
    for(auto itr=points.begin();itr != points.end();++itr){
        result += *itr;
    }

    cout << result << endl;
    return 0;

}

Measured memory_bytes: 4992
N = gets.to_i
As = gets.split.map(&:to_i)

require 'prime'

ul = As.max
ps = Prime.each(ul).to_a
h = As.tally; h.default = 0
s = ps.map{|p| p.step(ul, p).inject(0){|r, q| r + h[q]}}.max || 0
puts (s <= 1 ? 'pairwise' : s == N ? 'not' : 'setwise') + ' coprime'


Measured memory_bytes: 147532
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

ll gcd(ll a,ll b){
    if(a%b==0) return b;
    else return gcd(b,a%b);
}

int main() {
    ll A,B;
    cin>>A>>B;
    ll g=gcd(A,B);
    //cout<<g<<endl;

    ll ans=1ll;
    ll tmp=sqrt(g)+1;
    for (ll i = 2; i <= tmp; ++i) {
        if(g%i!=0) continue;
        ans++;
        while(g%i==0){
            g/=i;
        }
    }
    if(g!=1) ans++;
    //cout<<g<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define iamabatman ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precision cout.precision(10); cout << fixed;
#define endl '\n'
#define ll long long int
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
using namespace std;
int main()
{

  iamabatman
  precision
  string s;
  bool ok=false;
  cin>>s;
  for(int i=0;s[i]!='\0';i++)
  {
    if(s[i]=='7')
    ok=true;
  }
  if(ok)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}



Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=n;;i++)
	{
		if(i/100==i/10%10&&i/100==i%10)
		{
			printf("%d",i);
			return 0;
		}
	 } 
 } 

Measured memory_bytes: 128