akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 200010
int f[N],n,mx,pos;
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		f[x]=f[x-1]+1;
		if(f[x]>mx)mx=f[x],pos=x;
	}
	printf("%d\n",n-mx);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 2e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int dp[MAXM][MAXM];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>k;

    for(int i=0;i<=n;i++)
        dp[i][0] = dp[i][i] = 1;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=k;j++)
            dp[i][j] = (dp[i-1][j]+dp[i-1][j-1])%MOD;
    ll res;
    for(int i=1;i<=k;i++){
        if(n-k<i-1)cout<<"0\n";
        else {
            cur = (n-k)-(i-1);
            //cout<<dp[cur+i][i]<<" "<<dp[k-1][i-1]<<"\n";
            res = dp[cur+i][i];
            res *= (ll)dp[k-1][i-1];
            res %= MOD;
            cout<<res<<"\n";
        }
    }

    return 0;
}


Measured memory_bytes: 16000
from collections import deque

# input
K = int(input())

# process/output
dq = deque()
cnt = 0

for i in range(1, 10):
    dq.append(i)

if K > 9:
    cnt = 9
    while cnt < K:
        t = dq.popleft()
        t = t*10 + t%10
        if t%10 != 0:
            dq.append(t-1)
            cnt += 1
        dq.append(t)
        cnt += 1
        if t%10 != 9:
            dq.append(t+1)
            cnt += 1

print(dq[K-cnt-1])


Measured memory_bytes: 6120
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    ans = 0
    c = 1
    while c < B:
        c += A - 1
        ans += 1
    return ans


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6724
t = gets.to_s.to_i

def floor_sum(n, m, a, b)
  res = 0

  if a >= m
    res += (n - 1) * n * (a / m) / 2
    a %= m
  end

  if b >= m
    res += n * (b / m)
    b %= m
  end
  
  y_max = (a * n + b) / m
  x_max = (y_max * m - b)
  
  return res if y_max == 0
  
  # p [n, x_max, a, y_max]
  res += (n - (x_max + a - 1) / a) * y_max
  res += floor_sum(y_max, a, m, (a - x_max % a) % a)
  res
end

t.times do
  n, m, a, b = gets.split.map { |e| e.to_i }
  puts floor_sum(n, m, a, b)
end

Measured memory_bytes: 14352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>

#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))

using namespace std;

void print_func(int *array, int size){
    for (int j = 0; j < size; ++j) {
        cout << ( j ? " " : "" ) << array[j];
    }
    cout << endl;
}

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

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

    print_func(A, GET_ARRAY_SIZE(A));

    int v;
    int tmp;
    for (int i = 1; i < N; ++i) {
        v = A[i];
        tmp = i;
        for (int j = i-1; j >= 0 && A[j] > v ; --j) {
            A[j+1] = A[j];
            tmp = j;
        }
        A[tmp] = v;

        print_func(A, GET_ARRAY_SIZE(A));
    }

}

Measured memory_bytes: 3108
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, M, X;
    scan(N, M, X);
    auto C = new long[](N);
    auto A = new long[][](N);
    foreach (i; 0 .. N)
    {
        auto tmp = aryread();
        C[i] = tmp[0];
        A[i] = tmp[1 .. $];
    }
    long ans = long.max;
    foreach (s; 0 .. 1 << N)
    {
        auto cnt = new long[](M);
        long cost;
        foreach (i; 0 .. N)
            if (s & (1 << i))
            {
                cost += C[i];
                cnt[] += A[i][];
            }
        if (cnt.all!(a => X <= a))
        {
            ans = ans.min(cost);
        }
    }
    writeln(ans == long.max ? -1 : ans);
}


Measured memory_bytes: 3972
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
#define repM1(i, n) for(ll i = (ll)(n - 1); i > 0; i--)
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; }

