akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;

long long const inf = 2e18, linf = 2e9, mod = 1e9+7;
int const mxn = 1e6 + 10 ;  ; 

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));
}

long long ans ;
int main(){
	string s ; 
	cin>>s ;
	for (int i = 0 ; i < 3 ; i++){
		if (s[i]=='7'){
			cout<<"Yes";
			return 0 ; 
		}
	}
	cout<<"No" ; 

}

Measured memory_bytes: 3592
s = input()

for i in range(2**3):
    tmp = s
    for j in range(3):
        if (i>>j) &1:
            tmp = tmp[:j*2+1] + "+" + tmp[j*2+1:]
        else:
            tmp = tmp[:j*2+1] + "-" + tmp[j*2+1:]
    if eval(tmp) == 7:
        print(tmp+ "=7")
        exit()



Measured memory_bytes: 9060
n, m = (int(i) for i in input().split())
lr = [[int(i) for i in input().split()] for i in range(m)]
lr.sort(key=lambda x:x[0])
low = 1
high = n
for l,e in lr:
    if low < l:
        low = l
    if high > e:
        high = e
if high >= low:
    print(high-low+1)
else:
    print("0")

Measured memory_bytes: 22772
import sys
sys.setrecursionlimit(10**9)

global color 
global adlist
color = [0 for _ in range(100001)] 

def make_adlist(N, uvw):
  global adlist
  adlist = [[] for _ in range(N)]
  for u, v, w in uvw:
    adlist[u-1] += [[v-1, w%2]]
    adlist[v-1] += [[u-1, w%2]]
  return adlist 

def dfs(v, c):
  global color
  global adlist
  color[v] = c
  for next_v, w in adlist[v]:
    if color[next_v] != 0:
      continue
    if color[next_v] == 0 and w % 2 != 0:
      dfs(next_v, -c)
    elif color[next_v] == 0 and w % 2 == 0:
      dfs(next_v, c)

  return 


def main():
  N = int(input())
  uvw = [list(map(int, input().split())) for _ in range(N-1)]
  adlist = make_adlist(N, uvw)
  dfs(0, 1)
  for c in color[:N]:
    if c == 1:
      print(1)
    else:
      print(0)


if __name__ == "__main__":
  main()




Measured memory_bytes: 104492
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
  t = [str(sum([A[i][k] * B[k][j] for k in range(m)])) for j in range(l)]
  print(" ".join(t))
  


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

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N, K;
    cin >> N >> K;

    vector<int> memo;
    memo.resize(N,0);

    rep(i,K){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            a--;
            memo[a]++;
        }
    }

    int cnt = 0;
    rep(i,N){
        if(memo[i]==0) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll md=1e9+7;
ll dp[2010][2010]; 
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	dp[0][0]=1;
	for(int i=1;i<=2000;i++){
		for(int j=0;j<=i;j++){
			if(j==0){
				dp[i][j]=1;
				continue;
			}
			dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%md;
		}
	}
	for(int i=1;i<=k;i++){
		printf("%lld\n",(dp[n-k+1][i]*dp[k-1][i-1])%md);
	}
	return 0;
}


