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

class Main{
	public static void main(String[] args){
	
	Scanner sc = new Scanner(System.in);
	
	int a = sc.nextInt();
	int b = sc.nextInt();
	double A = (double)a;
	double B = (double)b;
	
	System.out.printf("%d %d %f", a/b, a%b, A/B);

	}
}


Measured memory_bytes: 26556
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int x[5];

int solve() {
    for (int i = 0; i < 5; i++) {
        if (x[i] == 0) {
            return i+1;
        }
    }
    return 0;
}

void input() {
    for (int i = 0; i < 5; i++) cin >> x[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3516
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int, int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[] = { 1, 0, -1, 0 }, DY[] = { 0, -1, 0, 1 };

int combination(int a, int n,int s){
	if (a == 10){
		return s == 0 && n == 0;
	}
	else
		return combination(a + 1, n - 1, s - a) + combination(a + 1, n, s);
}

int main(){
	int n, s;

	while(cin >> n >> s && n){

		cout << combination(0, n, s) << endl;
	
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,a,b;
  cin >> x >> a >> b;
  int a_d=a-x;
  int b_d=b-x;
  if(a_d<0)
    a_d*=-1;
  if(b_d<0)
    b_d*=-1;
  if(a_d>b_d)
    cout << "B" << endl;
  else
    cout << "A" << endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())で降順に,reverse()で逆に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,何文字)で文字列ゲット
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll n;  cin >> n;
  ll ans = 0;
  rep(i,n){
    ans += i;
  }
  cout << ans;
  // cout << 0.5*(n-1)*n;
  return 0;
}


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

using namespace std;

#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;

void solve() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    vector<vector<int>> dp(n + 1, vector<int>(s + 1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= s; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - a[i] < 0) continue;
            if (j - a[i] == 0) dp[i][j] += dp[i - 1][j - a[i]] + i;
            else dp[i][j] += dp[i - 1][j - a[i]];
            dp[i][j] %= MOD;
        }
        ans = (ans + dp[i][s]) % MOD;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    cout << fixed;
    solve();
}

Measured memory_bytes: 70784
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
#define make_pair mp
#define first f
#define second s
int dp[205][105];
int cloth[205][3];
int temp[205],n,d;
int main(){
memset(dp,-1,sizeof(dp));
scanf("%d %d",&d,&n);
for(int i=1;i<=d;i++){
	scanf("%d",&temp[i]);
}
for(int i=1;i<=n;i++){
	scanf("%d %d %d",&cloth[i][0],&cloth[i][1],&cloth[i][2]);
}
for(int i=1;i<=n;i++){
	if(cloth[i][0]<=temp[1] && temp[1]<=cloth[i][1]){
		dp[1][cloth[i][2]]=0;
	}
}
for(int i=2;i<=d;i++){
	for(int j=1;j<=n;j++){
		if(cloth[j][0]<=temp[i] && temp[i]<=cloth[j][1]){
			for(int h=0;h<=100;h++){
				if(dp[i-1][h]!=-1){
					dp[i][cloth[j][2]]=max(dp[i][cloth[j][2]],dp[i-1][h]+max(cloth[j][2],h)-min(h,cloth[j][2]));
				}
			}
		}
	}
}
int ans=0;
for(int i=0;i<=100;i++){
	ans=max(ans,dp[d][i]);
}
printf("%d\r\n",ans);
return 0;
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,z,e;
    scanf("%1d%1d%1d%1d",&x,&y,&z,&e);
    if(x==y||y==z||z==e)printf("Bad\n");
    else printf("Good\n");
    return 0;
}



Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=float('inf')

for i in range(0,n-k+1):
  b=a[i]
  c=a[i+k-1]
  if c<=0:
    ans=min(ans,abs(b))
  elif b>=0:
    ans=min(ans,abs(c))
  else:
    ans=min(ans,abs(c)+abs(b)*2,abs(c)*2+abs(b))
    
print(ans)

Measured memory_bytes: 20136
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
import queue
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(10000)


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(N, A, B, X):
    ans = 0
    c = X[0]
    for x in X[1:]:
        ac = A*(x - c)
        if ac > B:
            ans += B
        else:
            ans += ac
        c = x

    return ans


