akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    bool flag=true;
    cin>>N>>S;
    vector<int>v;
    int c=0;
    for(int i=0;i<N;i++){
        if(S[i]=='.'){
            if(flag==true){c++;}
            else{v.push_back(c);c=1;flag=true;}
        }
        else{
            if(flag==false){c++;}
            else{v.push_back(c);c=1;flag=false;}
        }
    }
    v.push_back(c);
    if(flag==false){
        v.push_back(0);
    }
    int size=v.size();
    vector<int>W,B;
    int num=0;
    for(int i=0;i<(size+1)/2;i++){
        num+=v[2*i];
        W.push_back(num);
    }
    num=0;
    for(int i=0;i<(size-1)/2;i++){
        num+=v[2*i+1];
        B.push_back(num);
    }
    vector<int>sub;
    int M=0;
    for(int i=0;i<W.size();i++){
        M=0;
        M+=W[W.size()-1]-W[i];
        if(i>0){M+=B[i-1];}
        sub.push_back(M);
    }
    sort(sub.begin(),sub.end());
    cout<<sub[0]<<endl;
}

Measured memory_bytes: 2956
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
typedef long long LL;
typedef pair<int,int> pii;

const int maxn = 2000;

int n, m, Q, cnt = 0;
int f[maxn+2][maxn+2];
int f2[maxn+2][maxn+2], f3[maxn+2][maxn+2];
char mmp[maxn+2][maxn+2];