Measured memory_bytes: 30208
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
int main(){
  int n, m;
  while(true){
    cin >> n >> m;
    if(n == 0 && m == 0){
      break;
    }
    vector<PII> pd(n);
    int ans = 0;
    for(int i = 0; i < n; ++i){
      int a, b;
      cin >> a >> b;
      pd[i] = make_pair(b, a);
      ans += b * a;
    }
    sort(pd.begin(), pd.end(), greater<PII>());
    /*
    for(int i = 0; i < n; ++i){
      cout << pd[i].first << " " << pd[i].second << endl;
    }
    */
    for(int i = 0; i < n && m != 0; ++i){
      if(m >= pd[i].second){
	ans -= pd[i].first * pd[i].second;
	m -= pd[i].second;
      }
      else if(pd[i].second > m){
	ans -= pd[i].first * m;
	m = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
int main(){

    ll A,B;
    cin >>A >>B;
    cout << lcm(A,B) << endl;

    return 0;
}



Measured memory_bytes: 256
import math
n, d = map(int, input().split())
t = 0
for i in range(0,n):
  alis = list(map(int, input().split()))
  sss = math.sqrt(alis[0] ** 2 + alis[1] ** 2)
  if d >= sss:
    t += 1
    
print(t)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<n;i++)
#define reps(i,s,n) for(long long i=s;i<n;i++)
using namespace std;
const long long mod = (long long)(1E9) + 7LL;

long long dgtdp(long long  k, bool t, long long md, long long& d, string& s, vector<vector<vector<long long>>>& memo) {
	if (memo[k][t][md] != -1) return memo[k][t][md];
	if (k >= s.size()) return md == 0;
	long long x = (long long)s[k]-'0';
	int lim = (t) ? x : 9;
	long long ret = 0;
	for (int i = 0; i <= lim; i++) {
		ret += dgtdp(k + 1LL, t and (i == lim), (md + (long long)i) % d,d,s,memo);
		ret %= mod;
	}
	return memo[k][t][md] = ret;
}

int main(void) {
	string s;
	long long d;
	cin >> s >> d;
	vector<vector<vector<long long>>> memo(s.size() + 1,vector<vector<long long>>(2,vector<long long>(d+1,-1LL)));
	cout << (dgtdp(0,true,0,d,s,memo)+mod -1LL)%mod << endl;
}


Measured memory_bytes: 18176
import math
from functools import reduce
N=int(input())
MOD=10**9+7
'''
def all_multiple(a):
    return reduce(lambda a,b:a*b,a)
'''
def all_multiple_mod(a,m):
    return reduce(lambda a,b:((a%m)*(b%m))%m,a)




def is_prime(n):
    if n==1: return False
    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False
    return True


A=[1]*(N+1)#indexと割られる数を合わせる
ans=1
for N_t in range(2,N+1):
    for num in range(1,N_t+1):
        if is_prime(num):
            cnt=0
            while N_t%num==0:
                N_t=N_t//num
                cnt+=1
            A[num]+=cnt 

print(all_multiple_mod(A,MOD)%MOD)

            


Measured memory_bytes: 3668
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MODPRIME = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
ans = 'No'
s = input()
if len(s)==6 and s[0] != s[1] and s[2] == s[3] and s[4] == s[5]:
    ans = "Yes"
print(ans)


# #########################################################################################
'''
THE LOGIC AND APPROACH IS BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
: DO NOT PLAGIARISE.
'''

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    
    vector<int> ans(N+1);
    FOR(i,1,sqrt(N)) FOR(j,1,N) {
        if (i * i + j*j> N) break;
        FOR(k,1,N) {
            int a = i*i+j*j+k*k + i*j + j*k + k*i;
            if (a > N) break;
            ans[a]++;
        }
    }
    
    FOR(i,1,N+1) cout << ans[i] << '\n';

    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e10

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n >> k;
    lli dp[n+1];
    rep(i,0,n+1)	dp[i]=0;
    while(k--){
    	cin >> d;
    	while(d--){
    		cin >> a;
    		dp[a]++;
    	}
    }
    rep(i,1,n+1){
    	if(dp[i]==0)	ans++;
    }
    cout<<ans;
    
    
}













int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */



Measured memory_bytes: 3632
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::HashSet;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }

    println!("{}", a * b);
}


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
#define ll int 
ll dp[100005],n,m;
vector<ll> adj[100005];
void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

ll solve(ll i)
{
	if(dp[i]!=-1)
		return dp[i];
	dp[i]=0;
	int j,temp=0;
	for(j=0;j<adj[i].size();j++)
	{
		temp = max(temp,1+solve(adj[i][j]));
	}	
	return dp[i]=temp;
}

