akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int E = s.nextInt();
		int Y = s.nextInt();
		
		if (E == 0){
			if (Y <= 1911){
				System.out.print("M");
				System.out.println(Y - 1867);
			}else if(Y <= 1925){
				System.out.print("T");
				System.out.println(Y - 1911);
			}else if(Y <= 1988){
				System.out.print("S");
				System.out.println(Y - 1925);
			}else{
				System.out.print("H");
				System.out.println(Y - 1988);
			}
		} else if(E == 1){
			System.out.println(1867 + Y);
		}else if(E == 2){
			System.out.println(1911 + Y);
		}else if(E == 3){
			System.out.println(1925 + Y);
		}else{
			System.out.println(1988 + Y);
		}
	}
}

Measured memory_bytes: 26340
def insertionSort( nums, n, g ):
	cnt = 0
	for i in range( g, len( nums ) ):
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
	
	return cnt


def shellSort( nums, n ):
	cnt = 0
	g = []
	val =0
	for i in range( 0, n ):
		val = 3*val+1
		if  n < val:
			break
		g.append( val )

	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	for i in range( 0, m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )


n = int( raw_input( ) )
nums = []
for i in range( 0, n ):
	nums.append( int( raw_input( ) ) )

shellSort( nums, n )
for val in nums:
	print( val )

Measured memory_bytes: 67856
#include <stdio.h>
#define NUMBER 100

void print_array(int array[],int num){
	int i;
	
	for(i = 0; i < num - 1; i++)
		printf("%d ", array[i]);
	
	//スペースを出力したくないので最後の要素だけfor文外で出力
	printf("%d\n", array[i]);
}

void insertionSort(int array[],int num){
	int i, j, v;
	for(i = 1; i <= num - 1 ; i++){
		v = array[i];
		j = i - 1;
		while(j >= 0 && array[j] > v){
			array[j + 1] = array[j];
			j--;
		}
		array[j + 1] = v;
		//配列の出力
		print_array(array, num);
	}
}

int main(void){
	int array[NUMBER];
	int num, i;
	
	scanf("%d", &num);
	
	for(i = 0; i < num; i++){
		//配列を入力
		scanf("%d", &array[i]);
	}
	print_array(array, num);
	
	//挿入ソート
	insertionSort(array, num);

	
	return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
#define MAX 500000

int A[MAX],H;

int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxHeapify(int *A,int i){
  int l,r,largest,temp;

  l=left(i);
  r=right(i);

  if(l<=H&&A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=H&&A[r]>A[largest])
    largest=r;

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

void buildMaxHeap(int *A){
  int i;
  
  for(i=H/2;i>=1;i--)
    maxHeapify(A,i);
}
int main(){
  int i;
  
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);

  buildMaxHeap(A);

  for(i=1;i<=H;i++) printf(" %d",A[i]);
  printf("\n");

  return 0;
}
    

  
  



Measured memory_bytes: 3676
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s).most_common()
m = c[0][1]
a = []
for i in c:
    s, k = i
    if k != m:
        break
    a.append(s)

print(*sorted(a), sep='\n')


Measured memory_bytes: 45044
#include<iostream>
using namespace std;
int main(){
    long long n, a,b;
    cin >> n >> a >> b;
    long long dif = b-a;
    if(dif%2==0){
        cout << dif / 2;
    }else if(n-b < a - 1){
        cout << n-b + 1 + dif/2;
    }else{
      cout << a + dif/2;
    }
}

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

using namespace std;


int main(){
    unsigned long n;
    scanf("%lu",&n);

    bitset<18> subset_flag(0);
    for(unsigned long i = 0;i < pow(2,n);i++){
        subset_flag = bitset<18>(i);
        printf("%lu:",i);
        for(unsigned long j = 0;j < n;j++){
            if(subset_flag.test(j)) printf(" %lu",j);
        }
        printf("\n");
    }

    return 0;   
}



Measured memory_bytes: 3380
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int n,m,Q;
ll q[100010],mul[100010],ans[100010];
void work(ll p,ll M){
	if(p<=q[1])ans[1]+=M,ans[p+1]-=M;
	else{
		int i=std::upper_bound(q+1,q+m+1,p)-q-1;
		mul[i]+=p/q[i]*M;work(p%q[i],M);
	}
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi(),Q=gi();
	q[m=1]=n;
	for(int i=1;i<=Q;++i){
		ll x=gi();
		while(m&&q[m]>=x)--m;
		q[++m]=x;
	}
	mul[m]=1;
	for(int i=m;i>1;--i)
		work(q[i]%q[i-1],mul[i]),mul[i-1]+=mul[i]*(q[i]/q[i-1]);
	ans[1]+=mul[1];ans[q[1]+1]-=mul[1];
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]+=ans[i-1]);
	return 0;
}


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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> s[M];
	rep(i,M){
		int k;
		cin >> k;
		rep(j,k){
			int x;
			cin >> x;
			x--;
			s[i].push_back(x);
		}
	}
	vector<int> p(M);
	rep(i,M){
		cin >> p[i];
	}
	int ans = 0;
	
	rep(bit, 1<<N){
		bool ok = true;
		rep(i,M){
			int count = 0;
			for (auto v: s[i]){
				if(bit & (1<<v)) count++;
			}
			if(count % 2 != p[i]) ok = false;
		}
		if(ok) ans++;
	}
	
	cout << ans << endl;
    return 0;
}



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