int main() {
	scanf("%d%d%d", &n, &m, &Q);
	for(int i = 1; i <= n; ++i) 
		scanf("%s", mmp[i] + 1);
	for(int i = 1; i <= n; ++i) {
		int tmp = 0, tmp2;
		for(int k = 1; k <= m; ++k) {
			if(mmp[i][k] == '1') {
				tmp2 = 0;
				if(i-1 >= 1 && mmp[i-1][k] == '1')
					++tmp2;
				if(k-1 >= 1 && mmp[i][k-1] == '1')
					++tmp2;
				if(tmp2 == 2)
					--tmp;
				else if(tmp2 == 0)
					++tmp;
			}
			f[i][k] = tmp + f[i-1][k];
		}
	}

	for(int i = 1; i <= n; ++i) {
		for(int k = 2; k <= m; ++k) {
			f2[i][k] = f2[i-1][k];
			if(mmp[i][k-1] == '1' && mmp[i][k] == '1')
				++f2[i][k];
		}
	}

	for(int i = 2; i <= n; ++i) {
		for(int k = 1; k <= m; ++k) {
			f3[i][k] = f3[i][k-1];
			if(mmp[i][k] == '1' && mmp[i-1][k] == '1')
				++f3[i][k];
		}
	}

	/*
	printf("\n");
	for(int i = 1; i <= n; ++i) {
		for(int k = 1; k <= m; ++k) {
			printf("%d ", f[i][k]);
		}
		printf("\n");
	}
	printf("\n");
	*/

	int x1, x2, y1, y2, ans;
	//printf("cnt = %d\n", cnt);
	for(int i = 1; i <= Q; ++i) {
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		ans = f[x2][y2] - f[x1-1][y2] - f[x2][y1-1] + f[x1-1][y1-1];
		if(x1 >= 2) {
			ans += f3[x1][y2] - f3[x1][y1 - 1];
		}
		if(y1 >= 2) {
			ans += f2[x2][y1] - f2[x1 - 1][y1];
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 52736
#include<iostream>
using namespace std;
int main() {
  int n, s=0;
  cin >> n;
  int t = n;
  while(t > 0) {
    s += t%10;
    t /= 10;
  }
  if(n%s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

int a[6];
int i,j,tmp;

for(i=0;i<3;i++){
scanf("%d %d",&a[2*i],&a[2*i+1]);
}

for (i=0; i<5; i++) {
		for (j=5; j>i; j--) {
			if (a[j-1] > a[j]) {
				tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
			}
		}
  }

if(a[1]==a[2] && a[3]==a[4]) printf("YES\n");
else printf("NO\n");


  return 0;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;

#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    
    ll n;
    cin>>n;
    ll ans = 0;
    ll c = 1;
    rep(i,0,n){
        ll x;
        cin>>x;
        if(x==c){
            c++;
        } else ans++;
    }
    if(ans==n) cout<<-1<<endl;
    else cout<<ans<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

signed main(){
	int A,B;
	cin>>A>>B;
	int g=gcd(A,B);

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int cnt[200010];
int main(){
    int i,n;
    cin >> n;
    for(i=0;i<n - 1;i++){
        int a; cin >> a; a--; cnt[a]++;
    }
    for(i=0;i<n;i++){
        cout << cnt[i] << endl;
    }
}

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


int main()
{
  long long x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<long long> red(a);
  vector<long long> green(b);
  for(int i=0; i<a; i++)
     cin>>red[i];
  for(int i=0; i<b; i++)
     cin>>green[i];
sort(red.begin(), red.end(), greater<long long>());
sort(green.begin(), green.end(), greater<long long>());

     vector<long long> aaa;
     for(int i=0; i<x; i++)
        aaa.push_back(red[i]);
    for(int i=0; i<y; i++)
        aaa.push_back(green[i]);
    long long k;
    for(int i=0; i<c; i++)
    {
        cin>>k;
        aaa.push_back(k);
    }
    sort(aaa.begin(), aaa.end(), greater<long long>());
    long long sum=0;
    for(int i=0; i<x+y; i++)
        sum+=aaa[i];

    cout<<sum;
    return 0;


     }




Measured memory_bytes: 7536
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N = int(stdin.readline().rstrip())
p = [int(x) for x in stdin.readline().rstrip().split()]

def isSorted(num_list):
    for index in range(N-1):
        if num_list[index+1] < num_list[index]:
            return False

    return True

if isSorted(p):
    print("YES")
    exit()

for i in range(N-1):
    for j in range(i+1, N):
        tmp_p = p[:]
        tmp = tmp_p[i]
        tmp_p[i] = tmp_p[j]
        tmp_p[j] = tmp

        if isSorted(tmp_p):
            print("YES") 
            exit()

print("NO")


Measured memory_bytes: 66028
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

soroban n = cond "* " " *" (n<5) ++ "=" ++ take 5 (replicate (mod n 5) '*' ++ " ****")
f n = transpose . reverse $ g 5 n
  where
    g 0 _ = []
    g t n = (soroban (mod n 10)) : (g (t-1) (div n 10))



main = intercalate [""] . map (f . readInt) . lines <$> getContents >>= mapM_ putStrLn

Measured memory_bytes: 4288
#include<cstdio>
using namespace std;

int main(){
	double a;
	while( scanf("%lf", &a ) == 1 ){
		double S = a;
		for( int i=2; i<=10; i++ ){
			if( i%2 )
				a /= 3.0;
			else
				a *= 2.0;
			S += a;
		}
		printf("%.8f\n", S);
	}
	return 0;
}

Measured memory_bytes: 0
int main() {
    int num1;
    int num2;
    int ans1;
    int ans2=0;
    int count=10;
    int judge=0;
    scanf("%d ", &num1);
    
    for(int i=0;i<=2;i++){
        num2 = num1%count;
        ans1=num2/(count/10);
        num1=num1-num2;
        count=count*10;
        if (i!=0){
            if(ans1==ans2){
                judge=1;
            }
        }
        ans2=ans1;
    }
    
    ans1=num1/1000;
    if(ans1==ans2){
        judge=1;
    }
    
    if(judge==1){
        printf("Bad");
    }else{
        printf("Good");
    }
   return 0;
}

Measured memory_bytes: 128
dp=[0]*110000
LINF=10**9

n,k=map(int,input().split())
h=list(map(int,input().split()))

dp[0]=0
for i in range(1,n):
  dp[i]=LINF
  for j in range(1,k+1):
    if i-j>=0:
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))

print(dp[n-1])

Measured memory_bytes: 53216
// https://atcoder.jp/contests/abc018/tasks/abc018_4

#include <bits/stdc++.h>
using namespace std;
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e18;
static const ll MOD = 1e9 + 7;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int main() {

  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }

  // ll ans = 0;

  // REP(i, 61){
  //   ll num1 = 0;
  //   ll num0 = 0;
  //   REP(j, N){
  //     // ll keta = 1LL < i;
  //     if((A[j] >> i) & 1LL) num1++;
  //     else num0++;
  //   }
  //   ll keta = 1LL << i;
  //   ll tmp = keta * num1;
  //   tmp %= MOD;
  //   tmp =  tmp * num0;
  //   tmp %= MOD;
  //   ans += tmp;
  //   ans %= MOD;
  // }
  // ans %= MOD;

  // cout << ans << endl;

  ll res = 0;
  REP(i, 61){
  int o = 0, l = 0;
    REP(j, N){
      if((A[j] >> i)&1) o++;
      else l++; 
    }
    ll tmp = 1LL << i;
    tmp %= MOD;
    tmp *= o;
    tmp %= MOD;
    tmp *= l;
     tmp %= MOD;
     res += tmp;
  }
  res %= MOD;

  cout << res << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main() {
    int a, b, c, x;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    int n = 0;
    for (size_t i = 0; i <= a; ++i) {
        int tmp_i = x - 500 * i;
        for (size_t j = 0; j <= b; ++j) {
            int tmp_j = tmp_i - 100 * j;
            for (size_t k = 0; k <= c; ++k) {
                if (tmp_j - 50 * k == 0) ++n;
            }
        }
    }
    cout << n << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int k;
	cin >> k;
	if (k % 2 == 1) {
		int s;
		s = k + 1;
		int l;
		l = s / 2;
		int j;
		j = l * (l - 1);
		cout << j << endl;
	}
	else if (k % 2 == 0) {
		int s;
		s = k / 2;
		int j;
		j = s * s;
		cout << j << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    CIN(M);
    N--;
    M--;
    COUT(N*M);
    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;

struct edge {
    int to, cap, rev;
};

vector<vector<edge>> G;
vector<bool> used;

int N;
const int inf = 1 << 30;

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    REP (i, 0, G[v].size()) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    while (true) {
        used = vector<bool>(2 * N + 2, false);
        int f = dfs(s, t, inf);
        if (f == 0) return flow;
        flow += f;
    }
}

int main() {
    cin >> N;
    vector<pii> red(N), blue(N);
    G.resize(2 * N + 2);
    REP (i, 0, N) {
        cin >> red[i].first >> red[i].second;
    }
    REP (i, 0, N) {
        cin >> blue[i].first >> blue[i].second;
    }
    REP (i, 0, N) {
        REP (j, 0, N) {
            if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
                add_edge(i, j + N, 1);
            }
        }
    }
    REP (i, 0, N) {
        add_edge(2 * N, i, 1);
    }
    REP (i, 0, N) {
        add_edge(N + i, 2 * N + 1, 1);
    }
    cout << max_flow(2 * N, 2 * N + 1) << endl;
    return 0;
}

Measured memory_bytes: 384
#D
       


#XXX=[int(x) for x in Input.split()]

n,q = (int(x) for x in input().split())
#n,q = XXX[0:2]

E = [[] for i in range(n+1)]
for i in range(n-1):
    a,b = (int(x) for x in input().split())
    #a,b = XXX[i*2+2:i*2+4]
    #A.append(a)
    #B.append(b)
    E[a].append(b)
    E[b].append(a)

P = []
X = []
for i in range(q):
    p,x = (int(x) for x in input().split())
    #p,x = XXX[i*2+n*2:i*2+n*2+2]
    P.append(p)
    X.append(x)

c = [0]*(n+1)
for i in range(len(P)):
    c[P[i]]+=X[i]

#sc = [-1]*(n+1)
sc = [0]*(n+1)
checked = [False]*(n+1)
stac = [1]

#dig(1,-1,0)

while stac:
    th = stac.pop()
    sc[th] += c[th]
    checked[th] = True
    
    for i in E[th]:
        if checked[i] == False:
            sc[i] += sc[th]
            stac.append(i)

result = map(str, sc[1:])
print(" ".join(result))
    

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

/*
*/

bool ok=true;
ll n,k,m;

void init(){
	cin>>n>>k;
	m=n*(n-1)/2 - k;
}

int main(void){
	init();
	if(m<(n-1)){
		cout<<-1<<endl;
	}else{
		cout<<m<<endl;
		reg(i,2,n){
			cout<<1<<" "<<i<<endl;
			m--;
		}
		reg(i,2,n){
			reg(j,i+1,n){
				if(m<=0)break;
				cout<<i<<" "<<j<<endl;
				m--;
			}
		}
	}
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int remain = 0;
	int temp;
	long long sum = 0;
	for (int i = 0; i < N; ++i){
		cin >> temp;
		if (temp == 0){
			remain = 0;
		}
		temp += remain;
		sum += temp / 2;
		remain = temp % 2;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
	int n,max,sum,t;
	scanf("%d", &n);
	while(n){
		scanf("%d", &t);
		max = sum = t;
		for(int i = 1; i < n; i++){
			if(sum < 0){
				sum = 0;
			}
			scanf("%d", &t);
			sum += t;
			if(sum > max){
				max = sum;
			}
		}
		printf("%d\n", max);
		scanf("%d", &n);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
 
using namespace std;
vector<int> v;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n,a,b;
  
  cin>>n>>a>>b;
  
  int t = n*a;
  
  if (t < b) {
    cout<<t<<endl;
    return 0;
  }
  
  else {
   cout<<b<<endl;
    return 0;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	for (auto& i : a)
		cin >> i;
	a.insert(a.begin(), 0);
	a.push_back(0);
	
	int sum = 0;
	for (int i = 0; i < n + 1; ++i)
		sum += abs(a[i + 1] - a[i]);

	for (int i = 1; i < n + 1; ++i)
		cout << (sum - abs(a[i - 1] - a[i]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1])) << endl;

	return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

int main() {

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

  vector<int> ans(2*K-1);

  // backward
  rep(i, K-1) {
	ans[i] = N-K+1 +i;
  }


  // center
  ans[K-1] = N;


  // forward
  int cnt = 1;
  for(int i=K; i<2*K-1; ++i) {
	ans[i] = N+cnt;
	cnt++;
  }


  rep(i,2*K-1) cout << ans[i] << endl;
  return 0;
}

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

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

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

mint dp[101][4][4][4];

int main() {
    int N;
    cin >> N;
    // A,G,C,T => 0,1,2,3
    // 長さ0の文字列は1
    // 0,1,2に関する制約しかないのでSは333Sとしてよい
    dp[0][3][3][3] = 1;

    rep(len, N) { // 文字列の文字数
        rep(i, 4) { // 最後から1文字目の文字列
            rep(j, 4) { // 最後から2文字目の文字列
                rep(k, 4) { // 最後から3文字目の文字列
                    if (dp[len][i][j][k].x == 0) continue;

                    // 新しく追加する文字列
                    rep(a, 4) {
                        // ダメな5つの条件をカットする(012またはswapして012)
                        if (j == 0 && i == 1 && a == 2) continue; // 012
                        if (j == 1 && i == 0 && a == 2) continue; // 102
                        if (j == 0 && i == 2 && a == 1) continue; // 021
                        if (k == 0 && i == 1 && a == 2) continue; // 0?12
                        if (k == 0 && j == 1 && a == 2) continue; // 01?2

                        // s     = .......k j i
                        // nextS = .......j i a
                        dp[len + 1][a][i][j] += dp[len][i][j][k];
                    }
                }
            }
        }
    }

    mint ans = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) ans += dp[N][i][j][k];
    cout << ans.x << endl;
}

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

const int N=300005;

int n,m;

struct Seg{
	int l,r,len;
	void readin(){
		scanf("%d%d",&l,&r);
		len=r-l+1;
	}
}a[N];

bool cmp(Seg x,Seg y){return x.len<y.len;}

struct Tree{
	
	int c[N];
	
	void updata(int x,int v){
		for(;x<=m;x+=x&(-x)) c[x]+=v;
	}
	
	int query(int x){
		int ret=0;
		for(;x>0;x-=x&(-x)) ret+=c[x];
		return ret;
	}
}T;

void work()
{
	int k=1; 
    for(int i=1,k=1;i<=m;i++)
    {
    	for(;k<=n&&a[k].len<i;k++) T.updata(a[k].l,1),T.updata(a[k].r+1,-1);
        int ans=n-k+1; 
        for(int j=i;j<=m;j+=i) ans+=T.query(j);
        printf("%d\n",ans);
    }
}

void init()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) a[i].readin();
	sort(a+1,a+1+n,cmp);
}

int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000

int main(){
  int N;
  cin>>N;
  vector<pair<ll,ll>> X(N);
  for(int i=0;i<N;i++){
    ll x,l;
    cin>>x>>l;
    X.at(i).first=x-l;
    X.at(i).second=x+l;
  }
  sort(X.begin(),X.end());

  vector<int> nk(N,N-1);
  for(int i=N-2;i>=0;i--){
    if(X.at(i).second<X.at(nk.at(i+1)).second){
      nk.at(i)=i;
    }else{
      nk.at(i)=nk.at(i+1);
    }
  }

  int ans=0;
  int k=0;
  while(1){
    int j=nk.at(k);
    pair<ll,ll> p=make_pair(X.at(j).second,-2000000000);
    k=lower_bound(X.begin()+k,X.end(),p)-X.begin();
    ans++;
    if(k==N){
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static int n;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		n = Integer.parseInt(br.readLine());

		long edge[][] = new long[n][n];

		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");
			for (int j = 0; j < n; j++) {
				edge[i][j] = Long.parseLong(str[j]);
			}
		}
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				if (edge[i][k] == 0)
					continue;
				for (int j = 0; j < n; j++) {
					if (edge[j][k] == 0)
						continue;
					if (edge[i][k] + edge[k][j] < edge[i][j]) {
						System.out.println(-1);
						return;
					}

					if (edge[i][k] + edge[k][j] == edge[i][j]) {
						edge[i][j] = 0;
						edge[j][i] = 0;
					}
				}
			}
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				ans += edge[i][j];
			}
		}

		System.out.println(ans / 2);
	}
}

Measured memory_bytes: 36052
#include <stdio.h>

int main(void){
	char a[200001];
  	char b[200001];
  	int i,count;
  	scanf("%s",a);
  	scanf("%s",b);
  	count=0;
  	for(i=0;a[i]!='\0';i++){
    	if(a[i]!=b[i]){
        	count++;
        }
    }
  	printf("%d",count);
}

Measured memory_bytes: 2124
a,b,c,d,e = map(int, input().split())
while True:
  if a < b:
    b,a = a,b
  elif b < c:
    c,b = b,c
  elif c < d:
    d,c = c,d
  elif d < e:
    e,d = d,e
  else:
    print(a,b,c,d,e)
    break


Measured memory_bytes: 5600
n,m = map(int,input().split())
s = [0]*n
for i in range(m):
    k = list(map(int,input().split()))
    for j in range(1,k[0]+1):
        s[k[j]-1] |= 1<<i
p=0
k = list(map(int,input().split()))
for i in range(m):
    p |= k[i]<<i
ans = 0
for i in range(1<<n):
    t = 0
    for j in range(n):
        if i>>j&1: t^=s[j]
    if t==p: ans+=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>

using namespace std;
double dp[305][305][305];
int n[5]={};

int main(){
    cin>>n[0];
    for(int i=0;i<n[0];i++){
        int buf;
        cin>>buf;
        n[buf]++;
    }
    for(int i=0;i<305;i++){
        for(int j=0;j<305;j++){
            for(int k=0;k<305;k++){
                dp[i][j][k]=0;
            }
        }
    }
    dp[1][0][0]=n[0];
    //    dp[0][1][0]=2.0*n[0];
    //    dp[0][0][1]=3.0*n[0];
    for(int k=0;k<=n[3];k++){
        for(int j=0;j<=n[2]+n[3];j++){
            for(int i=0;i<=n[0];i++){
                double sum=(double)i+(double)j+(double)k;
                dp[1][0][0]=n[0];
		/*                dp[0][1][0]=2.0*n[0];
                dp[0][0][1]=3.0*n[0];*/
                if(i-1>=0)dp[i][j][k]+=((double)i/sum)*(dp[i-1][j][k]+1);
                if(j-1>=0)dp[i][j][k]+=((double)j/sum)*(dp[i+1][j-1][k]+1);
		if(k-1>=0)dp[i][j][k]+=((double)k/sum)*(dp[i][j+1][k-1]+1);
		dp[i][j][k]+=((double)n[0]-sum)/sum;
            /*    if(j-1>=0)dp[i][j][k]+=(n[0]/(double)j)+(dp[i+1][j-1][k]);
                if(k-1>=0)dp[i][j][k]+=(n[0]/(double)k)+(dp[i][j+1][k-1]);*/
            }
        }
    }
    if(n[0]==1&&n[1]==1){
      cout<<1<<endl;
      return 0;
    }
    printf("%.24lf\n",dp[n[1]][n[2]][n[3]]);
    //    cout<<dp[n[1]][n[2]][n[3]]<<endl;
    return 0;
}


Measured memory_bytes: 221952
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		long n = h[0], c = h[1];
		var s = new int[h[0]].Select(_ => read()).ToArray();

		var t = new long[4, n + 1];
		for (int i = 1; i <= n; i++)
		{
			t[0, i] = t[0, i - 1] + s[i - 1][1];
			t[1, i] = t[1, i - 1] + s[n - i][1];
		}
		for (int i = 1; i <= n; i++)
		{
			t[0, i] -= s[i - 1][0];
			t[1, i] -= c - s[n - i][0];
			t[2, i] = Math.Max(t[2, i - 1], t[0, i]);
			t[3, i] = Math.Max(t[3, i - 1], t[1, i]);
		}
		var M0 = Enumerable.Range(0, (int)n + 1).Max(i => t[0, i] - (i > 0 ? s[i - 1][0] : 0) + t[3, n - i]);
		var M1 = Enumerable.Range(0, (int)n + 1).Max(i => t[1, i] - (i > 0 ? c - s[n - i][0] : 0) + t[2, n - i]);
		Console.WriteLine(Math.Max(M0, M1));
	}
}


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

