akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
ls = list(map(int,input().split()))
l,p = 0,0
for i in range(n):
    if l < k:
        p += (1+ls[i])/2
        l += 1
        continue
    if i == k:
        now = p
    now = now-((1+ls[i-k])/2)+((1+ls[i])/2)
    p = max(p,now)
print(p) 

Measured memory_bytes: 71792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int X,A,B;
	scanf("%d%d%d", &X , &A, &B);
	if (B <= A)printf("delicious");
	else if (B <= X + A)printf("safe");
	else printf("dangerous");






}

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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, M) {
    cin >> A.at(i);
  }
  int ans;
  ans = N;
  rep(i, M) {
    N -= A.at(i);
  }
  if(N < 0) {
    cout << -1 << endl;
  } else {
    cout << N << endl;
  }
}

Measured memory_bytes: 7220
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll r;
  cin >> r;
  cout <<(r<1200?"ABC":r<2800?"ARC":"AGC") << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3648
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//
# include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;

using namespace std;
using ll = long long;


bool ok(string s) {
    if (s[0] != 'A') return false;
    if (count(s.begin() + 2, s.end() - 1, 'C') != 1) return false;
    for (char c : s) {
        if (c != 'A' && c != 'C' && isupper(c)) return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    cout << (ok(s) ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
def main():
	k = int(input())
	a = list(map(int,input().split()))
	
	minans = []
	minlist = []
	for i in range(100):
		for s in range(k):
			minans.append((a[s] - i)**2)
		minlist.append(int(sum(minans)))
		minans = []
	print(min(minlist))
		
	
	
 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38640
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main(void) {
    int n, a;
    std::scanf("%d %d", &n, &a);
    if (n % 500 <= a) {
        std::puts("Yes");
    }
    else {
        std::puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,val=1;
    scanf("%d %d",&a,&b);
    while((a)--){
        if(val+val>val+b)
            val+= b;
        else
            val*=2;
    }
    printf("%d\n",val);
    return 0;    
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	int a,b,k,i;
	scanf("%d%d%d",&a,&b,&k);
	i=0;
	while(a+i<b && i<k){
		printf("%d\n",a+i);
		i++;
	}
	while(a+i<b-k+1){
		i++;
	}
	while(a+i<=b){
		printf("%d\n",a+i);
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, Y) = get!(i64, i64);

    // x, yについて全探索により解を求める
    let (x, y, z) = match (0..(N + 1))
        .flat_map(move |x| (0..(N - x + 1)).map(move |y| (x, y)))
        .find(|&(x, y)| 10000 * x + 5000 * y + 1000 * (N - x - y) == Y) {
            Some((x, y)) => (x, y, N - x - y),
            _ => (-1, -1, -1)
    };

    println!("{} {} {}", x, y, z);
}


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

#define ll                     long long
#define loop( i,a)             for(i=0;i<a;i++)
#define loop1(i,a)             for(i=1;i<=a;i++)
#define ppp(a)                 cout<<a<<endl;
#define sscd(a)                scanf("%lf",&a)
#define sss(a)                 cin>>a
#define scc(a)                 scanf("%c",&a)
#define FOR(i,a,b)             for(i=a;i<b;i++)
#define FORE(i,a,b)            for(i=a;i<=b;i++)
#define reverses(s)            reverse(s.begin(),s.end())
#define inf                    9000000000000000
#define pii                    3.1415926536
#define pb(a)                  push_back(a)
#define pppp(a,b)              cout<<a<<"  "<<b;
#define newline                printf("\n");
#define sorted(a)               sort(a.begin(),a.end())


int main()
{
    ll n,y,m,r10k=0,r5k=0,r1k=0,nn,r;
    cin>>n>>y;
    m=y;
    r10k=m/10000;
    m=m%10000;
    r5k=m/5000;
    m=m%5000;
    r1k=m/1000;
    m=m%1000;
    if(m>0)
    {
        ppp("-1 -1 -1")
        return 0;
    }
    if(n<(r10k+r5k+r1k))
    {
        ppp("-1 -1 -1")
        return 0;
    }
    if(n==(r10k+r5k+r1k))
    {
        printf("%lld %lld %lld\n",r10k,r5k,r1k);
        return 0;
    }
    nn=y/1000;
    for(ll i=0;i<=20000;i++)
    {
        for(ll j=0;j<=10000;j++ )
        {
            if(i+j*5>nn)
                continue;
            if((nn-(i+5*j))%10==0)
            {
                if((i+j+(nn-(i+5*j))/10)==n)
                {
                    printf("%lld %lld %lld\n",(nn-(i+5*j))/10,j,i);
                    return 0;
                }
            }
        }
    }
        ppp("-1 -1 -1")
    return 0;
}


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

int main(){
  long long N,P,j;
  cin >> N >> P;
  long long Q=P;
  long long A=1;
  if(N==1){cout << P << endl;}
  else if(N>=40){cout << 1 << endl;}
  else if(N==2){
    for(long long i=1000000;i>=2;i--){
      if(P%(i*i)==0){cout << i << endl; return 0;}
    }
    cout << 1 << endl; 
  }
  else{
    for(long long i=10000;i>=2;i--){
      P=Q;
      for(j=0;j<N;j++){
        if(P%i==0){P=P/i;}
        else{break;}
      }
      if(j==N){cout << i << endl; return 0;}
    }
    cout << 1 << endl;
  }
}


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

#define int long long 

using namespace std;

signed main()
{
    int n, w;
    cin >> n >> w;
    vector < vector < int > > weights(n, vector<int> (2));
    vector < vector <int> > dp(n + 1, vector<int> (w + 1));
    for(int i = 0;i < n;i++)
    {
        int v1, v2;
        cin >> v1 >> v2;
        weights[i][0] = v1;
        weights[i][1] = v2;
    }
    for(int i = 0;i <= n;i++)
    {
        for(int j = 0;j <= w;j++)
        {
            if(i == 0 || j == 0)dp[i][j] = 0;
            else if(weights[i - 1][0] <= j)dp[i][j] = max(weights[i - 1][1] + dp[i - 1][j - weights[i - 1][0]], dp[i - 1][j]);
            else dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 80256
def fib(W):
    a, b = 1, 1
    n = [a, b]
    while W > len(n):
        a, b = b, b + a
        n.append(b)
    return n
H, W, K = map(int, input().split())
f = fib(W)
r = [1] + [0] * (W - 1)
for i in range(H):
    tmp = [0] * W
    for j in range(W):
        if j == 0:
            tmp[j] = r[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] if W != 1 else 1
        elif j == W - 1:
            tmp[j] = r[j] * f[j] + r[j - 1] * f[j - 1]
        else:
            tmp[j] = r[j] * f[j] * f[W - j - 1] + r[j + 1] * f[W - j - 2] * f[j] + r[j - 1] * f[W - j - 1] * f[j - 1]
    r = tmp
print(r[K - 1] % 1000000007)

Measured memory_bytes: 3064
import java.util.*;
import java.util.stream.*;
import java.io.*;

class UnionFind {
  private int[] parent;
  private int[] rank;

  public int find(int i){
    int p = parent[i];
    if(i == p) return i;

    return parent[i] = find(p);
  }

  public void union(int i, int j){
    int root1 = find(i);
    int root2 = find(j);
    if(root1 == root2) return;

    if(rank[root1] > rank[root2]) parent[root2] = root1;
    else if(rank[root1] < rank[root2]) parent[root1] = root2;
    else parent[root2] = root1;
    rank[root1]++;
  }

  public UnionFind(int n){
    parent = new int[n];
    rank = new int[n];

    for(int i = 0; i < n; i++) parent[i] = i;
  }
}

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in1 = br.readLine().split(" ");
    int N = Integer.parseInt(in1[0]);
    int M = Integer.parseInt(in1[1]);
    
    in1 = br.readLine().split(" ");
    int[] p = Stream.of(in1).mapToInt(Integer::parseInt).toArray();
    
    for(int i = 0; i < N; i++){
      p[i]--;
    }

    int[][] xy = new int[M][2];

    for(int i = 0; i < M; i++){
      in1 = br.readLine().split(" ");
      xy[i] = Stream.of(in1).mapToInt(Integer::parseInt).toArray();
      xy[i][0]--; xy[i][1]--;
    }

    br.close();

    UnionFind uf = new UnionFind(N);

    for(int i = 0; i < M; i++){
      uf.union(p[xy[i][0]], p[xy[i][1]]);
    }

    List<List<Integer>> childList = new ArrayList<>();
    for(int i = 0; i < N; i++){
      childList.add(new ArrayList<Integer>());
    }

    for(int i = 0; i < N; i++){
      childList.get(uf.find(i)).add(i);
    }

    int[] idxArray = new int[N];
    for(int i = 0; i < N; i++){
      idxArray[p[i]] = i;
    }

    Set<Integer> idxSet = new HashSet<>();
    int ans = 0;

    for(int i = 0; i < N; i++){

      if(childList.get(i).isEmpty()) continue;
      
      idxSet.clear();
      for(int child : childList.get(i)){
        idxSet.add(idxArray[child]);
      }

      for(int child : childList.get(i)){
        if(idxSet.contains(child)){
          ans++;
        }
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 77236
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);

int main(){
  ll n;cin >> n;
  vl a(n),b(n);
  rep(i,n)cin >> a[i];rep(i,n)cin >> b[i];
  bool check=false;
  rep(i,n-1){
    if(max(a[i],b[i])!=max(a[i+1],b[i+1]))check=true;
  }
  mint ans=1;
  rep(i,n){
    if(i==0||a[i-1]<a[i]){
      if(b[i]<a[i])check=true;
      continue;
    }
    if(i==n-1||b[i+1]<b[i]){
      if(a[i]<b[i])check=true;
      continue;
    }
    if(i==0||i==n-1)continue;
    ans*=min(a[i],b[i]);
  }
  if(check)cout << 0 <<endl;
  else cout << ans <<endl;
}

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

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

  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    h-=a;
  }
  if(h<=0){
    puts("Yes");
  }
  else{
    puts("No");
  }
  
}

Measured memory_bytes: 384
from sys import stdin
s = str(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに
if s[0]==s[1]==s[2]:
    print("No")
else:
    print("Yes")


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

vector<int> p;
int n, a[50], sum;

/* sum : i<k テつづδ愿つづδつづδ径[i] テつづδ古つ組テつづδ敕つ催つつづδュテつづつケテつづδ古つ和 */
void cmb( int k, int sum ){
  if( k==n ){
    p.push_back( sum );
    return;
  }

  cmb( k+1,sum+a[k] );
  cmb( k+1,sum      );
}


int main(){
  int b,c,d;
  while( cin>>n && n ){
    sum=0;
    for( int i=0;i<n;i++ ){
      cin >> a[i];
      sum += a[i] ;
    }

    p.clear();
    cmb( 0,0 );
    sort( p.begin(),p.end() );

    int min=sum;
    for( unsigned int i=0;i<p.size();i++ ){
      b=p[i];
      c=sum-p[i];
      d=abs( b-c );
      if( d<min )min=d;
    }
    cout << min << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#encoding:utf-8 No.0513 2014.11.17
cards = (1..gets.chomp.to_i*2).to_a

gets.chomp.to_i.times do
  n = gets.chomp.to_i
  if n == 0 #リフルシャッフル
    stack1,stack2 = cards.each_slice(cards.length/2).to_a
    cards = []
    #cardsの初期化を行わないと二重に書き込まれてしまう。初期化のタイミングにも注意
    stack1.zip(stack2) do |a,b|
      cards << a << b
    end
  else #nの値に応じてカット
    cards = cards.each_slice(n).to_a
    cards << cards.delete_at(0)
    cards.flatten!
  end
end

puts cards

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N; cin >> N;
  string s, S;
  set<string> substrs;

  rep(i, N) {
    cin >> s;
    S += "|" + s;
  }

  REP(i, 1, 5) {
    for (int j = 0; j < S.size(); j++) {
      string s = S.substr(j, i);
      if (s.find("|") != string::npos)
        continue;
      substrs.insert(s);
    }
  }

  string t;
  rep(i, 27) rep(j, 27) rep(k, 27) rep(l, 26) {
    t = "";
    if (i) t += 'a' + i - 1;
    if (j) t += 'a' + j - 1;
    if (k) t += 'a' + k - 1;
    t += 'a' + l;
    if (!substrs.count(t)) {
      cout << t << endl;
      return 0;
    }
  }
  return 0; 
}

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

const int MAXN = 3002;

double dp[MAXN][MAXN],P[MAXN];
int vis[MAXN][MAXN],N;

double solve(int pos,int heads){
	
	if(heads < 0) return 0.0;

	if(pos == 0){
		return (heads == 0);
	}

	if(vis[pos][heads]) return dp[pos][heads];
	vis[pos][heads] = 1;

	return dp[pos][heads] =  (P[pos])*solve(pos-1,heads-1) + (1.0 - P[pos])*solve(pos-1,heads);

}

int main(){

	cin >> N;
	for(int i = 1;i<=N;i++){
		cin >> P[i];
	}

	double tot = 0;
	for(int heads = 0;heads<=N;heads++){
		int tails = N - heads;
		if(heads > tails) tot += solve(N,heads);
	}

	printf("%.9lf\n",tot);

	return 0;

}

Measured memory_bytes: 105600
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll low=1,high = 1000000000;
	while(low<high){
		ll mid = low + (high-low)/2;
		ll cnt=0;
		for(ll i=0;i<n;i++){
			cnt += a[i]/mid;
			if(a[i]%mid==0) cnt--;
		}
		if(cnt<=k) high=mid;
		else low = mid+1;
	}
	cout<<low;
	
	
	return 0;
}

Measured memory_bytes: 5076
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n, x = imap()
A = iarr()
ans = 0
for i in range(1, len(A)):
    tmp = A[i] + A[i-1]
    if tmp > x:
        A[i] -= tmp - x
        ans += tmp - x
    A[i] = max(0, A[i])
print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i=1;i<=N;i++)
    cin >> v.at(i-1);
  map<int,int> m;
  for (int i=1;i<=N;i++)
    m[ v.at(i-1) ]=i;
  for (int i=1;i<=N;i++){
    if (i==N)
      cout << m[i] << endl;
    else
      cout << m[i] << " ";
  }
}


Measured memory_bytes: 5888
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

typedef long long ll;

ll N;

int main() {
  std::cin >> N;
  std::vector<ll> L(N);
  for (int i = 0; i < N; ++i)
    std::cin >> L[i];

  int ans = 0;
  for (int i = 0; i < L.size(); ++i) {
    for (int j = i+1; j < L.size(); ++j) {
      if (L[i] == L[j]) continue;
      for (int k = j+1; k < L.size(); ++k) {
        if (L[i] == L[k] or L[j] == L[k]) continue;
        std::vector<ll> v = {L[i], L[j], L[k]};
        std::sort(v.begin(), v.end());
        if (v[0] + v[1] > v[2])
          ans++;
      }
    }
  }

  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  string s;
  cin>>s;
  ll cnt=0;
  ll cnt1=0;
  rep(i,s.size()){
    if(i%2&&s[i]=='0'){
      cnt++;
    }else if((i%2)==0&&s[i]=='1'){
      cnt++;
    }
  }
  rep(i,s.size()){
    if(i%2&&s[i]=='1'){
      cnt1++;
    }else if((i%2)==0&&s[i]=='0'){
      cnt1++;
    }
  }
  op(min(cnt,cnt1));
  return 0;
}

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

int main(){
  
  
  string s;
  cin>>s;
  
  if(s[0]==s[1]  &&  s[2]==s[3] &&  s[0]!=s[2]) cout<<"Yes";
  else if(s[0]==s[2]  &&  s[1]==s[3]  &&  s[0]!=s[1]) cout<<"Yes";
  else if(s[0]==s[3]  &&  s[1]==s[2] &&  s[0]!=s[1]) cout<<"Yes";
  else cout<<"No";
  
  
  return 0;
}


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

int main()
{
  int res=1;
  int N;
  cin >> N;
  vector<int> mountain(N);

  for (int i = 0; N > i; ++i) cin >> mountain[i];

  for (int current_number = 1;N>current_number; ++current_number) {
    int i = 0;
    // i番目の山が見れるのか．
    while (true) {
      if (i == current_number) {
        ++res;
        break;
      }
      if (mountain[i] > mountain[current_number]) break;
      ++i;
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x;}
    if(n%2==0){
        return power((x*x)%M,n/2);
    }
    if(n%2==1){
        return (power((x*x)%M,n/2)*x)%M;
    }
}

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

    string aa,bb;
    cin>>aa>>bb;
    string a="",b="";
    for(ll i=0;i<bb[0]-'0';++i){a+=aa;}
    for(ll i=0;i<aa[0]-'0';++i){b+=bb;}
    if(a<b){cout<<a;}
    else{cout<<b;}

    return (0);
}


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

using namespace std;
int main(){
    unsigned long int n;
    cin >> n;
    unsigned long int ans = 0;
    if(n > 2){
      ans = (n-1)*n/2;
      cout << ans;
    }else if(n == 2 ){
        cout << 1;
    }else {
        cout << 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 100010
vector<int> g[maxn];
int col[maxn];
ll num[3];
ll n,m;
bool dfs(int u,int c)
{
    col[u]=c;
    num[c]++;
    for(int v : g[u])
    {
        if(!col[v])
        {
            if(!dfs(v,3-c))return 0;
        }
        else if(col[u]==col[v])return 0;
    }
    return 1;
}
main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=0;i<m;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        g[x].push_back(y),g[y].push_back(x);
    }
    ll ans;
    if(dfs(1,1))ans=(ll)(num[1]*num[2]-m);
    else ans=(ll)(n*(n-1)/2-m);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#define MAX 100
#define INF 10000

int n, a[MAX][MAX];
int prim();

int main(){
  int i, j;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&a[i][j]);
    }
  }
  printf("%d\n",prim());
  
  return 0;
}

int prim(){
  int i, j, u, v, d[MAX], pi[MAX], color[MAX], min, sum = 0;
  for(u = 0; u < n; u++){
    d[u] = INF;
    pi[u] = -1;
    color[u] = 0;
  }
  d[0] = 0;
  
  while(1){
    min = INF;
    for(i = 0; i < n; i++){
      if(color[i] != 2 && min > d[i]){
	u = i;
	min = d[i];
      }
    }
    
    if(min == INF) break;

    color[u] = 2;
    
    for(v = 0; v < n; v++){
      if(color[v] != 2 && a[u][v] < d[v] && a[u][v] != -1){
	pi[v] = u;
	d[v] = a[u][v];
      }
    }
  }

  for(i = 0; i < n; i++){
    if(pi[i] != -1) sum += a[i][pi[i]];
  }

  return sum;
}

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

ll f(ll n) {return n%2 ? (n+1)/2%2: n/2%2^n;}

int main() {
  ll a,b;
  cin>>a>>b;
  cout<<(f(a-1)^f(b))<<endl;
}

Measured memory_bytes: 3600
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
ab = [inpl() for _ in range(n)]
cd = [inpl() for _ in range(n)]
ab.sort(key = lambda x:x[1],reverse = True)
cd.sort()
seen = [False] * n
for j in range(n):
    c,d = cd[j]
    for i,(a,b) in enumerate(ab):
        if seen[i]: continue
        if a < c and b < d:
            seen[i] = True
            break
print(sum(seen))

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

int main() {
  int N, M;
  cin >> N >> M;
  set<pair<int, int>> SE;
  for (int a, b; cin >> a >> b;) {
    SE.insert({--a, --b});
    SE.insert({b, a});
  }
  vector<int> P(N);
  for (int i = 0; i < N; i++) P.at(i) = i;
  int ans = 0;
  do {
    if (P.at(0) != 0) continue;
    bool b = 1;
    for (int i = 0; i + 1 < N; i++) {
      if (!SE.count({P.at(i), P.at(i + 1)})) b = 0;
    }
    if (b) ans++;
  } while (next_permutation(P.begin(), P.end()));
  cout << ans << "\n";
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
	char std[3][3];
	for (int a = 0; a < 3; a++) {
		for (int b = 0; b < 3; b++) {
			cin >> std[a][b];
		}
	}
	cout << std[0][0] << std[1][1] << std[2][2] << endl;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int A,B,C,D; cin >> A >> B >> C >> D;
    for(int i = 0; i < 1000; ++i) {
        if(i%2==0) {
            C -= B;
            corner(C<=0,"Yes");
        }
        else{
            A -= D;
            corner(A<=0,"No");
        }
    }

    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(){
    int a;
    int b;
    int c;
    int d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int r = 0;
    if((a == 1) || (b == 1) || (c == 1) || (d == 1)){
        r += 1;
    }
    if((a == 9) || (b == 9) || (c == 9) || (d == 9)){
        r += 1;
    }
    if((a == 7) || (b == 7) || (c == 7) || (d == 7)){
        r += 1;
    }
    if((a == 4) || (b == 4) || (c == 4) || (d == 4)){
        r += 1;
    }
    if (r == 4)
    printf("%s\n", "YES");
    else
    printf("%s\n", "NO");
    return 0;
}


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define scan(n)         scanf("%d",&n)
#define pb              push_back
#define vi              vector<int>
#define ii              pair<int,int>

using namespace std;

int main(){
    ll x;
	cin>>x;

	ll a[200];
	for(int i=0;i<=150;i++)
	{
		a[i]=pow(i,5);
	}
	ll f=0;
	for(ll i=0;i<=150;i++)
	{
		for(ll j=0;j<=150;j++)
		{
			if(a[i]-a[j]==x)
			{
				cout<<i<<" "<<j;
				f=1;
				break;
			}
			if(a[i]+a[j]==x)
			{
				j=-j;
				cout<<i<<" "<<j;
				f=1;
				break;
			}
		}
		if(f==1)
		break;
	}
}


Measured memory_bytes: 4028
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int H,W;cin >> H >> W;
    int K;cin >> K;
    string ans = "No";
    int nowblack = 0;
    for(int i = 0;i<=H;i++){
        for(int j = 0;j<=W;j++){
            int tate = j*H;
            int yoko = i*(W-j)-i*j;
            nowblack = tate+yoko;
            if(nowblack == K) ans = "Yes";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int a;
    cin >> a;
    int t = a % 10 ;
    if(t == 3) cout<< "bon"<<endl;
    else if(t == 0 || t == 1 || t == 6 || t == 8) cout<< "pon"<<endl;
    else cout<<"hon"<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
void low(char &c){
c=tolower(c);
}
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
        cout << n << " ";
}
#include <iostream>
using namespace std;
void fast();
map<int,int> M;
map<string,ll> M1;
vector<int> pos;
vector<int> nig;

int main() {
fast();
int q,l,r;
cin >>q;
int n=0;
for(int i=1;i<100000;i++){
    if(is_prime(i) &&is_prime((i+1)/2)){
        n++;
    }
    M[i]=n;
}
while(q--){
    cin >> l >> r;
    cout << M[r]-M[l-1] <<endl;

}
}


void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<bool> issafe(N+1, true);
  for (ll i=0; i<M; i++) {
    ll num;
    cin >> num;
    issafe[num] = false;
  }
  vector<ll> dp(N+1, 0);
  dp[0] = 1;
  if (issafe[1]) dp[1] = 1;
  for (ll i=2; i<=N; i++) {
    if (issafe[i-1]) dp[i] += dp[i-1];
    if (issafe[i-2]) dp[i] += dp[i-2];
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    for (int x : v) {
        ans = (ans+x)/2.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

raw_input()

for line in sys.stdin.readlines():
    a, b, c = map(int, line.strip().split())
    input_list = [a, b, c]
    input_list.sort()
    if input_list[2] ** 2 ==  input_list[0] ** 2 + input_list[1] ** 2:
    	print 'YES'
    else:
    	print 'NO'

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  r(i,n)cin>>x.at(i);
  int sum=0;
  r(i,n){
    if(x.at(i)>=k)sum+=(x.at(i)-k)*2;
    else if(x.at(i)<=k-x.at(i))sum+=x.at(i)*2;
    else sum+=(k-x.at(i))*2;
  }
  cout<<sum<<endl;






return 0;}


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

int main() {
	string S;
	cin >> S;
	if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private void solve(Scanner sc, PrintWriter out) {
    int N = sc.nextInt();
    out.println((N * (N + 1)) / 2);
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

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

int main(){
  vector<int> a(3);
  for (int i=0;i<3;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  string s;
  s= a[2]==a[1]+a[0] ? "Yes" : "No";
  cout << s << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        int n = Integer.parseInt(sc.next());
        pw.println(n%2 == 0 ? n/2 : (n+1)/2);
        
        pw.flush();
    }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        int money = int.Parse(Console.ReadLine());
        int count = 0;

        while (money > 1000 * count)
        {
            count++;
        }

        Console.WriteLine((1000 * count) - money);

    }

}

Measured memory_bytes: 27252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int N;
ll L, T;
vector<ll> X;
vector<int> W;

int main(){
    cin >> N >> L >> T;
    X.resize(N);  W.resize(N);
    rep(i,N) cin >> X[i] >> W[i];
//-------------------------------------------
    vector<ll> tmp(N);
    rep(i,N){
        if(W[i]==1) tmp[i] = (X[i]+T)%L;
        else tmp[i] = (X[i]-T)%L;//tmp[i] = ((X[i]-T)%L+L)%L; 
    }

    int cnt = 0;
    rep(i,N){
        if(W[i]==1) cnt += (X[i]+T)/L;
        else{
            //if(T > X[i])
              //  cnt -= 1+(T-X[i])/L;
            cnt += (X[i]-T)/L;
            if(tmp[i]<0) tmp[i]+=L, cnt--;
        }
    }
    int flag = (cnt%N+N)%N;
    sort(tmp.begin(), tmp.end());
//-------------------------------------------
    for(int i = flag; i < N; i++) cout << tmp[i] << endl;
    for(int i = 0; i < flag; i++) cout << tmp[i] << endl;
}

Measured memory_bytes: 3200
#include<stdio.h>
int main()
{
  int X,A,B,dif;
  scanf("%d",&X);
  scanf("%d",&A);
  scanf("%d",&B);
  dif=X;
  dif-=A;
  while(dif>=0){
  	dif-=B;
  }
  dif+=B;
  
  printf("%d",dif);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> parts(3, std::vector<int>(n));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < n; j++) std::cin >> parts[i][j];
        std::sort(parts[i].begin(), parts[i].end());
    }

    long long cnt = 0;
    for(int i = 0; i < n; i++){
        // まず真ん中の段を決める
        int b = parts[1][i];
        auto a_iter = std::lower_bound(parts[0].begin(), parts[0].end(), b);
        auto c_iter = std::upper_bound(parts[2].begin(), parts[2].end(), b);
        cnt += std::distance(parts[0].begin(), a_iter) * std::distance(c_iter, parts[2].end());
    }

    std::cout << cnt << std::endl;
    
    return 0;
}


Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    c = collections.Counter(S())
    for k in string.ascii_lowercase:
        if c[k] == 0:
            return k
    return 'None'

print(main())



Measured memory_bytes: 6864
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int N; cin >> N;
    int x[N], y[N], h[N];    
    rep(i, N){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0){
            swap(x[0], x[i]);
            swap(y[0], y[i]);
            swap(h[0], h[i]);
        }
    }

    bool checker;
    rep(cx, 101){
        rep(cy, 101){
            int ch = h[0] + abs(x[0] - cx) + abs(y[0] - cy);
            checker = true;
            rep(i, N){
                if( max( ch - abs( x[i] - cx ) - abs( y[i] - cy ), 0) != h[i]){
                    checker = false;
                }
            }
            if(checker){
                cout << cx << " "<< cy << " " << ch << endl;
                return 0;
            }
        }
    }



    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    vector<vector<ll>> f(n,vector<ll>(10)),p(n,vector<ll>(11));
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
                cin>>f[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=10;j++) cin>>p[i][j];
    }
    ll res=-1e9;
    for(int st=1;st<(1<<10);st++){
        ll tmp=0;
        for(int i=0;i<n;i++){
            int cnt=0;
            for(int j=0;j<10;j++){
                if(f[i][j]==0) continue;
                if(st & (1<<j)) cnt++;
            }
            tmp += p[i][cnt];
        }
        res=max(res,tmp);
    }
    cout<<res<<endl;
}


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

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var r = Enumerable.Range(1, 1009).FirstOrDefault(x => x * 8 / 100 == h[0] && x / 10 == h[1]);
		Console.WriteLine(r > 0 ? r : -1);
	}
}


