akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
  
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, ll> mll;
  
const int N = 1e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18 + 100;

  
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif	
}

template <typename T>
void scerr(T nums) {
    for (auto it : nums)
        cerr << it << " | ";
    cerr << "\n";
}

int n, k, a[N], dp[N];

int main() {
	data();
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	dp[0] = inf;
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for (int i = 3; i <= n; ++i) {
		dp[i] = inf;
		for (int j = 1; j <= min(k, i); ++j) {
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	printf("%d", dp[n]);
}
  
/*
    Timus: 288481RF
    CodeForces: fractal
*/


Measured memory_bytes: 1024
a = []
3.times do
  a << gets.split.map(&:to_i)
end
n = gets.to_i
bingo = Array.new(3){[false]*3}
n.times do 
  b = gets.to_i
  3.times do |i|
    3.times do |j|
      bingo[i][j] = true if b == a[i][j]
    end
  end
end
ans = false
3.times do |i|
  ans = true if bingo[i][0] && bingo[i][1] && bingo[i][2]
  ans = true if bingo[0][i] && bingo[1][i] && bingo[2][i]
end
ans = true if bingo[0][0] && bingo[1][1] && bingo[2][2]
ans = true if bingo[0][2] && bingo[1][1] && bingo[2][0]

puts ans ? "Yes" : "No"

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

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

    int r = n;
    const int c25 = r / 25;
    r -= 25 * c25;
    const int c10 = r / 10;
    r -= 10 * c10;
    const int c5 = r / 5;
    r -= 5 * c5;

    cout << c25 + c10 + c5 + r << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int k,s,ans=0;
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(0<=z&&z<=k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import math


N, D = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = 0
        for x1, x2 in zip(lst[i], lst[j]):
            tmp += (x1 - x2) ** 2
        val = math.sqrt(tmp)
        if val.is_integer():
        # if val == int(val):
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define M 300005
using namespace std;
int main()
{
    int n;
    char A[M];
    int B[M];
    while(scanf("%d",&n)!=EOF)
    {
        memset(A,'\0',sizeof(A));
        scanf("%s",A);

        for(int i=0,cnt=0;i<n;i++)
        {
            B[i] = cnt;
            if(A[i] == 'W') cnt++;
        }
        for(int i=n-1,cnt=0;i>=0;i--)
        {
            B[i] = B[i] + cnt;
            if(A[i] == 'E') cnt++;
        }
        sort(B,B+n);
        printf("%d\n",B[0]);
    }
    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<cctype>
#define RI register int
#define g (p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=1e5+10,size=N<<2;
char buf[size],*p1=buf,*p2=buf;
void qr(int &x) {
	char c=g;x=0;
	while(!isdigit(c))c=g;
	while(isdigit(c))x=x*10+c-'0',c=g;
}
int n; ll ans;
int a[N],deg[N],vis[N],footL[N],sum[N],f[N];
bool cir[N];
int qm(int x) {return x>=mod?x-mod:x;}
void workcir(int x) {
	int now=0,fr=0,frL=0,ed=0;
	//now是当前环的长度，fr是第一个有脚点的位置,frL是位置对应的脚长,ed为上一个有脚点的位置。 
	while(cir[x]) {
		++now; cir[x]=0;
		if(footL[x]) {
			if(!fr) ed=fr=now,frL=footL[x];
			else {
				ans=ans*((footL[x]<now-ed)+(footL[x]<=now-ed))%mod;//脚的放法 
				ed=now;
			}
		}
		x=a[x];
	}
	if(!ed) ++sum[now];
	else ans=ans*((frL<now-ed+fr)+(frL<=now-ed+fr))%mod;
}
void work() {
	for(RI i=1;i<=n;i++) {//脚对环上交接点贡献 
		if(deg[i]) continue;
		int x=i,len=0; while(!cir[x])x=a[x],++len;
		footL[x]=len;//脚长 
	}
	ans=f[0]=1;
	for(RI i=1;i<=n;i++) if(cir[i]) workcir(i);//以环为基准计算基环内向树的情况 
	for(RI i=1;i<=n;i++) {//计算简单环 
		for(RI j=1;j<=sum[i];j++) {
			if(i>1&&(i&1)) f[j]=qm(f[j-1]<<1);
			else f[j]=f[j-1];
			if(j>1) f[j]=qm(f[j]+(ll)f[j-2]*(j-1)%mod*i%mod);
		}
		ans=ans*f[sum[i]]%mod;
	}
}
int main() {
	qr(n);
	for(RI i=1;i<=n;i++) qr(a[i]),++deg[a[i]];
	for(RI i=1;i<=n;i++) if(!vis[i]) {
		int x=i;while(!vis[x]) vis[x]=i,x=a[x];
		if(vis[x]!=i) continue;//脚 
		while(!cir[x]) cir[x]=1,x=a[x];//标记环上点 
	}
	for(RI i=1;i<=n;i++)
		if((cir[i]&&deg[i]>2)||(!cir[i]&&deg[i]>1)) return puts("0"),0;//开叉就不行 
	work(); printf("%lld\n",ans); return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
char  c;
cin>>c;

if (c=='a'|| c=='i'||c=='u'||c=='e'||c=='o'){
cout <<"vowel"<< endl;
}
else{
cout <<"consonant" << endl;    
}
}

Measured memory_bytes: 3624
n = int(input())

G = []
G.append([])
for i in range(n):
    v = list(map(int, input().split()))
    G.append(v[2:])

q = []
q.append(1)

checked = [False] * (n + 1)
checked[1] = True
d = [-1] * (n + 1)
d[1] = 0

while q:
    current = q.pop(0)
    for v in G[current]:
        if not checked[v]:
            q.append(v)
            d[v] = d[current] + 1
            checked[v] = True

for i in range(1, n + 1):
    print(i, d[i])

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

int compare_int(const void *a, const void *b);

int main(void){
	int N, A, B, C;
    int D[10000];
    int best_pizza_cpp, pizza_cpp, calorie, price;
	int i;
	
	scanf("%d", &N);
    scanf("%d %d", &A, &B);
    scanf("%d", &C);
    for(i = 0; i < N; i++){
        scanf("%d", &D[i]);
    }

    calorie = C;
    price = A;
    best_pizza_cpp = calorie / price;
    
    qsort(D, N, sizeof(int), compare_int);
    for(i = 0; i < N; i++){
        calorie += D[i];
        price += B;
        pizza_cpp = calorie / price;
        if(best_pizza_cpp < pizza_cpp){
            best_pizza_cpp = pizza_cpp;
        }
    }    

	printf("%d\n",best_pizza_cpp);

	return 0;
}

int compare_int(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}


Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/* several useful subroutines */
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	@SuppressWarnings("unused")
	private static long calculateLCM(long a, long b) throws IOException {
		if ( a  < b ) {
			long t = a;
			a = b;
			b = t;
		}
		while ( b > 0 ) {
			long t = b;
			b = a % b;
			a = t;
		}
		return a;
	}

	
	/* main routine */
	
	public static void main(String args[]) throws IOException {
		double a = getInt();
		double b = getInt();
		double x = getInt();
		
		double d ;

		double s = a*a;

		if ( x > s*b/2 ) {
			x = (s*b - x) * 2 / s;
			d = Math.atan(x/a)  / Math.PI * 180 ;
		} else {
			x /= a * b / 2 ;
			d = Math.atan(b/x)   / Math.PI * 180;
		}
		
		
		System.out.println( d );
		
	}
}


Measured memory_bytes: 20948
#include <list>
#include <cstdio>
using namespace std;
int main(){
list<int>l;auto z=l.begin();
int q,a,b;
for(scanf("%d",&q);q--;){
scanf("%d",&a);
if(a==0)scanf("%d",&b),z=l.insert(z,b);
if(a==1)scanf("%d",&b),advance(z,b);
if(a==2)z=l.erase(z);
}
for(auto &e:l)printf("%d\n",e);
}


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

int main(){
    long long int a,b,c,d,ac,ad,bc,bd;
    //long long int a[4];
    cin >> a >> b >> c >> d;
    ac = a*c;
    ad = a*d;
    bc = b*c;
    bd = b*d;
    long long int ans;
    ans = max({ac,ad,bc,bd});
    cout << ans << endl;
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
long long w[101],v[101],f[101][100001];
int main()
{
        long long i,j,n,W;
        scanf("%lld %lld",&n,&W);
        for(i=1;i<=n;i++)
        {
                scanf("%lld %lld",&w[i],&v[i]);
        }
        for(i=1;i<=n;i++)
        {
                for(j=1;j<=W;j++)
                {
                        f[i][j]=f[i-1][j];
                        if(j>=w[i])
                                f[i][j]=max(f[i][j],f[i-1][j-w[i]]+v[i]);
                }
        }
        printf("%lld",f[n][W]);
        return 0;
}


Measured memory_bytes: 78336
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);




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

	int x;
	cin >> x;
	int ans = (x / 11) * 2;
	x = x % 11;
	if(x)ans += x <= 6 ? 1 : 2;
	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	string s = ReadLine();
    WriteLine(nex(s).ToString());
  }
  int nex(string s){
    switch (s) {
      case "SUN":
        return 7;
      case "MON":
        return 6;
      case "TUE":
        return 5;
      case "WED":
        return 4;
      case "THU":
        return 3;
      case "FRI":
        return 2;
      case "SAT":
        return 1;
      default:
        return 0;
    }
  }

}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

ll ans=0;
ll a[4];


int main()
{
	for(int i=0;i<4;i++) scanf("%lld",a+i);
	int n;
	cin>>n;
	
	if(n%2){
		ans+=min({a[2],a[1]*2,a[0]*4});n--;
	}
	
	ans+=(n/2)*min({a[3],a[2]*2,a[1]*4,a[0]*8});
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
lines = gets.chomp.split.map(&:to_i).sort

count = 0
lines[0...N].each_with_index do |b, bi|
  lines[0...bi].each do |a|
    c_candidates = lines[(bi+1)..N]
    ci_to = c_candidates.bsearch_index {|c| c >= a + b}
    # インデックス(ci_to - 1)までは三角形が成立する
    if ci_to.nil?
      count += c_candidates.length
    else
      # 全部成立する
      count += ci_to
    end
  end
end
puts count


Measured memory_bytes: 1912
#include <iostream>
#include <iomanip>

int main()
{
	int a, b ,c;
	char op;
	while (1)
	{
		std::cin >> a >> op >> b;
		if (op == '+') {
			c = a + b;
		}
		if (op == '-') {
			c = a - b;
		}
		if (op == '*') {
			c = a * b;
		}
		if (op == '/') {
			c = a / b;
		}
		if (op == '?') {
			break;
		}
		std::cout << c << std::endl;
	}

    return 0;
}


Measured memory_bytes: 3016
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int h, w;
    scanf("%d%d", &h, &w);
    char a[100][101];
    int x[100] = {};
    int y[100] = {};
    int i, j;

    for (i=0; i<h; i++)
    {
        scanf("%s", a[i]);
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (a[i][j] == '#') {
                x[j] = 1;
                y[i] = 1;
            }
        }
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (x[j] && y[i])
            printf("%c", a[i][j]);
        }
        if (y[i]) printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
vector<vector<int>>edge;
vector<int> x;
typedef pair<int,int> P;
bool ok =1;
P dfs(int node)
{
  if(edge[node].empty())return make_pair(0,x[node]);
  vector<vector<bool>>dp(2,vector<bool>(x[node]+1,0));
  dp[0][0]=1;
  int sz=edge[node].size();
  int cnt=0;
  rep(i,sz)
  {
    int ne=(i+1)&1,no=i&1;
    P tp=dfs(edge[node][i]);
    if(tp.first==-1)return make_pair(-1,-1);
    cnt+=tp.first+tp.second;
    rep(j,x[node]+1)dp[ne][j]=0;
    rep(j,x[node]+1)
    {
      if(tp.first+j<x[node]+1) dp[ne][j+tp.first] = dp[ne][j+tp.first] |dp[no][j];
      if(tp.second+j<x[node]+1) dp[ne][j+tp.second] = dp[ne][j+tp.second] |dp[no][j];

    }
  }
  for(int i=x[node];i>=0;i--)
  {
    if(dp[sz&1][i])
    {
      int a=cnt-i,b=x[node];
      if(a>b)swap(a,b);
      return make_pair(a,b);
    }
  }
  ok=0;
  return make_pair(-1,-1);
}

int main()
{
  int n;
  cin>>n;
  edge.resize(n+1);
  x.resize(n+1);
  rep(i,n-1)
  {
    int pare;
    cin>>pare;
    edge[pare].push_back(i+2);
  }
  rep(i,n)cin>>x[i+1];
  dfs(1);
  cout<<(ok? "POSSIBLE":"IMPOSSIBLE")<<endl;
  return 0;

}


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

int main(){
    ios::sync_with_stdio(false);
    int k,n;
    ll a[200005];
    cin>>k>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll max1=0;
    for(int i=0;i<n-1;i++){
        max1=max(abs(a[i+1]-a[i]),max1);
    }
    max1=max(k-a[n-1]+a[0],max1);
    cout<<k-max1;
    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = (1..n).map { val a = (readLine()!!.split(" ").map { it.toInt() }); Point(it-1, a[0], a[1]) }

    val xy = mutableMapOf<Int, MutableList<Int>>()
    val yx = mutableMapOf<Int, MutableList<Int>>()
    val uf = UnionFind(n)
    p.forEach {
        xy[it.x]?: run { xy[it.x] = mutableListOf() }
        yx[it.y]?: run { yx[it.y] = mutableListOf() }
        xy[it.x]!!.add(it.id)
        yx[it.y]!!.add(it.id)
    }

    xy.map { it.value }.forEach { it.reduce{ a,b -> uf.unite(a,b); b } }
    yx.map { it.value }.forEach { it.reduce{ a,b -> uf.unite(a,b); b } }

    val sum = p.groupBy { uf.find(it.id) }.map { it.value }.map {
        val x = it.distinctBy { it.x }.size
        val y = it.distinctBy { it.y }.size
        1L *x * y
    }.sum()

    println(sum-n)

}

data class Point(val id: Int, val x: Int, val y: Int)

class UnionFind(private val N: Int) {
    private val nodes = (0 until N).toList()
    private val parent = IntArray(N) { it }
    private val roots = parent.toMutableSet()
    private val rank = IntArray(N) { 0 }
    private val size = IntArray(N) { 1 }

    fun group() = nodes.groupBy { find(it) }
    fun groupCount() = roots.size
    fun sameGroupSize(x: Int) = size[find(x)]

    fun find(x: Int): Int = if (parent[x] == x) x else { parent[x] = find(parent[x]); parent[x] }
    fun unite(x: Int, y: Int) {
        val a = find(x)
        val b = find(y)
        if (a == b) return

        if (rank[a] < rank[b]) {
            roots.remove(a)
            parent[a] = b
            size[b] += size[a]
        } else {
            roots.remove(b)
            parent[b] = a
            size[a] += size[b]
            if (rank[a] == rank[b]) rank[a]++
        }
    }
}

Measured memory_bytes: 112760
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s; 
  cin >> s;

  cout << s.substr(0, s.size()-8) << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
input = sys.stdin.readline


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, k, l = map(int, input().split())
uf_k = UnionFind(n)
uf_l = UnionFind(n)
for i in range(k):
    p, q = map(int, input().split())
    uf_k.union(p - 1, q - 1)
for i in range(l):
    r, s = map(int, input().split())
    uf_l.union(r - 1, s - 1)
d = defaultdict(int)
for i in range(n):
    d[uf_k.find(i), uf_l.find(i)] += 1
print(*(d[uf_k.find(i), uf_l.find(i)] for i in range(n)))


Measured memory_bytes: 41572
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  ll ans = 1;
  while (true) {
    if (ans * 2 > N) {
      cout << ans << "\n";
      break;
    }
    else {
      ans *= 2;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
     int n,d;
     int ans=0;
     cin>>n>>d;
     int a[20][10];
     for(int i=0;i<n;i++)
     {
          for(int j=0;j<d;j++)
          {
               cin>>a[i][j];
          }
     }
     for(int i=0;i<n;i++)
     {
          for(int i1=i+1;i1<n;i1++)
          {
               int sum=0;
               for(int j=0;j<d;j++)
               {
                 sum+=abs(a[i][j]-a[i1][j])*abs(a[i][j]-a[i1][j]);
               }
               int gg=sqrt(sum);
               if(gg*gg==sum)
                    ans++;
          }

     }
     cout<<ans;
}


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

l = [0]*1000001
check = [False]*5000000

l[1] = s
ans = 0

for i in range(2, 1000000):
    if l[i-1] % 2 == 0:
        l[i] = round(l[i-1]/2)
    else:
        l[i] = 3*l[i-1]+1

for i in range(1,1000000):
    if check[l[i]]==False:
        check[l[i]]=True
    else:
        ans=i
        break

print(ans)


Measured memory_bytes: 76800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(i,n) memset(i,n,sizeof(i));
#define X first
#define Y second
#define pb push_back
#ifdef brian
#define  debug(...) do{\
    fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename t> void _do(t &&x){cerr<<x<<endl;}
template<typename t,typename ...T> void _do(t &&x,T &&...tail){cerr<<x<<", ";_do(tail...);}
#else
#define debug(...)
#endif // brian

const ll INF=ll(1e15);
const ll MAXn=100005;

ll n;
vector<ll> d;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    d.resize(n);
    REP(i,n)cin>>d[i];
    sort(d.begin(),d.end());
    d.erase(unique(d.begin(),d.end()),d.end());
    ll k=n-d.size();
    debug(d.size(),k);
    if(k==0)cout<<n<<endl;
    else if(k%2==0)cout<<d.size()<<endl;
    else cout<<d.size()-1<<endl;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

inline vi rotate(const vi &t)
{
    int idx=0;
    while(idx<6 && t[idx]!=0) ++idx;

    vi a;
    if(idx==0) a=vi({0,1,2,3,4,5});
    else if(idx==1) a=vi({1,5,2,3,0,4});
    else if(idx==2) a=vi({2,1,5,0,4,3});
    else if(idx==3) a=vi({3,1,0,5,4,2});
    else if(idx==4) a=vi({4,0,2,3,5,1});
    else if(idx==5) a=vi({5,4,2,3,1,0});

    vi ret(6);
    rep(i,6) ret[i]=t[a[i]];
    return ret;
}

inline vi normalize(const vi &t)
{
    vi side({t[1],t[2],t[4],t[3]});

    vector<vi> s;
    rep(i,4)
    {
        vi a(4);
        rep(j,4) a[j]=side[(j+i)%4];
        s.pb(a);
    }
    sort(all(s));
    return s[0];
}

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<vi> d(n);
        rep(i,n)
        {
            vi t(6);
            rep(j,6)
            {
                string s;
                cin >>s;
                if(s=="Red") t[j]=0;
                else if(s=="Yellow") t[j]=1;
                else if(s=="Blue") t[j]=2;
                else if(s=="Magenta") t[j]=3;
                else if(s=="Green") t[j]=4;
                else if(s=="Cyan") t[j]=5;
            }
            d[i]=rotate(t);
        }

        set<vi> s[6];
        rep(i,n) s[d[i][5]].insert(normalize(d[i]));

        int diff=0;
        rep(i,6) diff+=s[i].size();
        cout << n-diff << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
w, h, n = map(int, input().split())

list_state = [list(map(int, input().split())) for i in range(n)]

max_x = w
max_y = h
min_x = 0
min_y = 0

for i in list_state:
    if i[2] == 1 and min_x < i[0]:
        min_x = i[0]
    if i[2] == 2 and max_x > i[0]:
        max_x = i[0]
    if i[2] == 3 and min_y < i[1]:
        min_y = i[1]
    if i[2] == 4 and max_y > i[1]:
        max_y = i[1]

x = max_x - min_x
y = max_y - min_y

if x < 0 or y < 0:
    print(0)
else:
    print(x*y)

Measured memory_bytes: 3064
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add_self(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int add(int a,int b){
	int c=a+b;
	if(c>=mod){
		c-=mod;
	}
	return c;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;
int n;
int pw;
int calc(int x,int y,int fl){
	if(x==y&&fl){
		return 0;
	}
	if(x&1){
		return 1+calc((x-1)/2,y,1);
	}
	else{
		return 1+calc(x/2+pw,y,1);
	}
}

void solve(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for(int i=0;i<b;i++){
		int cnt=a;
		while(cnt--){
			cout<<'1';
		}
		for(int j=a;j<w;j++){
			cout<<'0';
		}
		cout<<"\n";
	}
	for(int i=b;i<h;i++){
		int cnt=a;
		while(cnt--){
			cout<<'0';
		}
		for(int j=a;j<w;j++){
			cout<<'1';
		}
		cout<<"\n";
	}
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back


int main(){
	int n;
	cin >> n;
	if(n % 2 == 1){
		cout << "No" << endl;
		return 0;
	}
	string s;
	cin >> s;

	rep(i,n/2){
		if(s[i] != s[i+n/2]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,m,k;

signed main() {
    cin >> n >> m >> k;
    rep(i,n+1) rep(j,m+1) if (i*m + j*n - 2*i*j == k) {cout << "Yes" << endl;return 0;}
    cout << "No" << endl;
}


Measured memory_bytes: 256
function main(input) {
  let args = input.split('\n');
  let x = 0;
  let a = args[x++].split(' ');
  for (let i = 0; i < a.length; ++i) {
    if (+a[i] == 0) {
      console.log(i + 1);
      return;
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29628
#include <bits/stdc++.h>
using namespace std;
int n,a,b,cost;
vector<int>ans;
int main(){
//	freopen("readin.txt","r",stdin);
	scanf("%d%d%d",&n,&a,&b);
	if(a*1LL*b < n || a + b - 1 > n)return puts("-1"),0;
	for(int i = n - a + 1;i <= n;i++)ans.push_back(i);
	n-=a;
	for(int i = b - 1;i >= 1;i--){
		int t = min(n - i + 1,a);
		for(int j = n - t + 1;j <= n;j++)ans.push_back(j);
		n-=t;
	}
	for(auto i : ans)printf("%d ",i);
}

Measured memory_bytes: 3440
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<string> a(n);
	vector<pair<int,string>> v;
	map<string,int> mp;
	for(int i=0;i<n;i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	for(auto p:mp){
		v.push_back({-p.second,p.first});
	}
	sort(v.begin(),v.end());
	int cnt=v[0].first;
	for(auto p:v){
		if(p.first==cnt)cout << p.second << endl;
	}
}


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

int main(){
  uint64_t ip;
  cin >> ip;
  uint64_t sum = (ip*(ip+1))/2;
  uint64_t divsum=0;
  for(uint64_t i=1;i<=ip;i++){
    if(i%3 == 0 || i%5 == 0)divsum+=i;
  }
  cout << sum-divsum << endl;
  return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

int k;
vector<ll> v;

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

    cin >> k;
    queue<ll> q;
    q.emplace(0);
    while (!q.empty()) {
        if ((int)v.size() > k + 1) break;
        ll now = q.front(); q.pop();
        v.emplace_back(now);
        int d = now % 10;
        int f = now == 0 ? 1 : max(0, d - 1);
        int t = now == 0 ? 9 : min(9, d + 1);
        for (int i = f; i <= t; i++) {
            q.emplace(now * 10 + i);
        }
    }
    cout << v[k] << endl;
    return 0;
}


Measured memory_bytes: 2676
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

constexpr int32_t MOD = 1000000007;

int msb(int64_t n)
{
    int count = 0;
    while (n != 0)
    {
        ++count;
        n >>= 1;
    }
    return count;
}

int main()
{
    int64_t n;
    std::cin >> n;

    /*
        解説にもある通りu<=vである。
        v<=Nを満たす範囲で、a,bのビット列のパターンを列挙する。
        a,bは各桁について対称性があるので、
        桁ごとに両方が0、一方が1もう一方が0、両方が1の3通りの状態がある。
        これをvの制約を満たすパターンの個数を数え上げる。
        また、この時、ある桁でa,bの両方が0の場合と1の場合で同じuになるが、vは異なっている。
        よって、a,bのパターンを数え上げればよいことがわかる。

        上位から桁DPを行う。
        繰り上がりによってa+bがNを超えるかは、(a+b)>>iとN>>iの差を調べることで判定できる。
        ここで、ｉは下位からの桁数である。
        j=(N>>i)-((a+b)>>i)として、
        j==0の場合、Ｎのi桁目が0ならa,bのi桁目も両方0でないとNを超える。
        j==1の場合、下に示すようにa,bのi桁目が両方1の場合にNを超える。
            N>>i     : 11     11  or, 10    10
            (a+b)>>i : 10 -> 110      01 -> 11
                a[i] :  1              1
                b[i] :  1              1
        j>=2の場合、以下のような状態が一例として示される。
        　　　　　　　a,bが両方1でもj>=2の状態が保たれる（次では一つ下の桁を扱うのでj>=2は変わらない）
            N>>i     : 111    111  or,  110    110
            (a+b)>>i : 011 -> 101       011 -> 101
                a[i] :   1                1
                b[i] :   1                1

        dp[j]は(N>>i)-((a+b)>>i)がj(ただし、2以上は2にまとめる)であるときの場合の数である。
    */
    std::vector<int64_t> dp(3);

    const int k = msb(n);
    for (int i = k - 1; i >= 0; --i)
    {
        if (i == k - 1)
        {
            dp[0] = 1;
            dp[1] = 1;
            continue;
        }
        std::vector<int64_t> tmp(3);
        if ((n >> i) % 2)
        {
            tmp[0] = dp[0];
            tmp[1] = dp[1] + dp[0];
            tmp[2] = dp[2] * 3 + dp[1] * 2;
        }
        else
        {
            tmp[0] = dp[0] + dp[1];
            tmp[1] = dp[1];
            tmp[2] = dp[2] * 3 + dp[1];
        }
        std::transform(tmp.begin(), tmp.end(), dp.begin(), [&](const int64_t v) { return v % MOD; });
    }

    std::cout << (std::accumulate(dp.begin(), dp.end(), 0ll) % MOD) << std::endl;
    return 0;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

vll pl;

bool is_prime(const unsigned n) {
  if (n % 2 == 0 || n % 3 == 0) {
    if (n == 2 || n == 3) {
      return true;
    }
    return false;
  }
  if (n == 1) {
    return false;
  }

  for (unsigned i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) {
      return false;
    }
  }

  return true;
}

// prime factorization (素因数分解)
// key: value of prime factor
// value: number of prime factor
std::map<ll, ll> prime_factorization(ll n) {
  std::map<ll, ll> prime_factors;
  for (ll i : pl) {
    if (i * i > n)
      break;

    while (n % i == 0) {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];

  set<ll> primes;

  REP(i, 1e6 + 10) {
    if (is_prime(i)) {
      pl.push_back(i);
    }
  }

  vll pp(1e6 + 10);

  rep(i, n) {
    auto pf = prime_factorization(a[i]);
    for (auto& p : pf) {
      pp[p.first]++;
    }
  }

  bool is_pairwise = true;
  for (auto i : pp) {
    if (i > 1) {
      is_pairwise = false;
    }
  }

  ll all_gcd = a[0];
  rep(i, n) {
    all_gcd = gcd(all_gcd, a[i]);
  }

  if (is_pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (all_gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 19676
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    ll p, q, r;
    vector<P> mem;
    REP(i, a) {
        cin >> p;
        mem.push_back({p, 1});
    }
    REP(i, b) {
        cin >> q;
        mem.push_back({q, 2});
    }
    REP(i, c) {
        cin >> r;
        mem.push_back({r, 3});
    }
    p = q = r = 0;
    ll s = a + b + c, res = 0;
    VSORTR(mem);
    REP(i, s) {
        // 必要なだけ一色で塗った余りの白を全部もう一色で塗ったとき足りているか
        if ((p + r >= x && r - max(0LL, x - p) + q >= y) || (q + r >= y && r - max(0LL, y - q) + p >= x)) {
            cout << res << endl;
            return 0;
        }
        if (mem[i].second == 1) p++;
        if (mem[i].second == 2) q++;
        if (mem[i].second == 3) r++;

        if (p > x && mem[i].second == 1) continue;
        if (q > y && mem[i].second == 2) continue;
        res += mem[i].first;
    }
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        a[i] %= m;
    }
    
    map<ll, ll> mp;
    vector<ll> s(n+1);
    s[0] = 0;
    mp[s[0]%m]++;
    for (int i = 1; i < n+1; i++)
    {
        s[i] = s[i-1] + a[i-1];
        mp[s[i]%m]++;
    }

    ll cnt = 0;
    for (auto u : mp){
        cnt += u.second * (u.second-1)/2;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
inline int read() {
	int f=1,sum=0;
	char x=getchar();
	for(;(x<'0'||x>'9');x=getchar()) if(x=='-') f=-1;
	for(;x>='0'&&x<='9';x=getchar()) sum=sum*10+x-'0';
	return f*sum;
}

#define M 1005
int n;
int a[M],f[2][M];

int main () {
	//freopen("a.in","r",stdin);
	n=read();
	for1(1,n,i) a[i]=read();
	
	int opt=0;
	for1(1,100,j) f[0][j]=1;
	f[0][a[1]]=0;
	for1(2,n,i) {
		memset(f[opt^1],0x3f,sizeof(f[opt^1]));
		for1(1,100,j) for1(1,100,k)
			if(j!=k) f[opt^1][k]=min(f[opt^1][k],f[opt][j]+(k!=a[i]));
		opt^=1;
	}
	int ans=n;
	for1(1,100,i) ans=min(ans,f[opt][i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n;
vi a,b,c;

ll memo[1000000] = {0};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;ll numn;
    rep(i,n){cin>>numn;a.pb(numn);}
    rep(i,n){cin>>numn;b.pb(numn);}
    rep(i,n){cin>>numn;c.pb(numn);}
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;bool flg = true;
    rep(i,n){
        auto c2 = upper_bound(all(c),b[i]);
        auto a2 = lower_bound(all(a),b[i]);
        ans += (c.end()-c2)*(a2-a.begin());
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1912
from sys import stdin
inf = 10**10

s = stdin.readline().rstrip()

point_s = 0
point_t = 0

for i in s:
    if i == "S":
        point_s += 1
    else:
        if point_s:
            point_s -= 1
        else:
            point_t += 1

print(point_s+point_t)

Measured memory_bytes: 3500
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    vector<ll> X(n);
    repi(i, n, 0) cin >> X[i];
    ll ans = 0;
    repi(i, n, 1)
    {
        ans += min(b, a * abs(X[i] - X[i - 1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int k,a,b;cin>>k>>a>>b;
    int cur=b/k-a/k;
    if(cur==0&&b%k&&a%k)cout<<"NG";
    else cout<<"OK";
    
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    cout <<180*(N-2) <<"\n";
}

Measured memory_bytes: 256
#include <cstdio>
char c[6][6];
char g[13];
 
bool b(char a)
{
for(int i = 0;i<3;i++)
{
if(a==c[i][0]&&a==c[i][1]&&a==c[i][2]) return true;
if(a==c[0][i]&&a==c[1][i]&&a==c[2][i]) return true;
}
 
if(a==c[0][0]&&a==c[1][1]&&a==c[2][2]) return true;
if(a==c[2][0]&&a==c[1][1]&&a==c[0][2]) return true;
return false;
}
 
 
int main()
{
while((scanf("%s",&g)!=EOF))
{
    for(int i =0;i<9;i++)
    {
        c[(i-i%3)/3][i%3]=g[i];
    }
 
if(b('o')) printf("o\n");
else if(b('x')) printf("x\n");
else printf("d\n");
}
return 0;
}

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


int main(){
    int Qi, Fi, rev_st = 0;
    char c;
    string S, Sc;
    std::cin >> S;

    long long Q;
    std::cin >> Q;

    for(int i = 0; i < Q; i++){
        //Q回操作をする。操作内容は愚直に実装
        std::cin >> Qi;
        if(Qi == 1){
            //Ti = 1の場合、反転状態を記録
            rev_st = (rev_st + 1)%2;
        }else{
            //Ti = 2の場合、反転状態に応じて文字を追加
            std::cin >> Fi >> c;
            if(rev_st == 1){
                //反転している場合
                if(Fi == 1){
                    S.push_back(c);
                }else{
                    S.insert(S.begin(), c);
                }
            }else{
                //反転していない場合
                if(Fi == 2){
                    S.push_back(c);
                }else{
                    S.insert(S.begin(), c);
                }
            }
        }
    }
    //入力完了
    if(rev_st == 1){
        std::reverse(S.begin(), S.end());
    }

    std::cout << S;

}

Measured memory_bytes: 3904
using System;
using System.Linq;
using System.Runtime.CompilerServices;

class Project2
{
    static void Main ()
    {
        int count = 0;
        var arg = Console.ReadLine().Split(' ').Select(value => double.Parse(value)).ToArray();
        for (int i = 0; i <= arg[0]; i++)
        {
            for (int j = 0; j <= arg[0]; j++)
            {
                var z = arg[1] - i - j;
                if (z >= 0 && z <= arg[0])
                {
                    count++;
                }
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 28216
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
const int mod = 1e9 + 7;
typedef pair<lint, lint> pi;
 
lint d;
lint p[20];
int dx1[20], dx2[20];
vector<lint> v;
 
void dfs(int s, int e, vector<pi> &w, lint val, lint cnt){
	if(s == e){
		w.push_back(pi(val, cnt));
		return;
	}
	for(int i=-9; i<=9; i++){
		dfs(s+1, e, w, val + i * v[s], cnt * (s == 0 ? dx2[i + 10] : dx1[i + 10]));
	}
}
 
lint solve(int l){
	v.clear();
	for(int i=0; l-1-i > i; i++){
		v.push_back(p[l-1-i] - p[i]);
	}
	vector<pi> v1, v2;
	dfs(0, (v.size() + 1) / 2, v1, 0, 1);
	dfs((v.size() + 1) / 2, v.size(), v2, 0, 1);
	lint ans = 0;
	map<lint, lint> mp;
	for(int i=0;i<v2.size();i++) mp[v2[i].first] += v2[i].second;
	for(int i=0;i<v1.size();i++){
		ans += mp[d+v1[i].first] * v1[i].second;
	}	
	if(l % 2 == 1) ans *= 10;
	return ans;
}
 
int main(){
	p[0] = 1;
	for(int i=1; i<20; i++) p[i] = p[i-1] * 10;
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			dx1[i-j+10]++;
		}
	}
	for(int i=1; i<10; i++){
		for(int j=0; j<10; j++){
			dx2[i-j+10]++;
		}
	}
	cin >> d;
	lint ans = 0;
	for(int i=2; i<=18; i++) ans += solve(i);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 207024
num_of_monsters = int(input())
monsters = list(map(lambda x: int(x), input().split(' ')))
monsters = sorted(monsters)

while len(monsters) > 1:
  minimum = monsters[0]
  for i in range(1, len(monsters)):
    max_division_times = int(monsters[i] / minimum)
    monsters[i] -= (minimum * max_division_times)
  
  monsters = sorted(filter(lambda a: a != 0, monsters))
print (monsters[0])

Measured memory_bytes: 14224
//abc123_b.cpp
//Tue Apr  9 22:05:06 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	int ans = 0;
	int amari = 10;
	int x = 0;
	for (int i=0;i<5;i++){
		if (a[i]%10 != 0 && a[i]%10 < amari){
			x = i;
			amari = a[i]%10;
		}
	}

	for (int i=0;i<5;i++){
		if (i==x){
			ans += a[i];
		}else{
			int temp = a[i]/10;
			temp = temp*10;
			if (a[i]%10>0){
				temp += 10;
			}
			ans += temp;
		}
//		cout << ans << endl;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 7;
const long long MOD = 1e9 + 7;

int a[N];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	long long ans = 0;
	for (int i = 1; i <= n; i++){
		for (int j = i + 1; j <= n; j++){
			if (a[i] > a[j]) ans ++;
		}
	}
	ans = ans * k % MOD;
	for (int i = 1; i <= n; i++){
		long long t = 0;
		for (int j = 1; j <= n; j++){
			if (a[i] > a[j]) t++;
		}
		ans += (1LL * k * (k - 1) / 2) % MOD * t % MOD;
	}	
	printf("%lld", ans % MOD);
	return 0;
}

Measured memory_bytes: 256