int main()
{
	ll x,y,i,ans=0;
	boost();
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
	}
	for(i=1;i<=n;i++)
	{
		if(dp[i]==-1)
			ans = max(ans,solve(i));
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	int m, n;
	cin >> m >> n;//m行n列
	double **a = new double*[m];
	for (int i = 0; i < m; i++)
	{
		a[i] = new double[n];
	}
	//以上为声明。
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> a[i][j];
		}
	}
	//以上为赋值。
	int sum = 0;
	for (int j = 0; j < m-1; j++)
	{
		for (int k = j + 1; k < m; k++)
		{
			double dis = 0;
			for (int i = 0; i < n; i++)
			{
				dis += fabs(a[k][i] - a[j][i])*fabs(a[k][i] - a[j][i]);
			}
			if (sqrt(dis) == (int)sqrt(dis))
				sum++;
		}
	}
	cout << sum;
	//
	for (int i = 0; i < m; i++)
	{
		delete[]a[i];
	}
	delete[]a;
	//以上为回收。
	return 0;
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    int cnt = 0;
    int ans;
    for (int i=min(A, B); i>0; --i) {
        if (A%i==0 && B%i==0) {
            ++cnt;
            if (cnt == K) {
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
        int a, b, c, result = 0;
        cin >> a >> b >> c;

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

        cout << result << endl;

        return 0;
}



Measured memory_bytes: 3112
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

  private void solve(Scanner in, PrintWriter out) {
    int N = in.nextInt();
    int count = 0;
    for (int i = 0; i < N; i++) {
      int a = in.nextInt();
      if (a % 2 == 1) {
        count++;
      }
    }
    if (count % 2 == 0) {
      out.println("YES");
    } else {
      out.println("NO");
    }
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(in, out);
    in.close();
    out.close();
  }
}


Measured memory_bytes: 33564
use std::cmp;

fn main(){
  loop {
    let rc: Vec<usize> = read_vec();
    let r = rc[0];
    let c = rc[1];
    
    if r == 0 && c == 0 { break; }
  
    let mut av: Vec<usize> = vec![0;c];
    let mut mxs: usize = 0;
  
    for _ in 0 .. r {
      let tv: Vec<usize> = read_vec();
      for i in 0 .. c {
        av[i] = av[i] * 2 + tv[i];
      }
    }

    for i in 0 .. 2usize.pow(r as u32) {
      let x: usize = av.iter().map(|t| (t ^ i).count_ones() as usize)
      .map(|t| cmp::max(t, r-t)).sum();
      mxs = cmp::max(mxs, x);
    }
    
    println!("{}", mxs);
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



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

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    set<int>Set;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        int X = a[i]/400;
        if(a[i]/400 >= 8) {
            ans++;
        }
        else {
            Set.insert(X);
        }
    }
    if(Set.size() == 0) {
        cout << 1 << " "<< ans << endl;
    }
    else {
        cout << Set.size() << " " << ans+Set.size() << endl;
    }
}

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

int main(int argc, char const* argv[])
{
    int n, x;
    std::cin >> n >> x;

    int lowest_cost = std::numeric_limits<int>::max();
    int result = 0;
    for(int i=0; i<n; ++i)
    {
        int m;
        std::cin >> m;
        lowest_cost = std::min(lowest_cost, m);
        x -= m;
        result++;
    }

    result += x / lowest_cost;
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    for(int c=1;c<=9;c++)
    {
        for(int c2=1;c2<=9;c2++)
        {
            cout<<c<<"x"<<c2<<"="<<c*c2<<endl;
        }
    }
}

Measured memory_bytes: 1112
from itertools import product
n=int(input())
ans=0
for k in range(3,10):
  dp=list(product("753",repeat=k))
  for i in range(len(dp)):
    if n>=int("".join(dp[i])) and "3" in dp[i] and "5" in dp[i] and "7" in dp[i]:
      ans+=1
print(ans)

Measured memory_bytes: 72060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int N,M,R;
  cin>>N>>M>>R;
  int r[R];
  rep(i,0,R){
    cin>>r[i];
    r[i]--;
  }
  sort(r,r+R);
  int d[N][N];
  rep(i,0,N){
    rep(j,0,N){
      d[i][j]=20000000;
    }
  }
  rep(i,0,N){
    d[i][i]=0;
  }
  rep(i,0,M){
    int a,b,c;
    cin>>a>>b>>c;
    d[a-1][b-1]=c;
    d[b-1][a-1]=c;
  }
  
  rep(k,0,N){
    rep(i,0,N){
      rep(j,0,N){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  int ans=200000000;
  do{
    int cur=0;
    rep(i,0,R-1){
      cur+=d[r[i]][r[i+1]];
    }
    ans=min(ans,cur);
  } while(next_permutation(r,r+R));
  cout<<ans<<endl;
}

Measured memory_bytes: 384
import Control.Monad
import Data.Char
import qualified Data.Sequence as S

main = do
    [n, k] <- map read <$> words <$> getLine
    s      <- getLine
    putStrLn $ show $ solve n k s

solve :: Int -> Int -> String -> Int
solve n k s = doit (S.fromList $ replicate k 0) 0 ('0' : s)
  where
    doit :: (S.Seq Int) -> Int -> String -> Int
    doit start pos []              = n - S.index start 0
    doit start pos ('0' : '1' : t) =                               doit (start S.|> pos) (pos + 1) ('1' : t)
    doit start pos ('1' : '0' : t) = max (pos - S.index start 0) $ doit (S.drop 1 start) (pos + 1) ('0' : t)
    doit start pos ( _        : t) =                               doit  start           (pos + 1) t

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, a, b;
  cin >> n >> a >> b;

  if (a * n < b) {
    cout << a * n << endl;
  } else {
    cout << b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>
#define N_MAX 100000

vector<int> a(N_MAX);

//input sorted vector
int mod_and_sort(int min_num){
  int i = 0;
  for(auto ai: a){
    if(a[i] % a[0] == 0)
      a[i] = a[0] ;
    else
      a[i] %= a[0];
    i++;
  }
  sort(a.begin(), a.end());
  if(min_num == a[0])
    return a[0];
  else
    return mod_and_sort(a[0]);
}

int main() {
  int n;
  cin >> n;
  
  a.resize(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  sort(a.begin(), a.end());
  int min_num = *min_element(a.begin(), a.end());
  cout << mod_and_sort(min_num) << endl;
  
  
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++)
	cout<<c<<' ';
	for(int i=b+1;i<=a;i++)
	{
		if(c==1e9)
		cout<<c-1<<' ';
		else
		cout<<c+1<<' ';
	}
	return 0;
}

Measured memory_bytes: 1280
# Problem: https://atcoder.jp/contests/agc027/tasks/agc027_a
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


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


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


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


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(allChild, haveCandy, eachHappy):
    result = 0
    allHappyCount = 0
    eachHappy.sort()
    for j in range(len(eachHappy)):
        allHappyCount = allHappyCount + eachHappy[j]
    # algorithm
    # print("{}".format(allHappyCount))
    # if allHappyCount < haveCandy:
    #    result = allChild - 1
    #     return result
    for j in range(0, allChild, +1):
        haveCandy = haveCandy - eachHappy[j]
        if haveCandy < 0:
            return result
        else:
            result = result + 1
    if 0 < haveCandy:
        result = result - 1
    return result


if __name__ == "__main__":
    N, X = MI()
    childHappyCount = LI()
    print("{}".format(solver(N, X, childHappyCount)))


Measured memory_bytes: 3064
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

		long f = sc.nextLong();
		long s = sc.nextLong();
        long a = Math.min(f, s);
        long b = Math.max(f, s);
        long a_ = (long)Math.ceil(Math.sqrt(a)) + 1;
        long b_ = (long)Math.ceil(Math.sqrt(b)) + 1;
        Set<Long> set_a = new HashSet<Long>();
        Set<Long> set_b = new HashSet<Long>();
        set_a.add(1L);
        set_b.add(1L);

        for(long i = 2; i <= a; i++){
            if(i > a_){
                set_a.add(a);
                break;
            }
            if(a % i == 0) set_a.add(i);
            else continue;
            while(a % i == 0){
                a /= i;
            }
            if(a == 1) break;
        }
        for(long i = 2; i <= b; i++){
            if(i > b_){
                set_b.add(b);
                break;
            }
            if(b % i == 0) set_b.add(i);
            else continue;
            while(b % i == 0){
                b /= i;
            }
            if(b == 1) break;
        }

        long count = 0;
        // if(set_a.size() < set_b.size()){
        //     for(long x: set_a){
        //         if(set_b.contains(x)) count++;
        //     }
        // }else{
        //     for(long x: set_b){
        //         if(set_a.contains(x)) count++;
        //     }
        // }
        for(long x: set_a){
            if(set_b.contains(x)) count++;
        }

        System.out.println(count);

    }

}


Measured memory_bytes: 22228
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count = 1;
        long sum = 0;

        if( a >= b ) {
            for(int i = 0 ; i < a ; i++){
                sum += b * count;
                count = count * 10;
            }
        }else{
            for(int i = 0; i < b  ; i++){
                sum += a * count;
                count = count * 10;
            }
        }

        System.out.println(sum);
        }
        
	}


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