signed main() {
	int n, m, ans = 0, cnt = -1;
	cin >> n >> m;
	pair<int, int>p[114514];
	rep(i, m) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + m);
	for (int i = 0; i < m; i++) {
		if (p[i].second >= cnt) {
			ans++;
			cnt = p[i].first;
		}
	}
	cout << ans << endl;

	END;
}

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

int main() {
    int n; cin >> n;
    vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i];
    int m; cin >> m;
    vector<string> t(m); for (int i = 0; i < m; i++) cin >> t[i];
 
    int ans = 0;
    for (int i = 0; i < n; i++){
      int score = 0;
      for (int j=0; j<n; j++) if(s[j]==s[i]) score++;
      for (int j=0; j<m; j++) if(t[j]==s[i]) score--;
      ans = max(ans, score);
    }
  
    cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a,b,c,d;

int sister(int a,int b) {
  if(a>b) return b;
  return a;
}

int main() {
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  printf("%d\n", sister(a,b) + sister(c,d));
  
  
  
  
  
  
  
  
  return 0;
}

Measured memory_bytes: 128
/* kadai5_3
   reo012 */


#include<stdio.h>

int main(void){
    int h, w, i, j;
    scanf("%d %d", &h, &w); //行数hと列数wの入力
    int row[h], col[w];  //h行目またはw列目に黒マスがあるかの情報を入れる配列
    char squares[h][w];  //h行w列の二次元配列squaresを定義

    //始めに配列row,colは全て0を入力
    for(i=0;i < h;i++){
        row[i] = 0;
    }
    for(j=0;j < w;j++){
        col[j] = 0;
    }

    //二次元配列squareに行ごとに入力
    for(i=0;i < h;i++){
        for(j=0;j < w;j++){
            scanf(" %c",&squares[i][j]);  //i行目j列目入力
            //黒が入力された場合その行と列の配列に１を入れる
            if(squares[i][j] == '#'){
                row[i] = 1;
                col[j] = 1;
            }
        }
    }

    //白い行、白い列を省いて出力していく。row[i]=1かつcol[j]=1のマスのみ出力
    for(i=0;i < h;i++){
        //行に黒が含まれる場合のみ表示する
        if(row[i] == 1){
            for(j=0;j < w;j++){
                //列に黒が含まれる場合のみ表示する
                if(col[j] == 1){
                    printf("%c",squares[i][j]);
                }
            }
            printf("\n");//行を出力したら改行
        }
    }

    return 0;
}


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

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

    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];

    if(prev_permutation(a, a+n)){
        for(int i = 0; i < n; i++)  cout << a[i] << " \n"[i == n-1];
    }
    next_permutation(a, a+n);

    for(int i = 0; i < n; i++)  cout << a[i] << " \n"[i == n-1];

    if(next_permutation(a, a+n)){
        for(int i = 0; i < n; i++)  cout << a[i] << " \n"[i == n-1];
    }

    return 0;
}


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

int main()
{
   int n;
   cin >> n;
   vector<int> color(n,-1);
   vector<P> dist[n];
   color[0] = 1;
   rep(i,n-1)
   {
      int u, v;
      ll w;
      cin >> u >> v >> w;
      --u; --v;
     dist[u].push_back(P(v,w));
     dist[v].push_back(P(u,w));
   }
   
   queue<ll> que;
   que.push(0);
   while(!que.empty())
   {
      int target = que.front(); que.pop();

      for(auto d : dist[target])
      {
         int num = d.first;
         ll len = d.second;
         if(color[num] != -1) continue;
         if(len%2 == 0) color[num] = color[target];
         else color[num] = 1 - color[target];
         que.push(num);
      }
   }
   rep(i,n) cout << color[i] << endl;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  vector<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];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	int s=(b+b+1);
	printf("%d",a%s==0?a/s:a/s+1);
	return 0;
}


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

using namespace std;

#define ops cout<<"ops"<<endl;
#define freopens freopen("cowpatibility.in", "r", stdin);freopen("cowpatibility.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 107
#define DIMM 100007
#define INF 1000000000007.0
#define X 31
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n,W,sv,res;
ll w[DIM],v[DIM];
ll dp[DIM][DIMM];

int main()
{
    //ops;
    //freopens;
    fast;
    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n>>W;
    for(int i=1;i<=n;i++){
     cin>>w[i]>>v[i];
     sv+=v[i];
    }
    for(int i=1;i<=sv;i++)dp[0][i]=INF;

    for(int i=1;i<=n;i++){
     for(int j=0;j<=sv;j++){
      dp[i][j]=dp[i-1][j];
      if(j>=v[i] && dp[i][j]>(dp[i-1][j-v[i]]+w[i]))dp[i][j]=dp[i-1][j-v[i]]+w[i];
     }
    }
    for(int j=0;j<=sv;j++)
     if(dp[n][j]<=W)
      res=j;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define MAX ((ll)(1e18 + 5))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(1e9 + 7))
