akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var s = Console.ReadLine();
		int r = 0;
		int h = 0;
		foreach(var c in s)
		{
			if(c == '(')
			{
				h++;
			}
			if(c == ')')
			{
				if(h==0)
					r++;
				else
					h--;
			}
		}
		for(int i = 0; i < r; i++)
			Console.Write("(");
		Console.Write(s);
		for(int i = 0; i < h; i++)
			Console.Write(")");
		Console.WriteLine();
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<ll> x(N), y(M);
	REP(i, N) cin >> x[i];
	REP(i, M) cin >> y[i];

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	ll mx = x[N-1];
	ll my = y[0];

	for(int i=mx+1;i<=my;i++){
		if(X<i && i<=Y){
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c,t;
  cin >> a >> b >> c;
  if (a>b) t = a, a = b, b = t;
  if (b>c) t = b, b = c, c = t;
  if (a>b) t = a, a = b, b = t;
  cout << a << " " << b << " " << c <<endl;
  return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
int main(void){
  int n,a[200000],i,j,b[200000],c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    b[i]=0;
  }
  for(i=0;i<n-1;i++){
    scanf("%d",&a[i]);
    b[a[i]-1]+=1;
  }
  for(i=0;i<n;i++){
    printf("%d\n",b[i]);
  }
  return 0;
}


Measured memory_bytes: 3252
#include <stdio.h>

int N, M, A[112], B[112][112];
int ans[112], wronger = 0;

int main(void) {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) { scanf("%d", &A[i]); }
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < N; ++j) {
			scanf("%d", &B[i][j]);
		}
	}

	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < N; ++j) {
			if (A[i] == B[i][j]) { ans[j]++; }
			else { wronger++; }
		}
		ans[A[i] - 1] += wronger;
		wronger = 0;
	}

	for (int i = 0; i < N; ++i) { printf("%d\n", ans[i]); }
	return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x) 
using namespace std;
const int N = 1e6+5;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;
typedef long long ll;
ll inv(ll b)
{
	if(b == 1)
	return 1;
	return (mod-mod/b)*inv(mod%b)%mod;
}
ll fac[N];
ll C(ll n,ll m)
{
	ll t = (fac[m]*fac[n-m])%mod;
	if(t == 0)
	return 1;
	return (fac[n]*inv(t))%mod;
}
ll ans[N][2];
int main()
{
	ll n,i,a,b,k;
	fac[0] = 1;
	fac[1] = 1;
	for(i = 2;i <= 3e5+5;i++)
	fac[i] = (fac[i-1]*i)%mod;
	sl(n);sl(a);sl(b);sl(k);
	ll cnt = 0;
	for(i = 0;i <= n;i++)
	{
		if(k-(i*a) >= 0 && (k-a*i)%b == 0 && (k-a*i)/b <= n)
		{
			ans[cnt][0] = i;
			ans[cnt++][1] = (k-a*i)/b;
		}
	}
	ll res=0;
	for(i = 0;i < cnt;i++)
	{
		res = (res+C(n,ans[i][0])*C(n,ans[i][1])%mod)%mod;
	}
	pl(res);
}

Measured memory_bytes: 8448
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,M;
int A[10005];
signed main(){
    scanf("%lld %lld",&N,&M);
    int sum=0;
    rep(i,M){
        scanf("%lld",&A[i]);
        sum+=A[i];
    }
    int ans=max((int)-1,N-sum);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1800
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static void Main()
    {
        var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (r[1] - r[2] >= 0)
        {
            Console.WriteLine("delicious");
        }
        else if (r[0] + (r[1] - r[2]) >= 0)
        {
            Console.WriteLine("safe");
        }
        else
        {
            Console.WriteLine("dangerous");
        }
    }
}

Measured memory_bytes: 27948
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
using namespace std;

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

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------

string s, f;