int main() {
    int n;
    long long ans = 0;
    cin >> n;
    vector<int> a(n + 1);
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        cin >> a.at(i);
        if(mp.count(i + a.at(i))) mp[i + a.at(i)]++;
        else mp[i + a.at(i)] = 1;
    }

    for (int i = 1; i <= n; i++) {
        int x = i - a.at(i);
        if(x <= 0) continue;
        else ans += mp[x];
    }
    cout << ans << endl;
}

Measured memory_bytes: 14228
using System;
using System.Collections.Generic;
using System.Text;

namespace mondai0001
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> hills = new List<int>();

            for (int i = 0; i < 10; i++)
            {
                hills.Add(int.Parse(Console.ReadLine()));
            }
            
            hills.Sort();
            hills.Reverse();

            Console.WriteLine(hills[0]);
            Console.WriteLine(hills[1]);
            Console.WriteLine(hills[2]);
        }        
    }
}

Measured memory_bytes: 5780
#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 sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n, W;
  cin >> n >> W;
  vector<ll> dp(W + 1);
  rep(i, n) {
    int w, v;
    cin >> w >> v;
    for (int j = W - w; j >= 0; --j) {
      chmax(dp[w + j], dp[j] + v);
    }
  }
  cout << *max_element(all(dp)) << endl;
}


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


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