int main(){
  int cnt =1;
  int a=5;
  int b;
  while(a--){
    cin>>b;
    if(b==0) {
        cout<<cnt;
        return 0;}
    
    cnt++;
    
  }
  
  
  
  
  
  
  return 0;
  
}

Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

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

const ll INF = 1e15;
const double eps = 1e-6;

int main() {
	string s;
	cin >> s;
	s = s + "T";
	vector<ll> vx;
	vector<ll> vy;
	ll f = 0;
	ll fl = 0;
	while (f < s.size() - 1) {
		ll p = f;
		while (s[p] == 'F')
			p++;
		if (fl % 2)
			vy.push_back(p - f);
		else
			vx.push_back(p-f);
		f = p+1;
		fl++;
	}
	ll mid = 8025;
	vector<ll> dpx(mid * 2);
	dpx[mid + vx[0]] = 1;
	for (ll k = 1; k < vx.size(); k++) {
		ll now = vx[k];
		vector<ll> next(mid * 2);
		for (ll from = 0; from < dpx.size();from++) {
			if (from - now >= 0)
				next[from - now] = max(next[from - now], dpx[from]);
			if(from + now < dpx.size())
				next[from + now] = max(next[from + now], dpx[from]);
		}
		dpx = next;
	}
	vector<ll> dpy(mid*2);
	dpy[mid] = 1;
	for (auto&& now : vy) {
		vector<ll> next(mid * 2);
		for (ll from = 0; from < dpy.size();from++) {
			if (from - now >= 0)
				next[from - now] = max(next[from - now], dpy[from]);
			if (from + now < dpy.size())
				next[from + now] = max(next[from + now], dpy[from]);
		}
		dpy = next;
	}
	ll gx, gy;
	cin >> gx >> gy;
	if (dpx[mid + gx] && dpy[mid + gy])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

using namespace std;
#define ll long long
#define endl '\n'
#define PB push_back
const ll modd=1e9+7;

int main(){

int a,b;
cin>>a>>b;
int ans=0,i,j;
int pl=0;
for(i=a;i<=b;++i){
        j=i;
        while(j){
            pl*=10;pl+=j%10;j/=10;
        }
if(i==pl)ans++;
pl=0;

}
cout<<ans<<endl;


return 0;

}


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

int main() {
    int n,k;
    ll s;
    cin >> n >> k >> s;
    for(int i=0; i<k; i++){
        cout << s << " ";
    }
    s++;
    if(s > 900000000) s = 1;
    for(int i=0; i<n-k; i++){
        cout << s << " ";
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

struct Monoid {
    Monoid() {}
    using T = int;
    T operator()(const T& a, const T& b) {
        return a < b ? a : b;
    }
    T identity() {return std::numeric_limits<T>().max();}
};
class SegmentTree {
private:
    using T = Monoid::T;
    std::vector<T> seg;
    Monoid ope;
    const int size;
    const int cap;
public:
    SegmentTree() : size(0), cap(0) {}
    SegmentTree(const int &sz) : size(sz), cap(sz << 1), seg(sz << 1, ope.identity()) {}
    void update(int idx, const T &val) {
        seg[idx += size] = val;
        while (idx >>= 1) seg[idx] = ope(seg[idx << 1], seg[(idx << 1) + 1]);
    }
    T get(int left, int right) {
        T leftRes = ope.identity(), rightRes = ope.identity();
        for (left += size, right += size; left < right; left >>= 1, right >>= 1) {
            if (left & 1) leftRes = ope(leftRes, seg[left++]);
            if (right & 1) rightRes = ope(rightRes, seg[--right]);
        }
        return ope(leftRes, rightRes);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree st(n);
    while (q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) {
            cout << st.get(x, y + 1) << endl;
        } else {
            st.update(x, y);
        }
    }
}

Measured memory_bytes: 3560
use std::io::*;
use std::io;
use std::str::FromStr;


fn read(s: &mut StdinLock) -> u32 {
    s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as u32 + a * 10)
}


fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| u64::from_str(n).unwrap());
    let a = it.next().unwrap();

    let mut vec = Vec::new();

    let mut s = stdin.lock();
    let s = &mut s;
    //    let mut acc: u32 = 0;
    for _ in 0..a {
        let n = read(s);
        vec.push(n);
    }



    vec.sort();

    let vs = a as usize;

    println!("{}", vec[vs - 1] - vec[0]);
}