int main() {
  cin >> s >> f;
  int s_i = s.size();
  bool ans = false;

  rep(i, s_i) {
    if(s == f) {
      ans = true;
      break;
    }
    s = s.back() + s.substr(0, (s_i-1));
  }

  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
N=int(input())
numbers=[]
for _ in range(N):
    a,b,c=input().split()
    numbers.append([int(a),int(b),int(c)])
dp = [[0 for i in range(3)] for j in range(N+1)]
def chmax(a,b):
    if a>=b:
        return a
    else:
        return b
for i in range(1,N+1):
    for j in range(3):
        K=[a for a in range(3) if a!=j]
        for k in K:
            dp[i][k]=chmax(dp[i][k],dp[i-1][j]+numbers[i-1][k])
print(max(dp[-1]))


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

int main(){
	string s;
	while(cin >> s){
		int n = s.length();
		int joi=0, ioi=0;
		for(int i=0; i<n-2; i++){
			if(s[i+1]=='O' && s[i+2]=='I'){
				if(s[i]=='J') joi++;
				if(s[i]=='I') ioi++;
			}
		}
		cout << joi << endl << ioi << endl;
	}
	return 0;
}


Measured memory_bytes: 3152
def run(n, w):
    for i in range(n-1):
        if w[i] in w[i+1:]:
            return 'No'
        if w[i][len(w[i])-1] != w[i+1][0]:
            return 'No'
    return 'Yes'


def main():
    n = int(input())
    w = []
    for i in range(n):
        w.append(input())
    print(run(n, w))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		if(a>b) printf("a > b\n");
		else if(a<b) printf("a < b\n");
		else printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2136
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			if(n==0 && k==0)break;
			int[] a = new int[n];
			int[] b = new int[n-k+1];
			
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
			}
			
			for(int i=0;i<n-k+1;i++){
				for(int j=0;j<k;j++){
					b[i] += a[i+j];
				}
			}
			
			Arrays.sort(b);
			
			System.out.println(b[n-k]);
		}
	
	}	
}