def main():
    N, A, B = read_int_n()
    X = read_int_n()

    print(slv(N, A, B, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 88428
import java.util.Scanner;
public class Main{
    static int stack[]=new int[101];
	public static void main(String[] args) {
		int i=0;
		String s;
		// TODO Auto-generated method stub
    Scanner sc= new Scanner(System.in);
	s=sc.next();
    while(true){
    	if(Number(s)){
    	 i++;
    	 stack[i]=Integer.parseInt(s);
    	 }else{
    		 if(s.equals("+")){
    			 stack[i-1]=stack[i-1]+stack[i];
    			 i--;
    		 }
    		if(s.equals("-")){
    			stack[i-1]=stack[i-1]-stack[i];
    			i--;
    		}
    		if(s.equals("*")){
    			stack[i-1]=stack[i-1]*stack[i];
    			i--;
    		}
    		if(s.equals("/")){
    			stack[i-1]=stack[i-1]/stack[i];
    			i--;
    		}
    	 
     }
    	if(!sc.hasNext()) break;
    	s=sc.next();
    }
    System.out.println(stack[1]);
	}
	public static boolean Number(String a){
		try{
			Integer.parseInt(a);
		return true ;
		}catch(Exception e){
		return false;
	}
}
}


Measured memory_bytes: 26360
#include<iostream>
using namespace std;
int main()
{
	char s[4];
	int flag=0;
	scanf("%s",&s);
	for(int i=1;i<4;i++)
	{
		if(s[i]==s[i-1])
		{
		flag=1;break;
		}
	}
	if(flag==1)
	cout<<"Bad";
	else
	cout<<"Good";
} 

Measured memory_bytes: 3644
n=int(input())
for i in range(3500):
    for j in range(3500):
        if 4*i*j-n*(i+j)>0 and n*i*j%(4*i*j-n*(i+j))==0:
            print(i,j,n*i*j//(4*i*j-n*(i+j)))
            exit()

Measured memory_bytes: 8964
from bisect import bisect_left, bisect_right
n = int(input())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

ans = 0
for b in bl:
    # b未満の要素の個数
    a_cnt = bisect_left(al,b)
    # bより大きい要素の個数
    c_cnt = n - bisect_right(cl,b)
    ans += a_cnt*c_cnt

print(ans)

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

int main(void){
    long long n;
    long long ans=0;
    cin>>n;
    for(long long i=n;ans==0;i++){
        bool sosuu=true;
        for(long long j=2;j*j<=i;j++){
            if(i%j==0){
                sosuu=false;
                break;
            }
        }
        if(sosuu){
            ans=i;
            break;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
#define MOD 1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define debug2 cout<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){

  int N;cin>>N;
  vector<vector<int>> F(N,vector<int>(10)),P(N,vector<int>(11));
  REP(i,0,N)REP(j,0,10)cin>>F[i][j];
  REP(i,0,N)REP(j,0,11)cin>>P[i][j];
  int ans=-INF;

  for (int bit = 1; bit < 1024; ++bit) {
    vector<int> open(10,0),counts(N,0);
    for (int i = 0; i < 10; ++i) {
      if(bit&(1<<i)){
        REP(j,0,N){
          if(F[j][i]){
            counts[j]+=1;
          }
        }
      }
    }
    int tmp=0;
    REP(i,0,N){
      tmp+=P[i][counts[i]];
    }
    ans=max(ans,tmp);
  }
  print(ans)

}


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

using namespace std;
int a;
vector<int> yoyo;
int main(){
  int a;
  cin>>a;
  for(int i=0;i<a;i++){
    int b;
    cin>>b;
    yoyo.push_back(b);
  }
  sort(yoyo.begin(),yoyo.end());
  int count=0;
  for(int i=0;i<a;i++){
    if(i!=a-1)count+=yoyo[i];
    else count+=yoyo[i]/2;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lop ios; ll t; cin>>t; while(t--)
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl "\n"
typedef long long ll;
ll lcm(ll x, ll y){ll k=x*y; k/=(__gcd(x,y)); return k;}
ll power(ll x,ll y){ ll r= 1;x = x % M;if(x==0) return 0; while(y>0) {if(y&1) r=(r*x)%M; y=y>>1; x=(x*x)%M;} return r;}  
ll check(string str) 
{ 
    
    ll  n = str.length(); 
    ll  digitSum = 0; 
    for (int i=0; i<n; i++) 
        digitSum += (str[i]-'0'); 
  
    
    return (digitSum % 9 == 0); 
} 
void solve()
{ 
 ll n;
 cin>>n;
 vi v(n);
 for(auto &i:v) cin>>i;
 ll ans=0;
 for(ll i=1;i<n;i++){
     ll tmp=v[i-1];
     while(v[i]<=tmp and i<n){
         ans=ans+(tmp-v[i]);
         i++;
     }
 }
 cout<<ans;
}
int main() 
{ 
    // lop
    solve();
	return 0; 
} 




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

using namespace std;

typedef long long ll;
typedef long double ld;



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

    int n;
    string s;
    cin >> n >> s;

    if (n % 2 == 0)
    {
        n /= 2;
        for (int i = 0; i < n; i++)
        {
            if (s[i] != s[i + n])
            {
                cout << "No\n";
                return 0;
            }
        }
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
  in(int, N);
  N = (N/111) + !!(N%111);
  out(111*N);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 410


int main() {
	vector<int>a;
	vector<int>b;
	int n, x;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &x);
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	f(i, n) {
		if (i > 0) {
				if ((a[i] - a[i-1]) % 2 == 0) {
					b.push_back(((b[b.size() - 1] + 1) % 2));
					if (b.size() >= n) {
						if (b[n - 1] == 1)printf("Second\n");
						else printf("First\n");
						return 0;
					}
					f(j, a[i] - a[i-1]) {
						if (j % 2 == 0)b.push_back(0);
						else b.push_back(1);
						if (b.size() >= n) {
							if (b[n - 1] == 1)printf("Second\n");
							else printf("First\n");
							return 0;
						}
					}
				}
				else {
					b.push_back(0);
					if (b.size() >= n) {
						if (b[n - 1] == 1)printf("Second\n");
						else printf("First\n");
						return 0;
					}
					f(j, a[i] - a[i-1]) {
						if (j % 2 == 0)b.push_back(1);
						else b.push_back(0);
					if (b.size() >= n) {
						if (b[n - 1] == 1)printf("Second\n");
						else printf("First\n");
						return 0;
					}
				}

				}
         }
		else {
			if (a[i] % 2 == 0) {
				f(j, a[i]) {
					if (j % 2 == 0)b.push_back(0);
					else b.push_back(1);
					if (b.size() >= n) {
						if (b[n - 1] == 1)printf("Second\n");
						else printf("First\n");
						return 0;
					}
				}
			}
			else {
				f(j, a[i]) {
					if (j % 2 == 0)b.push_back(1);
					else b.push_back(0);
				if (b.size() >= n) {
					if (b[n - 1] == 1)printf("Second\n");
					else printf("First\n");
					return 0;
				}
			}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  if(a+b<=c*2){
  	cout<<(a*x)+(b*y)<<endl;
  }else{
  	int ans = 0;
  	ans+=min(x,y)*c*2;
  	if(x>y){
  	  x-=y;
  	  if(a<=c*2){
  	  	ans+=x*a;
  	  }else{
  	  	ans+=x*c*2;
  	  }
  	}else{
  	  y-=x;
  	  if(b<=c*2){
  	  	ans+=y*b;
  	  }else{
  	  	ans+=y*c*2;
  	  }
  	}
  	cout<<ans<<endl;
  }
}




Measured memory_bytes: 256
a,b=map(int,input().split())
import fractions
gcds=fractions.gcd(a,b)
cnt=0
primelist=[2]

while gcds%2==0:
    gcds=gcds//2
    cnt+=1
#この時点でgcdsは奇数になっているはずである
n = 10**6
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                #エラトステネスの篩
prime.remove(2)

for some in prime:
    if gcds%some==0:
        while gcds%some==0:
            gcds=int(gcds/some)
        primelist.append(some)  

if gcds!=1 and cnt>=1:
    primelist.append("larger")
    primelist.append(1)
    
elif gcds!=1 and cnt==0:
    primelist.append("larger")
    primelist.remove(2)
    primelist.append(1)
elif gcds==1 and cnt>=1:
    primelist.append(1)
elif gcds==1 and cnt==0:
    primelist.remove(2)
    primelist.append(1)

print(len(primelist))

Measured memory_bytes: 76484
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int main()
{
  int res,p,q,N,M,Q,L[200001],R[200001],sum[501][501];
  cin >> N >> M >> Q;
  REP(i,M)cin >> L[i] >> R[i];
  REP(i,501)REP(j,501)sum[i][j] = 0;
  REP(i,M)sum[L[i]][R[i]]++;
  for(int i=1;i<=N;i++)
    for(int j=1;j<=N;j++){
      sum[i][j] += sum[i][j-1];
    }
  REP(i,Q){
    res = 0;
    cin >> p >> q;
    for(int i=p;i<=q;i++)
      res += sum[i][q]-sum[i][p-1];
    cout << res << endl;
  }
}

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

int main(){
long int N;
 cin >> N;
long int F,B,FB;
 F=0;
 B=0;
 FB=0;
  
 for(int i=1;3*i<=N;i++){
 F+=3*i;
 }
 for(int i=1;5*i<=N;i++){
 B+=5*i;
 }
 for(int i=1;15*i<=N;i++){
 FB+=15*i;
 }
long int total=0;
 for(int i=1;i<=N;i++){
 total+=i;
 }
 cout << total-F-B+FB <<endl;
}
 

Measured memory_bytes: 3588
#include <cstdlib>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    //stringstream geek(x);
    //geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
ll modInverse(ll a, ll m)
{
    a = a%m;
    for (int x=1; x<m; x++)
       if ((a*x) % m == 1)
          return x;
}
ll maxDivide(ll a, ll b)
{
  while (a%b == 0)
   a = a/b;
  return a;
}
  set<ll>ans;
void primeFactors(ll n)
{

    while (n % 2 == 0)
    {
       ans.insert(2);
        n = n/2;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            ans.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        ans.insert(n);
}
ll is(ll no)
{   if(no==1) return 0;
    set<ll>::iterator it;
for(it=ans.begin();it!=ans.end();it++){
  no = maxDivide(no, *it);
  if(no==1) return 1;
//  if()
 // no = maxDivide(no, 3);
 // no = maxDivide(no, 5);
}
//if(no==1) return 1;
//for(it=ans.begin();it!=ans.end();it++){
//if(no==*it) return 1;
//}
  return 0;
}

int comp(string a,string b)
{
    string aa = a.append(b);
    string bb = b.append(a);

    return aa.compare(bb) > 0 ? 1: 0;

}
int main()
{
   string s;
   cin>>s;
   int a = (s[0]-'0')*10+(s[1]-'0');
   int b = (s[2]-'0')*10+(s[3]-'0');
   if(a>=1&&a<=12)
   {
       if(b>=1&&b<=12)
       cout<<"AMBIGUOUS"<<endl;
       else
        cout<<"MMYY"<<endl;
   }
   else if(b>=1&&b<=12)
    cout<<"YYMM"<<endl;
   else
    cout<<"NA"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  vi a(3);
  rep(i,3){
    cin >> a[i];
  }
  sort(all(a));
  if(a[0]==a[1]){
    print(a[2]);
  }
  else{
    print(a[0]);
  }
}

Measured memory_bytes: 256
class Dice
  attr_reader :u, :f, :r, :l, :b, :d
  def initialize(line)
    @u, @f, @r, @l, @b, @d = line.split.map(&:to_i)
  end
  def rot(direc)
    case direc
    when "E";
      @u, @l, @d, @r = @l, @d, @r, @u
    when "N";
      @u, @f, @d, @b = @f, @d, @b, @u
    when "S";
      @u, @f, @d, @b = @b, @u, @f, @d
    when "W";
      @u, @l, @d, @r = @r, @u, @l, @d
    when "Z";
      @f, @r, @b, @l = @r, @b, @l, @f
    end
  end
  def dispUp
    printf "%d\n", @u
  end
  def arr
    {:u=>u, :f =>f, :r=>r, :l=>l, :b=>b, :d=>d}
  end
  def out
    return sprintf "%d %d %d %d %d %d", u, f, r, l, b, d
  end
  def diceMatch(dice2)
    dice2.arr.each{|key, val|
      if self.u == val then
        d2 = dice2.clone
        k = sprintf "%s", key
        case k
        when "d"; d2.rot("N"); d2.rot("N");
        when "f"; d2.rot("N");
        when "b"; d2.rot("S");
        when "l"; d2.rot("E");
        when "r"; d2.rot("W");
        end
        4.times do
          if self.out == d2.out then
            return "Yes"
          end
          d2.rot("Z")
        end
      end
    }
    return "No"
  end
end

n = gets.to_i
dice = Array.new(n)
i = 0
n.times{
  dice[i] = Dice.new(gets.chomp)
  for j in 0..i-1
    if dice[i].diceMatch(dice[j]) == "Yes" then
      printf "No\n"
      exit
    end
  end
  i += 1
}
printf "Yes\n"

Measured memory_bytes: 8836
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long i,j,n,a,b,c,d,ans,A,B;
	string s,s1,s2,s3;
	cin>>a>>b>>c;
	ans=0;
	for(i=1;i<=b;i++)
	{
	    if((b*i+c)%a==0)ans++;
	}
	if(ans)cout<<"YES";
	else cout<<"NO";
    }
	return 0;
}

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


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

using namespace std;

int main() {

	int H, W, K;
	int x, y, gx, gy;


	cin >> H >> W >> K;
	cin >> x >> y >> gx >> gy;

	x--; y--; gx--; gy--;

	vector<vector<bool>> masu(H, vector<bool>(W, false));
	vector<vector<int>> step(H, vector<int>(W, -1));

	
	rep(i, H) {
		rep(j, W) {
			char c;
			cin >> c;
			if (c == '.')
				masu[i][j] = true;
		}
	}

	/*
	cout << endl << x << y << endl;

	*/
	
	queue<pair<pair<int, int>,int>> q;
	q.push({ { x,y } ,15});
	step[x][y] = 0;



	while (!q.empty()) {
		auto tmp = q.front(); q.pop();
		int i = tmp.first.first;
		int j = tmp.first.second;
		int dir = tmp.second;
		bool l = (dir & 1 )== 1;
		bool r = (dir & 2) == 2;
		bool u = (dir & 4) == 4;
		bool d = (dir & 8 )== 8;

		//cout << endl << i << "," << j << "," << dir <<":"<< l<<r<<u<<d<<endl;

		rep(k, K+1) {
			if (k == 0)continue;

			if (u && i-k >= 0 && masu[i - k][j] && step[i - k][j] == -1) {
				step[i - k][j] = step[i][j] + 1;
				int nex = 1 | 2;
				if (k == K)nex |= 4;
				q.push({ { i - k,j},nex });
			}
			else if (u && i - k >= 0 && masu[i - k][j] && step[i - k][j] == step[i][j] + 1)
			{
				;
			}
			else {
				u = false;
			}
			if (d && i + k < H && masu[i + k][j] == true && step[i + k][j] == -1) {
				step[i + k][j] = step[i][j] + 1;
				int nex = 1 | 2;
				if (k == K)nex |= 8;
				q.push({ { i + k,j},nex });
			}
			else if (d && i + k < H && masu[i + k][j] == true && step[i + k][j] == step[i][j] + 1)
			{
				;
			}
			else {
				d = false;
			}
			if (l && j -k >= 0 && masu[i][j-k] == true && step[i][j-k] == -1) {
				step[i][j-k] = step[i][j] + 1;
				int nex = 4 | 8;
				if (k == K)nex |= 1;
				q.push({ { i,j-k},nex });
			}
			else if (l && j - k >= 0 && masu[i][j - k] == true && step[i][j - k] == step[i][j] + 1)
			{
				;
			}
			else {
				l = false;
			}
			if (r && j + k < W && masu[i][j+k] == true && step[i][j+k] == -1) {
				step[i][j+k] = step[i][j] + 1;
				int nex = 4 | 8;
				if (k == K)nex |= 2;
				q.push({ { i,j+k},nex });
			}
			else if (r && j + k < W && masu[i][j + k] == true && step[i][j + k] == step[i][j] + 1)
			{
				;
			}
			else {
				r = false;
			}

			if (!u&&!d&&!l&&!r)
				break;
		}

		/*
		rep(i, H) {
			rep(j, W) {
				if (!masu[i][j])cout << " @";
				else printf("%2d", step[i][j]);
			}
			cout << endl;
		}
		cout << endl;
		*/
		
	}

	cout << step[gx][gy] << endl;

	/*
	rep(i, H) {
		rep(j, W) {
			cout << step[i][j];
		}
		cout << endl;
	}
	*/
	//cin >> H;
	

	return 0;
}

Measured memory_bytes: 11436
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
	int n;
	string s,t;
	cin >> n >> s >> t;
	REP(i,0,n) {
		if (s.substr(i,n-i) == t.substr(0,n-i)) {
			cout << 2 * n - (n - i) << endl;
			return 0;
		}
	}
	cout << 2 * n << endl;
	
	return 0;
}

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

using namespace std;

int H, W;
char grid[100][100];
int D[100][100];

int main() {
    cin >> H >> W;
    int n = 0;

    for (int i = 0; i < H; i++) {
        cin >> grid[i];
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            D[i][j] = H * W + 1;
            if (grid[i][j] == '#') {
                n++;
            }
        }
    }

    deque<pair<int, pair<int, int> > > q;
    q.push_back(make_pair(1, make_pair(0, 0)));

    while (!q.empty()) {
        auto t = q.front();
        q.pop_front();
        int cost = t.first;
        int y = t.second.first;
        int x = t.second.second;

        if (y == H - 1 && x == W - 1) {
            cout << H * W - n - cost << endl;
            return 0;
        }
        if (D[y][x] > cost) {
            D[y][x] = cost;

            int dydx[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

            for (int i = 0; i < 4; i++) {
                int ny = y + dydx[i][0];
                int nx = x + dydx[i][1];
                if (ny >= 0 && ny < H && nx >= 0 && nx < W &&
                    grid[ny][nx] != '#') {
                    q.push_back(make_pair(cost + 1, make_pair(ny, nx)));
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
def Int ():
    return int(input())

N = Int()
cnt = [[0] * 10 for i in range(10)]

for i in range(1,N+1):
    S = str(i)
    cnt[int(S[0])][int(S[-1])] += 1
ans = 0

for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)


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

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

	for (int i = n; i <= 999; i++) {
		string s = to_string(i);
		bool ok = true;
		for (int j = 0; j < s.size()-1; j++) {
			if (s[j] != s[j + 1])ok = false;
		}
		if (ok) { cout << s << endl; return 0; }
	}

	return 0;
}

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

bool check(vector<int> &v, int x, int y, int k, int q) {
    int many = 0, n = v.size(), len = 0, greater = 0;

    for(int i = 0; i < n; ++i) {
        if(v[i] < x) {
            many += max(0, min(len - k + 1, len - greater));
            len = 0;
            greater = 0;
        } else {
            if(v[i] > y)
                greater += 1;
            len += 1;
        }
    }

    many += max(0, min(len - k + 1, len - greater));
    return many >= q;
}

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i)
        cin >> v[i];

    vector<int> w = v;

    sort(w.begin(), w.end());
    int ans = 2e9;

    for(int i = 0; i < n; ++i) {
        int x = w[i];
        int best = 2e9;
        for(int lf = i, rt = n - 1; lf <= rt;) {
            int mid = (lf + rt) / 2;
            int y = w[mid];
            if(check(v, x, y, k, q)) {
                best = y;
                rt = mid - 1;
            } else {
                lf = mid + 1;
            }
        }
        ans = min(ans, best - x);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C066
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            string[] b = new string[n];
            int start = n / 2;
            int sign = n % 2 == 1 ? 1 : -1;
            for (int i = 0; i < n; i++)
            {
                int index = (i + 1) / 2;
                sign *= -1;
                b[start + index * sign] = a[i];
            }
            Console.WriteLine(string.Join(" ", b));
        }
        
    }
}


Measured memory_bytes: 36416
N, D = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

count = 0
for i in range(N):
    for j in range(i+1, N):
        diff = 0
        for k in range(D):
            diff += (X[i][k] - X[j][k])**2
        if (diff**(1/2)).is_integer():
            count += 1
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace P_AtCoder
{
    class Program
    {
        class ScoreItem
        {
            public int Level { get; set; }
            public int Count { get; set; }
            public int CompleteBouns { get; set; }
        }

        static int _maxLevel { get; set; }
        static int _goal { get; set; }

        static List<ScoreItem> QuestionList { get; set; }
        static int? result;

        static void Main(string[] args)
        {
            var cache = Console.ReadLine().Split(' ');
            _maxLevel = int.Parse(cache[0]);
            _goal = int.Parse(cache[1]);

            QuestionList = new List<ScoreItem>();
            for (int lv = 1; lv <= _maxLevel; lv++)
            {
                var addCache = new ScoreItem() { Level = lv };
                var inputStr = Console.ReadLine().Split(' ');
                addCache.Count = int.Parse(inputStr[0]);
                addCache.CompleteBouns = int.Parse(inputStr[1]);
                QuestionList.Add(addCache);
            }

            result = null;
            //Recursion
            CalcRecursion(1, 0, 0, false);

            Console.WriteLine(result);
        }

        static void CalcRecursion(int nowLevel, int beforeAns, int beforeScore, bool useIncomplete)
        {
            if (beforeScore >= _goal)
            {
                if (!result.HasValue)
                {
                    result = beforeAns;
                    return;
                }
                else if (beforeAns < result.Value)
                {
                    result = beforeAns;
                    return;
                }
            }

            var nowSet = QuestionList.FirstOrDefault(x => x.Level == nowLevel);
            if (nowSet == null)
            {
                return;
            }

            CalcRecursion(
                nowLevel + 1,
                beforeAns + nowSet.Count,
                beforeScore + (nowSet.Level * nowSet.Count * 100) + nowSet.CompleteBouns,
                useIncomplete);

            CalcRecursion(
                nowLevel + 1,
                beforeAns,
                beforeScore,
                useIncomplete);

            if (!useIncomplete)
            {
                for (int ct = 1; ct < nowSet.Count; ct++)
                {
                    CalcRecursion(nowLevel + 1, beforeAns + ct, beforeScore + (ct * nowSet.Level * 100), true);
                }
            }
        }
    }
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int ans = 0, idx = 1;
    while (idx <= N)
    {
        int tmp1 = idx;
        int tmp2 = idx;
        while ((A[tmp1 - 1] <= A[tmp1]) && (tmp1 < N))
        {
            tmp1++;
        }
        while ((A[tmp2 - 1] >= A[tmp2]) && (tmp2 < N))
        {
            tmp2++;
        }
        ans++;
        idx = max(tmp1, tmp2) + 1;
    }
    cout << ans << endl;

    return 0;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N,M;

signed main() {
    cin>>N>>M;

    int ans,d=(int)sqrt(M);
    rep(i,1,d+1) {
        if(M%i==0) {
            int b=M/i;
            if(M-(N-1)*b>=b) {
                ans=b;
                break;
            }else{
                if(M-(N-1)*i>=i) {
                    ans=i;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}





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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

//最大公約数
int gcd(int a, int b){
    //a>bになるように入れ替え
    if(a<b){
        int tmp=a;
        a=b;
        b=tmp;
    }

    //ユークリッドの互除法
    if(a%b==0) return b;
    return gcd(b,a%b);
}

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

    //A[0]~A[N-1]に格納する
    int* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    //L[i]は、A[0]~A[i]のgcdを格納
    int* L;
    NEW(L,N);
    L[0]=A[0];
    for(int i=1;i<N;i++){
        L[i]=gcd(L[i-1],A[i]);
    }

    //R[i]は、A[i]~A[N-1]のgcdを格納
    int* R;
    NEW(R,N);
    R[N-1]=A[N-1];
    for(int i=N-2;i>=0;i--){
        R[i]=gcd(R[i+1],A[i]);
    }

    //A[i]を除いた時の最大公約数をM[i]に格納
    int* M;
    NEW(M,N);

    M[0]=R[1];
    M[N-1]=L[N-2];
    for(int i=1;i<N-1;i++){
        M[i]=gcd(L[i-1],R[i+1]);
    }

    int ans=0;
    for(int i=0;i<N;i++){
        if(ans<M[i]) ans=M[i];
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)


int main() {
    int n;
    while (cin >> n && n) {
        int l, r; cin >> l >> r;
        int a[n]; rep(i, n) cin >> a[i];
        int cnt = 0;
        rep3(x, l, r + 1) {
            int tmp = inf; int key = -1;
            rep(i, n) {
                if (x % a[i] == 0) {
                    if (tmp > a[i]) {
                        tmp = a[i];
                        key = i + 1;
                        break;
                    }
                }
            }
            if (tmp == inf) {
                if (n % 2 == 0) {
                    cnt++;
                    //out(x);
                }
            } else {
                if (key % 2 == 1) {
                    cnt++;
                    //out(x << " " << key);
                }
            }
        }
        out(cnt);
    }
}




Measured memory_bytes: 3136
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

int main(){
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++) cout << 'x';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        A[i] = { b, a };
    }
    SORT(A);
    cout << A[0].first + A[0].second << endl;
    return 0;
}

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

int main()
{
   string s,t;
   cin>>s>>t;
   int m=s.length();
   int n=t.length();
   int dp[m+1][n+1]={0};
   for(int i=0;i<=m;i++)
    for(int j=0;j<=n;j++)
        dp[i][j]=0;
   for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    
    stack<char> c;
    int x=m,y=n;
    while(x>0&&y>0)
    {
        if(dp[x-1][y-1]+1==dp[x][y]&&s[x-1]==t[y-1])
            {
                c.push(s[x-1]);
                x--;
                y--;
            }
        else if(dp[x-1][y]>dp[x][y-1])
            x--;
        else
            y--;
    }
    while(!c.empty())
    {
        cout<<c.top();
        c.pop();
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator > (const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int n, m, q;
	while (cin >> n >> m >> q, n)
	{
		vector<vi> v(m);
		REP(i, m)REP(j, n) v[i].push_back(j);
		string b, s, preb(m,'0'), pres(n,'0');
		REP(r, q)
		{
			cin >> s >> b;
			vi op,rem;
			REP(i, n)
			{
				if (s[i]=='1') op.push_back(i);
				else rem.push_back(i);
			}
			
			REP(i, m)
			{
				if (v[i].size()>1 && preb[i] == b[i])
				{
					REP(j, v[i].size())
					{
						if (find(ALL(op), v[i][j]) != op.end())
						{
							v[i].erase(v[i].begin() + j);
							j--;
						}
					}
				}
				else if (v[i].size()>1 && preb[i] != b[i])
				{
					REP(j, v[i].size())
					{
						if (find(ALL(rem), v[i][j]) != rem.end())
						{
							v[i].erase(v[i].begin() + j);
							j--;
						}
					}
				}
			}
			pres = s; preb = b;
		}
		REP(i, m)
		{
			if (v[i].size() > 1||v[i].size()==0) cout << '?';
			else if (v[i][0] < 10) cout << v[i][0];
			else
			{
				cout << char('A' + v[i][0] - 10);
			}
		}
		cout << endl;
 	}
	return 0;
}

Measured memory_bytes: 1376
def main():
  import collections
  import bisect


  def cmb(n, r, mod):
      if (r < 0 or r > n):
          return 0
      r = min(r, n-r)
      return g1[n] * g2[r] * g2[n-r] % mod


  mod = 10**9+7  # 出力の制限
  N = 10**5
  g1 = [1, 1]  # 元テーブル
  g2 = [1, 1]  # 逆元テーブル
  inverse = [0, 1]  # 逆元テーブル計算用テーブル

  for i in range(2, N + 1):
      g1.append((g1[-1] * i) % mod)
      inverse.append((-inverse[mod % i] * (mod//i)) % mod)
      g2.append((g2[-1] * inverse[-1]) % mod)

  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  table = collections.defaultdict(int)
  A.sort()
  for x in A:
      table[x] += 1
  ans = 0
  for x in table:
      left = bisect.bisect_left(A, x)
      for i in range(1, table[x]+1):
          if left >= K - i:
              ans += x * cmb(left, K - i, mod) * cmb(table[x], i, mod)

      right = left + table[x] - 1
      for i in range(1, table[x]+1):
          if N - 1 - right >= K - i:
              ans -= x * cmb(N - 1 - right, K-i, mod) * cmb(table[x], i, mod)
      ans %= mod
  print(ans)
main()

Measured memory_bytes: 30364
from bisect import *

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
X = reads()
sX = sorted(X)

ml = sX[N//2 - 1]
mr = sX[N//2]

for x in X:
    print(mr if x <= ml else ml)


Measured memory_bytes: 93780
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
lis = inpl()

m = INF
ans = 0
for i in lis:
    if m > i:
        ans +=  1
    m = min(m, i)
print(ans)

Measured memory_bytes: 26984