#define xx first
#define yy second
#define NN ((ll)(1e6+2))
#define N ((int)(4e2 + 2))
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long lu;

typedef tree < ll,  null_type,  less < ll >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;

ll dp[N][N];

int a[N];

ll call(int l, int r)
{
    if(l==r) return 0;
    if(dp[l][r]!=-1) return dp[l][r];
    dp[l][r] = MAX;
    for(int i = l+1; i<=r; i++){
        dp[l][r] = min(dp[l][r],call(l,i-1)+call(i,r));
    }
    for(int i = l; i<=r; i++) dp[l][r] += a[i];
    return dp[l][r];
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i<n; i++) scanf("%d",&a[i]);
    memset(dp,-1,sizeof dp);
    printf("%lld\n",call(0,n-1));
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	ll X;
	cin >> X;
	ll q=X/500, r;
	r=(X-q*500)/5;
	cout << q*1000+r*5 << endl;
	return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  int w, h, n;
  cin>>w>>h>>n;
  int x1max, x2min, y1max, y2min;
  x1max = y1max = 0;
  x2min = w;
  y2min = h;
  for(int i=0; i<n;i++)
  {
    int x, y, a;
    cin>>x>>y>>a;
    if(a == 1)
    {
      x1max = max(x1max, x);
    }
    if(a == 2) x2min = min(x2min, x);
    if(a == 3) y1max = max(y1max, y);
    if(a == 4) y2min = min(y2min, y);
  }
  //cout<<x1max<<" "<<y1max<<" "<<x2min<<" "<<y2min<<endl;
  if((x2min <= x1max) || (y2min <= y1max)) cout<<"0"<<endl;
  else
  {
    int area = (x2min - x1max) * (y2min - y1max);
    cout<<area<<endl;
  }
  return 0;
}


Measured memory_bytes: 12160
#include <cstdio>
#include <unordered_map>
#include <vector>

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

using namespace std;

int64_t comb(int64_t n) { return (n > 1) ? (n * (n - 1)) / 2 : 0; }