Measured memory_bytes: 64308
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  string s;
  cin >> s;
  int sum = 0;
  REP(i,s.size()){
    sum += s[i]-'0';
  }
  if (stoi(s)%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[100005],b[100005];
int a[100005],ans=0,cnt=0;
inline int abs(int x)
{return (x<0?-x:x);}
int main (){
	scanf ("%s",s+1);
	int len=strlen(s+1),i;
	for (i=1;i<=len;i++)
	{if (s[i]!='x')
	{a[++cnt]=i;
	b[cnt]=s[i];
	}
	}
	for (i=1;i<=cnt;i++)
	{if (b[i]!=b[cnt+1-i])
	{puts("-1");return 0;}
	}
	a[cnt+1]=len+1;
	for (i=1;i<=cnt+1-i;i++)
	{int k1=a[i]-a[i-1]-1;
	int k2=a[cnt+2-i]-a[cnt+1-i]-1;
	ans+=abs(k1-k2);
	}
	printf ("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
let rec tabulate n f = 
  let rec loop acc m =
    if m < n then loop (f m :: acc) (m + 1)
    else List.rev acc in
  loop [] 0

let () =
  let n, l = Scanf.scanf "%d %d\n" (fun n l -> n, l) in
  let ss = tabulate n (fun _ -> Scanf.scanf "%s\n" (fun s -> s)) in
  List.sort compare ss
  |> List.fold_left ( ^ ) ""
  |> print_endline


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b,c,d;
    a=read(), b=read(), c=read(), d=read();
    printf("%lld\n",min(a,b)+min(c,d));
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  cout << ((N+1)/2 >= K ? "YES" : "NO") << endl;
}


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

using namespace std;

int b[10];

bool dfs(int idx, int left, int right)
{
	if (idx == 10) return true;

	if (b[idx] > left && dfs(idx + 1, b[idx], right)) return true;
	if (b[idx] > right && dfs(idx + 1, left, b[idx])) return true;

	return false;
}

int main()
{
	int n; cin >> n;
	while (n--) {
		for (int i = 0; i < 10; ++i) cin >> b[i];

		cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
	}
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = InputNumList();
            WriteLine(a[1] - a[2] >= 0 ? "delicious" : ((a[2] - a[1]) <= a[0] ? "safe" : "dangerous"));
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11220
//
//AtCoder Beginner Contest 148
//C - Snack
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()

using ll = long long;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
    int a, b;

    cin >> a >> b;

    cout << lcm(a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn Agrawal coderbond007  PLEASE!! PLEASE!! HACK MY SOLUTION!!
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String s = in.nextString();
            out.println(s.indexOf("9") >= 0 ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = pread();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int E = (C + B - 1) / B,F = (D + A - 1) / D;
    if (E > F){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

class Graph{
	private:
	int GV,GE;
	vvi List;
	void DFS(int v,vb& used,int time,vi& scc){
		used[v]=1;
		for(int i=0;i<List[v].size();i++){
			int u=List[v][i];
			if(!used[u]) DFS(u,used,time,scc);
		}
		scc[v]=time;
	}
	void Order(int v,vb& used,vi& Vec){
		used[v]=1;
		for(int i=0;i<List[v].size();i++){
			int u=List[v][i];
			if(!used[u]) Order(u,used,Vec);
		}
		Vec.push_back(v);
	}
	Graph Rev(){
		Graph Gtmp(GV,GE);
		for(int i=0;i<GV;i++){
			for(int j=0;j<List[i].size();j++){
				int v=List[i][j];
				Gtmp.List[v].push_back(i);
			}
		}
		return Gtmp; 
	}
	public:
	vi scc;
	Graph(int v,int e){
		GV=v;
		GE=e;
		List=vvi(v);
	}
	void add_edge(int x,int y){
		List[x].push_back(y);
	}
	void SCC(){
		vi Vec;
		scc=vi(GV);
		vb used(GV);
		for(int i=0;i<GV;i++){
			if(!used[i]) Order(i,used,Vec);
		}
		Graph revgra=Rev();
		used=vb(GV);
		int time=0;
		while(!Vec.empty()){
			time++;
			int v=Vec.back();
			Vec.pop_back();
			if(!used[v]) revgra.DFS(v,used,time,scc);
		}
	}
};

int V,E,Q;

int main(){
	cin>>V>>E;
	Graph gra(V,E);
	int s,t;
	for(int i=0;i<E;i++){
		cin>>s>>t;
		gra.add_edge(s,t);
	}
	gra.SCC();
	cin>>Q;
	for(int i=0;i<Q;i++){
		cin>>s>>t;
		if(gra.scc[s]==gra.scc[t]) cout<<1<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 2416
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

int n, a[MAX];

int main()
{
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%d", &a[i]);
		}
		sort(a+1, a+n+1, greater<int>());
		for(int i = 1; i <= n; i++){
			if(i+1 <= a[i+1]) continue;
			int ans = 0;
			for(int j = i+1; a[j]==i; j++) ans ^= 1;
			ans |= (a[i]-i)&1;
			if(ans) puts("First");
			else puts("Second");
			break;
		}
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int n, q,cnt=0;

struct node {
	int t,d,x;
}c[1000000+5];

bool cmp(node a, node b)
{
	if (a.t == b.t)
		return a.d < b.d;
	return a.t < b.t;
}

multiset<int>que;

int main()
{
	file(1);
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; i++)
	{
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		s -= x, t -= x;
		cnt++;
		c[cnt].t = s, c[cnt].x = x, c[cnt].d = 0;
		cnt++;
		c[cnt].t = t, c[cnt].x = x, c[cnt].d = 1;
	}
	sort(c + 1, c + 1 + cnt, cmp);
	int cc = 1;
	while (q--)
	{
		int d;
		scanf("%d", &d);
		while (c[cc].t <= d && cc <= cnt)
		{
			if (c[cc].d == 0)
				que.insert(c[cc].x);
			else
				que.erase(que.find(c[cc].x));
			cc++;
		}
		if (que.size())
			printf("%d\n", *que.begin());
		else
			printf("-1\n");
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	ll n,a,b,x,y=1;
	cin >> n>>a>>b;
	ll ans=0;
	FOR(i,n){
		cin >> x;
		if(i==0) y=x;
		ans+=min(a*(x-y),b);
		//error(a*(x-y),b);
		y=x;

	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, w;
  cin >> n >> w;
  VPLL item(n);
  INPUTP(item);
  VLL vs(n);
  vs[0] = item[0].second;
  REP2(i, 1, n) vs[i] = vs[i-1] + item[i].second;
  VVLL dp(n, VLL(vs[n-1]+1, INF));
  REP(i, item[0].second+1) dp[0][i] = i ? item[0].first : 0LL;
  REP2(i, 1, n) REP(value, vs[i]+1) dp[i][value] = min(dp[i-1][value], value >= item[i].second ? dp[i-1][value-item[i].second] + item[i].first : item[i].first);
  REPR(i, vs[n-1]+1)
  {
    if (dp[n-1][i] <= w)
    {
      cout << i << endl;
      return 0;
    }
  }
}


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

int main(){
  int N;
  string S;
  cin >>N;
  cin >>S;
  int count=0;
  for (int i = 0;i <N;i++){
    if(S.substr(i,3)=="ABC"){
      count ++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;

        if(a%2==1){
            cout << "first\n";
            return 0;
        }
    }
    cout << "second\n";
}

Measured memory_bytes: 3620
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;
typedef long long ll;
 
int main(){
 
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  
  if(k % 2 == 1) cout << b - a << endl;
  else			 cout << a - b << endl;
 
 
return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;

            var lucs = Lucas.Enumerate()
                            .Select((Value, Index) => new { Index, Value })
                            .TakeWhile(x => x.Index <= N);

            WriteLine(lucs.Last().Value);

        }
    }

    public static class Lucas
    {
        public static IEnumerable<long> Enumerate()
        {
            yield return 2;
            yield return 1;

            long[] array = new long[] { 2, 1 };
            while(true)
            {
                var luc = array[0] + array[1];
                array[0] = array[1];
                array[1] = luc;
                yield return luc;
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==1||b==1)
	{
		if(a==b)
		{
			printf("Draw\n"); 
		}
		else if(a==1&&b!=1)
		{
			printf("Alice\n");
		}
		else if(b==1&&a!=1)
		{
			printf("Bob\n");
		}
	}
	else
		{
			if(a>b) printf("Alice\n");
			else if(b>a) printf("Bob\n");
			else printf("Draw\n"); 
		}
		return 0;
 } 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define PB push_back
#define FO(i,a,b) for (int i = a; i <= b; i++)
#define FOb(i,a,b) for(int i=b;i>=a;i--)
#define vi vector<int>
#define vulli vector<unsigned long long int>
using namespace std;
typedef unsigned long long int ulli;
void solve()
{ 
 ulli n,cnf=0,i=0;
 cin >> n;
 vulli arr(n);
 for(auto &i:arr)
 {
     cin >> i;
    //cnf += i;
 }
 sort(arr.rbegin(),arr.rend());
//  //cnf -= arr[n-1];
//  for(i;i<n/2;i++){
//     cnf += arr[i] * 2l; 
//  }
//  if(!(n%2))
//     cnf += arr[i];
 for(i;i<n;i++){
    //cnf += max(arr[i-1],arr[i-2]; i iz stooopid , array already sorted
    //cnf += arr[i-1];
    cnf += arr[i/2];
 }
 cout << cnf-arr[0];

}
int main()
{
    std::ios_base::sync_with_stdio(false);
    ulli t=1;
   // cin>>t;   
    while(t--){ solve(); cout<<"\n"; }
    return 0;
}

Measured memory_bytes: 4804
N = int(input())
txn = []
for i in range(N):
  txn.append([int(i) for i in input().split()])

ima = [0,0,0]
for i in range(N):
  dist = abs(ima[1] - txn[i][1]) + abs(ima[2] - txn[i][2])

  if dist > (txn[i][0] - ima[0]) :
    print("No")
    exit()
  
  if dist%2 != (txn[i][0] - ima[0])%2 :
    print("No")
    exit()
  
  ima = txn[i]

print("Yes")

Measured memory_bytes: 25464
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main(void){
  int n, m;
  cin>>n>>m;
  vector<int> l, r;
  int s, t;
  REP(i, n){
    cin>>s>>t;
    l.push_back(s);
    r.push_back(t);
  }
  int maxl = 1;
  int minr = n;
  REP(i, n){
    maxl = max(maxl, l[i]);
    minr = min(minr, r[i]);
  }
  int ans = minr-maxl+1;
  ans = max(ans, 0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1276
#include "bits/stdc++.h"
using namespace std;

#define MAX 110000
#define INFTY (1 << 29)

class DisjointSet {
public:
	vector<int> rank, p;

	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i<size; i++) makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};

class Edge {
public:
	int source, target, cost;
	Edge(int source = 0, int target = 0, int cost = 0) :
		source(source), target(target), cost(cost) {}
	bool operator < (const Edge &e) const {
		return cost < e.cost;
	}
};

int kruskal(int N, vector<Edge> edges) {
	int totalCost = 0;
	// edgesを昇順でソート
	sort(edges.begin(), edges.end());

	DisjointSet dset = DisjointSet(N + 1);

	for (int i = 0; i<N; i++) dset.makeSet(i);

	for (int i = 0; i<edges.size(); i++) {
		Edge e = edges[i];
		if (!dset.same(e.source, e.target)) {
			totalCost += e.cost;
			dset.unite(e.source, e.target);
		}
	}
	return totalCost;
}

int main() {
	int N, M, cost;
	int source, target;

	cin >> N >> M;

	vector<Edge> edges;
	for (int i = 0; i<M; i++) {
		cin >> source >> target >> cost;
		edges.push_back(Edge(source, target, cost));
	}

	cout << kruskal(N, edges) << endl;

}



Measured memory_bytes: 5444
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
char S[200002];
int dp[2][200002];
int main(){
  int i, j, res;
  N = rd(S);
  dp[0][1] = 1;
  dp[1][1] = -1073709056;
  for(i=(1);i<(N);i++){
    if(S[i]!=S[i-1]){
      dp[0][i+1] = dp[0][i] + 1;
    }
    chmax(dp[0][i+1], dp[1][i] + 1);
    chmax(dp[1][i+1], dp[0][i-1] + 1);
    chmax(dp[1][i+1], dp[1][i-1] + 1);
  }
  res =max_L(dp[0][N], dp[1][N]);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190817-1

// --- original code ---
// int N;
// char S[200002];
// 
// int dp[2][200002];
// 
// {
//   int i, j, res;
//   rd(S@N);
// 
//   dp[0][1] = 1;
//   dp[1][1] = -int_inf;
//   rep(i,1,N){
//     if(S[i]!=S[i-1]) dp[0][i+1] = dp[0][i] + 1;
//     dp[0][i+1] >?= dp[1][i] + 1;
//     dp[1][i+1] >?= dp[0][i-1] + 1;
//     dp[1][i+1] >?= dp[1][i-1] + 1;
//   }
// 
//   res = max(dp[0][N], dp[1][N]);
//   wt(res);
// }


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int N = s.size();
  int c = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] != t[i])
      c++;
  }
  cout << c;
}


Measured memory_bytes: 3920
n,t = gets.split.map(&:to_i)
input = gets.split.map(&:to_i)

ans = 0
n.times do |i|
  if i > 0 && input[i] - input[i-1] < t then
    ans += input[i] - input[i-1]
  else
    ans += t
  end
end

puts ans

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

vector<vector<int>> v(222222);
bool ng[222222];

int main(){
	
	int n,m;cin >> n >> m;
	string str;cin >> str;
	REP(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		v[a].PB(b);
		if(a != b)v[b].PB(a);
	}
	
	queue<ll> q;
	REP(i,n)q.push(i);
	
	while(!q.empty()){
		int now = q.front();q.pop();
		if(ng[now])continue;
		bool A = true;
		bool B = true;
		REP(i,v[now].size()){
			if(ng[v[now][i]])continue;
			if(str[v[now][i]] == 'A')A = false;
			else B = false;
		}
		if(A | B){
			ng[now] = true;
			REP(i,v[now].size()){
				if(!ng[v[now][i]])q.push(v[now][i]);
			}
		}
	}
		
	REP(i,n){
		if(ng[i])continue;
		REP(j,v[i].size()){
			if(!ng[v[i][j]]){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
			
		
	
	return 0;
}

Measured memory_bytes: 12804
#include <iostream>
using namespace std;
int main(void){
    
    int a, b;
    cin >> a >> b;
    
    int seki = a * b;
    if(seki % 2 == 0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
    
}


Measured memory_bytes: 3084
import math
def prime_number(num):
    if num==2:
        return True
    elif num%2==0:
        return False
    else:
        flag=0
        for i in range(3,math.floor(num**0.5)+1,2):
            if num%i==0:
                flag=1
        if flag==0:
            return True
        else:
            return False
N = int(input())
counter=0
for i in range(N):
    num = int(input())
    if prime_number(num):
        counter+=1
print(counter)


Measured memory_bytes: 5728
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++)cin >> v[i];
	double ans = 0;
	for (int i = 0; i < N; i++)ans += 1 / v[i];
	cout << 1 / ans << endl;
}

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

typedef long long ll;


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

    ll cnt1,cnt2;
    cnt1 = cnt2 = 0;
    ll sum = 0;

    //最初が正の時
    for(ll i=0; i<n; i++){
        sum += a[i];
        if(i%2 == 0 && sum <= 0){
            cnt1 += abs(sum-1);
            sum = 1;
        }

        else if(i%2 != 0 && sum >= 0){
            cnt1 += sum+1;
            sum = -1;
        }
    }
    sum = 0;

    //最初が負の時
    for(ll i=0; i<n; i++){
        sum += a[i];
        if(i%2 == 0 && sum >= 0){
            cnt2 += sum+1;
            sum = -1;
        }
        
        if(i%2 != 0 && sum <= 0){
            cnt2 += abs(sum-1);
            sum = 1;
        }
    }

    ll ans = min(cnt1,cnt2);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
  
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
  
using namespace std;

void solution() {
    char c;
    cin >> c;
    if (c >= 'a') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
}
  
/*-------------------*/
      
int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);
      
    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif
      
/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/
       
#ifdef Time
double P2HxQ = clock();
printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
  ll n,k=0;
  cin >>n;
  vector <ll> s;
  if(n==0){
    cout <<n<<endl;
    return 0;
  }
  while(1){
    if(n==1) {
      s.push_back(1);
      break;
    }
    ll k=n%(-2),l=n/(-2);
    if(k<0) {
      k+=2;
      l++;
    }
    s.push_back(k);
    n=l;
  }
  ll ss=s.size();
  for(ll i=ss-1;i>=0;i--) cout <<s[i];
  cout <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN (100005);
#if !testing
	#define cerr if(0)cout
#endif
int32_t main() {
	IAMSPEED
	int n; cin >> n;
	map<string,int> mp;
	FOR(i,1,n) {
		string x; cin >> x;
		mp[x]++;
	}
	int m; cin >> m;
	FOR(i,1,m) {
		string x; cin >> x;
		mp[x]--;
	}
	int mx=0; 
	for (auto i : mp) maxself(mx,i.s);
	cout << mx;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	a--;b--;c--;d--;
	string s;
	cin >> s;
	bool change = false,imp = false;
	REP(i,n){
		if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.' && b < i + 2 && i < d) change = true;
		if(s[i] == '#' && s[i + 1] == '#' && a < i && i + 1 < max(c,d)) imp = true;
	}
	if(c < d) change = true;
	if(change == true && imp == false) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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



int main() {

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

  int ans = 1;
  for (int i = 0; i < N; i++) {
   if ( ans + K > ans * 2) ans*= 2;
    else ans+= K;

  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,T,A;
    int H[1000];
    cin>>N>>T>>A;
    REP(i,N)cin>>H[i];
    int ans = 1;
    double min_d = 10000000;
    REP(i,N){
        double t = T - H[i] * 0.006;
        double d = fabs(A - t);
        if(min_d > d){
            min_d = d;
            ans = i + 1;
        }
    }
    PUTS(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return 1;
  if(cross(a,b)<-eps)return -1;
  if(dot(a,b)<-eps)return 2;
  if(a.norm()<b.norm())return -2;
  return 0;
}

int contains(Polygon g,Point p){
  int n=g.size();
  bool x=false;
  for(int i=0;i<n;i++){
    Vector a=g[i]-p,b=g[(i+1)%n]-p;
    if(abs(cross(a,b))<eps && dot(a,b)<eps)return 1;
    if(a.y>b.y)swap(a,b);
    if(a.y<eps && eps<b.y && cross(a,b)>eps)x=!x;
  }
  if(x)return 2;
  return 0;
}

Polygon convex_hull(Polygon s){
  Polygon g;
  int n=s.size();
  if(n<3)return s;

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

  for(int i=0;i<n;i++){
    for(int n=g.size();n>=2&&ccw(g[n-2],g[n-1],s[i])==1;n--){
      g.pop_back();
    }
    g.push_back(s[i]);
  }
  for(int i=n-2;i>=0;i--){
    for(int n=g.size();n>=2&&ccw(g[n-2],g[n-1],s[i])==1;n--){
      g.pop_back();
    }
    g.push_back(s[i]);
  }
  reverse(g.begin(),g.end());
  g.pop_back();
  return g;
}

int n;
Polygon p;

bool check(){
  if(n<=3)return true;
  Polygon P;
  FOR(i,0,n){
    if(3<=i && contains(P,p[i]))return false;
    P.pb(p[i]);
    P=convex_hull(P);
  }
  return true;
}

bool solve(){
  if(!check())return false;
  reverse(all(p));
  if(!check())return false;
  return true;
}

int main()
{
  cin>>n;
  FOR(i,0,n){
    int x,y;
    cin>>x>>y;
    p.pb(Point(x,y));
  }
  cout<<(solve() ? "Possible" : "Impossible")<<endl;
  return 0;
}

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

using namespace std;

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  
  vector<vector<char>> c(H, vector<char>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> c[i][j];
    }
  }
  
  int num = 0;
  for(int bi = 0; bi < (1 << H); bi++){
    for(int bj = 0; bj < (1 << W); bj++){
      int black = 0;
      for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
          if(((bi >> i) & 1) && ((bj >> j) & 1) && c[i][j] == '#'){
            black++;
          }
        }
      }
      
      if(black == K) ++num;
    }
  }
  
  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n;
    cin>>n;
    ll ans=0;
    rep(i,1,n+1){
    	rep(j,1,n+1){
    		rep(k,1,n+1){
    			ans+=(__gcd(i,(__gcd(j,k))));
    		}
    	}
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3636
from collections import Counter

n = int(input())
vvv = list(map(int, input().split()))
cnt1 = Counter(vvv[0::2])
cnt2 = Counter(vvv[1::2])
mc1 = cnt1.most_common(2)
mc2 = cnt2.most_common(2)
if mc1[0][0] == mc2[0][0]:
    sc1 = mc1[1][1] if len(mc1) > 1 else 0
    sc2 = mc2[1][1] if len(mc2) > 1 else 0
    print(min(n - mc1[0][1] - sc2, n - sc1 - mc2[0][1]))
else:
    print(n - mc1[0][1] - mc2[0][1])


Measured memory_bytes: 18656