Measured memory_bytes: 28244
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


template<class T> struct ConvexHullTrick {
  struct Line { T a, b; };
  ConvexHullTrick(bool f = false) : monotone(f) {}
  void add(T a, T b) {
    if (l.empty() or a < l[0].a) {
      while (l.size() >= 2 and !is_need({a, b}, l[0], l[1])) {
        l.pop_front();
      }
      l.emplace_front((Line) {a, b});
    } else if (a > l.back().a) {
      while (l.size() >= 2 and !is_need(l[l.size() - 2], l.back(), {a, b})) {
        l.pop_back();
      }
      l.emplace_back((Line) {a, b});
    } else assert(false);
  }
  T max(T x) {
    if (monotone) {
      while (l.size() >= 2 and l[0].a * x + l[0].b <= l[1].a * x + l[1].b) {
        l.pop_front();
      }
      return l[0].a * x + l[0].b;
    }
    int ok = 0, ng = l.size();
    while (ng - ok > 1) {
      int m = ok + ng >> 1;
      (l[m - 1].a * x + l[m - 1].b <= l[m].a * x + l[m].b ? ok : ng) = m;
    }
    return l[ok].a * x + l[ok].b;
  }
private:
  deque<Line> l;
  bool monotone;
  bool is_need(const Line& l, const Line& m, const Line& r) {
    return m.b * (r.a - l.a) > l.b * (r.a - m.a) + r.b * (m.a - l.a);
  }
};

using CHT = ConvexHullTrick<lint>;

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  lint c; cin >> c;
  V<lint> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  CHT cht(true);
  V<lint> dp(n, 1e18);
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i] = 0;
    } else {
      dp[i] = -cht.max(h[i]) + h[i] * h[i] + c;
    }
    cht.add(2 * h[i], -(dp[i] + h[i] * h[i]));
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k) cout << s << endl;
    else {
        string t = s.substr(0, k);
        t += "...";
        cout << t << endl; 
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double z=abs(h+m/60-m/5);
  double ans=sqrt(a*a+b*b-2*a*b*(double)cos(z*PI/6));
  cout << fixed << setprecision(30);
  cout << ans << endl;
}

Measured memory_bytes: 4216