akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int p[n];
  ARRIN(p, n);
  vector<int> a(n, 0);
  vector<int> b(n, 0);

  REP(i, n){
    a[i]+=n*(i+1);
    b[i]+=n*(n-i);
    a[p[i]-1]+=i;
  }
  DUMP(a);
  DUMP(b);

  return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int g[101][101];
int main(){
  long ii,jj,kk;
  vector<int> a;

  memset(g,0,sizeof(g));
  int n;
  cin >> n;
  int v,vn,r;
  for(ii=0;ii<n;ii++){
    cin >> v;
    cin >> vn;
    for(jj=0;jj<vn;jj++){
      cin >> r;
      g[v][r] = 1;
    }
  }

  for(ii=1;ii<=n;ii++){
    for(jj=1;jj<=n;jj++){
      cout << g[ii][jj] ;
      if(jj!=n){
        cout << " ";
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
n=int(input())
ls=sorted(["".join(sorted(list(input()))) for i in range(n)])

count=0
c=0
prev=ls[0]
for i,name in enumerate(ls):
    if name!=prev:
        count+=c*(c-1)/2
        c=0
        prev=name
    if i==n-1:
        if name==prev:
            c+=1
        count+=c*(c-1)/2
        c=0
        prev=name
    c+=1

print(int(count))

Measured memory_bytes: 58224
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val c = sc.next()
    println(problem151a(c))
}

fun problem151a(c: String): Char {
    val charArray = charArrayOf('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')
    return charArray[charArray.indexOf(c.toCharArray()[0]) + 1]
}

Measured memory_bytes: 35960
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d,e,sum=0;
	cin>>a>>b>>c>>d>>e;
	sum=(c-a)*60-b+d;
	if(sum<=e){
		cout<<0;
	}
	else{
		cout<<sum-e;
	}
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll n,m;
    cin >> n >> m;
    ll p[m],y[m];
    vector<ll> pre[n];
    for (ll i=0;i<m;i++){
        cin >> p[i] >> y[i];
        pre[p[i]-1].push_back(y[i]);
    }
    for (ll i=0;i<n;i++){
        sort(ALL(pre[i]));
    }
    for (ll i=0;i<m;i++){
        cout << setfill('0') << setw(6) << p[i];
        auto x=lower_bound(ALL(pre[p[i]-1]),y[i])-pre[p[i]-1].begin();
        cout << setfill('0') << setw(6) << x+1;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 10428
#include <stdio.h>

int main(){
  int count;
  int a[3];
  int max, maxidx;
  int i, j;

  scanf("%d", &count);
  for(i=0; i<count; i++){
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    max=0;
    for(j=0; j<3; j++){
      if(max<a[j]){
         max=a[j];
         maxidx=j;
      }
    }
    max=max*max;
    a[maxidx]=0;
    for(j=0; j<3; j++){
       max-=a[j]*a[j];
    }
    if(max==0) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC161A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string[] ans = new string[3];
            ans[0] = input[2];
            ans[1] = input[0];
            ans[2] = input[1];
            Console.WriteLine(string.Join(" ", ans));

        }
    }
}


Measured memory_bytes: 25884
import sys

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 1

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

time1 = (s[2] - s[0]) * 60 + (s[3] - s[1])
time2 = time1 - s[4]
if time2 > 0:
    print(time2)
else:
    print(0)


Measured memory_bytes: 9164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		
		long[] a = new long[n];
		
		long mincnt = 0;
		
		for(int i = 0; i < a.length; i++){
			a[i] = sc.nextLong();
			
			if(a[i] < 0) mincnt++;
		}
		
		long res = Arrays.stream(a).map(x -> Math.abs(x)).sum();
		
		if(mincnt % 2 != 0) {
			long min = Long.MAX_VALUE;
			
			for(int i = 0; i < n; i++) {
				min = Math.min(Math.abs(a[i]), min);
			}
			
			res-=min*2;
		}
		
		out.println(res);
		
		out.flush();
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 42664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c;
	if((a+b)%2==1)
	c=(a+b)/2+1;
	else
	c=(a+b)/2;
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    N, K = map(int, input().split())
    a = [tuple(map(int, input().split())) for _ in range(N)]
    a.sort()
    i = 0
    while 1:
        K -= a[i][1]
        if K > 0:
            i += 1
        else:
            print(a[i][0])
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 17092
MOD = 10**9 + 7
list_size = 200001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

n, a, b, c = map(int, input().split())
numer, denom = 100, 100 - c
denom *= pow(a+b, 2*n-1, MOD)
x, y = 0, 0
for i in range(n):
	x += (n+i) * comb(n-1+i, i) * pow(b, i, MOD) * pow(a+b, n-1-i, MOD)
	x %= MOD
	y += (n+i) * comb(n-1+i, i) * pow(a, i, MOD) * pow(a+b, n-1-i, MOD)
	y %= MOD
x *= pow(a, n, MOD)
y *= pow(b, n, MOD)
numer *= (x+y) % MOD
ans = numer * pow(denom, MOD-2, MOD)
print(ans % MOD)

Measured memory_bytes: 20852
N,Q=map(int,input().split())
S=input()
lr=[0]*Q
for i in range(Q):
    lr[i]=list(map(int,input().split()))

num=[0]*N
flag=0
for i in range(N):
    if S[i]=='A':
        flag=1
        num[i]=(num[i-1],0)[i==0]
    elif S[i]=='C' and flag==1:
        num[i]=num[i-1]+1
        flag=0
    else:
        num[i]=(num[i-1],0)[i==0]
        flag=0
for i in range(Q):
    print(num[lr[i][1]-1]-num[lr[i][0]-1])

Measured memory_bytes: 30664
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		String s = in.nextToken().replace(",", " ");
		System.out.println(s);
	}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

Measured memory_bytes: 21332
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	bb := make([]int, n)
	cc := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		cc[i] = getNextInt(scanner)
	}

	sort.Ints(aa)
	sort.Ints(cc)
	var ans int64
	for i := 0; i < n; i++ {
		l := -1
		r := n
		for l+1 < r {
			m := (l + r) >> 1
			if aa[m] < bb[i] {
				l = m
				continue
			}
			r = m
		}
		a := r
		l = -1
		r = n
		for l+1 < r {
			m := (l + r) >> 1
			if cc[m] > bb[i] {
				r = m
				continue
			}
			l = m
		}
		c := n - r
		sonomasaka := int64(a) * int64(c)
		ans += sonomasaka
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x;i <= y;++ i)
#define repd(i,x,y) for(register int i = x;i >= y;-- i)
typedef long long ll;
using namespace std;
template<typename T> inline bool chkmax(T&x,T y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool chkmin(T&x,T y) { return x > y ? x = y, 1 : 0; }
template<typename T> inline void read(T&x)
{
	char c;int sign = 1;x = 0;
	do { c = getchar(); if(c == '-') sign = -1; }while(!isdigit(c));
	do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
	x *= sign;
}

const int N = 2e5 + 50;
int w[N],sz[N],mx[N],num,cnt,rt,n;
vector<pair<int,int> > g[N];
#define mk(x,y) make_pair(x,y)
bool vis[N];

struct EDGE
{
	int u,v;ll w;
	EDGE(){}
	EDGE(int _u,int _v,ll _w) { u = _u; v = _v,w = _w; }
}e[N * 31];

void get_rt(int x,int fa)
{
	sz[x] = 1; mx[x] = 0;
	for(auto&i:g[x])
		if(!vis[i.first] && i.first != fa)
		{
			get_rt(i.first,x);
			sz[x] += sz[i.first];
			if(sz[i.first] > mx[x])
				mx[x] = sz[i.first];
		}
	chkmax(mx[x],num - sz[x]);
	if(mx[rt] > mx[x]) rt = x;
}

int P;ll W;

void get_p(int x,int fa,ll dep)
{
	if(W > dep + w[x]) P = x,W = dep + w[x];
	for(auto&i:g[x]) if(i.first != fa && !vis[i.first])
		get_p(i.first,x,dep + i.second);
}

void get_e(int x,int fa,ll dep)
{
	e[++cnt] = EDGE(P,x,1ll *W + dep + w[x]);
	for(auto&i:g[x]) if(i.first != fa && !vis[i.first])
		get_e(i.first,x,dep + i.second);
}

void dfs(int x)
{
	vis[x] = 1;W = 1e18;get_p(x,x,0); 
	get_e(x,x,0);
	for(auto&i:g[x])
		if(!vis[i.first])
		{
			num = sz[i.first];
			rt = 0; get_rt(i.first,i.first);
			dfs(rt);		
		}
}

inline bool cmp(EDGE a,EDGE b) { return a.w < b.w; }

int p[N];

int get_fa(int x) { return p[x] == x ? x : p[x] = get_fa(p[x]); }

int main()
{
	read(n);
	rep(i,1,n) read(w[i]);
	rep(i,2,n)
	{
		int u,v,w;
		read(u); read(v); read(w);
		g[u].push_back(mk(v,w));
		g[v].push_back(mk(u,w));
	}
	
	mx[0] = n;
	num = n; get_rt(1,1);

	dfs(rt);

	sort(e + 1,e + 1 + cnt,cmp);

	rep(i,1,n) p[i] = i;

	ll ans = 0;
	rep(i,1,cnt)
	{
		int u = get_fa(e[i].u),v = get_fa(e[i].v);

		if(u != v)
		{
			ans += e[i].w;
			p[u] = v;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 77824
#include <stdio.h>
#include <math.h>
 
int main()
{
  int a,b,c;
  double S,L;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  S=a*b*sin(c*M_PI/180)/2;
  L=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c*M_PI/180))+a+b;
  printf("%lf\n",S);
  printf("%lf\n",L);
  printf("%lf\n",2*S/a);
  return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  bool flag = true;
  for(int i=0;i<s.size()/2;i++) if(s[i]!=s[s.size()-1-i]) flag = false;
  std::cout << (flag?"Yes":"No") << '\n';
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int cnt = 0;
	for (int i = 0; i < n; i++)
		cnt += (s[i] != t[i]);
	cout << cnt << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B) {
    if (B == C) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else {
    if (A == C || B == C) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
#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>;

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

    string s;
    cin>>s;
    string av1;
    string av2;

    if(s.size() < 3 || s.size() > 99)
    {
        cout<<"No"<<endl;
    }

    int n;
    int flag = 0;
    n = s.size();

    int a1, a2;

    a1 = (n - 1) / 2;
    a2 = (n + 1) / 2;

    for(int i = 0; i<a1; i++)
    {
        av1.push_back(s.at(i));
    }

    //cout<<a1<<endl;
    //cout<<a2<<endl;

    for(int i = a2; i<n; i++)
    {
       av1.push_back(s.at(i));
    }

    for(int i = 0; i<a1; i++)
    {
        if(av1.at(i) != av1.at(a1+i))
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}

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

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

    if ((s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) || (s[0] == s[2] && s[1] == s[3] && s[2] != s[1]) || (s[0] == s[3] && s[1] == s[2] && s[3] != s[1]))
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>


typedef long long LL;
using namespace std;
 
void read(int &v) {
    int k = 0, l = 1;
    char ch;
    ch = getchar();
    while (ch > '9' || ch < '0') {
        if (ch == '-')
            l = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') k = k * 10 + ch - '0', ch = getchar();
    v = l * k;
}

void print(int v) {
    if (v < 0)
        putchar('-'), v = -v;
    if (v > 9)
        print(v / 10);
    putchar(v % 10 + '0');
}

int max(int a, int b) {
        return a > b ? a : b;
}

int min(int a, int b) {
        return a < b ? a : b;
}

static int a[100005], b[100005];
static int  n;

int main() {
        read(n);
        for (int i=1; i<=n; ++i) {
                scanf("%d",&a[i]);
                a[i]=-a[i];
        }
        int len=1;
        int ans=1;
        int k;
        b[len]=a[1];
        for (int i=2; i<=n; ++i) {
                k=upper_bound(b+1,b+len+1,a[i])-b;
                b[k]=a[i];  
                if (k>len)  {
                    ++ans;
                        ++len;
                }       
        }   
        print(ans);
        return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int R,C; cin >> R >> C;
vector<string> V(R);
for (auto&v:V) cin >> v;
for (int r=0; r<R;++r)for(int c=0;c<C;++c) {
if (V[r][c]!='#'){V[r][c]='0';
for (int dr=-1; dr<=1;++dr)for(int dc=-1;dc<=1;++dc) {
if(r+dr>=0&&r+dr<R&&c+dc>=0&&c+dc<C&&V[r+dr][c+dc]=='#')V[r][c]++;
}
}
}
for(auto&v:V) cout << v << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    ll A,B,Q,x;
    cin>>A>>B>>Q;
    //INF用に余分に配列を用意しておく
    vector<ll> s(A+2),t(B+2);
    for(int i=1;i<=A;i++){
        cin>>s[i];
    }
    s[0]=-1e12;
    s[A+1]=1e12;
    for(int i=1;i<=B;i++){
        cin>>t[i];
    }
    t[0]=-1e12;
    t[B+1]=1e12;
    vector<ll> ans(Q);
    for(int i=0;i<Q;i++){
        cin>>x;
        //x以上の要素を持つ中で最小値のインデックス
        //マイナスのs.begin()をすることでインデックスにしている
        auto c=lower_bound(s.begin(),s.end(),x)-s.begin();
        auto d=lower_bound(t.begin(),t.end(),x)-t.begin();
        ll tmp=1e18;
        //xちょうど，もしくは一個右側の要素を参照しているから
        //インデックスはc-1もしくはcしか見る必要はない
        for(int j=c-1;j<c+1;j++){
            for(int k=d-1;k<d+1;k++){
                tmp=min(tmp,abs(x-s[j])+abs(s[j]-t[k]));
                tmp=min(tmp,abs(x-t[k])+abs(t[k]-s[j]));
            }
        }
        ans[i]=tmp;
    }
    for(int i=0;i<Q;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
n = int(input())
MX = 10**18
a = list(map(int, input().split()))
for x in a:
  if x == 0:
    print(0)
    exit(0)
ans = 1
for x in a:
  ans *= x
  if ans > MX:
    print(-1)
    exit(0)
print(ans)


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

int N;
int x[9], y[9];

double calc(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    cin >> N;
    for (int i=1; i <= N; i++) cin >> x[i] >> y[i];

    double sum = 0.0;
    vector<int> indices(N);
    for (int i=0; i < N; i++) indices[i] = i + 1;

    double step = 0.0;
    do {
        for(int i=0; i < N-1; i++) {
            sum += calc(indices[i], indices[i+1]);
        }
    step++;
    } while (next_permutation(indices.begin(), indices.end()));

    cout << fixed << setprecision(10) << sum / step << endl;

    return 0;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
m,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
total = 0
for i in range(m+1):
    for k in range(m+1):
        if n-i-k <= m and n-i-k >= 0: total+=1
print(total)

Measured memory_bytes: 15060
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = (200**2)*100
    for m in range(-100, 101):
        x = 0
        for a in A:
            x += (m-a)**2
        ans = min(ans, x)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int ans=0,b[111];
bool tr(int a,int b,int c)
{
	if((a+b)>c&&(a+c)>b&&(b+c)>a&&a!=b&&a!=c&&b!=c)	return 1;
	return 0;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n-2;i++)
		for(int c=i+1;c<n-1;c++)
			for(int v=c+1;v<n;v++)
				if(tr(b[i],b[c],b[v]))
					ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  vector<int> P(3);
  for(int i=0; i<3; i++){
    cin>>P.at(i);
  }
  
  sort(P.begin(),P.end());
  
  cout<<P.at(0)+P.at(1)<<endl;
}


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

c = [0]*40
ans = 0
for aa in a:
    for k in range(40):
        if aa & (1<<k):
            c[k] += 1
x = 0
for k in range(39,-1,-1):
    if x + (1<<k) > K:continue
    if c[k] <= N - c[k]:
        x += (1<<k)

for aa in a:
    ans += x^aa
print(ans)

Measured memory_bytes: 20276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= a+b;
		if(a%3==0||b%3==0||c%3==0){
			System.out.println("Possible");
		}
		else{
			System.out.println("Impossible");
		}
	}
	public static void combinations(String suffix,String prefix){
        if(prefix.length()<0)return;
        s.add(suffix);
        for(int i=0;i<prefix.length();i++)
         combinations(suffix+prefix.charAt(i),prefix.substring(i+1,prefix.length()));
    }
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

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

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



Measured memory_bytes: 19540
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
X = LI()
l = I()
log_n = (n - 1).bit_length()
doubling = [[n] * n for _ in range(log_n)]
for i in range(n - 1):
    doubling[0][i] = bisect_right(X, X[i] + l) - 1

for j in range(1, log_n):
    for k in range(n):
        if doubling[j - 1][k] == n:
            continue
        doubling[j][k] = doubling[j - 1][doubling[j - 1][k]]
q = I()
for _ in range(q):
    a, b = LI()
    if a > b:
        a, b = b, a
    a -= 1
    b -= 1
    ans = 0
    for m in range(log_n - 1, -1, -1):
        if doubling[m][a] < b:
            a = doubling[m][a]
            ans += 2 ** m
    print(ans + 1)








Measured memory_bytes: 72916
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def _euclid(x, y):
    if x > y:
        large = x
        small = y
    else:
        large = y
        small = x

    if small == 0:
        return large

    return _euclid(small, large % small)


def euclid_multi(nums):
    if len(nums) == 1:
        return nums[0]

    e = -1
    for i in range(1, len(nums)):
        if e == -1:
            e = _euclid(nums[0], nums[1])
        else:
            e = _euclid(e, nums[i])
    return e


def solve(inputs):
    [x1, y1, x2, y2] = string_to_int(inputs[0])
    diff_x = x2 - x1
    diff_y = y2 - y1
    x3 = x2 - diff_y
    y3 = y2 + diff_x
    x4 = x1 - diff_y
    y4 = y1 + diff_x
    return "{} {} {} {}".format(x3, y3, x4, y4)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3316
import java.util.*;

	//多分ソートする問題

public class Main {

	public static void main(String[] args){
		Scanner sc  = new Scanner(System.in);
		int N = sc.nextInt();
		double[] v= new double[N];
		double ans=0;

		for(int i=0;i<N;i++){
			v[i] = sc.nextDouble();
		}

		//ここでｖの中身を昇順にソート

		Arrays.sort(v);

		//答えを求める

		ans = v[0];
		for(int j=1;j<N;j++){
			ans=(ans+v[j])/2;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

}
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}










int main() {
    ll x,y;
    cin >> x >> y;
    ll sum = x,cnt=1;
    while (y>=sum*2){
      sum*=2;
      cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
using namespace std;
struct condition{
	int64_t vertex;
	int64_t total;
};
struct current{
	int64_t parent;
	int64_t vertex_num;
	int64_t sum;
};
struct edge{
	int64_t v1;
	int64_t v2;
};
bool operator< (const condition& a,const condition& b){
	return a.total>b.total;
}
int main() {

	int64_t n;
	cin>>n;
	std::vector<condition> cd;
	vector<edge> ans;
	ans.reserve(n);
	cd.reserve(n);
	for(int64_t i=0;i<n;i++){
		int64_t temp;
		cin>>temp;
		cd.push_back(condition{i+1,temp});
	}
	bool ans_possible=true;
	sort(cd.begin(),cd.end());
	map<int64_t,vector<current> > flow;
	for(auto i=cd.begin();i!=cd.end();i++){
		bool islast = (i==cd.end()-1);
		int64_t sum_vertex=0;
		int64_t total_cost=0;
		if(flow.count(i->total)){
			vector<current>& t=flow.at(i->total);

			for(auto k=t.begin();k!=t.end();k++){
				ans.push_back(edge{k->parent,i->vertex});
				sum_vertex+=(k->vertex_num);
				total_cost+=k->sum;
			}
			ans_possible=(total_cost==i->total);

			flow.erase(i->total);
		}else{
			ans_possible=false;
		}

		sum_vertex++;
		total_cost+=sum_vertex;

		int64_t parent_value=i->total-(n-2*sum_vertex);
		if(!islast&&parent_value>=i->total){
			ans_possible=false;
			break;
		}
		if(flow.count(parent_value)){
			flow.at(parent_value).push_back(current{i->vertex,sum_vertex,total_cost});
		}else{
			vector<current> temp2;
			temp2.push_back(current{i->vertex,sum_vertex,total_cost});
			flow.emplace(parent_value,temp2);
		}

	}
	if(flow.size()==1&&ans_possible&&ans.size()==(n-1)){
		for(auto i=ans.begin();i!=ans.end();i++){
			cout<<i->v1<<" "<<i->v2<<endl;
		}
	}else{
		cout<<-1<<endl;
	}





	return 0;

}


Measured memory_bytes: 9856
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

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

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

  bool flag = false;
  for(; N<10000000; N++)
    {
      flag = true;
      for(int i=2; i*i<N; i++)
	{
	  if(N%i==0)
	    {
	      flag = false;
	      break;
	    }
	}
      if(flag)
	{
	  cout << N << endl;
	  return 0;
	}
    }
  
  return 0;
}



Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Dec 30 22:43:45 2018
//
package main

import "fmt"

func main() {
	var N int
	_, _ = fmt.Scan(&N)
	m := map[string]int{}
	for i := 0; i < N; i++ {
		var s string
		_, _ = fmt.Scan(&s)
		m[s]++
	}

	if len(m) == 3 {
		fmt.Println("Three")
	} else {
		fmt.Println("Four")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double 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;
}

ll gcd(ll x,ll y){
  if (y==0){
    return x;
  }
  return gcd(y,x%y);
}

int main(){
    ll T;
    cin >> T;
    rep(i,T){
        ll A,B,C,D;
        cin >> A >> B >> C >> D;
        if (A>=B&&B<=C){
            if (B>D){
                cout << "No" << endl;
            }
            else {
                cout << "Yes" << endl;
            }
            continue;
        }
        if (A<B){
            cout << "No" << endl;
            continue;
        }
        ll E=gcd(B,D);
        A%=B;
        ll F=(B-A-1)/E;
        if (A+F*E<=C&&D>=B){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {
        a:i64,b:i64,
    }

    if a > 0 {
        println!("Positive");
    } else if a <= 0 {
        if b >= 0 {
            println!("Zero");
        } else {
            if (a.abs() - b.abs()) % 2 == 1 {
                println!("Positive");
            } else {
                println!("Negative");
            }
        }
    }
}
const INF: i64 = 1 << 60;


Measured memory_bytes: 2100
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,a[1 << 17],b[1 << 17],c[1 << 17],ans[1 << 17],anss;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = 1;i <= n;i++) cin >> b[i];
	for(int i = 1;i <= n;i++) cin >> c[i];
	sort(a + 1,a + 1 + n);	
	sort(b + 1,b + 1 + n);	
	sort(c + 1,c + 1 + n);	
	for(int i = 1;i <= n;i++)
	{
		auto it = upper_bound(c + 1,c + 1 + n,b[i]);
		ans[i] = c + 1 + n - it;
		ans[i] += ans[i - 1];
	}
	for(int i = 1;i <= n;i++)
	{
		auto it = upper_bound(b + 1,b + 1 + n,a[i]);
		if(it == b + 1 + n) break;
		anss += ans[n] - ans[it - b - 1];
	}
	rc(anss);
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
    string s;

    cin >> s;

    string a,b;

    a.reserve(s.size());
    b.reserve(s.size());

    for(int i = 0; i < s.size();i++)
    {
        if(i % 2 == 0)
        {
            a.push_back('0');
            b.push_back('1');
        }else
        {
            
            b.push_back('0');
            a.push_back('1');
        }
    }
    
    int a_diff,b_diff;
    a_diff = b_diff = 0;

    for(int i = 0; i < s.size();i++)
    {
        if(a[i] != s[i])
        {
            a_diff+=1;
        }
        if(b[i] != s[i])
        {
            b_diff+=1;
        }
    }

    cout << min(a_diff,b_diff) << endl;

    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  int cont = 0;
  for (int i = 100; i >= 1; i--) {
    if (A % i == 0 && B % i == 0) {
      cont++;
      if (cont == K) {
        cout << i << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    set<int> se;
    rep(i, N) {
        int a;
        cin >> a;
        if (se.find(a) == se.end()) {
            se.insert(a);
        } else {
            se.erase(se.find(a));
        }
    }

    cout << se.size() << endl;
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int sumw=0,sumb=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='#'){
      sumb++;
    }else{
      sumw++;
    }
  }
  int sum=sumw,suml=sumw;
  for(int i=0;i<N;i++){
    if(S.at(i)=='#'){
      sum++;
    }else{
      sum--;
    }
    suml=min(sum,suml);
  }
  cout<<suml<<endl;
    
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	char ch[1];
	cin >> ch[0];
	if (ch[0] >= 'A' && ch[0] <= 'Z')
	{
		cout << "A" << endl;
	}
	else
	{
		cout << "a" << endl;
	}
	return 0;
}

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

using namespace std;

int a[111];
int b[111];

int main(){
	int n, m, x, y;
	scanf("%d %d %d %d", &n, &m, &x, &y);
	for (int i = 0; i < n; i++){
		scanf("%d", a + i);
	}
	for (int j = 0; j < m; j++){
		scanf("%d", b + j);
	}
	a[n] = x;
	b[m] = y;
	sort(a, a + n + 1);
	sort(b, b + m + 1);
	if (a[n] < b[0])
		puts("No War");
	else 
		puts("War");
	return 0;
}


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

int main() {
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>> x(n,vector<int>(2));
  vector<int> k(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i).at(0) >> x.at(i).at(1) >> k.at(i);
  }
  
  vector<vector<int>> b(w,vector<int>(h));
  for(int i=0;i<n;i++){
    if(k.at(i) == 1){
      for(int j=0;j<x.at(i).at(0);j++){
        for(int g=0;g<h;g++){
          b.at(j).at(g) = 1;
        }
      }
    }
    else if(k.at(i) == 2){
      for(int j=x.at(i).at(0);j<w;j++){
        for(int g=0;g<h;g++){
          b.at(j).at(g) = 1;
        }
      }
    }
    else if(k.at(i) == 3){
      for(int j=0;j<x.at(i).at(1);j++){
        for(int g=0;g<w;g++){
          b.at(g).at(j) = 1;
        }
      }
    }
    else {
      for(int j=x.at(i).at(1);j<h;j++){
        for(int g=0;g<w;g++){
          b.at(g).at(j) = 1;
        }
      }
    }
  }
  
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(b.at(j).at(i) == 0){
        ans++;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	int a[2][100];
	for (int i = 0; i < n; i++)
		cin >> a[0][i];
	for (int i = 0; i < n; i++)
		cin >> a[1][i];
	int sum_up[100], sum_down[100];
	sum_up[0] = a[0][0];
	sum_down[0] = a[1][0];
	for (int i = 1; i < n; i++) {
		sum_up[i] = sum_up[i - 1] + a[0][i];
		sum_down[i] = sum_down[i - 1] + a[1][i];
	}
	int maxs = 0;
	for (int i = 1; i < n; i++)
		if (maxs < sum_up[i] + sum_down[n - 1] - sum_down[i - 1])
			maxs = sum_up[i] + sum_down[n - 1] - sum_down[i - 1];
	cout << max(maxs, sum_up[0] + sum_down[n - 1]) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 20000000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 110
#define MAXP 100010
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = 2.0 * acos(0.0);
const int BLOCK = 333;

ll dp[MAXN][MAXP], peso[MAXN], ganho[MAXN];
int N, W;

ll solve(int i, int c)
{
	if(c < 0) return -INF;
	if(dp[i][c] != -1) return dp[i][c];
	if(i == N) return 0;

	return dp[i][c] = max(solve(i + 1, c), ganho[i] + solve(i + 1, c - peso[i]));
}

int main(int argc, char const *argv[])
{
	optimize;
	
	memset(dp, -1, sizeof dp);

	cin >> N >> W;

	for(int i = 0; i < N; i++)
		cin >> peso[i] >> ganho[i];

	cout << solve(0, W) << endl;

	return 0;
}

Measured memory_bytes: 89552
#include <iostream>
typedef long long ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    ll H, W;
    cin >> N >> H >> W;
    int cont=0;
    while(N--){
        ll A, B;
        cin >> A >>B;
        if(A>=H && B>=W && A*B>=H*W) cont++;
    }
    cout << cont << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 51, maxm = maxn * maxn;
const ll inf = 1ll << 55;
int n, m, s, gain[maxn], wait[maxn];
ll dp[maxn][maxm];
bool vis[maxn][maxm];
void init() {
	for (int i = 0;i <= n;++i)
		fill(dp[i], dp[i]+maxm, inf);
}
struct info { int u, a, w; };
vector<info> edge[maxn];
#define NW(i) min(i, maxm-1)
struct st {
	int now, mon; ll len;
	bool operator < (const st &b) const {
		return len > b.len;
	}
};
void dij() {
	// [len, now]
	priority_queue<st> pq;
	pq.push({1, s, 0});
	while (pq.size()) {
		auto [now, mon, len] = pq.top();
		pq.pop();
		if (vis[now][mon]) continue;
		vis[now][mon] = true;
		for (auto [u, a, w] : edge[now]) if (mon >= a && dp[u][mon-a] > len + w) {
			dp[u][mon-a] = len + w;
			pq.push({u, mon-a, len+w});
		}
		if (len + wait[now] < dp[now][NW(mon + gain[now])]) {
			dp[now][NW(mon + gain[now])] = len + wait[now];
			pq.push({now, NW(mon+gain[now]), len+wait[now]});
		}
	}
	for (int i = 2;i <= n;++i)
		cout << *min_element(dp[i], dp[i]+maxm) << '\n';
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m >> s;
	for (int i = 0, u, v, a, b;i < m;++i) {
		cin >> u >> v >> a >> b;
		edge[u].push_back({v, a, b});
		edge[v].push_back({u, a, b});
	}
	for (int i = 1;i <= n;++i)
		cin >> gain[i] >> wait[i];
	init();
	s = min(s, maxm-1);
	dij();
}


Measured memory_bytes: 6540