Measured memory_bytes: 4352
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
1 3
---+/

void main(string[] args) {
  long A, P;
  readf(" %d %d ", &A, &P);
  ((A*3+P)/2).writeln;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	for (int& x : a) {
		cin >> x;
	}
	vector<int> b(n);
	for (int& x : b) {
		cin >> x;
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int x = min(a[i], b[i]);
		a[i] -= x;
		b[i] -= x;
		ans += x;
		x = min(b[i], a[i+1]);
		a[i+1] -= x;
		b[i] -= x;
		ans += x;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
H, W = map(int, input().split())
pic = []
for i in range(H):
    pic.append(input())
print("".join(['#' for i in range(W + 2)]))
for i in range(H):
    print('#' + pic[i] + '#')
print("".join(['#' for i in range(W + 2)]))

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

struct UnionFind{
    vector<int> nxt,ct;
    UnionFind(int x){
        nxt.resize(x);
        ct.resize(x);
        for (int i = 0; i < x;i++){
            nxt[i] = i;
            ct[i] = 1;
        }
    }
    int find(int x){
        if(nxt[x]==x)
            return x;
        return nxt[x] =find(nxt[x]);
    }
    inline void unite(int x,int y){
        ct[find(x)] += ct[find(y)];
        nxt[find(y)] = find(x);
    }
    inline int cont(int x){
        return ct[find(x)];
    }
};
ll N,M;
char S[101010];
ll qq[2];
ll i, j, k;
vector<pll> hokaiv;
ll ans[101010];
int main(){
    scanf("%lld%lld", &N,&M);
    UnionFind uf(N+1);
    fornum(i,0,M){
        ll a, b;
        scanf("%lld%lld",&a,&b);
        hokaiv.push_back(mp(a, b));
    }
    
    ll an = (N-1) * N / 2;
    //printf("%lld\n", an);
    for (i = M - 1; i >= 0;i--){
        //printf("%llda", i);
        ans[i] = an;
        auto ha = hokaiv[i];
        //printf("b");
        if(uf.find(ha.first)!=uf.find(ha.second)){
            //printf("b");
            an -= uf.cont(ha.first) * uf.cont(ha.second);
            uf.unite(ha.first, ha.second);
        }
    }
    fornum(i,0,M){
        printf("%lld\n", ans[i]);
    }

    return 0;
}

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

int main() {

  int n;
  cin >> n;
  while( n-- ) {
    int score = 0, out = 0;
    int base[4] = {0};

    while(1) {      
      if( out == 3 ) {
	cout << score << endl;
	break;;
      }
      
      string event;
      cin >> event;
      if( event == "HIT" ) {
	if( base[3] ) {
	  score++;
	  base[3] = 0;
	}
	if( base[2] ) {
	  base[3] = 1;
	  base[2] = 0;
	}
	if( base[1] ) {
	  base[2] = 1;
	  base[1] = 0;
	}
	base[1] = 1;
      }
      
      else if( event == "HOMERUN" ) {
	score += base[3]+base[2]+base[1]+1;
	base[3] = base[2] = base[1] = 0;
      }
      
      else {
	out++;
      }
    }
  }
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		if (a <= c && c <= b){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 20948
#include <stdio.h>
int main(void){
  long a,b,p,q,r;
  scanf("%ld %ld",&a,&b);
  p=a;
  q=b;
  while(q!=0){
	  r=p%q;
	  p=q;
	  q=r;
  }
  printf("%ld",a*b/p);
}

Measured memory_bytes: 128
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
x_list.append(X)
y_list.append(Y)

if max(x_list) < min(y_list):
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
# 解説参照
# 安易なソート順の貪欲ではだめ
# x最小青と組める赤のうちy最大
# どうやって気づくのかは知らない

n = int(input())
#赤
p1 = [tuple(map(int, input().split( ))) for i in range(n)]
#青
p2 = [tuple(map(int, input().split( ))) for i in range(n)]
p2.sort()
#赤＜青

used = [0]*(n+1) 
ans = 0

for j in range(n):
    y = -1
    ind = -1
    for i in range(n):
        if p1[i][0]<p2[j][0] and p1[i][1]<p2[j][1] and not used[i]:
            if y<p1[i][1]:
                y = p1[i][1]
                ind = i
    if ind>=0:
        ans += 1
        used[ind] = 1
        
print(ans)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

struct Node{
  int now;
  //int sub;
  long cost;
};

struct Edge{
  int from;
  int to;
  long cost;
};

bool operator<(const Node &a, const Node &b){
  if(a.cost != b.cost){
    return a.cost < b.cost;
  }else{
    return a.now < b.now;
  }
}
bool operator>(const Node &a, const Node &b){return (b < a);}
bool operator<=(const Node &a, const Node &b){return !(b < a);}
bool operator>=(const Node &a, const Node &b){return !(a < b);}

//vector<vector<Edge>> Graph(n);
//sは始点
vector<long> Dijkstra(vector<vector<Edge>> &Graph, int s){ //最小コスト
  priority_queue<Node, vector<Node>, greater<Node>> que;
  vector<long> dist(Graph.size(), 1e16);

  dist.at(s) = 0;
  que.push(Node{s, 0});

  while(que.size()){
    Node node = que.top();
    que.pop();
    int v = node.now;
    if(node.cost > dist.at(v)) continue;
    for(Edge edge : Graph.at(v)){
      int nv = edge.to;
      long cost = edge.cost;
      if(dist.at(nv) > dist.at(v) + cost){
        dist.at(nv) = dist.at(v) + cost;
        que.push(Node{nv, dist.at(nv)});
      }
    }
  }
  return dist;
}

int main(){
  long n,m;
  cin >> n >> m;
  vector<vector<Edge>> Graph(n);
  REP(i,1,n){
    Graph.at(i).push_back(Edge{i,i-1,0});
  }
  rep(i,m){
    long l,r,c;
    cin >> l >> r >> c;
    l--;r--;
    Graph.at(l).push_back(Edge{l,r,c});
  }
  vector<long> dist = Dijkstra(Graph,0);
  if(dist.at(n-1) > 1e15) cout << -1 << endl;
  else cout << dist.at(n-1) << endl;
}

Measured memory_bytes: 10104
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

long long n;
vector<pair<long long, long long>> v;
vector<bool> ch;

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].fi >> v[i].se;
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if(n == 1) return 1;
  long long ans = n;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      if(i != j) {
        long long now = 0, nx = v[i].fi - v[j].fi,
                  ny = v[i].se - v[j].se;
        if(nx == ny && nx == 0) continue;
        ch.assign(n, 0);
        for(int k = 0; k < n; ++k)
          if(!ch[k]) {
            pair<long long, long long> np = v[k];
            ++now;
            ch[k] = 1;
            while(1) {
              bool wch = 0;
              np.fi += nx;
              np.se += ny;
              for(int l = 0; l < n; ++l)
                if(np == v[l]) {
                  ch[l] = 1;
                  wch = 1;
                  break;
                }
              if(!wch) break;
            }
          }
        ans = min(ans, now);
      }
  return ans;
}

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

stlist=[]
for _ in range(N):
  s,t=input().split()
  stlist.append((s,t))
#print(stlist)

X=input()

answer=0
flg=False
for s,t in stlist:
  if s==X:
    flg=True
  else:
    if flg:
      answer+=int(t)
      
print(answer)

Measured memory_bytes: 9084
S = input()
flag = True

if (S[0] != 'A'): 
  flag = False
if (S[2:-1].count('C') != 1):
  flag = False
if (S.lower() != S.replace('A','a').replace('C','c')):
  flag = False
  
if flag:
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
using namespace std;
 
int main()
{
  int A, B, K, i;
  cin >> K >> A >> B;

  if( K > A && K > B)
    cout << "NG";
  
  else if ( (A%K == 0) || (B%K == 0) || (K >= A && K <= B) || (K <= abs(A - B)) || (A%K > B%K))
  {
    cout << "OK";
  }
  
  else
    cout << "NG";
  
  return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 2000;
int vals[N];

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

	int n; ll k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> vals[i];

	ll res = 0;
	for (int a = 0; a < n; ++a) {
		for (int b = a+1; b < n; ++b) {
			if (vals[a] < vals[b]) {
				res = (res + k * (k-1) / 2) % MOD;
			} else if (vals[a] > vals[b]) {
				res = (res + k * (k+1) / 2) % MOD;
			}
		}
	}
	cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a=0, b=0, c;
  for(int i = 0; i < 3; i++) {
    cin >> c;
    if(c == 7) a++;
    if(c == 5) b++;
  }
  
  if(a == 1 && b == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;++i) cin >> a[i];
  vector<int> s=a;//コピーした配列を用意
  sort(s.rbegin(),s.rend());//降順でソートしたいときはrをつける。beginとendはイテレータと呼ばれるもの。
  for (int i=0;i<n;++i){
    int ans = s[0];
    if (s[0]==a[i]) ans=s[1];
    cout << ans << endl;
  }
}


Measured memory_bytes: 3200
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    if(N == M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main() {
    int n, i, x[100], y[100];
    double l=0, m=0, D1=0, D2=0, D3=0, D4=0;
    scanf("%d", &n);
    for (i = 0;i < n;i++) {
        scanf("%d", &x[i]);
    }
    for (i = 0;i < n;i++) {
        scanf("%d", &y[i]);
    }
    D4 = abs(x[0] - y[0]);
    for (i = 0;i < n;i++) {
        D1 += abs(x[i] - y[i]);
        l += (x[i] - y[i])*(x[i] - y[i]);
        D2 = sqrt(l);
        m += abs(x[i] - y[i])*abs(x[i] - y[i])*abs(x[i] - y[i]);
        D3 = cbrt(m);
        if (abs(x[i] - y[i]) > D4) {
            D4 = abs(x[i] - y[i]);
        }
    }
    printf("%lf\n", D1);
    printf("%lf\n", D2);
    printf("%lf\n", D3);
    printf("%lf\n", D4);
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int;
using namespace std; 

int main()
{
	cpp_int a; double b;
	cin >> a >> b;
	b = ((b)*(1000.0000000000000000));
	cpp_int bb = (cpp_int)b;
	cpp_int aa = a;
	cpp_int aans = (aa*bb);
	cpp_int t = aans/1000;
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 3868
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);

    ll n;
    cin >> n;

    vll b(n, 0);

    for1(i, n){
        ll a;
        cin >> a;
        --a;
        ++b[a];
    }

    for0(i, n){
        cout << b[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 4784