akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;

struct point {
	int x; int y;
};
//x座標が小さい順になるように並べ替えたい
bool order(point a, point b) {
	return a.x < b.x;
}
point blue[200];
point red[200];
//配列の宣言の時に={}をつけると全部の要素が0になる
//この配列usedの役割は後で、
int used[200] = {};
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int p, q;
		cin >> p >> q;
		red[i] = { p,q };
	}
	for (int i = 0; i < n; ++i) {
		int p, q;
		cin >> p >> q;
		blue[i] = { p,q };
	}
	int ans = 0;//最終的な答え
	sort(blue, blue + n,order);//青点をソート
	for (int i = 0; i < n; ++i) {
		//i番目の青点からみていく。以下i番目の青点をbiと呼ぶ
		int  bx = blue[i].x;
		int by = blue[i].y;
		int max_red = -1;
		int max_red_y = -1000000;
		//上記の2行と以下のfor文が配列に入っている要素の中で最大の
		//要素は何番目?いう問題の典型的な解き方
		//jがn-1まで動くが今まで見てきた中での最大値をmax_red_yに、
		//、それが何番目かをmax_redに保存する
		//それをjが動くごとに更新する
		//なお、max_red_yに最初はとても小さい値を入れておく
		//今回は配列に入っている要素の中で～の条件を満たすものの中で最大の要素は何番目？
		//という問題なので、更新は～の条件を満たす場合のみ更新する
		for (int j = 0; j < n; ++j) {
			//上記のcの条件を管理しているのが配列usedで
				//used[j]==0の場合はj番目の赤点はまだペアになっておらず、1
				//の場合はもうペアになっている。
				//一般に状態を管理するための配列をちゅくるというのはよくあるテク
			if (used[j] == 0 && red[j].x < bx&&red[j].y<by&&red[j].y>max_red_y) {
				max_red = j;
				max_red_y = red[j].y;
			}
		}
		if (max_red != -1) {
			ans++;
			used[max_red] = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

int const INF = 1e9;

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

struct state {
  int score_k;
  int type;
  int last[26];
  int score;
  std::vector<state>::iterator prev;
  bool operator< (state const& rhs) const { return score_k > rhs.score_k; } // reverse order
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  int const B = 800;
  int const K = 3;
  std::vector<int> t(D);
  
  std::vector<std::vector<state>> states(D+1);
  auto beam_step = [&](int d, int k) {
    auto& prev = states[d];
    auto& curr = states[d+1];
    curr.reserve(prev.size()*26);
    int dd = std::min(d+k, D-1);
    for(auto it = prev.begin(); it != prev.end(); ++it) {
      for(int T = 0; T < 26; ++T) {
        curr.push_back(*it);
        state& st = curr.back();
        st.prev = it;
        st.last[T] = d;
        st.type = T;
        st.score_k = st.score + s[d][T];
        for(int cx = 0; cx < 26; ++cx) {
          st.score_k -= c[cx]*(d+dd - 2*st.last[cx])*(dd-d+1)/2;
        }
      }
    }
    std::sort(curr.begin(), curr.end());
    if(curr.size() > B) curr.resize(B);
    for(auto& st: curr) {
      st.score += s[d][st.type];
      for(int cx = 0; cx < 26; ++cx) {
        st.score -= c[cx]*(d - st.last[cx]);
      }
    }
  };
  
  auto beam_search = [&](int k) {
    states.assign(D+1, std::vector<state>());
    states[0].emplace_back();
    states[0][0].score = 0;
    states[0][0].score_k = 0;
    std::fill_n(states[0][0].last, 26, -1);
    for(int d = 0; d < D; ++d) beam_step(d, k);
    auto it = states[D].begin();
    for(int d = D-1; d >= 0; it = it->prev, --d) {
      t[d] = it->type;
    }
  };
  beam_search(K);
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


Measured memory_bytes: 948464
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string N;
  cin >> N;

  for(int i = 0; i < 3; i++) {
    if(N[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;  

  return 0;
  
}


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

int main(){
	int i, j, input, weight;
	while(cin>>input){
		i=1;
		while(true){
			weight = 1;
			if(input%2){
				for(j=1;j<i;j++){
					weight *= 2;
				}
				cout << weight;
				if(input/2 == 0){
					cout << endl;
					break;
				}
				cout << " ";
			}
			input /= 2;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = min(a[0], b[0])
tmp = max(0, b[0]-a[0])

for i in range(1,n):
  if tmp > a[i]:
    ans += a[i]
    tmp = b[i]
  else:
    ans += tmp
    m = a[i]-tmp
    ans += min(m, b[i])
    tmp = max(0, b[i]-m)
ans += min(a[n], tmp)
print(ans)

Measured memory_bytes: 18476
#include<iostream>
using namespace std;
int main()
{
int a,b,x;
cin>>a>>b>>x;
if(a>x)
cout<<"NO";
if(a==x)
cout<<"YES";
if(a<x)
   {
    if(a+b<x)
    cout<<"NO";
    if(a+b>=x)
    cout<<"YES";
   }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n<3){
        cout<<0<<endl;
        return 0;
    }
    vector<int> vec(5);
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s[0]=='M'){
            vec[0]++;
        }
        if(s[0]=='A'){
            vec[1]++;
        }
        if(s[0]=='R'){
            vec[2]++;
        }
        if(s[0]=='C'){
            vec[3]++;
        }
        if(s[0]=='H'){
            vec[4]++;
        }
    }
   // cout<<vec[4]<<endl;
    int c=0;
    vector<ll> reg;
    for(int i=0;i<5;i++){
        if(vec[i]==0)c++;
        else reg.push_back(vec[i]);
    }
    
    if(c>=3){
        cout<<0<<endl;
        return 0;
    }
    ll sum=0;
    for(int i=0;i<reg.size();i++){
        for(int j=i+1;j<reg.size();j++){
            for(int k=j+1;k<reg.size();k++){
                sum += reg[i]*reg[j]*reg[k];
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
h,n=map(int,input().split())
attack=[list(map(int,input().split())) for _ in range(n)]

max_attack=max(at[0] for at in attack)

dp = [0]*(h+max_attack)
for i in range(1,h+max_attack):
    at=[]
    for a,b in attack:
        at.append(dp[i-a]+b)
    dp[i]=min(at)
print(min(dp[h:]))


Measured memory_bytes: 44876
def noofrupees(x,y,z):
    if(x==y and x==z):
        return 0
    elif(x==y):
        if(x<z):
            return z-x
        else:
            if(x%2==0 and z%2==0):
                return int((x-z)/2)
            elif(x%2!=0 and z%2!=0):
                return int((x-z)/2)
            else:
                z = z-1
                return int((x-z)/2)+1
    elif(x==z):
        if(x<y):
            return y-x
        else:
            if(x%2==0 and y%2==0):
                return int((x-y)/2)
            elif(x%2!=0 and y%2!=0):
                return int((x-y)/2)
            else:
                y = y-1
                return int((x-y)/2)+1
    elif(y==z):
        if(y<x):
            return x-y
        else:
            if(y%2==0 and x%2==0):
                return int((y-x)/2)
            elif(y%2!=0 and x%2!=0):
                return int((y-x)/2)
            else:
                x = x-1
                return int((y-x)/2)+1
    
#t= int(input())
t=1;
for v in range(t):
    x,y,z = map(int,input().split())
    if(x!=y and x!=z and y!=z):
        list1 = [x,y,z]
        list1.sort()
        s = list1[2] - list1[1]
        list1[0]+=s
        list1[1]+=s
        print(s+noofrupees(list1[0],list1[1],list1[2]))
    else:
        print(noofrupees(x,y,z))
    
        
        
                
                
                
                
        

Measured memory_bytes: 3064
import numpy as np
import math
N,D = map(int,input().split())
x = []
for i in range(N):
    x.append(list(map(int,input().split())))
count = 0
for i in range(len(x)):
    for j in range(len(x)-i-1):
        dis = 0
        for k in range(D):
            dis += (x[i][k]-x[i+j+1][k])**2
        if (math.sqrt(dis).is_integer()):
            count += 1
print(count)

Measured memory_bytes: 20644
#include<cstdio>

int can[300000];
int rcan[300000];
int main(void) {
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++) {
        int a,b;
        scanf("%d%d",&a,&b);
        if(a==1) can[b] = 1;
        if(b==1) can[a] = 1;
        if(a==n) rcan[b] = 1;
        if(b==n) rcan[a] = 1;
    }

    char res = 0;
    for(int i=0; i<=n+5; i++) {
        if(can[i] && rcan[i])
            res = 1;
    }
    printf("%s\n", res ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    System.out.println( (H-h) * (W-w) );
  }
 }

Measured memory_bytes: 23252
import Data.Char (isLower, isUpper, toLower, toUpper)
    
main :: IO ()
main = getLine >>= putStrLn . toggleCases

toggleCases :: String -> String
toggleCases = map toggleCase
    where toggleCase c
              | isUpper c = toLower c
              | isLower c = toUpper c
              | otherwise = c

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
#define N 1000
#define N2 N*N
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
bool prime[N2+1];
int cave[N+1][N+1]={};
pair<int,int> dp[N+1][N+1];
int m,n;

pair<int,int> rec(int x,int y){
    if(y==0 || x==0 || x==N+1 || cave[x][y]>m)return pair<int,int>(0,0);
    if(dp[x][y].first)return dp[x][y];
    pair<int,int> child[3];
    child[0]=rec(x-1,y-1);
    child[1]=rec(x,y-1);
    child[2]=rec(x+1,y-1);
    sort(child,child+3);
    if(child[2].first==0 && prime[cave[x][y]])return dp[x][y]=pair<int,int>(1,cave[x][y]);
    if(prime[cave[x][y]])child[2].first++;
    return dp[x][y]=child[2];
}

int main(void){
    fill(prime,prime+N2+1,true);
    prime[0]=prime[1]=false;
    for(int i=2;i<=N2;i++){
        if(!prime[i])continue;
        for(int k=2;i*k<=N2;k++)prime[i*k]=false;
    }

    int x=1,y=N,d=0;
    pair<int,int> locate[N2+1];
    for(int i=N2;i>0;i--){
        cave[x][y]=i;
        locate[i] = pair<int,int>(x,y);
        int nextX=x+dx[d],nextY=y+dy[d];
        if(nextX==0 || nextX==N+1 || nextY==0 || nextY==N+1 || cave[nextX][nextY])d=(d+1)%4;
        x+=dx[d];
        y+=dy[d];
    }


    while(cin>>m>>n, m|n){
        rep1(i,N)rep1(j,N)dp[i][j].first=dp[i][j].second=0;
        pair<int,int> tmp=rec(locate[n].first,locate[n].second);
        cout<<tmp.first<<" "<<tmp.second<<endl;
    }

    return 0;
}

Measured memory_bytes: 21772
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if (n == 0 && x == 0) break;
            int i,j,k;
            int c = 0;
            for(i=1;i<=n-2;i++){
                for(j=i+1;j<=n-1;j++){
                    for(k=j+1;k<=n;k++){
                       if(i+j+k == x) c++;
                    }
                }
            }
            System.out.printf("%d\n",c);
        }
    }
}



Measured memory_bytes: 27472
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

int h[200000];
int dp[200000];

int main()
{
  int n=0;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&h[i]);
  dp[1]=0,dp[2]=abs(h[2]-h[1]);
  for(int i=3;i<=n;i++)dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  printf("%d",dp[n]);return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	string s = sc.NextString();
    	Console.WriteLine(int.Parse(s.Substring(5, 2)) <= 4 && int.Parse(s.Substring(8, 2)) <= 30 ? "Heisei" : "TBD");
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 11092
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
q=int(input())
import collections
D=collections.defaultdict(int)
ans=sum(A)
for a in A:
  D[a]+=1
for _ in range(q):
  b,c=map(int,input().split())
  ans+=(c-b)*D[b]
  D[c]+=D[b]
  D[b]=0
  print(ans)


Measured memory_bytes: 23836
// https://atcoder.jp/contests/aising2020/tasks/aising2020_b

use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        n: usize,
        a_n: [i64; n],
    }
    let mut ans = 0;
    for (i, x) in a_n.iter().enumerate() {
        if (i + 1) % 2 != 0 && x % 2 != 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, X;
    cin >> N >> X;

    if (X == 1 || X == 2 * N - 1) {
        write("No");
        return 0;
    }

    write("Yes");

    vector<int> ans(2 * N - 1, -1);
    ans[N - 1] = X;

    int small = X - 1, large = 2 * N - 1 - X;

    if (small < large) {
        ans[N - 2] = X + 1;
        ans[N] = X - 1;
        ans[N + 1] = X + 2;

        int i = 0;
        for (int n = 1; n < X - 1 && i < 2 * N - 1; ++i) {
            if (ans[i] == -1) {
                ans[i] = n;
                n++;
            }
        }
        for (int n = X + 3; n <= 2 * N - 1 && i < 2 * N - 1; ++i) {
            if (ans[i] == -1) {
                ans[i] = n;
                n++;
            }
        }
    }
    else {
        ans[N - 2] = X - 1;
        ans[N] = X + 1;
        ans[N + 1] = X - 2;

        int i = 0;
        for (int n = 1; n < X - 2 && i < 2 * N - 1; ++i) {
            if (ans[i] == -1) {
                ans[i] = n;
                n++;
            }
        }
        for (int n = X + 2; n <= 2 * N - 1 && i < 2 * N - 1; ++i) {
            if (ans[i] == -1) {
                ans[i] = n;
                n++;
            }
        }
    }

    for (int a : ans) {
        write(a);
    }
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

double PI = acos(-1.0);

int X[100], Y[100];
double P[100];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> X[i] >> Y[i];
    for (int i = 0;i < N;i++) {
    	P[i] = 0;
    	vector<double> Q;
    	for (int j = 0;j < N;j++) {
    		if (i == j) continue;
    		double ang = atan2(X[j] - X[i], Y[j] - Y[i]);
    		Q.push_back(ang);
    		Q.push_back(ang + 2.0 * PI);
    	}
    	sort(Q.begin(), Q.end());
    	for (int j = 1;j < Q.size();j++) {
    		if (Q[j] - Q[j - 1] >= PI) {
    			P[i] = max(P[i] / 2.0 / PI, (Q[j] - Q[j - 1] - PI) / 2.0 / PI);
    		}
    	}
    }
    for (int i = 0;i < N;i++) {
    	cout << P[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 2*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif


vector<pii> edge[2] ;
int id[N] ;

int root(int x){
    if(x == id[x])
        return x ;
    return id[x] = root(id[x]) ;
}

void merge(int x,int y){
    x = root(x) ;
    y = root(y) ;
    if(x == y) return ;
    id[x] = y ;
}
void solve()
{
    repA(i,1,N-1)
        id[i] = i ;
    set<int> st ;
    int n,m ;
    cin >> n >> m ;
    rep(i,m){
        int x,y,w ;
        cin >> x >> y >> w ;
        edge[w%2].pb({x,y}) ;
    }
    for(auto it : edge[0]){
        merge(it.ff,it.ss) ;
    }

    for(auto it : edge[1]){
        merge(it.ff,it.ss) ;
    }
    repA(i,1,n) st.insert(root(i)) ;
    cout << (int)st.size() ;
}   
     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 8044
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeScanner(1024)
	s := eGetFields(scanner)[0]
	l := len(s) - 2
	fmt.Printf("%c%d%c\n", s[0], l, s[len(s)-1])
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  string N; cin >> N;
  bool ans = false;
  REP(i,3) {
    if(N[i] == '7') {
      ans = true;
      break;
    }
  }
  if(ans) cout << "Yes";
    else  cout << "No";
}

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


using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int ctoi(char c) {
	if (c >= '0'&&c <= '9') {
		return c - '0';
	}

	return 0;
}

int main() {

	string s; cin >> s;

	for (int i = 0; i < (1 << 3); i++) {
		string buf = "";
		buf = buf + s[0];
		int sum = ctoi(s[0]);

		for (int j = 0; j < 3; j++) {
			
			if ((i >> j) & 1) {
				sum += ctoi(s[j + 1]);
				buf = buf + "+" + s[j + 1];
			}
			else {
				sum -= ctoi(s[j + 1]);
				buf = buf + "-" + s[j + 1];
			}
		}

		if (sum == 7) {
			buf = buf + "=7";
			cout << buf << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int t;
	scanf("%d",&t);
	for(int i=111;i<=999;i+=111)
	if(t<=i){printf("%d\n",i);return 0;}
}

Measured memory_bytes: 256
package main

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

var H int

func maxHeapify(A []int, i int) {
	left := 2*i
	right := 2*i + 1
	if left > H {
		return
	}
	var largest int
	if left <= H && A[left] > A[i] {
		largest = left
	} else {
		largest = i
	}
	if right <= H && A[right] > A[largest] {
		largest = right
	}

	if largest != i {
		A[i], A[largest] = A[largest], A[i]
		maxHeapify(A, largest)
	}
}

func buildMaxHeap(A []int) {
	for i := H/2; i > 0; i-- {
		maxHeapify(A, i)
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	H, _ = strconv.Atoi(scanner.Text())
	heap := make([]int, H+1)
	for i := 1; i <= H; i++ {
		scanner.Scan()
		heap[i], _ = strconv.Atoi(scanner.Text())
	}
	buildMaxHeap(heap)
	for i := 1; i <= H; i++ {
		fmt.Printf(" %d", heap[i])
	}
	fmt.Println()
}


Measured memory_bytes: 10020
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      if(S.contains("a")&&S.contains("b")&&S.contains("c")){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35760
#include <bits/stdc++.h> // {{{
using namespace std;
// clang-format off
#define ARG4(_1,_2,_3,_4,...) _4
#define rep(...) ARG4(__VA_ARGS__,FOR,REP)(__VA_ARGS__)
#define REP(i, a) FOR(i,0,a)
#define FOR(i, a, b) for(int i=(a);i<(int)(b);++i)
#define rrep(...) ARG4(__VA_ARGS__,RFOR,RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i,0,a)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(int)(a);--i)
#define ALL(c) begin(c),end(c)
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template<typename __VA_ARGS__>inline
#define USE2(T, ...) USE1(T,typename __VA_ARGS__)

using ll=long long;
template<typename T>using vec=vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<T>ndvec(T&&v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T&&v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pu(T&&x){cout<<x;}
USE1(T)void pr(T&&x){cout<<x<<'\n';}
USE2(T,...Ts)void pr(T&&x,Ts...xs){cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T)ostream&operator<<(ostream&o,vector<T>const&v){int f=0;for(auto&&x:v){if(f++)o<<' ';o<<x;}return o;}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout.setf(ios::fixed);
  }
} iosetup; //}}}
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {

  vec<pair<int, int>> v;
  rep(i, 4) {
    v.pb(i, in());
  }
  sort(ALL(v), [](pair<int, int> a, pair<int, int> b) {
    return ((1ll << (3 - a.fi)) * a.se) < ((1ll << (3 - b.fi)) * b.se);
  });
  ll N = in() * 4ll;
  ll ans = 0;
  for (auto&& p : v) {
    p.fi = 1 << p.fi;
    ans += (N / p.fi) * p.se;
    N %= p.fi;
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18,INF=1<<30;

int bit[MAX+1],N;

//1-indexed

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}

//sからtの和=sum(t)-sum(s-1)

void add(int i,int x){
    while(i<=N){
        bit[i]+=x;
        i+=i&-i;
    }
}

ll rui(ll a,ll b){
    //if(b==0) return 0;
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main(){
    
    cin>>N;
    vector<pair<pair<int,int>,int>> P(N);
    for(int i=0;i<N;i++){
        cin>>P[i].first.first>>P[i].first.second;
        P[i].second=i;
    }
    
    sort(all(P),[&](auto a,auto b){
        return a.first.first<b.first.first;
    });
    for(int i=0;i<N;i++) P[i].first.first=i+1;
    
    sort(all(P),[&](auto a,auto b){
        return a.first.second<b.first.second;
    });
    for(int i=0;i<N;i++) P[i].first.second=i+1;
    
    vector<int> UL(N),UR(N),DL(N),DR(N);
    
    for(int i=0;i<N;i++){
        int x=P[i].first.first,num=P[i].second;
        
        DL[num]=sum(x);
        DR[num]=i-sum(x);
        
        add(x,1);
        
    }
    
    memset(bit,0,sizeof(bit));
    
    sort(all(P),[&](auto a,auto b){
        return a.first.second>b.first.second;
    });
    
    for(int i=0;i<N;i++){
        int x=P[i].first.first,num=P[i].second;
        
        UL[num]=sum(x);
        UR[num]=i-sum(x);
        
        add(x,1);
    }
    
    ll ans=0,ALL=rui(2,N)-1;
    
    for(int i=0;i<N;i++){
        ans+=ALL;
        
        ans+=rui(2,UL[i]);
        ans+=rui(2,UR[i]);
        ans+=rui(2,DR[i]);
        ans+=rui(2,DL[i]);
        ans+=mod-rui(2,UL[i]+UR[i]);
        ans+=mod-rui(2,UR[i]+DR[i]);
        ans+=mod-rui(2,DR[i]+DL[i]);
        ans+=mod-rui(2,DL[i]+UL[i]);
        
        ans%=mod;
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 6784
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
string s,t;
int main(){
    cin>>s>>t;
    puts(t+s);
}

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

using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;

struct UnionFind {
  vector<int> par;
  vector<int> count;

  UnionFind(int N) : par(N), count(N) {
    for (int i = 0; i < N; i++) {
      par[i] = i;
      count[i] = 1;
    }
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  int getCount(int x) {
    return count[x];
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    if (count[rx] < count[ry]) {
      count[ry] += count[rx];
      par[rx] = ry;
    } else {
      count[rx] += count[ry];
      par[ry] = rx;
    }
  }
};

int main() {
	int n, m;
	cin >> n >> m;
	auto u = UnionFind(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		u.unite(a, b);
	}
	set<int> s;
	for (int i = 0; i < n; i++) {
		s.insert(u.root(i));
	}
	cout << s.size() - 1 << endl;
}


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

int main()
{
	std::string o, e;
	std::cin >> o >> e;
	for (unsigned int i = 0;; i++)
	{
		if (i == o.size()) break;
		std::cout << o[i];
		if (i == e.size()) break;
		std::cout << e[i];
	}
	std::cout << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vvl a(2, vl(n));
    rep(i, 2) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }

    ll ans = 0;
    rep(x, n) {  // x列目で下にいくとする
        ll now = 0;
        exrep(j, 0, x) {
            now += a[0][j];
        }
        exrep(j, x, n-1) {
            now += a[1][j];
        }
        chmax(ans, now);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  map<int64_t ,int64_t>k;
  for(int i=2;i<=N;i++){
    auto t=prime_factorize(i);
    for(auto c:t){
      k[c.first]+=c.second;
    }
  }
  int64_t ans=1;
  for(auto c:k){
    ans*=(c.second+1);
    ans%=1000000007;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    sort(ALL(A)); sort(ALL(B));
    if (N%2) {
        int mid_h, mid_l;
        mid_h = B[(N+1)/2-1];
        mid_l = A[(N+1)/2-1];
        cout << mid_h-mid_l+1 << endl;
    }
    else {
        int mid_h, mid_l;
        mid_h = (B[N/2-1] + B[N/2])/2;
        mid_l = (A[N/2-1] + A[N/2])/2;
        int ans = (mid_h-mid_l)*2 + 1;
        if ((B[N/2-1] + B[N/2])%2) ans++;
        if ((A[N/2-1] + A[N/2])%2) ans--;
        cout << ans << endl;
    }
}


Measured memory_bytes: 4848
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
int main(){
    int k,s;
    cin >> k >> s;
    int count=0;
    for(int i=0;i<=k;i++){
        int sum = s;
        sum -= i;
        for(int j=0;j<=k;j++){
            int sum1 = sum;
            sum1 -= j;
          //  if(i==5)cout<<sum1<<endl;
            if(sum1>=0&&sum1<=k){
                count++;
              //  cout<<i<<" "<<j<<endl;
            }
        }
    }
    cout<<count<<endl;
}

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

int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll t[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        t[i]=a[i];
    }
    sort(t,t+n,greater<ll>());
    ll m1 = t[0];
    ll m2 = t[1];
    for(ll i=0;i<n;i++){
        if(a[i]==m1)cout<<m2<<endl;
        else cout<<m1<<endl;
    }
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;
const int MOD = 1000 * 1000 * 1000 + 7;

int N;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N;
	LL ans = 1;
	REP (i, 1, N + 1) {
		ans = ans * i % MOD; 
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,x,y,ans;
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>x>>y;
    ans=ans+max(0LL,y-x+1);
}
cout<<ans;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
balls = sorted(input().split())
kinds = len(set(balls))
amo = [1] * kinds

balls.append(0)
j = 0
for i in range(n):
    if balls[i] == balls[i+1]:
        amo[j] += 1
    else:
        j += 1
amo.sort()
print(sum(amo[:max(0, kinds-k)]))

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



int main() {


    
    int a,b;
    cin>>a>>b;
    
    b = b*2 + 1;
    
    if(a%b==0)
        cout<<(a/b);
    else
        cout<<(a/b)+1;
        




      return 0;
      }


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
class Counter:
    def __init__(self):
        self.dict = {}

    def add(self,x):
        if x in self.dict: self.dict[x] += 1
        else: self.dict[x] = 1

    def decrement(self,x):
        self.dict[x] -= 1
        if self.dict[x] <= 0:
            del self.dict[x]

    def get_dict(self):
        return self.dict

def main():
    S=input()
    counter = Counter()
    for s in S:
        counter.add(s)

    d = counter.get_dict()
    for s in ['a','b','c']:
        if not s in d  or d[s] != 1:
            print("No")
            exit()
        
    print("Yes")






if __name__ == "__main__":
    main()

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;

int N, M, Q; 
vector<int> a(50), b(50), c(50), d(50);

int solve(vector<int> A){
    if(A.size() == N){
        int now = 0;
        rep(i,Q){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        return now;
    }

    int res = 0;

    int last;
    if(A.empty()) last = 1;
    else last = A[A.size()-1];

    for(int i=last; i<=M; i++){
        A.push_back(i);
        res = max(res, solve(A));
        A.pop_back();
    }

    return res;
}

int main(){
    cin >> N >> M >> Q;
    
    rep(i,Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    vector<int> A;
    int ans = solve(A);

    cout << ans << endl;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, M;
    vector<int> s, c;
    cin >> N >> M;
    s.resize(M);
    c.resize(M);
    rep(i, M){
        cin >> s[i] >> c[i];
        s[i]--;
    }
    vector<int> ans(N);
    vector<bool> seen(N);
    rep(i, N){
        seen[i] = false;
        ans[i] = 10;
    }

    rep(i, M){
        if(!seen[s[i]]){
            seen[s[i]] = true;
            ans[s[i]] = c[i];
        }else{
            if(ans[s[i]] != c[i]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    if(ans[0] == 10){
        if(N == 1)
            ans[0] = 0;
        else
            ans[0] = 1;
    }
    rep(i, N)
        if(ans[i] == 10)
            ans[i] = 0;
    if(ans[0] == 0 && N >= 2){
        cout << -1 << endl;
        return 0;
    }

    rep(i, N)
        cout << ans[i];
    cout << endl;

	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) {
    cin >> A.at(i);
    --A.at(i);
  }
  set<int> found;
  int current = 0;
  found.insert(current);
  int count = 1;
  REP(i, N){
    int next = A.at(current);
    if(next == 1){
      cout << count << endl;
      return 0;
    }

    if(found.find(next) != found.end()){
      break;
    }
    found.insert(next);
    current = next;
    ++count;
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 8248
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim S, T As String
        Dim arr() As String
        arr = Split(Console.ReadLine())
        S = arr(0) : T = arr(1)
        Console.WriteLine(T & S)
        Return
    End Sub
End Class


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

int main(){
  double l,ans;
  cin >> l;
  
  ans =  (l/3)*(l/3)*(l/3);
  
  printf("%f", ans);
    
  }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
const int N=2e5+10,mod=1e9+7;
int n,m,q,Ans,HH[N],ZZ[N],dis[N],vis[N];
char s[N],t[N];
set<int> H[2],Z[2];
queue<int> Q;
struct Node{int x,y;}P[N];
void GetAns(int x1,int y1,int x2,int y2)
{
	int ch=0,cz=0,c=0;
	set<int>::iterator it;
	for(int i=0;i<2;i++)
	{
		it=H[i].lower_bound(x1);
		if(it!=H[i].end()) HH[++ch]=*it;
		if(it!=H[i].begin()) HH[++ch]=*(--it);
		it=H[i].lower_bound(x2);
		if(it!=H[i].end()) HH[++ch]=*it;
		if(it!=H[i].begin()) HH[++ch]=*(--it);

		it=Z[i].lower_bound(y1);
		if(it!=Z[i].end()) ZZ[++cz]=*it;
		if(it!=Z[i].begin()) ZZ[++cz]=*(--it);
		it=Z[i].lower_bound(y2);
		if(it!=Z[i].end()) ZZ[++cz]=*it;
		if(it!=Z[i].begin()) ZZ[++cz]=*(--it);
	}
	sort(HH+1,HH+ch+1);
	ch=unique(HH+1,HH+ch+1)-HH-1;
	sort(ZZ+1,ZZ+cz+1);
	cz=unique(ZZ+1,ZZ+cz+1)-ZZ-1;
	
	for(int i=1;i<=ch;i++)
		for(int j=1;j<=cz;j++)
			P[++c]=(Node){HH[i],ZZ[j]};
	for(int i=1;i<=c;i++)
		if(P[i].x==x1&&P[i].y==y1)
			dis[i]=0,Q.push(i),vis[i]=1;
		else dis[i]=1e9;
	while(!Q.empty())
	{
		int x=Q.front();
		for(int i=1;i<=c;i++)
		{
			if(P[i].x!=P[x].x&&P[i].y!=P[x].y) continue;
			if(P[i].x==P[x].x)
			{
				if(P[i].y>P[x].y&&s[P[i].x]=='W') continue;
				if(P[i].y<P[x].y&&s[P[i].x]=='E') continue;
			}
			if(P[i].y==P[x].y)
			{
				if(P[i].x>P[x].x&&t[P[i].y]=='N') continue;
				if(P[i].x<P[x].x&&t[P[i].y]=='S') continue;
			}
			int val=dis[x]+abs(P[i].x-P[x].x)+abs(P[i].y-P[x].y);
			if(dis[i]<=val) continue;
			dis[i]=val;
			if(!vis[i]) Q.push(i),vis[i]=1;
		}
		Q.pop(),vis[x]=0;
	}
	for(int i=1;i<=c;i++)
		if(P[i].x==x2&&P[i].y==y2)
			Ans=dis[i];
}
int main()
{
	scanf("%d%d%d%s%s",&n,&m,&q,s+1,t+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='E') H[1].insert(i);
		else H[0].insert(i);
	for(int i=1;i<=m;i++)
		if(t[i]=='N') Z[1].insert(i);
		else Z[0].insert(i);
	for(int i=1,x1,y1,x2,y2;i<=q;i++)
	{
		cin>>x1>>y1>>x2>>y2;
		GetAns(x1,y1,x2,y2);
		if(Ans==1e9) puts("-1");
		else printf("%d\n",Ans);
	}
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 104 C / Link: http://abc104.contest.atcoder.jp/tasks/abc104_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N, G; cin >> N >> G;
	vector<LL> x(N), y(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}

	ans = LINF;

	FOR(state, 0, 1 << N) {
		LL points = 0;
		LL ret = 0;
		FOR(i, 0, N) {
			if (state & 1 << i) {
				ret += x[i];
				points += x[i] * (100)*(i + 1) + y[i];
			}
		}
		FORR(i, N - 1, 0 - 1) {
			if (points >= G)break;
			if (state & 1 << i)continue;
			FOR(k, 1, x[i] + 1) {
				ret++;
				points += 100 * (i + 1);
				if (x[i] == k)points += y[i];
				if (points >= G)break;
			}
		}


		ans = min(ans, ret);
	}



	cout << ans << "\n";

	return 0;
}


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

const int MAXN = 10;
const int MAXH = 51;
const int MAXW = 51;
const int INF = 1<<28;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
int H, W, si, sj, gi, gj;
char G[MAXH][MAXW];
int S;
int T[MAXN][MAXH][MAXW];
int F[1<<MAXN][MAXH][MAXW];
int cost[1<<MAXN][2][MAXH][MAXW];

struct State {
  int s, f, i, j;
};

int bfs() {
  queue<State> que;
  memset(cost, -1, sizeof(cost));
  State src = {0, 0, si, sj};
  que.push(src);
  cost[src.s][src.f][src.i][src.j] = 0;
  while(que.size()) {
    const State s = que.front();
    que.pop();
    if(s.i == gi && s.j == gj) return cost[s.s][s.f][s.i][s.j];
    for(int k = 0; k < 4; ++k) {
      const State t = {s.s, s.f, s.i + di[k], s.j + dj[k]};
      if(t.i < 0 || t.i >= H) continue;
      if(t.j < 0 || t.j >= W) continue;
      if(G[t.i][t.j] == '#') continue;
      if(G[t.i][t.j] != '|' && F[t.s][t.i][t.j] != t.f) continue;
      if(cost[t.s][t.f][t.i][t.j] != -1) continue;
      que.push(t);
      cost[t.s][t.f][t.i][t.j] = cost[s.s][s.f][s.i][s.j] + 1;
    }

    if(isalpha(G[s.i][s.j]))
      do {
        int id = toupper(G[s.i][s.j]) - 'A';
        int ns = s.s ^ (1 << id);
        const State t = {ns, F[ns][s.i][s.j], s.i, s.j};
        if(cost[t.s][t.f][t.i][t.j] != -1) continue;
        que.push(t);
        cost[t.s][t.f][t.i][t.j] = cost[s.s][s.f][s.i][s.j] + 1;
      } while(0);

    if(G[s.i][s.j] == '|')
      do {
        const State t = {s.s, s.f ^ 1, s.i, s.j};
        if(cost[t.s][t.f][t.i][t.j] != -1) continue;
        que.push(t);
        cost[t.s][t.f][t.i][t.j] = cost[s.s][s.f][s.i][s.j] + 1;
      } while(0);
  }
  return -1;
}

bool getFloor(char c) {
  if(isalpha(c)) return isupper(c);
  if(c == '_') return 0;
  if(c == '^') return 1;
  return 0;
}

int main() {
  while(cin >> W >> H) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
        if(G[i][j] == '%') {
          G[i][j] = '_';
          si = i;
          sj = j;
        }
        if(G[i][j] == '&') {
          G[i][j] = '_';
          gi = i;
          gj = j;
        }
      }
    }
    cin >> S;
    for(int k = 0; k < S; ++k) {
      for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
          char c; cin >> c;
          T[k][i][j] = (c == '*');
        }
      }
    }
    for(int b = 0; b < (1<<S); ++b) {
      for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j) {
          F[b][i][j] = getFloor(G[i][j]);
          for(int k = 0; k < S; ++k){
            if(b >> k & 1); else continue;
            F[b][i][j] ^= T[k][i][j];
          }
        }
      }
    }
    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 33052