akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    if(a+b>c+d){
        p("Left");
    }
    else if(a+b<c+d){
        p("Right");
    }
    else{
        p("Balanced");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, K, ans = 1000000007;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(ALL(A));
    for (int i = 0; i + K - 1< N; i++) {
        ans = min (A.at(i + K - 1) - A.at(i), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = 1;
        int W = 1;

        while(true) {
            H = sc.nextInt();
            W = sc.nextInt();
            if(H == 0 && W == 0) break;

            for (int i = 0; i < H; i++){
                for (int j = 0; j < W; j++) {
                    System.out.printf("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 61168
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> nest(n), mn(n, 0);
  int l = 0, r = 0;
  REP(i, n) {
    string s; cin >> s;
    int now = 0;
    for (char c : s) {
      now += c == '(' ? 1 : -1;
      (c == '(' ? l : r) += 1;
      chmin(mn[i], now);
    }
    nest[i] = now;
  }
  if (l != r) {
    cout << "No\n";
    return 0;
  }
  vector<int> idx(n);
  iota(ALL(idx), 0);
  sort(ALL(idx), [&](int a, int b) { return mn[a] > mn[b]; });
  int pos = 0, depth = 0;
  priority_queue<pair<int, int>> que;
  vector<int> minus;
  REP(_, n) {
    // cout << depth << '\n';
    while (pos < n && -mn[idx[pos]] <= depth) {
      if (nest[idx[pos]] >= 0) {
        que.emplace(nest[idx[pos]], idx[pos]);
      } else {
        minus.emplace_back(idx[pos]);
      }
      ++pos;
    }
    if (que.empty() && minus.empty()) {
      cout << "No\n";
      return 0;
    }
    if (!que.empty()) {
      int id = que.top().second;
      que.pop();
      depth += nest[id];
    } else {
      if (_ + minus.size() < n) {
        cout << "No\n";
        return 0;
      }
      sort(ALL(minus), [&](int a, int b) { return mn[a] - nest[a] < mn[b] - nest[b]; });
      for (int id : minus) {
        if (depth + mn[id] < 0) {
          cout << "No\n";
          return 0;
        }
        depth += nest[id];
      }
      break;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 22788
macro_rules! input {
    // ?
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };

    // stdinの生成 値の読み込み開始
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    // ?
    ($next:expr) => {};
    // ?
    ($next:expr, ) => {};

    // 変数名:型の読み込みの繰り返し
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    // 値を読み込むベース 型,の繰り返し
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    // 配列の読み込み
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    // 文字列Vec<char>の読み込み
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    // usize1?の読み込み
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // 指定した型で読み込み
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! tests {
    ($($test_name:ident:$name:ident($( $args:expr ),*) => $expected:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $test_name() {
                    assert_eq!($expected,super::$name($($args),*));
                }
            )*
        }
    }
}

fn main() {
    input! {
        chars: chars,
    };

    println!("{}", solve(chars));
}

fn solve(chars: Vec<char>) -> i64{
    let mut ans: i64 = 0;
    for c in chars {
        match c {
            '+' => ans += 1,
            _ => ans -= 1,
        }
    }
    return ans;
}




tests! {
    //テスト名:[引数]=>expected
    test1:solve("+-++".chars().collect())=>2,
    test2:solve("-+--".chars().collect())=>-2,
    test3:solve("----".chars().collect())=>-4,
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cout << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MAX_H = 300;
const int MAX_W = 300;


int c[10][10];
int A[MAX_H][MAX_W];
int mincost[10];

void dfs(int i, int g, int *visited, int cost)
{
    if(mincost[i] > cost && g == 1)
    {
        mincost[i] = cost;
    }

    bool all_visited =true;
    //dump("visited")
    for(int t = 0; t <= 9; t++)
    {
        if(visited[t] == 0) all_visited = false;

    }
    if(all_visited) return;

    for(int j = 0; j < 10; j++)
    {
        if(visited[j] == 0)
        {
            cost += c[g][j];
            visited[j] = 1;
            dfs(i, j, visited, cost);
            cost -= c[g][j];
            visited[j] = 0;
        }
    }

    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int H,W; cin >> H >> W;
    REP(i,10)
    {
        if(i == 1) mincost[i] = INF;
        else mincost[i] = INF;

        REP(j,10)
        {
            cin >> c[i][j];
        }
    }
    REP(i,H)
    {
        REP(j,W)
        {
            cin >> A[i][j];
        }
    }

    REP(i,10)
    {
        int visited[10] = {0};  
        visited[i] = 1;
        dfs(i,i,visited,0);
    }

    LL ans = 0;

    REP(i,H)
    {
        REP(j,W)
        {
            if(A[i][j] != -1) ans += mincost[A[i][j]];
        }
    }

    REP(i,10)
    {
        dump(mincost[i])
    }

    cout << ans << endl;





}


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

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

typedef long long ll;



int main(){
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  REP(i, N){
    cin >> V[i];
  }
  
  int sum = 0, msum = -1;
  vector<int> mi;
  for(int i = 0; (i<K+1)&&(i<N+1); ++i){
    for(int j=0; (j+i< K+1) && (i+j < N+1); j++){
      sum = 0;
      REP(k, i){
        sum+= V[k];
        if(V[k] < 0){
          mi.push_back(V[k]);
        }
      }
      REP(k, j){
        sum+= V[N-1-k];
        if(V[N-1-k] < 0){
          mi.push_back(V[N-1-k]);
        }
      }
      sort(mi.begin(), mi.end());
      for(int k = 0; (k+i+j < K) && (k < mi.size()); ++k){
        sum -= mi[k];
      }
      msum = max(sum, msum);
      mi.clear();
    }
  }
  cout << msum << endl;
  return 0;
}

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll A, B;
    cin >> A >> B ;
    cout << (1900 * B + 100 * (A - B)) * pow(2 , B) << endl;
    
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int i;
  cin>>i;
  int p,s;
  p=i/100;
  s=i%100;
  if(p==0){
    p=13;}
  if(s==0){
    s=13;}
  if(p>12&&s>12){
    cout<<"NA"<<endl;}
  else if(p<=12&&s<=12){
    cout<<"AMBIGUOUS"<<endl;}
  else if(p>12&&s<=12){
    cout<<"YYMM"<<endl;}
  else {
    cout<<"MMYY"<<endl;}
  return 0;
}


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

int main(){
  int n, t;
  cin >> n >> t;
  vector<int>dis(n);
  for(int i=0; i<n; ++i){
    cin >> dis[i];
  }
  
  int sum=0;
  for(int i=0; i<n-1; ++i){
    sum += min(t, dis[i+1]-dis[i]);
    
  }
  sum += t;
  
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    vector<vector<int>> field(3,vector<int>(3,0));
   rep(i,3){
       rep(j,3){
           cin>>field[i][j];
       }
   } 
   bool ok=true;
   int a[3],b[3];
   a[0]=0;
   rep(i,3){
       b[i]=field[0][i]-a[0];
       a[i]=field[i][0]-b[0];
   }
   rep(i,3){
       rep(j,3){
           if(field[i][j]!=a[i]+b[j])ok=false;
           }
       
   }
   if(ok)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        A[0] = 0;
        for (int i = 1; i < N+1; i++) {
            A[i] = sc.nextInt();
        }
        int Q = sc.nextInt();
        int[] B = new int[Q+1];
        int[] C = new int[Q+1];
        B[0] = 0;
        C[0] = 0;
        for (int i= 1; i < Q+1; i++) {
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }
        long[] S = new long[Q+1];
        S[0] = 0;
        for (int i = 0; i < A.length; i++) {
            S[0] = S[0] + A[i];
        }
        int[] n = new int[100000+1];
        for (int i = 0; i < n.length; i++) {
            n[i] = 0;
        }
        for (int i = 1; i < A.length; i++) {
            n[A[i]] = n[A[i]] + 1;
        }
        for (int i = 1; i < Q+1; i++) {
            S[i] = (C[i]-B[i])*n[B[i]] + S[i-1];
            System.out.println(S[i]);
            n[C[i]] = n[C[i]] + n[B[i]];
            n[B[i]] = 0;
        }
    }
}

Measured memory_bytes: 62124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long double B){
  cout<<floorf64x(A*B)<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long double B;
    scanf("%Lf",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3904
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int A, B, C;
    cin >> A >> B >> C;

    const int mx = max({A, B, C});
    const int S = A + B + C;

    int target;
    if (mx % 2 == S % 2) {
        target = mx;
    } else {
        target = mx + 1;
    }

    int acc = (target - A) + (target - B) + (target - C);
    cout << acc / 2 << endl;

    return 0;
}


Measured memory_bytes: 3596
import java.util.*;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String[] a = new String[h];
    int[][] y = new int[h][w];
    int[][] t = new int[h][w];
    for(int i=0;i<h;i++){
      a[i] = sc.next();
    }
    
    for(int i=0;i<h;i++){
      int f=a[i].indexOf('.');
      int b;
      while(f!=-1){
        b=a[i].indexOf('#',f);
        b=(b==-1?w:b);
        for(int j=f;j<b;j++){
          y[i][j]=b-f;
        }
        f=a[i].indexOf('.',b);
      }
    }
    
    for(int i=0;i<w;i++){
      t[0][i]=( a[0].charAt(i)=='.' ? 1 : 0 );
      for(int j=1;j<h;j++){
        t[j][i]=( a[j].charAt(i)=='.' ? t[j-1][i]+1 : 0 );
      }
      for(int j=h-1-1;j>=0;j--){
        t[j][i]=( y[j][i]==0 ? 0 : Math.max(t[j+1][i],t[j][i]) );
      }
    }
    
    int max=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        max=Math.max(y[i][j]+t[i][j],max);
      }
    }
    System.out.println(max-1);
  }
}

Measured memory_bytes: 84456
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <memory>
#include <memory.h>
using namespace std;
char map[110][110];
int m,n,cnp;
int way[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
void dfs(int y,int x,char ch)
{
	for(int i = 0;i<4;i++)
	{
		int dx = x+way[i][0];
		int dy = y+way[i][1];
		if(dx>=0 && dx <n&& dy>=0&& dy < m && map[dy][dx]==ch)
		{
			map[dy][dx] = '0';
			dfs(dy,dx,ch);
		}
	}
}
int main()
{
	while(cin >> m >> n&&m+n)
	{
		memset(map,0,sizeof(map));
		cnp = 0;
		char ch;
		for(int i = 0;i<m;i++)
		{
			for(int j =0;j<n;j++)
			cin >> map[i][j];
		}
		for(int i = 0;i<m;i++)
		{
			for(int j = 0;j<n;j++)
			{
				if(map[i][j]=='@'||map[i][j]=='#'||map[i][j]=='*')
				{
					ch = map[i][j];
					cnp++;
					dfs(i,j,ch);
				}
			}
		}
		cout << cnp << endl;
	}
	return 0;
}

Measured memory_bytes: 1644
p="0123456789543210"
for i in range(input()):
	sp,ep=raw_input().split()
	(sp,ep)=(p.find(sp),p.find(ep)+1) if sp<ep else (p.rfind(sp),p.rfind(ep)+1)
	print " ".join(list(p[sp:ep])) if sp<ep else " ".join(list(p[sp:]+p[1:ep]))

Measured memory_bytes: 4220
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A = inputInt()
    B = inputInt()
    
    if A > B:
        print("GREATER")
    elif A < B:
        print("LESS")
    else:
        print("EQUAL")
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::vector<int> a(n), b(n), c(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++) scanf("%d", &b[i]);
	for(int i = 0; i < n - 1; i++) scanf("%d", &c[i]);

	auto C = make_v<int>(n, n);
	for(int i = 0; i < n - 1; i++) C[i][i + 1] = c[i];

	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += b[--a[i]];
		
		if(i < n - 1) ans += C[a[i]][a[i + 1] - 1];
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << a[k-1] << endl;

    return 0;
}

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

using namespace std;

int main() {
  string s1, s2;
  cin >> s1 >> s2;
  
  if (s1[1] != s2[1]) {
 	cout << "NO" << endl;
    return 0;
  }
  
  if (s1[0] == s2[2] and s1[2] == s2[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  
}

Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

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

    int rank[N+1];
    for(int i=1;i<N+1;i++){
        rank[A[i]] = i;
    }

    for(int i=1;i<N+1;i++){
        cout << rank[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
long long INF = (1LL<<62);

const LL C = 998244353;

LL powmod(LL base, LL k, LL mod){
	if(k == 0){ return 1; }
	if(k == 1){ return (base % mod); }

	LL q = k / 2;
	LL r = k % 2;
	LL u = powmod((base*base)%mod, q, mod);
	LL v = powmod(base, r, mod);
	return ( (u * v ) % mod );
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N; cin >> N;
	vector<LL> D;
	for(int i=0; i<N; i++){
		LL d; cin >> d;
		D.push_back(d);
	}
	if(D[0] != 0){
		printf("0\n");
		return 0;
	}
	sort(D.begin(), D.end());
	LL maxd = D[D.size()-1];
	if(D[1] == 0 || maxd > N-1){
		printf("0\n");
		return 0;
	}
	
	vector<LL> V(maxd + 1, 0);
	for(int i=0; i<N; i++){
		V[D[i]]++;
	}
	LL ans = 1;
	for(int d=1; d<=maxd; d++){
		if(V[d] == 0){
			printf("0\n");
			return 0;
		}
		ans *= powmod(V[d-1], V[d], C);
		ans %= C;
	}
	ans %= C;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4968
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, const char* argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    string S, T;
    cin >> S >> T;
    int Ans = T.size();

    for (int i = 0; i <= S.size() - T.size(); i++) {
        int count = T.size();
        for (int k = 0; k < T.size(); k++) {
            if (T[k] == S[k + i]) {
                count--;
            }
        }
        Ans = min(Ans, count);
    }
    cout << Ans << endl;
    /////////////////////

    return 0;
}

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

int main()
{
	string s; cin >> s;
	int seq = 0;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == 'R') {
			seq += 1;
		}
		else {
			seq = 0;
		}
		ans = max(ans, seq);
	}
	cout << ans << endl;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 998244353;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> dp(n + 2, 0);
  vector<int> l(k), r(k);
  rep(i,k) cin >> l[i] >> r[i];
  dp[0] = 0;
  dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      (dp[i] += (dp[max(0, i - l[j])] - dp[max(0, i - r[j] - 1)] + mod) % mod) %= mod;
    }
    (dp[i + 1] += dp[i]) %= mod;
  }

  cout << dp[n] << endl;
  return 0; 
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 210000;
int ans;
int fa[maxn];
int sz[maxn];
void init()
{
    for (int i = 1; i <= maxn; i++)
    {
        fa[i] = i;
        sz[i] = 1;
    }
}
int find(int x)
{
    if (x == fa[x])
        return x;
    else
        return fa[x] = find(fa[x]);
}
void merge(int x, int y)
{
    sz[find(y)] += sz[find(x)];
    fa[find(x)] = find(y);
}
void run_case()
{
    init();
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        if (find(u) != find(v))
        {
            merge(u, v);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        //DBG(sz[i]);
        ans = max(ans, sz[i]);
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 5256
import sys
import math
K=int(input())
gcd_list = [[0 for i in range(K)] for j in range(K)]
ij_list = []
ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        ij_list.append(math.gcd(i,j))

for k in range(1,K+1):
    for v in ij_list:
        ans += math.gcd(k,v)


print(ans)

Measured memory_bytes: 9696
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{ 
 int N,Q; cin>>N; cin>>Q; 
  string str; cin>>str;
  vector<pair<char,char> > vp;
  for (int i = 0; i < Q; i++)
  {
    char X,Y;cin>>X>>Y;
    vp.emplace_back(X,Y);
  }
  int L = -1, R = N;
  while(R - L > 1)
  {
    int mid = (L+R)/2;
    int X = str[mid];
    int P = mid;
    for (int i = 0; i < Q; i++)
    {
      if(vp[i].first == X)
      {
        if(vp[i].second == 'L')
        {
          X = str[P-1];
          P--;
        }
        else
        {
          X = str[P+1];
          P++;
        }
      }
      if(P == -1 || P == N)break;
    }
    if(P == -1)
    {
      L = mid;
    }
    else
    {
      R = mid;
    }
    
  }
  int P1 = L;

  L = -1, R = N;
  while(R - L > 1)
  {
    int mid = (L+R)/2;
    int X = str[mid];
    int P = mid;
    for (int i = 0; i < Q; i++)
    {
      if(vp[i].first == X)
      {
        if(vp[i].second == 'L')
        {
          X = str[P-1];
          P--;
        }
        else
        {
          X = str[P+1];
          P++;
        }
      }
      if(P == -1 || P == N)break;
    }
    if(P == N)
    {
      R = mid;
    }
    else
    {
      L = mid;
    }
    
  }
  int P2 = R;
  // DEBUG(P1,P2);
  cout<<N - P1 -1 - (N - P2)<<endl;

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"Draw";
    else if((a>b||a==1)&&b!=1)
        cout<<"Alice";
    else if((a<b||b==1)&&a!=1)
        cout<<"Bob";


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    char a[50],b[50],c[100];
    while(cin>>a>>b){
        int i,j;
        c[0]=a[0];
        for(i=1,j=0;i<=100;i++){
            if(i%2!=0)
                {c[i]=b[j];j++;}
                else c[i]=a[j];

        }
        cout<<c<<endl;




    }

    return 0;
}








Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i=1,n;
	
	while(1)
	{
		scanf("%d",&n);
		
		if(n==0)
			break;
		
		printf("Case %d: %d\n",i,n);
		i++;
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while ( x != NIL ) {
        y = x;
        if ( z->key < x->key ) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if ( y == NIL ) {
        root = z;
    } else {
        if ( z->key < y->key ) {
            y->left = z;
        } else {
            y->right = z;
        }   
    }
}

void inorder (Node *u) {
    if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder (Node *u) {
    if ( u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i<n; i++ ) {
        cin >> com;
        if (com[0] == 'f' ) {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        } else if ( com == "insert" ) {
            scanf("%d",&x);
            insert(x);
        } else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
return 0;
}



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

ll N, M, Q;

vector<ll> A(50);
vector<ll> B(50);
vector<ll> C(50);
vector<ll> D(50);

ll solve(int digit, int upperBound, ll point, vector<ll> E)
{
    if (digit < 0)
    {
        ll tmp = 0;
        rep(i, Q)
        {
            if (E.at(B.at(i) - 1) - E.at(A.at(i) - 1) == C.at(i))
            {
                tmp += D.at(i);
            }
        }
        return max(point, tmp);
    }
    else
    {
        for (int i = 1; i <= upperBound; i++)
        {
            E.at(digit) = i;
            point = max(point, solve(digit - 1, i, point, E));
        }
    }

    return point;
}

int main()
{

    cin >> N >> M >> Q;

    rep(i, Q) cin >> A.at(i) >> B.at(i) >> C.at(i) >> D.at(i);

    vector<ll> E(N, 1);
    ll ans = solve(N - 1, M, 0, E);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
  int N;
  int A;
  double sum = 0;
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> A;
    sum += 1.0/A;
  }
  cout << 1.0/sum << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa=0,sb=0;//score
	
	
	while(cin>>n&&n!=0){
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a<b){sb+=(a+b);}
		else if(a>b){sa+=(a+b);}
		else
		{
			sa+=a;
			sb+=b;
		}
	}
	cout<<sa<<" "<<sb<<"\n";
	sa=0;sb=0;
	}
	return 0;
}

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



int main(){
    ll N; cin >> N;
    vector<vector<ll>> V(N);
    for(int i = 0; i < N-1; i++){
        ll a, b; cin >> a >> b; a--; b--;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    vector<ll> C(N);
    for(int i = 0; i < N; i++) cin >> C[i];
    sort(C.rbegin(), C.rend());
    vector<bool> Grid(N);
    set<pair<ll, ll>> ST;
    ll score = 0;
    for(int i = 1; i < N; i++) score += C[i];
    queue<ll> Q; Q.push(0); Grid[0] = true;
    int idx = 1; ST.insert(make_pair(1, C[0]));
    while(!Q.empty()){
        ll x = Q.front(); Q.pop();
        for(auto v : V[x]){
            if(!Grid[v]){
                Grid[v] = true;
                ST.insert(make_pair(v+1, C[idx]));
                idx++;
                Q.push(v);
            }
        }
    }
    
    cout << score << endl;
    for(auto s : ST){
        cout << s.second << " ";
    }
    cout << endl;


}


Measured memory_bytes: 1664
#include"bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>

using namespace std;

int n;


multiset<int> mt;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		mt.insert(a);
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int a;
		scanf("%d", &a);
		if (mt.find(a)!=mt.end()) {
			mt.erase(mt.lower_bound(a));
		}
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int top(int x)
{
    int ans = x;
    while(ans >= 10){
        ans = ans/10;
    }
    return ans;
}

int main()
{
    int n;
    long long c[10][10] = {0};
    cin >> n;
    
    long long ans = 0;
    
    for (int i = 1;i <= n;i++){
        int k = top(i);
        c[k][i%10]++;
    }
    
    for (int i = 0;i <= 9;i++){
        c[i][0] = 0;
        c[0][i] = 0;
    }
    
    for (int i = 0;i <= 9;i++){
        for (int j = 0;j <= 9;j++){
            ans += c[i][j]*c[j][i];
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
d,n=map(int,input().split())
if d==0:
    if n==100:
        print(n+1)
    else:
        print(n)
elif d==1:
    if n==100:
        print(100*n+100)
    else:
        print(100*n)
elif d==2:
    if n==100:
        print(n*10000+10000)
    else:
        print(n*10000)
    


Measured memory_bytes: 3060
#include <iostream>

int main()
{
	int m, f, r;
	while (std::cin >> m >> f >> r)
	{
		if (m == -1 && f == -1 && r == -1)
		{
			break;
		}
		if (m == -1 || f == -1)
		{
			std::cout << 'F' << '\n';
		}
		else if (m + f >= 80)
		{
			std::cout << 'A' << '\n';
		}
		else if (m + f >= 65)
		{
			std::cout << 'B' << '\n';
		}
		else if (m + f >= 50)
		{
			std::cout << 'C' << '\n';
		}
		else if (m + f >= 30)
		{
			if (r >= 50)
			{
				std::cout << 'C' << '\n';
			}
			else
			{
				std::cout << 'D' << '\n';
			}
		}
		else
		{
			std::cout << 'F' << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 3068
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#include<bitset>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX_B = 32;
signed main(){
  init_io();
  ll n,k,ans=0;
  cin >> n >> k;
  vector<ll> a(n),b(n);
  vector<vector<ll>> dp(MAX_B,vector<ll>(2,0));
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<n;i++){
    if((a[i]|k) == k){
      ans += b[i];
    }
  }
  for(int r=0;r<MAX_B;r++){
    ll tmp = 0,tk=0;
    for(ll i=0;i<MAX_B;i++){
      if(i<r){
        tk += (1ll << i);
      }else if(i==r){
        if((k&(1ll << i))==0){
          tk = 0;
          break;
        }
      }else{
        tk += ((1ll << i) & k);
      }
    }
    for(int i=0;i<n;i++){
      if((a[i]|tk) == tk){
        tmp+=b[i];
      }
    }
    ans = max(tmp,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4740
L = list(map(int, input().split()))
a = L[0]
b = L[1]
c = L[2]
k = L[3]

if k<=a:
    s = k
elif k>a and k<=a+b:
    s = a
elif k>a+b:
    s = a - (k-a-b)
print(s)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
    	cin >> a[i];
    }
    sort(a,a+n);
    int suma = 0;
    int ama = 0;
    for(int i=0; i<n; i+=2){
    	suma+=a[i];
    }
    for(int i=1; i<n; i+=2){
    	ama+=a[i];
    }
    cout << abs(suma - ama) << endl;
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <map>
using namespace std;
typedef long long int ll;
map<ll, ll> Map;

int main()
{
    ll N, M;
    cin >> N >> M;

    for (ll i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        Map[a] += b;
    }

    ll sum = 0;
    for (auto i : Map)
    {
        if (i.second < M)
        {
            sum += i.first * i.second;
            M -= i.second;
        }
        else
        {
            sum += M * i.first;
            break;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
#define int long long 
#define CAL(x,y) ((x)+(y)*(y))
using namespace std;
typedef pair<int,int> pii;

int k,n;
int hako[111111];
vector<pii> td;
bool mycomp(const pair<int,int> &a,const pair<int,int> &b)
{
  return a.second>b.second;
}

signed main(){
  cin>>n>>k;
  int t,d;
  
  for(int i=0;i<n;i++){
    cin>>t>>d;
    td.pb(pii(t,d));
  }
  sort(td.begin(),td.end(),mycomp);
  int res=0;
  int syu=0;

  priority_queue<pii,vector<pii>,greater<pii> > q1;
  priority_queue<pii> q2;
    
  for(int i=0;i<k;i++){
    if(hako[td[i].first]==0) syu++;
    hako[td[i].first]++;
    res+=td[i].second;
    q1.push(pii(td[i].second,td[i].first));
  }
  for(int i=k;i<n;i++){
    if(hako[td[i].first]==0) q2.push(pii(td[i].second,td[i].first));
  }

  int res_max=CAL(res,syu);
  while(!q2.empty() && !q1.empty()){
    pii p1,p2;
    p1=q1.top();
    p2=q2.top();
    if(hako[p2.second]!=0) q2.pop();
    else if(hako[p1.second]==1) q1.pop();
    else{
      q1.pop();
      q2.pop();
      res=res-p1.first+p2.first;
      syu++;
      hako[p2.second]++;
      hako[p1.second]--;
      res_max=max(res_max,CAL(res,syu));
    }
  }
  cout<<res_max<<endl;
  return 0;
}



Measured memory_bytes: 6128
N = gets.to_i
D = gets.split.map(&:to_i)

D.sort!

if D.size % 2 == 0
  if D[(D.size / 2 - 1)] == D[(D.size / 2)]
    puts 0
  else
    puts D[(D.size / 2)] - D[(D.size / 2 - 1)]
  end
else
  puts 0
end

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

#define pb push_back
#define sz(v) ((int)(v.size()))
#define all(v) v.begin(), v.end()
#define nie NULL
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
typedef vector<pii> vpi;

const int inf(1e9);
const int maxN(3e5 + 10);
const ll mod(1e9 + 7);

template <typename T1>
inline void in(T1 &a1) { cin >> a1; }
template <typename T1, typename T2>
inline void in(T1 &a1, T2 &a2) { cin >> a1 >> a2; }
template <typename T1, typename T2, typename T3>
inline void in(T1 &a1, T2 &a2, T3 &a3) { cin >> a1 >> a2 >> a3; }

void _main();
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/*--------------------------------------*/
	_main(); return 0;
}

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

void _main() {
	string S, T; in(S, T);
	vector<string> res;

	int i, j, n = sz(S), m = sz(T);
	if (n < m) goto end;

	for (i = 0; i + m <= n; i++) {
		for (j = 0; j < m; j++) {
			if (S[i + j] == '?') continue;
			if (S[i + j] != T[j]) break;
		}
		if (j == m) {
			string tp = S;
			for (j = 0; j < n; j++) {
				if (i <= j && j < i + m)
					tp[j] = T[j - i];
				else if (tp[j] == '?')
					tp[j] = 'a';
			} res.pb(tp);
		}
	}

	if (res.empty()) {
	end:
		puts("UNRESTORABLE");
	}
	else {
		cout << *min_element(all(res)) << endl;
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = k; i < n; i++) {
    if (a[i] > a[i - k]) {
      puts("Yes");
    } else {
      puts("No");
    }
  }

  return 0;
}


Measured memory_bytes: 4400
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if((N%2)==0){
            System.out.println(N/2);
        }else{
            System.out.println(N/2+1);
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  double ans = 0;
  vector<double> a(n); rep(i, n) cin >> a[i], ans += 1 / a[i];
  cout << fixed << setprecision(15) << 1/ans << endl;
}

Measured memory_bytes: 256
MOD = int(1e+9 + 7)
N, K = map(int, input().split())
 
cnt = [0] * (K + 1) # 要素が全てXの倍数となるような数列の個数をXごとに求める
for x in range(1, K + 1):
    cnt[x] = pow(K // x, N, MOD)
for x in range(K, 0, -1): # 2X, 3Xの個数を求めてひく
    for i in range(2, K // x + 1):
        cnt[x] -= cnt[x * i]
ans = 0
for k in range(K+1):
    ans += cnt[k] * k
ans = ans % MOD
print(ans)

Measured memory_bytes: 11332
n, x = input().split(" ")
n = int(n)
x = int(x)

d = 0
m = []

for i in range(n):
    m.append(int(input()))
m.sort()

for i in range(n):
    if(x >= m[i]):
        d+=1
        x -= m[i]

if x > m[0]:
    res = int(x/m[0])
    d += res
print(d)


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
ll n,k;
  cin>>n>>k;
  ll ans=0;
  rep(i,k,n+2){
    ans+=(i*(2*n-i+1)/2)-(i*(i-1)/2)+1;
   // cout<<(i*(2*n-i+1)/2)<<" "<<(i*(i-1)/2)<<endl;
      ans%=inf;
  }
  cout<<ans<<endl;
}






//ガンバる

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define p 1000000007
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        sum=(sum%p+a[i]%p)%p;
    }
   // cout<<sum<<endl;
    ll prod=0;
    ll prev=0;
    for(ll i=0;i<n;i++)
    {
        prev=(prev%p+a[i]%p)%p;
        
        prod=((prod%p+(((sum%p-prev%p+p)%p)*a[i]%p)%p))%p;
    }
    cout<<prod<<endl;
}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    string s, t;
    cin >> s >> t;
    bool flag = true;
    rep(i, s.size()) {
        if (s[i] != t[i]) flag = false;
    }
    if (flag) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define     FAST            ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
#define ll long long
using namespace std;
int main()
{

    int n,x,t;
    cin>>n>>x>>t;

    if(n%x==0)
    {
        cout<<(n/x)*t<<endl;
    }
    else
    {
        cout<<((n/x)+1)*t<<endl;
    }















    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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 FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;
const int mod = 1000000007;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ans(n,0);
    if (n == 1 && m == 0){
        cout << 0;
        rn 0;
    }
    rep(i,m){
        int s,c;
        cin >> s >> c;
        s--;
        if (m == 1 && n == 1 && c == 0){
            cout << 0;
            rn 0;
        }
        if (s == 0 && c == 0){
            cout << -1;
            rn 0;
        }
        if (ans[s] != c && ans[s] != 0){
            cout << -1;
            rn 0;
        }
        ans[s] = c;
    }
    if (ans[0] == 0) ans[0] =1;
    rep(i,n) cout << ans[i];
}


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

int main(){
  long long int x;
  cin >> x;
  long long int f = 100;
  long long int count = 0;
  
  while(f < x){
    f += f / 100;
    count ++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3624
from collections import deque
k = int(input())
q = deque(list(range(1, 10)))
for _ in range(k-1):
	d = q.popleft()
	if d%10 > 0:
		q.append(d*10 + d%10 - 1)
	q.append(d*10 + d%10)
	if d%10 < 9:
		q.append(d*10 + d%10 + 1)
print(q.popleft())

Measured memory_bytes: 11912
S = input()

import sys

if S[0] != "A":
    print("WA")
    sys.exit()
else:
    if S[2:len(S)-1].count("C") != 1:
        print("WA")
        sys.exit()
    else:
        for i in range(1,len(S)):
            if 97 <= ord(S[i]) and ord(S[i]) <= 122:
                continue
            elif S[i] == "C":
                continue
            else:
                print("WA")
                sys.exit()
    print("AC")
        

Measured memory_bytes: 3060