int main() {
  int n;
  scanf("%d", &n);

  auto avec = vector<int>(n);
  for (auto &x : avec) {
    scanf("%d", &x);
  }

  auto arr = vector<int>(n + 1, 0);
  for (const auto &x : avec) {
    arr[x]++;
  }

  int64_t sum = 0;
  for (const auto &x : arr) {
    sum += comb(x);
  }

  for (const auto &x : avec) {
    auto n = arr[x];
    auto result = sum - (n - 1);

    printf("%ld\n", result);
  }

  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
vector<int> A, B, C;
int main()
{
    int N,sum=0;
    cin >> N;
    A.resize(N);
    B.resize(N);
    C.resize(N - 1);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];
    rep(i, 0, N - 1) cin >> C[i];

    rep(i,0,N){
        sum += B[A[i]-1];
        //cout << B[A[i]-1] << endl;
        if (i > 0)
        {
            if(A[i-1]+1==A[i])
                sum += C[A[i-1]-1];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import math
N,H=map(int,input().split())
sword=[list(map(int,input().split())) for _ in range(N)]
throw=0
smash=0
cnt=0
sword.sort(key=lambda x:x[0],reverse=True)
smashmax=sword[0][0]
sword.sort(key=lambda x:x[1],reverse=True)
for i in range(N):
    if (smashmax<=sword[i][1])and(throw<H):
        throw=throw+sword[i][1]
        cnt=cnt+1
if throw>=H:
    print(cnt)
else:
    print(cnt+math.ceil((H-throw)/smashmax))


Measured memory_bytes: 68952
//======================================================================
// Contents    : AOJ ITP1_7_B
//               1 から n までの数の中から、重複無しで３つの数を選び合計が x となる組み合わせの数を求める
// Input       : n, x
// Output      : 組み合わせの数
// Constraints : 3 ≤ n ≤ 100
//               0 ≤ x ≤ 300
// Author      : 廣部智也
// LastUpdate  : 2020/06/28
// Since       : 2020/06/28
//======================================================================

#include <stdio.h>
#include <stdlib.h>                                                       // exit 関数を使用するため

#define LOWER_LIMIT_n     3
#define UPPER_LIMIT_n   100
#define LOWER_LIMIT_x     0
#define UPPER_LIMIT_x   300

// 入力エラーを判断する関数
int Input_error( int number, int lower_limit, int upper_limit );

// 成績を判断し出力する関数
void Combination( int n, int x );



int main(){

    int n = 0, x = 0;

    while( 1 ){
    
        // データの入力
        scanf("%d %d", &n , &x );

        if( n == 0 && x == 0 ){              // 入力終了の判断
            break;
        }

        Input_error( n , LOWER_LIMIT_n, UPPER_LIMIT_n );
        Input_error( x , LOWER_LIMIT_x, UPPER_LIMIT_x );

        // データの処理と出力
        Combination( n, x );

    }

    return 0;
}



//=========================================================================
// Contents    : 重複無しで３つの数を選び合計が x となる組み合わせの数を求める
// Author      : 廣部智也
// LastUpdate  : 2020/06/28
// Since       : 2020/06/28
//=========================================================================

void Combination( int n, int x ){

    int c = 0;
    int i = 0, j = 0, k = 0;

    for( i = 1 ; i <= (n - 2) ; i++ ){
        for( j = ( i + 1 ) ; j <= ( n - 1 ) ; j++ ){
            for( k = ( j + 1 ) ; k <= n ; k++ ){

                if( i + j + k == x ){
//                    printf("%d　%d　%d\n", i ,j ,k );               //消す。組み合わせ確認用
                    c ++;
                }
                
            }
        }
    }
    
    printf("%d\n", c);
    
    return;
}



//============================================================
// Contents    : 入力エラーを判断
// Input       : 調べる変数, 下限, 上限
// Output      : エラーなら強制終了
// Author      : 廣部智也
// LastUpdate  : 2020/06/05
// Since       : 2020/06/05
//============================================================

int Input_error( int number, int lower_limit, int upper_limit ){
    
    if( number < lower_limit || number > upper_limit ){
        printf("Input error\n");
        exit(1);
    }

    return 0;
}



Measured memory_bytes: 2040
#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>;

const double pi = 3.1415926535;

int main() {
    long double a, b, x;
    cin >> a >> b >> x;

    long double V = a * a * b;
    if (x <= V / 2) {
        cout << fixed << setprecision(8) << atan(a * b * b / 2 / x) * 180 / pi << endl;
    } else {
        cout << fixed << setprecision(8) << atan(2 / (a * a * a) * (V - x)) * 180 / pi << endl;
    }
}



Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define MM(arr,x) memset(arr,x,sizeof(x))
using namespace std;
int main()
{
	int x;
	cin>>x;
	cout<<1-x;
	return 0;
} 

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

int main() {
	ll a;
	cin >> a;
	string s;
	cin >> s;
	int b = ((int)s[0]-48) * 100 + ((int)s[2] - 48) * 10 + ((int)s[3] - 48);

	ll ans0 = a * b;
	int ans1 = ans0 % 100;
	cout << (ans0 - ans1) / 100 << endl;

}



Measured memory_bytes: 3724
N = int(input())
S = input()
MOD = 10**9 + 7

dp = [[0]*(N+1) for i in range(N+1)]
P = [0]*(N+1); Q = [0]*(N+1)
P[1] = 1
for i in range(N-2, 0, -1):
    r = 0
    if S[i-1] == '<':
        if S[i] == '<':
            for k in range(1, N-i+1):
                Q[k] = r = (r + P[k-1]) % MOD
        else:
            for k in range(1, N-i+1):
                Q[k] = r = (r + P[N-i-k]) % MOD
    else:
        if S[i] == '<':
            for k in range(1, N-i+1):
                Q[k] = r = (r + P[N-i-k]) % MOD
        else:
            for k in range(1, N-i+1):
                Q[k] = r = (r + P[k-1]) % MOD
    P, Q = Q, P
print(sum(P) % MOD)

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

int main(){
  long long n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0){
			ans+=i;
	}
  }
	cout<<ans<<endl;
    return(0);
}
/*for(int i=1;i<=n;i++){
   if (i%3==0) break;
   if (i%5==0) break;
   ans+=i;
  }
  だとif文からbreakしてるだけでfor文からbreakできてない*/

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x=0;
  int y=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='B'){
      x++;
    }
    else{
      y++;
    }
  }
  cout << (x<y?"Yes":"No") << endl;
}


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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> C(H);
	for (int i = 0; i < H; i++) cin >> C[i];
	for (int i = 0; i < H; i++) cout << C[i] << endl << C[i] << endl;
}

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

int main(){
  int N;
  string S,T;
  cin >> N >> S >> T;
  int f;
  for(int i=0;i<N;i++){
    f=0;
    for (int j=0;i+j<N;j++){
      f+=S[i+j]==T[j]?0:1;
    }
    if (f==0){
      cout << N+i << endl;
      return 0;
    }
  }
  cout  << N*2 << endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

const int mod = 1000000007;
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint mpow(int x, int n){
  if(n==0)return 1;

  mint y = mpow(x, n/2);
  y *= y;

  if(n%2==1) y *=x;
  return y;
}

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];
  }
} c(200005);

map<ll, int > prime_factor(ll n) {
  map<ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

  map<ll,int> mp = prime_factor(m);

  mint ans=1;
  for(auto v: mp){
    ans *= c(v.second+n-1, v.second);
  }
  cout << ans.x << endl;
}



Measured memory_bytes: 3328
# include "stdio.h"