int main(void){
    int N;
    cin >> N;
    vector<int> A;
    rep(i, N){
        int m;
        cin >> m;
        A.pb(m);
    };
    
    int cnt = 0;
    int Q;
    cin >> Q;
    auto s = A.begin();
    auto e = A.end();
    rep(i, Q){
        int m;
        cin >> m;
        if(binary_search(s, e, m)) ++cnt;
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3432
#include <stdio.h>

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

    int a, b, c;
    a = y/10000;
    b = (y - 10000*a)/5000;
    c = (y - 10000*a - 5000*b)/1000;
    // printf("%d %d %d\n", a, b, c);

    int i, j, k;

    if(n<a+b+c) {
        printf("-1 -1 -1\n");

        return 0;
    // }
    } else {
        for(i=a; i>=0; i--) {
            // printf("%d %d %d a\n", i, b, c);
            // printf("%d\n", i*10000+b*5000+c*1000);

            if(i+b+c==n) {
                printf("%d %d %d\n", i, b, c);
                // printf("%d\n", i*10000+b*5000+c*1000);
                return 0;
            }
            k = c;
            for(j=b-1; j>=0; j--) {
                k += 5;
                // printf("%d %d %d b\n", i, j, k);
                // printf("%d\n", i*10000+j*5000+k*1000);
                if(i+j+k==n) {
                    printf("%d %d %d\n", i, j, k);
                    // printf("%d\n", i*10000+j*5000+k*1000);
                    return 0;
                }
            }
            b += 2;
        }
    }

    printf("-1 -1 -1 \n");

    return 0;

}

Measured memory_bytes: 128
a,b,c,d=list(map(int, input("").split()))
la=[]
lb=[]
if a<0 and b>0:
    la.append(0)
la.append(a)
la.append(b)
if c<0 and d>0:
    lb.append(0)
lb.append(c)
lb.append(d)
m=a*c
for i in la:
    for j in lb:
        o=i*j
        if o>m:
            m=o
print(m)

Measured memory_bytes: 9148
Imports System.Console
Module Module1
    Dim ans As Integer
    Dim n As Integer
    Dim Wnum() As Integer
    Sub Main()
        n = ReadLine()
        Dim min As Integer = 2 * 10 ^ 5
        Dim s As String = ReadLine()
        ReDim Wnum(n)
        For i = 1 To n
            Dim w As Char = s.Substring(i - 1, 1)
            If w = "W" Then
                Wnum(i) = Wnum(i - 1) + 1
            Else
                Wnum(i) = Wnum(i - 1)
            End If
        Next
        For i = 1 To n
            Dim ww As Integer = Calc(i)
            If ww < min Then
                min = ww
            End If
        Next
        If Wnum(n) = n Then
            WriteLine("0")
        Else
            WriteLine(min)
        End If
    End Sub
    Function Calc(ByVal num As Integer)
        Dim ctoR, ctoW As Integer
        ctoR = Wnum(num)
        ctoW = (n - Wnum(n)) - (num - Wnum(num))
        If ctoR > ctoW Then
            Return ctoR
        Else
            Return ctoW
        End If
    End Function
End Module


Measured memory_bytes: 42668
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
cnt = [0, 0, 0]
ans = 1
for e in a:
    idx = -1
    c = 0
    for i, cnt_e in enumerate(cnt):
        if e == cnt_e:
            c += 1
            idx = i

    if idx == -1:
        print(0)
        exit()

    cnt[idx] += 1
    ans *= c
    ans %= mod

print(ans)


Measured memory_bytes: 52952
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<usize>();

    let mut ans = 0.0;
    for elem in v {
        ans += 1.0 / elem as f64;
    }
    println!("{}", 1.0 / ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

const int mod = 1e9 + 7;

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    int min_cnt = INT_MAX;
    for (int i = 0; i < n; i++) {
        int cnt = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }

        min_cnt = std::min(min_cnt, cnt);
    }

    std::cout << min_cnt << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;
const ll maxn=1000001;
const ll LOGMAXN=30;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
}