int main()
{
	cout << fixed << setprecision(18);

	ll a;
	double b;

	cin >> a >> b;
	ll bb = (b * 100) + 0.5;
	
	ll tmp = a * bb;
	ll ans = tmp / 100;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3700
#include<stdio.h>

int main(void)
{
	int num,i,j,r,b;
	char hoge[100];
	
	scanf("%d",&num);
	scanf("%s",hoge);
	
	for(i = 0; hoge[i] != '\0'; i++);
	
	r = 0;
	b = 0;
	
	for(j = 0; j < i; j++){
		if(hoge[j] == 'R'){
			r++;
		}
		
		else if(hoge[j] == 'B'){
			b++;
		}
	}
	
	if(r > b){
		printf("Yes\n");
	}
	
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#define For(N) for (int i = 0; i < N; i++)

using namespace std;
using ll = long long int;
using vi = vector<int>;

int main() {
	int A, B;
	string s;
	string a, b;
	bool flag = true;
	cin >> A >> B >> s;
	a = s.substr(0, A);
	b = s.substr(A + 1, B);
	for (char x : a) {
		if (x < '0' || x > '9')flag = false;
	}
	for (char x : b) {
		if (x < '0' || x > '9')flag = false;
	}
	if (s[A] != '-')flag = false;
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
var input=require("fs").readFileSync("/dev/stdin","utf8");
input=input.split("\n");

var str,oup;
var H,W,h,w;
var i=0;

while(1){
    str=input[i].split(" ");
    H=str[0];
    W=str[1];
    if(H==0&&W==0){
        break;
    }
    
    for(h=0;h<H;h++){
        oup="";
        for(w=0;w<W;w++){
            if(h==0||h==H-1){
                oup+="#";
            }
            else{
                if(w==0||w==W-1){
                    oup+="#";
                }
                else{
                    oup+=".";
                }
            }
        }
        console.log(oup);
    }
    
    console.log();
    i++;
}


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

int main(){
	int n, rmin, lmax;
	cin >> n;
	vector<int> d(n);
	for(int i=0; i<n; i++){
		cin >> d[i];
	}
	sort(d.begin(), d.end());

	//for(int i=0; i<n; i++){
	//	cout << d[i] << " ";
	//}

	rmin = d[n/2];
	lmax = d[n/2-1];
	cout << rmin - lmax << endl;
	return 0;

}

Measured memory_bytes: 768
#include <cstdio>

int search(int s[], int n, int key) {
    int i = 0;
    s[n] = key;
    while (s[i] != key) i++;
    return i != n;
}

int main() {
    int n;
    scanf("%d", &n);
    int s[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }

    int q;
    int answer = 0;
    scanf("%d", &q);
    int key;
    for (int i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(s, n, key)) {
            answer++;
        }
    }
    
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 2756
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int a[] = new int[m+1];
    int b[] = new int[m+1];
    int answer = 0;
    int maxb = -1;
    int maxidx = -1;
    int work = 1;
    boolean flag = true;
	boolean hflag = true;
    for(int i = 1; i <= m; i++){
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    if(n == 1){
      for(int i = 1; i <= m; i++){
        if(a[i] == 1 && b[i] == 1){
          flag = false;
          break;
        }
      }
      if(!flag){
        System.out.println(1);
      }else{
        System.out.println("Impossible");
      }
    }else if(n == 2){
		boolean aflag = false;
		boolean bflag = false;
		int aidx = -1;
		int bidx = -1;
		for(int i = 1; i <= m; i++){
			if(a[i] == 1){
				aflag = true;
				aidx = i;
			}
			if(b[i] == 2){
				bflag = true;
				bidx = i;
			}
		}
		if(aflag && bflag){
			if(aidx != bidx){
				System.out.println(2);
			}else{
				System.out.println(1);
			}
		}else{
			System.out.println("Impossible");
		}
    }else{
      while(work < n){
        maxb = -1;
        for(int i = 1; i <= m; i++){
		  if(hflag){
		  	if(a[i] <= 1){
			  if(b[i] > maxb){
                maxb = b[i];
                maxidx = i;
              }
		  	}
		  }else{
            if(a[i] <= work+1){
              if(b[i] > maxb){
                maxb = b[i];
                maxidx = i;
              }
          	}
		  }
        }
        if(maxb == -1){
          flag = false;
          break;
        }else{
          answer++;
          work = maxb;
          a[maxidx] = 101;
          b[maxidx] = 101;
		  hflag = false;
        }
      }
      if(flag){
        System.out.println(answer);
      }else{
        System.out.println("Impossible");
      }
    }
  }
}



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


int main(){
    int n;
    long long k;
    cin >> n >> k;
    int a[n];
    vector<int> G[n];
    vector<int> c(n ,INT_MAX);
    vector<int> b(n ,INT_MAX);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        a[i]--;
        G[i].push_back(a[i]);
    }
    /**/
    int counter  = 0, roop = 0, initial = 0;
    c[counter] = 0;
    b[0] = counter;
    //printf("%d : %d\n", 0, c[0] + 1);
    while(1){
        c[counter + 1] = a[c[counter]];
        if(b[c[counter + 1]] == INT_MAX){
            b[c[counter + 1]] = counter + 1;
        }
        else{
            //printf("%d : %d\n", counter + 1, c[counter + 1] + 1);
            //printf("%d : %d    %d\n", counter + 1, c[counter + 1] + 1, b[c[counter + 1]]);
            roop = counter + 1 - b[c[counter + 1]];
            //cout << "かぶっているのは" << c[counter + 1] + 1<< endl;
            initial = b[c[counter + 1]];
            //printf("%d - %d\n", counter + 1, b[c[counter + 1]]);
            
            break;
        }
       //printf("%d : %d    %d\n", counter + 1, c[counter + 1] + 1, b[c[counter + 1]] + 1);
        counter++;
    }

    if(k > initial){
        //cout << c[(k - initial + 1)%roop + initial] + 1 << endl;
       // cout  << (k - initial)%roop << endl;
        //cout << roop << endl;
        cout << c[(k - initial)%roop + initial] + 1 << endl;
    }
    else{
        cout  << c[k] + 1<< endl;
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    
    int f = 0;
    for (int j = 0; j <= i; j++) {
      if (n == v.at(j)) f++;
    }
    
    if (!f) v.at(i) = n;
  }
  
  int s = 0;
  for (int i = 0 ; i < N; i++) {
    if (v.at(i)) s++;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> vec(S.size()+2, 0);
    for(int i=0; i<S.size(); i++) {
        vec[i+1] += vec[i];
        if(S[i]=='A' && S[i+1]=='C') vec[i+2]++;
    }
    cout << endl;
    for(int q=0; q<Q; q++) {
        int l, r;
        cin >> l >> r;
        cout << vec[r]-vec[l] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n; cin>>n;
    int a[n];
    int ans=0;
    int t=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        t=0;
        while(t==0){
            t=a[i]%2;
            a[i]=a[i]/2;
            if(t==0) ans++;
        }
    }
    cout<<ans<<endl;
    
    
}



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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

ll isprime[MAX] ;

void sol( ){
    for( ll i=1;i<MAX;i++){
        for( ll j=i;j<MAX;j+=i)
            isprime[j]++ ;
    }
    ll ans=0, n ;
    cin >> n ;
    for( ll i=1;i<=n;i++){
        ll num = n-i ;
        ans += isprime[num] ;
    }
    cout << ans << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
      sol( );
  }
}

Measured memory_bytes: 11464
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
A = many_int()

count=0
index=1
for a in A:
    if a!=index:
        count+=1
    else:
        index += 1

if len(A) == count:
    print(-1)
else:
    print(count)

Measured memory_bytes: 76364
#include<cstdio>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int p=1;for(int i=1;i<=m;i++) p*=2;
    p*=1900*m+100*(n-m);
    printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 128
H, W = map(int,input().split())
grid = [input() for _ in range(H)]

row = [False]*H
col = [False]*W

for i in range(H):
  for j in range(W):
    if grid[i][j] == "#":
      row[i] = True
      col[j] = True

for i in range(H):
  if row[i]:
    for j in range(W):
      if col[j]:
        print(grid[i][j], end="")
    print()

Measured memory_bytes: 4468
#include<stdio.h>
int main(){
  int n=1; 
  long long int a=0;
  long long int b=0;
  while(scanf("%d",&a) != EOF){
    scanf("%d",&b);
    a+=b;
    while(a/10!=0){
      n++;
      a=a/10;
    }
    printf("%d\n",n);
    n=1;
  }
  return(0);
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <string.h>
char X[1001],Y[1001];
int q;
int LCSLength(){
  int m,n,i,j;
  int c[1001][1001];
  m=strlen(X);
  n=strlen(Y);
  for(i=1;i<=m;i++){
    c[i][0]=0;
  }
  for(j=0;j<=n;j++){
    c[0][j]=0;
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){

      if(X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;

      else if(c[i-1][j] >= c[i][j-1]) c[i][j]=c[i-1][j];

      else c[i][j]=c[i][j-1];
    }
  }
  printf("%d\n",c[m][n]);



}
int main(){
  int i;
  scanf("%d",&q);

  for(i=1;i<=q;i++){
    scanf("%s",X);
    scanf("%s",Y);
    LCSLength();
  }
  return 0;
}

Measured memory_bytes: 4512
#include <bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v)      \
    {                            \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                         \
    cerr << #v ":" << endl;              \
    for (auto macro_row : v)             \
    {                                    \
        cerr << "[";                     \
        for (auto macro__vi : macro_row) \
        {                                \
            cerr << macro__vi << " ";    \
        }                                \
        cerr << "]" << endl;             \
    }
#define damp(m)                                                       \
    for (auto macro_pair : m)                                         \
    {                                                                 \
        cerr << macro_pair.first << ":" << macro_pair.second << endl; \
    }
#define dpair(p) cerr << #p ":" \
                      << "(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();

    bool good = true;
    for (int i = 1; i <= n; i++)
    {
        // dd(i, s[i-1])
        char c = s[i - 1];
        if (i % 2 == 0)
        {
            if (c == 'L' or c == 'U' or c == 'D')
                continue;
            else
            {
                good = false;
                break;
            }
        }
        else
        {
            if (c == 'R' or c == 'U' or c == 'D')
                continue;
            else
            {
                good = false;
                break;
            }
        }
    }
    if (good)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
# tokenakatta ...
def main():
    N, K = map(int, input().split())
    l = []
    for _ in range(N):
        t, d = map(int, input().split())
        l.append((t, d))
    l.sort(key=lambda x:x[1], reverse=True)
    s = set()
    e = []
    t = 0
    for i in range(K):
        t += l[i][1]
        if l[i][0] in s:
            e.append(l[i])
        else:
            s.add(l[i][0])
    rl = [t + len(s) * len(s)]
    e.reverse()
    ei = 0
    for i in range(K, N):
        if l[i][0] in s:
            continue
        if ei >= len(e):
            break
        s.add(l[i][0])
        t -= e[ei][1]
        t += l[i][1]
        ei += 1
        rl.append(t + len(s) * len(s))
    return max(rl)
print(main())


Measured memory_bytes: 19456
#include <stdio.h>

int main(void) {

	int w,h;
	int i ,j;

	while(1){
		scanf("%d %d",&h,&w);
		if((w ==0) || (h == 0)){
			break;
		}
		for(i=0;i < h;i++){
			if((i == 0) || (i == h-1)){
				for(j = 0;j<w;j++){
					printf("#");
				}
			}else{
				for(j = 0;j<w;j++){
					if((j == 0) || (j == w-1)){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}



Measured memory_bytes: 2044
import math
k = int(input())
ans = 0
def gcd(a, b, c):
    p = math.gcd(a, b)
    return math.gcd(p, c)

for i in range(1, k+1):
    for j in range(i, k+1):
        for l in range(j, k+1):
            if i == j and j == l:
                ans += i
            elif i==j or j==l or l==i:
                ans += 3*gcd(i, j, l)
            else:
                ans += 6 * gcd(i, j, l)
print(ans)

Measured memory_bytes: 68440
#include <stdio.h>
int main() {
	int a, num[100] = {0}, cnt = 0;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a);
		num[a - 1]++;
	}
	for (int i = 0; i < 100; i++) {
		if (num[i] >= 1) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost {ios_base::sync_with_stdio(false);}
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PII, PII> PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
typedef vector <int> vi;
const int mod = 1e9+7;
const int inf = 1e9+10;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
#define maxn 1010100
int n, m, zap;

int bucket[maxn], ile[maxn], wyn, a, b, tab[maxn];

void addBucket(int x, int type)
{
	if (x <= 0) return;
	wyn += (bucket[x] > 0)?1:0;
	bucket[x] += type;
	wyn -= (bucket[x] > 0)?1:0;
}

void addElement(int x, int type)
{
	int pos = x - ile[x];
	if (type < 0) pos++;
	addBucket(pos, type);
	ile[x] += type;
}

int main()
{
	boost;
	cin >> n >> zap;
	wyn = n;
	FOR(i, 1, n)
	{
		cin >> a;
		addElement(a, 1);
		tab[i] = a;
	}
	FOR(i, 1, zap)
	{
		cin >> a >> b;
		addElement(tab[a], -1);
		tab[a] = b;
		addElement(tab[a], 1);
		cout << wyn << "\n";
	}
}


Measured memory_bytes: 10496
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $sqrt = floor(sqrt($n));

  $a=0; $b=0;
  for($i=1; $i<=$sqrt; $i++){
    if($n%$i==0){
      $a=$i;
      $b=$n/$i;
    }
  }
  echo $a+$b-2;

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

const int A=0,G=1,C=2,T=3;
long long dp[111][4][4][4];
int main(){
    int n;
    cin>>n;
    int mod=1000000007;
    dp[0][T][T][T]=1;
    for(int i=0 ; i<n ; ++i){
        for(int j=0 ; j<4 ; ++j){
            for(int k=0 ; k<4 ; ++k){
                for(int l=0 ; l<4 ; ++l){
                    for(int m=0 ; m<4 ; ++m){
                        if(k==A && l==G && m==C)continue;
                        if(k==G && l==A && m==C)continue;
                        if(k==A && l==C && m==G)continue;
                        if(j==A && l==G && m==C)continue;
                        if(j==A && k==G && m==C)continue;
                        (dp[i+1][k][l][m] += dp[i][j][k][l]) %= mod;
                    }
                }
            }
        }
    }
    long long ans=0;
    for(int i=0 ; i<4 ; ++i){
        for(int j=0 ; j<4 ; ++j){
            for(int k=0 ; k<4 ; ++k){
                ans += dp[n][i][j][k];
            }            
        }
    }
    cout<<ans%mod<<endl;
    return 0;
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string s;
	cin >> s;
	if(s[0] == s[2]){
		P("Yes");
	}else{
		P("No");
	}
}

int main() {
    solve();
    return 0;
}


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

dic={}
for i in range(n):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1


dic = sorted(dic.items(),key=lambda x:x[0])
dic = sorted(dic,key=lambda x:x[1],reverse=True)

ma=dic[0][1]
for i,v in dic:
  if v!=ma:
    break
  else:
    print(i)

Measured memory_bytes: 146772
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let x : i32 = get_one();
    println!("{}", x * 800 - (x / 15) * 200)
}


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

const int MAXN = 3e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

ll a[MAXN],sums[MAXN],xorr[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    ll n;cin >> n;
    for(ll i=1;i<=n;++i) cin >> a[i];
    for(ll i=1;i<=n;++i) sums[i] = sums[i-1] + a[i],xorr[i] = xorr[i-1] ^ a[i];
    ll res=0;
    for(ll i=1;i<=n;++i){
        ll l = 0,r = i;
        while(r-l > 1){
            ll mid = l + (r-l) / 2;
            if(sums[i] - sums[mid-1] == (xorr[i] ^ xorr[mid-1])) r = mid;
            else l=mid;
        }
        res += i - r +1;
    }
    cout << res;
}



Measured memory_bytes: 6016
#include <stdio.h>
#include <stdlib.h>
#include <math.h> 


int main(void)
{
	int a , b ;
	char op;
	while(scanf("%d %c %d" , &a , &op , &b))
	{
		if(op == '?')
		{
			break;
		}
		switch(op)
		{
			case '+': printf("%d\n" , a + b); break;
			case '-': printf("%d\n" , a - b); break;
			case '*': printf("%d\n" , a * b); break;
			case '/': printf("%d\n" , a / b); break;
		}
		
	}
	return 0;
}



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

int main() {
	int N,M,a,b,r=0;
	cin >> N >> M;
	Graph g(N);
	vector<P> p(M);

	rep(i,M) {
		cin >> a >> b;
		--a, --b;
		g.at(a).push_back(b);
		g.at(b).push_back(a);
		p.at(i) = P(a,b);
	}

	rep(i,M) {
		int c=0;
		vector<bool> s(N,0);
		queue<int> q;
		q.push(0);

		while(!q.empty()) {
			int x = q.front();
			q.pop();
			s.at(x)=1;

			for(auto nx : g.at(x)) {
				if((x==p.at(i).first && nx==p.at(i).second) || (nx==p.at(i).first && x==p.at(i).second) || s.at(nx))
					continue;
				q.push(nx);
			}
		}

		rep(j,N)
			if(s.at(j))
				++c;
		if(c != N)
			++r;
	}

	cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rrep(i,n) for(int i = 1;i <= n;i++)
#define drep(i,n) for(int i = n;i >= 1;i--)

int a[5010], n, k;
bitset<5010> dp1[5010], dp2[5010];

int solve(int mid){
	if(a[mid] >= k)return 1;
	bitset<5010> dp = dp2[mid+1];
	rrep(i,k)if(dp1[mid-1][i])dp |= dp2[mid+1]<<i;
	dp[k] = 0;
	drep(i,k-1)dp[i] = max(dp[i],dp[i+1]);
	return dp[k-a[mid]];
}

signed main(){
	scanf("%lld%lld", &n, &k);
	rrep(i,n)scanf("%lld", &a[i]);
	
	sort(a+1,a+n+1);
	dp1[0] = dp2[n+1] = 1;
	rrep(i,n)dp1[i] = dp1[i-1] | dp1[i-1]<<a[i];
	drep(i,n)dp2[i] = dp2[i+1] | dp2[i+1]<<a[i];
	
	int lb = 0, ub = n+1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		if(solve(mid))ub = mid;
		else lb = mid;
	}
	printf("%lld\n", ub-1);
	return 0;
}

Measured memory_bytes: 6528
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int n;
    Edge[] g;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        n = sc.nextInt();
        g = new Edge[n];
        for (int i = 0; i < n; i++) {
            g[i] = new Edge();
        }

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1, b = sc.nextInt() - 1, c = sc.nextInt();
            g[a].add(new Node(b, c));
            g[b].add(new Node(a, c));
        }

        int q = sc.nextInt(), k = sc.nextInt() - 1;
        long[] ds = new long[n];
        dfs(-1, k, 0, ds);

        for (int i = 0; i < q; i++) {
            int x = sc.nextInt() - 1, y = sc.nextInt() - 1;
            out.println(ds[x] + ds[y]);
        }

        out.flush();
    }

    void dfs(int par, int cur, long d, long[] ds) {
        ds[cur] = d;
        for (Node next : g[cur]) {
            if (next.to == par) continue;
            dfs(cur, next.to, d + next.cost, ds);
        }
    }

    class Edge extends ArrayList<Node> {}

    class Node {
        int to;
        long cost;
        Node(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 196712
#include <bits/stdc++.h>
#define F first
#define S second
#define mkp(x, y) make_pair(x, y)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll a[22222];
int main()
{
	ll x;
	cin >> x;
	a[1] = 1;
	for(int i = 2; i <= 1000; i ++)
	{
		ll k = i*i;
		while(1)
		{
			if(k > 1000)
				break;
			a[k] = 1;
			k *= i;
		}
	}
	for(int i = x; i >= 1; i --)
	{
		if(a[i])
		{
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define anin(a) printf("%d\n",a);
#define ando(a)printf("%lf\n",a);

int main(void){
	int N,ans(0);
	scanf("%d",&N);
	int A[N],B[N],C[N - 1];
	rep(i,0,N){
		scanf("%d",&A[i]);
	}
	rep(i,0,N){
		scanf("%d",&B[i]);
	}
	rep(i,0,N - 1){
		scanf("%d",&C[i]);
	}
	rep(i,0,N){
		ans += B[A[i] - 1];
		if(A[i] + 1 == A[i + 1] && i <= N -1){
			ans += C[A[i] - 1];
		}
	}
	anin(ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

res = 0
for i in range(10):
  idx_1 = S.find(str(i))
  if (idx_1 == -1) or (idx_1 > N-3):
    continue
  for j in range(10):
    idx_2 = S[idx_1+1:].find(str(j))
    if (idx_2 == -1) or (idx_2 > N-2):
      continue
    for k in range(10):
      idx_3 = S[idx_1+1+idx_2+1:].find(str(k))
      if idx_3 != -1:
        res += 1

print(res)


Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type student struct {
	no, arv int
}
type stdList []student

func (a stdList) Len() int           { return len(a) }
func (a stdList) Less(i, j int) bool { return a[i].arv < a[j].arv }
func (a stdList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make(stdList, N)
	for i := 0; i < N; i++ {
		A[i].no = i + 1
		A[i].arv = scanInt()
	}
	sort.Sort(A)

	for i := 0; i < N; i++ {
		fmt.Printf("%d ", A[i].no)
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 4224
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
    }
    println!("{}", s.replace(",", " "));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	cout << "ABC" << n <<endl;

	return 0;
}



Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    K = int(readline())

    x = K // 2
    y = (K + 1) // 2

    print(x * y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61708
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
lint gcd(lint a, lint b) {
  if(a < b) {
    swap(a, b);
  }
  while(b > 0) {
    lint r = a % b;
    a = b;
    b = r;
  }
  return a;
}
lint lcm(lint a, lint b) {
  return a * b / gcd(a, b);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint K;
    cin >> K;
    lint ans = 0;
    FOR(i, 1, K+1) {
        FOR(j, 1, K+1) {
            FOR(k, 1, K+1) {
                ans += gcd(gcd(i, j), k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
from itertools import permutations

n = int(input())
p = [int(x) for x in input().split(' ')]
q = [int(x) for x in input().split(' ')]

p, q = tuple(p), tuple(q)

d = list(range(1, n+1))

a = 0
b = 0

for i, x in enumerate(permutations(d)):
    if x == p:
        a = i
    if x == q:
        b = i

print(abs(a - b))


Measured memory_bytes: 3064
from collections import deque
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
CH, CW = map(lambda x: int(x) - 1, input().split())
DH, DW = map(lambda x: int(x) - 1, input().split())
S = [input().rstrip() for _ in range(H)]
v = [[False] * W for _ in range(H)]
dq = deque([(0, CH, CW)])
while dq:
    d, h, w = dq.popleft()
    if (h, w) == (DH, DW):
        print(d)
        exit()
    if v[h][w]:
        continue
    v[h][w] = True
    for mh, mw in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        nh, nw = mh + h, mw + w
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
            dq.appendleft([d, nh, nw])
    for mh in range(-2, 3):
        for mw in range(-2, 3):
            if mh == mw == 0:
                continue
            nh, nw = mh + h, mw + w
            if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and not v[nh][nw]:
                dq.append([d + 1, nh, nw])
print(-1)

Measured memory_bytes: 236972
while True:
    n = int(input())
    if n == 0: break

    dic = {
        0: 0, 1: 0, 2: 0, 3: 0, 4: 0,
        5: 0, 6: 0, 7: 0, 8: 0, 9: 0
    }
    for _ in range(n):
        c = int(input())
        dic[c] += 1

    for v in dic.values():
        print('*' * v if v != 0 else '-')


Measured memory_bytes: 5620
n, m = input().split(" ")
n = int(n)
m = int(m)

votes = input().split(" ")
votes = [int(vote) for vote in votes]
votes.sort(reverse=True)

check_vote = votes[m-1]

if check_vote >= sum(votes) / (4*m):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		ArrayList<Integer> arr = new ArrayList<Integer>();
		
		for (int i = 0; i < N; i++) {
			int temp = input.nextInt();
			if(!arr.contains(temp)) {
				arr.add(temp);
			}
		}
		System.out.println(arr.size());
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int>p(n);
  rep(i,n) cin >> p[i];
  vector<int>s(n);
  rep(i,n) s[i] = p[i];
  sort(s.begin(), s.end());
  string ans = "NO";
  bool ex = true;;
  rep(i,n) {
    if (p[i] != s[i]) ex = false;
  }
  if(ex) ans = "YES";
  rep(i,n - 1) {
    for (int j = i + 1; j < n; j++) {
      vector<int>a(n);
      rep(k,n) a[k] = p[k];
      swap(a[i], a[j]);
      bool b = true;
      rep(k,n) {
        if (a[k] != s[k]) b = false;
      }
      if(b) ans = "YES";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const int INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    reverse(all(s));
    if (s == t) PRINT("YES");
    else PRINT("NO");
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,t,a,h,x,tt,mn,mi,i;
	scanf("%d",&n);
	scanf("%d %d",&t,&a);
	mn=2000000000;
	for(i=1;i<=n;i++)	{
		scanf("%d",&h);
		tt=t*1000-h*6;
		x=a*1000-tt;
		if(x<0)	x=-x;
		if(mn>x)	{
			mn=x;	mi=i;
		}
	}
	printf("%d\n",mi);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define NIL -1 
using namespace std;
// A class that represents an undirected graph 
int bridges;
class Graph 
{ 
    int V;    // No. of vertices 
    list<int> *adj;    // A dynamic array of adjacency lists 
    void bridgeUtil(int v, bool visited[], int disc[], int low[], 
                    int parent[]); 
public: 
    Graph(int V);   // Constructor 
    void addEdge(int v, int w);   // to add an edge to graph 
    void bridge();    // prints all bridges 
}; 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V]; 
} 
  
void Graph::addEdge(int v, int w) 
{ 
    adj[v].push_back(w); 
    adj[w].push_back(v);  // Note: the graph is undirected 
} 
  
// A recursive function that finds and prints bridges using 
// DFS traversal 
// u --> The vertex to be visited next 
// visited[] --> keeps tract of visited vertices 
// disc[] --> Stores discovery times of visited vertices 
// parent[] --> Stores parent vertices in DFS tree 
void Graph::bridgeUtil(int u, bool visited[], int disc[],  
                                  int low[], int parent[]) 
{ 
    // A static variable is used for simplicity, we can  
    // avoid use of static variable by passing a pointer. 
    static int time = 0; 
  
    // Mark the current node as visited 
    visited[u] = true; 
  
    // Initialize discovery time and low value 
    disc[u] = low[u] = ++time; 
  
    // Go through all vertices aadjacent to this 
    list<int>::iterator i; 
    for (i = adj[u].begin(); i != adj[u].end(); ++i) 
    { 
        int v = *i;  // v is current adjacent of u 
  
        // If v is not visited yet, then recur for it 
        if (!visited[v]) 
        { 
            parent[v] = u; 
            bridgeUtil(v, visited, disc, low, parent); 
  
            // Check if the subtree rooted with v has a  
            // connection to one of the ancestors of u 
            low[u]  = min(low[u], low[v]); 
  
            // If the lowest vertex reachable from subtree  
            // under v is  below u in DFS tree, then u-v  
            // is a bridge 
            bridges += low[v] > disc[u]; 
        } 
  
        // Update low value of u for parent function calls. 
        else if (v != parent[u]) 
            low[u]  = min(low[u], disc[v]); 
    } 
} 
  
// DFS based function to find all bridges. It uses recursive  
// function bridgeUtil() 
void Graph::bridge() 
{ 
    // Mark all the vertices as not visited 
    bool *visited = new bool[V]; 
    int *disc = new int[V]; 
    int *low = new int[V]; 
    int *parent = new int[V]; 
  
    // Initialize parent and visited arrays 
    for (int i = 0; i < V; i++) 
    { 
        parent[i] = NIL; 
        visited[i] = false; 
    } 
  
    // Call the recursive helper function to find Bridges 
    // in DFS tree rooted with vertex 'i' 
    for (int i = 0; i < V; i++) 
        if (visited[i] == false) 
            bridgeUtil(i, visited, disc, low, parent); 
} 
int main() {
  int N,M,a,b;
  cin >> N;
  Graph G(N);
  for (cin >> M; M; M--) {
    cin >> a >> b;
    G.addEdge(--a,--b);
    G.addEdge(b,a);
  }
  G.bridge();
  cout << bridges;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll res=1;a%=mod;for(;b;b>>=1){if(b&1) res=res*a%mod;a=a*a%mod;}return res;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=998244353;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N=1e3+10;
int main()
{
    sync;
    ll a,b,c;
    cin>>a>>b>>c;
    if(c-a-b<0)
        return cout<<"No"<<endl,0;
    if(4*a*b<(c-a-b)*(c-a-b))
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include    <iostream>
#include    <stack>

using namespace std;

int main() {
    int n;
    stack<int> array;
    
    cin >> n;
    for(int i = 0; i < n; i++) {
        int buff;

        cin >> buff;
        array.push(buff);
    }
    while(!array.empty()) {
        cout << array.top();
        array.pop();
        if(!array.empty()) cout << ' ';
    }
    cout << endl;

    return 0;
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)

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

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

int main() {
    ll N, x;
    cin >> N >> x;
    
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    
    ll ans = 0;
    rep(i, N-1) {
        ll j = i + 1;
        ll sum = a[i] + a[j];
        if (sum <= x) continue;
        
        ll dx = sum - x;
        dx = (a[j] >= dx ? dx : a[j]);
        
        a[j] -= dx;
        ans  += dx;
        sum = a[i] + a[j];
        if (sum <= x) continue;
        
        dx = sum - x;
        a[i] -= dx;
        ans  += dx;
        sum = a[i] + a[j];
        if (sum <= x) continue;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <string>

using namespace std;

typedef pair<int, int> WESet;

int main()
{
    int n; cin >> n;
    int ret = 0;
    // int a[n];
    // vector<int> a;
    map<string, int> a;

    for (int i = 0; i < n; i++) {
        string x; cin >> x;
        a[x] += 1;
        if (a[x] % 2 != 0) ret++;
        else if (a[x] % 2 == 0) ret--;

        // a.push_back(x);
        // cin >> a[i];
        // b.push_back(a[i]);
        // int cnt = count(b.begin(), b.end(), a[i]);
        // if (cnt % 2 != 0) ret++;
        // else if (cnt % 2 == 0) ret--;
    }



    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>

int main(void){

  int a,b,c,i;
  int count=0;

  scanf("%d%d%d",&a,&b,&c);

  for(i=a; i<=b; i++){
    if(c%i == 0)count++;
  }

  printf("%d\n",count);

return 0;
}

Measured memory_bytes: 1812