int main(){
    char s[20];
    scanf("%s",s);
    for(int i=0;i<5;i++)
    printf("%c",s[i]);
    printf(" ");
    for(int i=6;i<13;i++)
    printf("%c",s[i]);
    printf(" ");
    for(int i=14;i<19;i++)
    printf("%c",s[i]);
    printf("\n");
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int m,n;
    cin >>m>>n;
    if(m<n){
        for(int i=0;i<n;i++){
            cout << m;
        }
    }
    else{
        for(int i=0;i<m;i++){
            cout << n;
        }
    }
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Random;
import java.util.Scanner;


public class Main {


	public static void main(String[] args){

		long startTime = System.currentTimeMillis();
		Scanner sc = new Scanner(System.in);
		//Main player = new Main();

		final int H = Integer.parseInt(sc.next());
		final int W = Integer.parseInt(sc.next());
		int[][] A = new int[H][W];
		int[][] B = new int[H][W];
		boolean[][][] DP = new boolean[H+1][W+1][25601];

		for (int h=0; h<H; h++){
			for (int w=0; w<W; w++){
				A[h][w] = Integer.parseInt(sc.next());
			}
		}
		for (int h=0; h<H; h++){
			for (int w=0; w<W; w++){
				B[h][w] = Integer.parseInt(sc.next());
			}
		}

		for (int h=0; h<H+1; h++){
			for (int w=0; w<W+1; w++){
				for (int i=0; i<25601; i++){
					DP[h][w][i] = false;
				}
			}
		}
		DP[0][0][12800] = true;

		for (int h=0; h<H; h++){
			for (int w=0; w<W; w++){
				int d = A[h][w] - B[h][w];
				for (int i=0; i<25601; i++){
					if (DP[h][w][i]){
						DP[h+1][w][i+d] = true;
						DP[h+1][w][i-d] = true;
						DP[h][w+1][i+d] = true;
						DP[h][w+1][i-d] = true;
					}
				}
			}
		}
		for (int i=0; i<12801; i++){
			if (DP[H][W-1][12800+i] || DP[H][W-1][12800-i]){
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 238752
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int ans=0;
	string s;
	cin>>s;
	for (int i=0;i<s.length();++i)
       		if (s[i]=='2')
       		  ans++;
    printf ("%d\n",ans);
	return 0;
	
 } 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int ans = 0;
			for(int i = 0; i < N; i++) {
				int l = in.nextInt();
				int r = in.nextInt();
				ans += r - l + 1;
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define fs first
#define sc second
#define pb push_back
#define sz size()

using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> L;
typedef vector<int> vi;

inline int dot(const P &a, const P &b){return a.fs*b.fs + a.sc*b.sc;}
inline int cross(const P &a, const P &b){return a.fs*b.sc - a.sc*b.fs;}
inline int norm(const P &a){return a.fs*a.fs + a.sc*a.sc;}

inline int ccw(const P &a,P b,P c){
  b.fs -= a.fs; b.sc -= a.sc;
  c.fs -= a.fs; c.sc -= a.sc;
  if (cross(b,c)>0) return 2;
  if (cross(b,c)<0) return -2;
  if (dot(b, c)<0) return 1;
  if (norm(b)<norm(c)) return -1;
  return 0;
}

vector<vi> g;
vi cols;
int n,m,ans;

void dfs(int d, int num, const int &clique){
  if(num >= ans || num>=m)return;
  if(d==m){ ans = num; return; }
  if((clique>>d)&1){ dfs(d+1,num,clique); return; }

  vi use(num,0);
  rep(i,m){
    if(i<d || (clique>>i)&1){
      if(g[d][i])use[cols[i]] = 1;
    }
  }
  
  rep(i,num){
    if(!use[i]){
      cols[d] = i;
      dfs(d+1,num,clique);
      if(num>=ans)return;
    }
  }

  cols[d] = num;
  dfs(d,num+1,clique);
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  while(cin >> n){
    if(n==0)break;

    map<string,int> country;
    vi id(n);
    vector< vector<L> > poly(n);

    m = 0;
    rep(i,n){
      string name;
      cin >> name;

      if(country.find(name)==country.end()){
	country[name] = m++;
      }
      id[i] = country[name];
      
      int x,y;
      vector<P> points;

      for(;;){
	cin >> x;
	if(x<0)break;
	cin >> y;
	points.pb( P(x,y) );
      }

      rep(j,points.sz){
	poly[i].pb(L(points[j],points[(j+1)%points.sz]));
	if(poly[i][j].sc < poly[i][j].fs)swap(poly[i][j].fs, poly[i][j].sc);
      }
    }

    g = vector<vi>(m,vi(m,0));

    rep(i,n)rep(j,i){
	bool f = false;
	for(L a : poly[i]){
	  for(L b: poly[j]){
	    if(abs(ccw(a.fs,a.sc,b.fs))<=1 && abs(ccw(a.fs,a.sc,b.sc))<=1){
	      if( (b.fs < a.sc && a.fs < b.sc) || (a.fs < b.sc && b.fs < a.sc) ){
		f = true; break;
	      }
	    }
	  }
	  if(f)break;
	}
	if(f)g[id[i]][id[j]] = g[id[j]][id[i]] = 1;
    }

    int clique = 1, s = 1;
    for(int bit=1;bit<(1<<m);bit++){
      int p = __builtin_popcount(bit);
      if(p<=s)continue;
      bool f = true;
      rep(i,m)rep(j,i){
	if( ((bit>>i)&1) && ((bit>>j)&1) && !g[i][j])f = false;
      }
      if(f){
	clique = bit; s = p;
      }
    }

    cols.resize(m);
    s = 0;
    rep(i,m){
      if((clique>>i)&1)cols[i] = s++;
    }

    ans = m;
    dfs(0,s,clique);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)

int pm(ll& X, ll& Y) {
	X++;
	Y--;
	return(1);
}

int ask(int nxt, ll& X, ll& Y) { // nxt = {0 if XY, 1 if YZ, 2 if ZX}, ret = {0:no, 1:X++, 2:Y++}
	if (X > Y) {
		return(pm(Y, X) + 1);
	}
	else if (X < Y) {
		return(pm(X, Y));
	}
	else { // X == Y
		if (X == 0) {
			cout << "No" << endl;
			return(0);
		}
		switch (nxt) {
		case 0: // どちらでもいい
			return(pm(X, Y));
			break;
		case 1: // YZ -> Y++
			return(pm(Y, X) + 1);
			break;
		case 2: // ZX -> X++
			return(pm(X, Y));
			break;
		}
	}
}

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

	ll N, A, B, C;
	cin >> N >> A >> B >> C;
	ll iA = A;
	ll iB = B;
	ll iC = C;
	char S[3];
	vector<int> X(N+1, 0); // 1 = BC, 2 = CA, 3 = AB
	for (ll i = 0; i < N; i++) {
		cin >> S;
		if (S[0] == 'A' && S[1] == 'B') {
			X[i] = 3;
		}
		else if (S[0] == 'B' && S[1] == 'C') {
			X[i] = 1;
		}
		else {
			X[i] = 2;
		}
	}

	vector<int> Y(N + 1, 0);
	for (ll i = 0; i < N; i++) {
		switch (X[i]) {
		case 1: // BC // nxt = {0 if XY, 1 if YZ, 2 if ZX}, ret = {0:no, 1:X++, 2:Y++}
			Y[i] = ask(X[i + 1] - 1, B, C) + 1;
			if (Y[i] == 1) return(0);
			break;
		case 2: // CA // 1 = BC, 2 = CA, 3 = AB // nxt = {0 if XY, 1 if YZ, 2 if ZX}, ret = {0:no, 1:X++, 2:Y++}
			Y[i] = ((ask((X[i + 1] + 1) % 3, C, A) + 1) % 3) + 1;
			if (Y[i] == 2) return(0);
			break;
		case 3: // AB // 1 = BC, 2 = CA, 3 = AB // nxt = {0 if XY, 1 if YZ, 2 if ZX}, ret = {0:no, 1:X++, 2:Y++}
			Y[i] = ask(X[i + 1] % 3, A, B);
			if (Y[i] == 0) return(0);
			break;
		}
	}
	cout << "Yes" << endl;
//	cout << "  " << iA << " " << iB << " " << iC << endl;
	for (int i = 0; i < N; i++) {
/*		if (X[i] == 1) {
			iB--;
			iC--;
			cout << "BC -> ";
		}
		if (X[i] == 2) {
			iC--;
			iA--;
			cout << "CA -> ";
		}
		if (X[i] == 3) {
			iA--;
			iB--;
			cout << "AB -> ";
		}*/
		switch (Y[i]) {
		case 1:
			iA += 2;
//			cout << "A" << " " << iA << " " << iB << " " << iC << endl;
			cout << "A" << endl;
			break;
		case 2:
			iB += 2;
//			cout << "B" << " " << iA << " " << iB << " " << iC << endl;
			cout << "B" << endl;
			break;
		case 3:
			iC += 2;
//			cout << "C" << " " << iA << " " << iB << " " << iC << endl;
			cout << "C" << endl;
			break;
		default:
			cout << "Bad Number " << Y[i] << endl;
		}
	}
	return(0);
}


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

int main(){
    // input
    int n;
    ll k; cin >> n >> k;
    vector<ll> a(n),f(n); 
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    // prepare
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>()); // a昇順、f降順の時のa[i]*f[i]が最適
    // binary-search
    ll right = a[n-1]*f[0]; // 常に条件を満たす
    ll left = -1; // 常に条件を満たさない
    ll mid;
    while(right-left>1){
        mid = (right+left)/2; // midが最大値になり得るか
        ll sum = 0;
        rep(i,n) sum += max(a[i]-(mid/f[i]), 0LL); // a[i]*f[i]がmidより小さくなるような修行回数
        if(sum > k) left = mid; // midが最大値になり得ない
        else right = mid; // midが最大値になり得る
    }
    // output
    cout << right << "\n";
}

Measured memory_bytes: 3328
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var strN string
	fmt.Scanf("%s", &strN)
	N, _ := strconv.Atoi(strN)

	max := 0
	count := 0
	for i := 0; i < N; i++ {
		var strA string
		fmt.Scanf("%s", &strA)
		A, _ := strconv.Atoi(strA)
		if max < A {
			max = A
		} else {
			count += max - A
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 6436
using System;
using System.Linq;
namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int t = In[0];
            int a = In[1];
            int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            double min = 100100;
            int minidx = -2;
            for(int i = 0; i < n; i++)
            {
                double b = t - 0.006 * H[i];
                double dist = Math.Abs(a - min);
                double disb = Math.Abs(a - b);
                if (dist > disb)
                {
                    min = b;
                    minidx = i;
                }
            }
            Console.WriteLine(minidx+1);
        }
    }
}


Measured memory_bytes: 28624
N  =int(input())
T  =list(map(int,input().split()))
M  =int(input())
P,X = [],[]
for i in range(M):
    p,x = map(int,input().split())
    P.append(p)
    X.append(x)

total = sum(T)
for i in range(M):
    print(total -  T[P[i]-1] + X[i])

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

public class Main {
    static int gcd(int a, int b)
    {
        // Everything divides 0
        if (a == 0)
            return b;
        if (b == 0)
            return a;

        // base case
        if (a == b)
            return a;

        // a is greater
        if (a > b)
            return gcd(a-b, b);
        return gcd(a, b-a);
    }
    public static void main(String[] args) throws Exception{

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));


        int k = fs.nextInt();
      long ans = 0 ;
        for(int i=1 ; i<=k ; i++){
          for(int j=1 ; j<=k ; j++){
          	for(int l=1 ; l<=k ; l++){
            	ans += gcd(gcd(i,j),l);
            }
          }
        }
       
        out.println(ans);
        


        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


Measured memory_bytes: 33232
X = int(input())

ans = 0
if 400 <= X <= 599:
    ans = 8
elif 600 <= X <= 799:
    ans = 7
elif 800 <= X <= 999:
    ans = 6
elif 1000 <= X <= 1199:
    ans = 5
elif 1200 <= X <= 1399:
    ans = 4
elif 1400 <= X <= 1599:
    ans = 3
elif 1600 <= X <= 1799:
    ans = 2
else:
    ans = 1
print(ans)

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

using namespace std;
typedef long long ll;

struct queryData{int l,r,n;}q[500001];
int n,sqrtn,m;
int d[500001],ans[500001],cnt[5000001];

bool cmp(const queryData &p1, queryData &p2){
    if(p1.l/sqrtn==p2.l/sqrtn)return p1.r<p2.r;
    return p1.l/sqrtn<p2.l/sqrtn;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    sqrtn=sqrt(n);
    for(int i=1;i<=n;i++)cin>>d[i];
    for(int i=0;i<m;i++){
        cin>>q[i].l>>q[i].r;
        q[i].n=i;
    }
    sort(q,q+m,cmp);
    int l=q[0].l,r=q[0].r,c=0;
    for(int i=l;i<=r;i++){
        cnt[d[i]]++;
        if(cnt[d[i]]==1){
            c++;
        }
    }
    ans[q[0].n]=c;
    for(int i=1;i<m;i++){
        while(l<q[i].l){
            cnt[d[l]]--;
            if(cnt[d[l]]==0)c--;
            l++;
        }
        while(q[i].l<l){
            l--;
            cnt[d[l]]++;
            if(cnt[d[l]]==1)c++;
        }
        while(r<q[i].r){
            r++;
            cnt[d[r]]++;
            if(cnt[d[r]]==1)c++;
        }
        while(q[i].r<r){
            cnt[d[r]]--;
            if(cnt[d[r]]==0)c--;
            r--;
        }
        ans[q[i].n]=c;
    }
    for(int i=0;i<m;i++)cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 15480
#include<stdio.h>
#include<string.h>
int main()
{
    char a[102],b[102];
    int i,sum1=0,sum2=0,j;
    scanf("%s",a);
    scanf("%s",b);
    for(i=0; a[i]!='\0'; i++){
        sum1=sum1+a[i];
    }

    for(j=0; a[j]!='\0'; j++){
        sum1=sum1+a[j];
    }
    if(sum1<sum2){
        printf("%s%s\n",a,b);
    }
    else{
        printf("%s%s\n",b,a);
    }
}


Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n;


int main(){
    cin>>n;
    multiset<int> l;
    int a;
    for (int i=0;i<n;i++){
        cin>>a;
        l.insert(a);
    }
    int ans=0;
    while (l.empty()==false){
        auto itr=l.end();
        itr--;
        int x=*itr;
        //cout<<x;
        l.erase(itr);
        int j=1;
        while(j<=x){
            j*=2;
        }
        int pairx=j-x;
        //cout<<pairx<<endl;
        if (l.count(pairx)!=0){
            auto itr2=l.find(pairx);
            l.erase(itr2);
            ans+=1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9600
import numpy as np
from numba import njit
import sys
# import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
# A = np.array(list(map(int, (input().split()))))
A = np.array(input().split(), dtype=np.int64)
# A = list(map(int, (input().split())))
# nd = np.zeros((N,N), dtype=bool)
# print(*A)

# @njit('(i8[::1],)', cache=True)
@njit(cache=True)
def loop(A):
    for i in range(K):
        # cnt = [0]*N
        cnt = np.zeros_like(A)
        for j, x in enumerate(A):
            # nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
            l = max(j-x,0)
            r = min(j+x+1,N)
            cnt[l] += 1
            if r<N:
                cnt[r] -= 1
            # for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
            #     cnt[k] += 1
        # print(nd)
        # A = np.count_nonzero(nd, axis=0)
        # print(cnt)
        A = np.cumsum(cnt)
        if A[0] == A[N-1] == N:
            break
        # print(*A)
    return A

A = loop(A)
print(*A)

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

int main(void){
    int n, t[100010], x[100010], y[100010];
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i=0;i<n;++i){
        int z = x[i] + y[i];
        if(t[i]%2==0){
            if(z%2==1 || z>t[i]) {
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(z%2==0 || z>t[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

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

int main() {
  int i = 0;
  string S;
  cin >> S;
  while (i < 3) {
    if ( S.at(i) == S.at(i + 1)) {
      cout << "Bad" << endl;
      break;
    }
    i++;
    if (i == 3) {
      cout << "Good" << endl;
    }
  }
}

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

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  
  vector<double> p(n + 1);
  for(int i = 1; i <= n; i++) cin >> p[i];
  
  vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
  
  dp[0][0] = 1;
  
  for(int i = 1; i <= n; i++){
    dp[i][0] = dp[i - 1][0] * (1 - p[i]);
    for(int j = 1; j <= i; j++){
      dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
    }
  }
  
  double sum = 0;
  for(int i = (n + 1) / 2; i <= n; i++) sum += dp[n][i];
  
  cout << sum << endl;
  
  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<int> a(3*n);
    for (int i=0; i<3*n; ++i) {
        cin >> a.at(i);
    }

    priority_queue<int, vector<int>, greater<int>> usedP, unusedB, unusedDelB;
    priority_queue<int> usedB, usedDelB;
    ll sumP = 0, sumB = 0;
    for (int i=0; i<n; ++i) {
        sumP += a.at(i);
        usedP.push(a.at(i));
    }
    for (int i=n; i<3*n; ++i) {
        if ((int)usedB.size() < n) {
            sumB += a.at(i);
            usedB.push(a.at(i));
        } else if (a.at(i) < usedB.top()) {
            int tmp = usedB.top(); usedB.pop();
            sumB += a.at(i) - tmp;
            usedB.push(a.at(i));
            unusedB.push(tmp);
        } else {
            unusedB.push(a.at(i));
        }
    }
    ll res = sumP - sumB;
    for (int i=n; i<2*n; ++i) {
        while (!usedDelB.empty() && usedDelB.top() == usedB.top()) {
            usedDelB.pop();
            usedB.pop();
        }
        while (!unusedDelB.empty() && unusedDelB.top() == unusedB.top()) {
            unusedDelB.pop();
            unusedB.pop();
        }
        int cur = a.at(i);
        if (cur > usedP.top()) {
            int tmp = usedP.top(); usedP.pop();
            sumP += cur - tmp;
            usedP.push(cur);
        }
        if (cur <= usedB.top()) {
            int tmp = unusedB.top(); unusedB.pop();
            sumB += tmp - cur;
            usedB.push(tmp);
            usedDelB.push(cur);
        } else {
            unusedDelB.push(cur);
        }
        chmax(res, sumP - sumB);
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
 
class Hello
{
    static void aiueo(int w,int h)
    {
        for(int i=1;i<=w;i++)
        {
            if(i==1||i==w)Console.WriteLine(new string('#',h));
            else Console.WriteLine("#{0}#",new string('.',h-2));
        }
        Console.WriteLine();
        return;
    }
    static void Main()
    {
        string [] str=Console.ReadLine().Split(' ');
        int w=int.Parse(str[0]);
        int h=int.Parse(str[1]);
        for(int i=0;w!=0||h!=0;i++)
        {
            aiueo(w,h);
            str=Console.ReadLine().Split(' ');
            w=int.Parse(str[0]);
            h=int.Parse(str[1]);
        }
    }
}


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

int main(){
    int n, k; string s;
    cin >> n >> k >> s;
    s[k-1] += 'a'-'A';
    cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int a[100];
int b[100];
int c[100];
int i;
char op[100];

int main(void){
	
	for(i=0;i<100;i++){
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if(op[i] == '?'){
			break;
		}
	}
	for(i=0;i<100;i++){
		if(op[i] == '+'){
			c[i] = a[i] + b[i];
		}else{
			if(op[i] == '-'){
				c[i] = a[i] - b[i];
			}else{
				if(op[i] == '*'){
					c[i] = a[i] * b[i];
				}else{
					if(op[i] == '/'){
						c[i] = a[i] / b[i];
					}
				}
			}
		}
		printf("%d\n",c[i]);
		if(op[i+1] == '?'){
			break;
		}
	}
	return 0;
}

				

Measured memory_bytes: 600