int main()
{
   
  IOS
  ll m1,d1,m2,d2;
  cin>>m1>>d1>>m2>>d2;
  ll a[]={31,28,31,30,31,30,31,31,30,31,30,31};
  if(a[m1-1]==d1)
  {
    cout<<1;
  }
  else
  {
    cout<<0;
  }
  

}
    

  
  
	

 

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

typedef long long ll;
typedef unsigned long long ull;


int main() {
    vector<bool> prime(100001, true);
    prime[0] = false;
    prime[1] = false;
    rep(i, 100001) {
        if (!prime[i]) continue;
        for (int j = 2 * i; j < 100001; j += i) {
            prime[j] = false;
        }
    }
    vector<int> s(100001, 0);
    rep(i, 100000) {
        s[i + 1] = s[i];
        if (i % 2 == 0 && prime[i + 1] && prime[(i + 2) / 2]) s[i + 1]++;
    }
    int Q, l, r;
    cin >> Q;
    rep(i, Q) {
        cin >> l >> r;
        cout << s[r] - s[l - 1] << "\n";
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
void test_case()
{
	ll n;
	cin>>n;
	ll h[n];
	for(ll i=0; i<n; i++){
		cin>>h[i];
	}
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(ll i=2; i<n; i++){
		dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout<<dp[n-1]<<endl;
}
int main ()
{
	fastio
	int t;
	t=1;
	while(t--)
	test_case();
	return 0;
	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define inf 999999999999
#define F first
#define S second
#define eb emplace_back
#define mp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 200009
#define mod 1000000007
using namespace std;
int main(){//read(x);
//fast;
ll a,b,c,d,g,h,i,l,j,k,n,t,x,y,z,e,f,p;
cin>>a>>b>>c;
if(a==0){
    if(b&1)cout<<c<<endl;
    else cout<<0<<endl;
}
else if(a>0){
    e=a/c;
    f=a%c;
    d=c-f;
    if(e>=b){
        a=a-b*c;
        cout<<a<<endl;
    }
    else{
        a=b-e;
        if(a&1)cout<<d<<endl;
        else cout<<f<<endl;

    }
}
else{
    d=0-a;
    e=(d)/c;
    f=d%c;
    h=c-f;
    if(e>=b){
        h=a+b*c;
        cout<<0-h<<endl;
    }
    else{
        a=b-e;
        if(a&1)cout<<h<<endl;
        else cout<<f<<endl;
    }
}

}


Measured memory_bytes: 3668
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

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

set<int> seen;
vector<set<int>> links;
unordered_map<int, set<int>> F;
unordered_map<int, set<int>> B;

void dfs_sub(int i, set<int>& s) {
    if (seen.count(i) != 0) return;

    s.insert(i);
    seen.insert(i);
    for (auto node : F[i]) {
        dfs_sub(node, s);
    }
}

void dfs(int i) {
    links.push_back(set<int>{});
    dfs_sub(i, links.back());
}

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

    int a, b;
    rep(i, M) {
        cin >> a >> b;
        F[a].insert(b);
        F[b].insert(a);
    }
    rep(i, K) {
        cin >> a >> b;
        B[a].insert(b);
        B[b].insert(a);
    }

    for (int i = 1; i <= N; ++i) {
        if (seen.count(i) != 0) {
            continue;
        }
        dfs(i);
    }

    vector<int> ret(N);
    for (int i = 0; i < links.size(); ++i) {
        for (auto node : links[i]) {
            ret[node - 1] = links[i].size() - 1;
            for (auto block_node : B[node]) {
                if (links[i].count(block_node) != 0) ret[node - 1]--;
            }
            for (auto block_node : F[node]) {
                if (links[i].count(block_node) != 0) ret[node - 1]--;
            }
        }
    }

    for (int i = 0; i < N; ++i) {
        cout << ret[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 52268
%:pragma GCC optimize("Ofast")
  %:pragma GCC optimize("inline")
#include <bits/stdc++.h>
#define rint register int
#define fo(i, n) for(rint i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
  using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
#define P pair<int, int>
#define fi first
#define se second
const int N = 633;
int dp[2][N][N];
int n, d1, d2;

inline void doit(int d, int fff) {
  int t = 0;
  while(d % 4 == 0) d /= 4, ++ t;
  if(d % 4 == 2) {
    for(int x = 0; x < 2 * n; x ++)
      for(int y = 0; y < 2 * n; y ++)
        if(!((x >> t) & 1)) dp[fff][x][y] = 1;
  }
  if(d % 4 == 1){
    for(int x = 0; x < 2 * n; x ++)
      for(int y = 0; y < 2 * n; y ++)
        if(((x >> t) & 1) == ((y >> t) & 1)) dp[fff][x][y] = 1;
  }
  
  // for(int x = 0; x < 2 * n; x ++) {
  //   for(int y = 0; y < 2 * n; y ++)
  //     cout << dp[fff][x][y] << " "; puts("");
  // }
}

main(void) {
  read(n); read(d1); read(d2);
  doit(d1, 0); doit(d2, 1);
  int res = n * n;
  for(int x = 0; x < 2 * n; x ++)
    for(int y = 0; y < 2 * n; y ++)
      if(dp[0][x][y] && dp[1][x][y]) {
        cout << x << " " << y << "\n";
        if(-- res == 0) return 0;
      }
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    int a = sqrt(n);
  	OUT(a*a);

    return 0;
}

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

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

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

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n;
  cin >> n;
  vector<pair<pair<string,int>, int>> sp(n);
  rep(i,n){
    cin >> sp.at(i).first.first >> sp.at(i).first.second;
    sp.at(i).first.second *= -1;
    sp.at(i).second = i + 1;
  }
  sort(ALL(sp));
  rep(i,n){
    cout << sp.at(i).second << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
    INF = 1 << 30
    H, W = wall.shape
    S = Sx * W + Sy
    T = Tx * W + Ty
    dist = np.full(H * W, INF, np.int64)
    deq = np.empty(H * W + 100, np.int64)
    dist[S] = 0
    deq[0], l, r = S, 0, 1
    while l < r:
        v, l = deq[l], l + 1
        vx, vy = divmod(v, W)
        # そのままあるく
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            wx, wy = vx + dx, vy + dy
            if not (0 <= wx < H):
                continue
            if not (0 <= wy < W):
                continue
            if wall[wx, wy]:
                continue
            w = wx * W + wy
            if dist[w] <= dist[v]:
                continue
            dist[w] = dist[v]
            deq[l - 1], l = w, l - 1
        # ワープする
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                wx, wy = vx + dx, vy + dy
                if not (0 <= wx < H):
                    continue
                if not (0 <= wy < W):
                    continue
                if wall[wx, wy]:
                    continue
                w = wx * W + wy
                if dist[w] <= dist[v] + 1:
                    continue
                dist[w] = dist[v] + 1
                deq[r], r = w, r + 1
    ans = dist[T]
    if ans == INF:
        ans = -1
    return ans

H, W = map(int, readline().split())
Sx, Sy = map(lambda x: int(x) - 1, readline().split())
Tx, Ty = map(lambda x: int(x) - 1, readline().split())
wall = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'#'

print(main(wall, Sx, Sy, Tx, Ty))


Measured memory_bytes: 118416
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [a, b]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const r = IntUtil.gcd(a, b)[0];
    return `${a * b / r}`;
  }
}

export class IntUtil {
  /**
   * aをbで割った時の商と余りを求める。
   * @param a 割られる数
   * @param b 割る数
   * @return [商, 余り]
   */
  static extraQ(a: number, b: number): [number, number] {
    const r = a % b;
    return [(a - r) / b, r];
  }

  /**
   * 最大公約数を求める。
   * @param x 数値1
   * @param y 数値2
   * @return [最大公約数r, a, b] (ただしa, bは ax + by = r となる整数)
   */
  static gcd(x: number, y: number): [number, number, number] {
    let r0 = x;
    let r1 = y;
    let a0 = 1;
    let a1 = 0;
    let b0 = 0;
    let b1 = 1;
    while(r1 > 0) {
      const [q, r] = IntUtil.extraQ(r0, r1);
      const a = a0 - q * a1;
      const b = b0 - q * b1;
      r0 = r1;
      r1 = r;
      a0 = a1;
      a1 = a;
      b0 = b1;
      b1 = b;
    }
    return [r0, a0, b0];
  }

  /**
   * pを法とした時のxの逆数を返す
   * @param x 数値
   * @param p xと互いに素である数値
   * @return x^{-1} (mod p)
   */
  static inverseMod(x: number, p: number): number {
    const [r, a, _] = IntUtil.gcd(x, p);
    if (r != 1) {
      throw new Error(`NOT COPRIME: IntUtil.inverseMod(${x}, ${p})`);
    }

    return a >= 0 ? (a % p) : (p + (a % p));
  }
}

console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <cstring>
#define MAX_N 1000 + 16
 
using namespace std;
 
int N, H, W;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
int fld[2 * MAX_N][2 * MAX_N], // 填充遍历用，代表坐标(i, j)处是否空白（压缩后）
dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };
 
// 压缩坐标，将坐标的值变成“这是第几种值”，返回一共有几种坐标
int compress(int *x1, int *x2, int w)
{
	vector<int>xs;
 
	for (int i = 0; i < N; ++i)
	{
		int tx1 = x1[i], tx2 = x2[i];
		if (1 <= tx1 && tx1 < w) xs.push_back(tx1);
		if (1 <= tx2 && tx2 < w) xs.push_back(tx2);
	}
	xs.push_back(0);
	xs.push_back(w);
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for (int i = 0; i < N; ++i)
	{
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size() - 1;
}
 
int bfs()
{
	int ans = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (fld[i][j]) continue;
			++ans;
			queue<pair<int, int> >que;
			que.push(make_pair(j, i));
			while (!que.empty())
			{
				int nx = que.front().first, ny = que.front().second;
				que.pop();
 
				for (int i = 0; i < 4; ++i)
				{
					int tx = nx + dx[i], ty = ny + dy[i];
					if (tx < 0 || W < tx || ty < 0 || H< ty || fld[ty][tx] > 0) continue;
					que.push(make_pair(tx, ty));
					fld[ty][tx] = 1;
				}
			}
		}
	}
	return ans;
}
 
int main(int argc, char *argv[])
{
	while (cin >> W >> H, W | H)
	{
		cin >> N;
		for (int i = 0; i < N; ++i)
		{
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		}
 
		memset(fld, 0, sizeof(fld));
 
		W = compress(X1, X2, W);
		H = compress(Y1, Y2, H);
 
		// imos-法
		for (int i = 0; i < N; i++)
		{
			fld[Y1[i]][X1[i]]++;
			fld[Y1[i]][X2[i]]--;
			fld[Y2[i]][X1[i]]--;
			fld[Y2[i]][X2[i]]++;
		}
		// 横向累积
		for (int i = 0; i < H; i++)
		{
			for (int j = 1; j < W; j++)
			{
				fld[i][j] += fld[i][j - 1];
			}
		}
		// 纵向累积
		for (int i = 1; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				fld[i][j] += fld[i - 1][j];
			}
		}// 累积完后，fld中非0部分表示有挡板
		cout << bfs() << endl;
	}
	return 0;
}


Measured memory_bytes: 19032
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int m = scn.nextInt();
		int[] a = new int[m];
      	int[] b = new int[m];
		for(int i=0; i<m; i++){
			a[i] = scn.nextInt();
          	b[i] = scn.nextInt();
		}
      	ArrayList<Integer> list = new ArrayList<>();
      	for(int i=0; i<m; i++){
			if(a[i]==1) list.add(b[i]);
          	if(b[i]==n) list.add(a[i]);
		}
      	Collections.sort(list);
      	String ans = "IMPOSSIBLE";
      	for(int i=0; i<list.size()-1; i++){
          if((int)list.get(i) == (int)list.get(i+1)){
            ans = "POSSIBLE";
            break;
          }
        }
      	System.out.println(ans);
	}
}


Measured memory_bytes: 61888