akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, i;
    cin >> N;
    vector<int> d(N);
    for (i=0;i<N;i++) {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());

    int j=1;
    for(i=0;i<N-1;i++) {
        if(d.at(i)!=d.at(i+1)) j++;
    }

    cout << j << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define max(a,b) ((a)>(b) ? (a):(b))
int dp[1001][1001];
int lcs(char *s,char *t){
    int i,j,ls,lt;

    ls=strlen(s);
    lt=strlen(t);
    for(i=0;i<ls;i++){
	for(j=0;j<lt;j++){
	    if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
	    else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
	}
    }
    return dp[ls][lt];
}
int main(void){
    char s[1001],t[1001];
    int k;

    scanf("%d",&k);
    while(k--){
	scanf("%s%s",s,t);
	printf("%d\n",lcs(s,t));
    }

    return 0;
}

Measured memory_bytes: 4520
import math

n, m = map(int, input().split())
r = 2

if (n > 1):
  cn = math.factorial(n) / (2 * math.factorial(n - r))
else:
  cn = 0
  
if (m > 1):
  cm = math.factorial(m)  / (2 * math.factorial(m - r))
else :
  cm = 0
  
print(int(cn+cm))

Measured memory_bytes: 9140
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;

void main(){
    auto s = readln.chomp;
    auto n = s.length.to!int;

    if(n == 2){
        if(s[0] == s[1]){
            writeln(1, " ", 2);
            return;
        } else {
            writeln(-1, " ", -1);
            return;
        }
    }

    foreach(i ; 0 .. n - 2){
        if(s[i] == s[i + 1]){
            writeln(i+1, " ", i + 2);
            return;
        } else if(s[i + 1] == s[i + 2]){
            writeln(i+2, " ", i+3);
            return;
        } else if(s[i] == s[i + 2]){
            writeln(i+1, " ", i+3);
            return;
        }
    }

    writeln(-1, " ", -1);

}

Measured memory_bytes: 508
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		BitSet multiple = new BitSet(1000002);
		BitSet bs = new BitSet(1000002);
		for (int i = 0; i < N; i++) {
			int a = Integer.parseInt(sc.get());
			if (bs.get(a)) multiple.set(a);
			bs.set(a);
		}

		for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
			for (int j = 2; ; j++) {
				var divisible = i * j;
				if (bs.get(divisible)) {
					bs.clear(divisible);
				} else if (bs.nextSetBit(divisible) < 0){
					break;
				}

			}
		}
		bs.andNot(multiple);

		System.out.println(bs.cardinality());
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll m=n%10;
  if(m==3) cout<<"bon"<<endl;
  else if(m==2 ||m==4||m==5||m==7||m==9) cout<<"hon"<<endl;
  else cout<<"pon"<<endl;
}


Measured memory_bytes: 3692
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Paren> queue = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
		    queue.add(new Paren(sc.next().toCharArray()));
		}
		long current = 0;
		while (queue.size() > 0) {
		    Paren p = queue.poll();
		    if (current + p.min1 < 0) {
		        System.out.println("No");
		        return;
		    }
		    current += p.result;
		}
		if (current == 0) {
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
	
	static class Paren implements Comparable<Paren> {
	    int result;
	    int min1;
	    int min2;
	    
	    public Paren(char[] arr) {
	        min1 = 0;
	        result = 0;
	        for (char c : arr) {
	            if (c == '(') {
	                result++;
	            } else {
	                result--;
	            }
	            min1 = Math.min(min1, result);
	        }
	        min2 = min1 - result;
	    }
	    
	    public int compareTo(Paren another) {
	        if (result > 0 && another.result > 0) {
	            return another.min1 - min1;
	        } else if (result > 0 && another.result <= 0) {
	            return -1;
	        } else if (result <= 0 && another.result > 0) {
	            return 1;
	        } else {
	            return min2 - another.min2;
	        }
	    }
	}
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    for (int h = 1; h <= 3500; h++) {
        for (int n = 1; n <= 3500; n++) {
            lint par, chi;
            par = N * h * n;
            chi = 4 * h * n - N * (n + h);
            if (chi == 0) continue;
            if (par % chi == 0) {
                lint w = par / chi;
                if (w >= 1) {
                    cout << h << " " << n << " " << w << endl;
                    return 0;
                }
            } else {
                continue;
            }
        }
    }
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

const int M = 998244353;

int main() {

	IOS

	int n, k;
	cin >> n >> k;

	vector<pair<int, int>> interval(k);
	int x, y;

	for (int i = 0; i < n; i++)
		cin >> interval[i].first >> interval[i].second;

	vector<ll> pref_sum(n+2);
	vector<ll> ways(n+1, 0);

	ways[1] = 1;
	pref_sum[0] = 0;
	pref_sum[1] = 1;

	for (int i = 2; i <= n; i++) {
		// deb(i);

		for (int j = 0; j < k; j++) {
			int ri = i - interval[j].first;
			int li = i - interval[j].second;

			if (ri < 1)
				continue;

			li = max(1, li);

			ll rs = (pref_sum[ri] - pref_sum[li-1] + M) % M;
			ways[i] = (ways[i] + rs) % M;

			// deb(li);
			// deb(ri);
			// deb(rs);
		}

		pref_sum[i] = (ways[i] + pref_sum[i-1]) % M;
	}

	// for (int x: pref_sum)
	// 	cout << x << " ";
	// cout << endl;

	// for (int y: ways)
	// 	cout << y << " ";
	// cout << endl;

	cout << ways[n];

	return 0;
}

Measured memory_bytes: 6340
N, C = map(int, input().split())
STC = [[int(i) for i in input().split()] for i in range(N)]
STC.sort()

R = [[STC[0][1], STC[0][2]]]
for s, t, c in STC[1:]:
    for i in range(len(R)):
        t_r, c_r = R[i][0], R[i][1]
        if c == c_r and t_r <= s:
            R[i] = [t, c]
            break
        if c != c_r and t_r < s:
            R[i] = [t, c]
            break
    else:
        R.append([t, c])
        
print(len(R))

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

int main(void){
    ll N;
    cin >> N;
    string C;
    cin >> C;
    int W_n = count(C.begin(),C.end(),'W');
    int R_n = count(C.begin(),C.end(),'R');
    /*int Min_num;
    if(W_n > R_n) Min_num = W_n;
    else Min_num = R_n; 
    */
    int cnt = 0;
    int WW = C.length() - 1;
    int RR = 0;
    rep(k,N){
        if(C[RR] == 'W' && C[WW] == 'R'){
            C[RR] = 'R';
            C[WW] = 'W';
            RR++;
            WW--;
            cnt++;
        }
        if(C[RR] == 'R') RR++;
        if(C[WW] == 'W') WW--;
        if(RR >= WW) break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3724
/*input
300
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    let mut input: u32 = read_line().trim().parse().expect("");
    input = input / 100;
    let mut s = format!("ai1333");
    for _ in 0..input {
        s.push('3');
    }
    println!("{}", s);
}



Measured memory_bytes: 5028
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll b, ll exp){
    ll res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

int main()
{
    boost
    ll t,n;
    cin >> t;
    map<string,ll> ma;
    while(t--)  {
        string s;
        cin >> s;
        ma[s]++;
    }
    cout << "AC x " << ma["AC"] << "\nWA x " << ma["WA"] << "\nTLE x " << ma["TLE"] << "\nRE x " << ma["RE"];
    return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>

const int MAX_H = 100;
const int MAX_W = 100;

//&#36755;入
int H, W;
char g[MAX_H][MAX_W + 1];

int d[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};		//方向

//深度&#20248;先遍&#21382;g[i][j]同&#31867;局域
void dfs(int x, int y, int c){
	for(int i = 0; i < 4; i ++){
		int nx = x + d[i][0], ny = y + d[i][1];
		if(0 <= nx && nx < H && 0 <= ny && ny < W && g[nx][ny] == c){
			g[nx][ny] = '1';
			dfs(nx, ny, c);
		}
	}
}

void solve(){
	//遍&#21382;果&#22253;，&#27599;到一个新位置，遍&#21382;&#35813;位置能到&#36798;的地方
	int ans = 0;
	for(int i = 0; i < H; i ++){
		for(int j = 0; j < W; j ++){
			if(g[i][j] != '1'){
				ans ++;
				char c = g[i][j];
				g[i][j] = '1';
				dfs(i, j, c);
			}
		}
	}
	printf("%d\n", ans);
}

int main(int argc, char const *argv[]){

	while(scanf("%d %d", &H, &W)){
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i ++){
			scanf("%s", g[i]);
		}
		solve();
	}

	return 0;
}

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

int main(){
  string s;
  int x = 0;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if (i%2 == 0) {if (s.at(i) == '0'){ x++;}}
    else if (s.at(i) == '1') x++;
  }
  if (s.size() -x > x) cout << x << endl;
  else cout << s.size()  - x<< endl;
  
}

Measured memory_bytes: 512
import sys
N = int(input())
W = [input() for i in range(N)]

if len(W) != len(set(W)):
    print('No')
    sys.exit()

for i in range(1,N):
    if W[i][0] != W[i-1][-1]:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int S,h,m,s;
  scanf("%d",&S);
  s=S%60;
  S-=s;
  S/=60;
  m=S%60;
  S-=m;
  h=S/60;
    printf("%d:%d:%d\n",h,m,s);
  
    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define forn(i, n) for (int i = 0 ; i < int(n) ; i++)
#define fore(i, s, t) for (int i = s ; i < (int)t ; i++)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf(x) printf("%d\n",x)
#define each(x) for(auto it:x)  cout<<it<<endl;
#define pi pair<int,int>
#define pb push_back
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y) 
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
using namespace std;
typedef long long ll;
const ll P=1e9+7;
int main(){   
	long double n;
	cin>>n;
	n/=3.0;
	printf("%.10LF\n",n*n*n);
	
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int a,b;cin >>a>>b;
    if(a*b%2==0)puts("Even");
    else puts("Odd");
}

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

bool isPrime( int n )
{
	if( n == 2 ) return true;
	if( n % 2 == 0 ) return false;
	for( int i = 3; i * i <= n; i += 2 ) {
		if( n % i == 0 ) return false;
	}
	return true;
}

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

	int ans = 0;
	for( int i = 0; i < n; i++ ) {
		int x;
		cin >> x;
		if( isPrime( x ) ) ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>

int main()
{
  int i, j, narea, ssum;
  char s[20001];
  fgets(s, 20001, stdin);
  if (s[strlen(s)-1]=='\n') s[strlen(s)-1]='\0';
  int d, dmin, dmax, total, slen = strlen(s);
  d = dmin = dmax = 0;
  for (i=0;i<slen;i++) {
    if (s[i]=='\\') d--;
    else if (s[i]=='/')  d++;
    if (dmin>d) dmin=d;
    else if (dmax<d) dmax=d;
  }
  int start[dmax-dmin+1];
  for (i=0; i<dmax-dmin+1; i++)  start[i] = -1;
  int h[slen];
  bzero(h, sizeof(int)*slen);
  total = 0;
  d = -dmin;
  for (i=0; i<slen; i++) {
    if (s[i]=='\\') start[d--]=i;
    else if (s[i]=='/') {
      d++;
      if (start[d]>=0) {
        for (j=start[d]; j<i; j++)  h[j]++;
        total += i-start[d];
      }
    }
  }

  printf("%d\n", total);
  narea=ssum=0;
  for (i=0; i<slen; i++) {
    ssum += h[i];
    if (h[i]==0) {
      if (ssum>0) narea++;
      ssum=0;
    }
  }
  printf("%d", narea);
  if (narea>0) {
    for (i=0; i<slen; i++) {
      ssum += h[i];
      if (h[i]==0) {
        if (ssum>0) printf(" %d", ssum);
        ssum=0;
      }
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2140
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100


int main(){
  int W, H, N;
  int ans[SIZE][SIZE];
  int x[SIZE], y[SIZE], z[SIZE];

  cin >> W >> H >> N;

  priority_queue<pair<int, pair<int,int>>> pq;

  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      ans[i][j] = -INF;
    }
  }


  for (int i=0; i<N; i++) {
    cin >> x[i] >> y[i] >> z[i];
    x[i]--; y[i]--;
    pq.push({z[i], {y[i], x[i]}});
  }

  while(pq.size()) {
    auto p = pq.top(); pq.pop();
    int y = p.second.first;
    int x = p.second.second;
    int z = p.first;

    if (ans[y][x] != -INF) continue;
    ans[y][x] = z;

    if (0 < y) pq.push({z-1, {y-1, x}});
    if (0 < x) pq.push({z-1, {y, x-1}});
    if (y < H-1) pq.push({z-1, {y+1, x}});
    if (x < W-1) pq.push({z-1, {y, x+1}});
  }

  for (int i=0; i<N; i++) {
    ans[y[i]][x[i]] = z[i];
  }

  int sum = 0;

  bool ng = false;

  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (0 < i) ng |= abs(ans[i][j] - ans[i-1][j]) > 1;
      if (0 < j) ng |= abs(ans[i][j] - ans[i][j-1]) > 1;
      if (i < H-1) ng |= abs(ans[i][j] - ans[i+1][j]) > 1;
      if (j < W-1) ng |= abs(ans[i][j] - ans[i][j+1]) > 1;
    }
  }

  if (ng) {
    puts("No");
    return 0;
  }

  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      sum += ans[i][j];
    }
  }

  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;

int main(){
   int a, b, c, k;
   cin >> a>> b>>c >>k;
   int ans = 0;
   while(k){
       if(a > 0){k--;ans += 1;a--;}
       else if(b > 0){k--;ans += 0;b--;}
       else if(c > 0){k--; ans += -1; c--;}
   }
   cout << ans;

}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

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

int main ()
{
    fastio
    char c , a [5] = {'a' , 'e' , 'i' , 'o' , 'u' } ;
    bool t = false ;
    cin >> c ;
    loop (5)
        if (c == a[i])
            t = true ;
    cout << (t ? "vowel" : "consonant") ;


    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

type AB struct {
	A int
	B int
}
type ABS []AB

func (ab ABS) Len() int {
	return len(ab)
}

func (ab ABS) Swap(i, j int) {
	ab[i], ab[j] = ab[j], ab[i]
}

type ByA struct {
	ABS
}

func (b ByA) Less(i, j int) bool {
	return b.ABS[i].A < b.ABS[j].A
}

type ByB struct {
	ABS
}

func (b ByB) Less(i, j int) bool {
	return b.ABS[i].B < b.ABS[j].B
}

// func (b ByA) Less(i, j int) bool {
// if b[i].B < b[j].B {
// 	return true
// } else if b[i].B == b[i].B {
// 	if b[i].A < b[j].A {
// 		return true
// 	}
// }
// return false
// }

// type ByA []AB

// func (b ByA) Len() int {
// 	return len(b)
// }

// func (b ByA) Swap(i, j int) {
// 	b[i], b[j] = b[j], b[i]
// }

// func (b ByA) Less(i, j int) bool {
// 	// if b[i].B < b[j].B {
// 	// 	return true
// 	// } else if b[i].B == b[i].B {
// 	// 	if b[i].A < b[j].A {
// 	// 		return true
// 	// 	}
// 	// }
// 	// return false
// }

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

	n := nextInt()
	ab := make([]AB, n)
	for i := 0; i < n; i++ {
		ab[i] = AB{A: nextInt(), B: nextInt()}
	}

	// fmt.Println(ab)
	sort.Sort(ByA{ab})
	sort.Sort(ByB{ab})

	total := 0
	for i := 0; i < len(ab); i++ {
		total += ab[i].A

		if total <= ab[i].B {
			continue
		} else {
			fmt.Println("No")
			return
		}

	}

	fmt.Println("Yes")
}


Measured memory_bytes: 6272
import numpy as np
from sys import argv
import time


def input_from_file():
    with open(argv[1], "r") as f:
        D = int(f.readline())
        C = np.array(f.readline().split(), dtype=int)
        S = tuple(tuple(map(int, f.readline().split())) for _ in range(D))
    return D, C, S


def input_from_console():
    D = int(input())
    C = np.array(input().split(), dtype=int)
    S = tuple(tuple(map(int, input().split())) for _ in range(D))
    return D, C, S


def greed(D, C, S):
    last = np.ones(26, dtype=int)
    ans = []
    for s in S:
        s = np.array(s)
        tmp = s + C * last
        i = np.argmax(tmp)
        last[i] = 0
        last += 1
        ans.append(i + 1)
    return ans


def calc_score(D, C, S, T):
    res = 0
    last = np.ones(26, dtype=int)
    for d, t in enumerate(T):
        t -= 1
        last[t] = 0
        score = S[d][t]
        score -= (C * last).sum()
        res += score
        last += 1
    return res


def output_to_file(ans):
    with open("output.txt", "w", newline="") as f:
        for a in ans:
            f.write("{}\n".format(a))


def main():
    start = time.time()
    lim = 1.800
    D, C, S = input_from_console()
    #D, C, S = input_from_file()
    #初期解, 貪欲法
    sol = greed(D, C, S)
    score = calc_score(D, C, S, sol)
    while True:
        d = np.random.randint(0, D//2)
        q = np.random.randint(1, 27)
        old = sol[d]
        sol[d] = q
        new_score = calc_score(D, C, S, sol)
        if new_score > score:
            score = new_score
        else:
            sol[d] = old
        if time.time() - start >= lim:
            break
    print(*sol, sep="\n")
    # output_to_file(sol)


if __name__ == "__main__":
    main()

Measured memory_bytes: 27816
<?php
fscanf(STDIN, "%d %d %d %d %d", $n, $a, $b, $c, $d);
fscanf(STDIN, "%s", $s);
$s1 = substr($s, $a, $c - $a - 1);
$s2 = substr($s, $b, $d - $b - 1);
if (strpos($s1, '##') !== false || strpos($s2, '##') !== false) exit('No');
if ($c > $d) {
	$s = substr($s, $b - 2, $d - $b + 3);
	if (strpos($s, '...') === false) exit('No');
}
echo 'Yes';

Measured memory_bytes: 4604
#include <stdio.h>

int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);

	if((a==b)&&(a!=c))printf("Yes\n");
	else if((a!=b)&&(a==c))printf("Yes\n");
	else if((b==c)&&(b!=a))printf("Yes\n");
	else printf("No\n");
}

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

int main() {
  string S; cin >> S;
  long long int sum = 0;
  for (int i = 0; i < pow(2, S.length()-1); i++) {
    long long int s = 0;
    long long int t = S[0] - '0';
    for (int j = 1; j < S.length(); j++) {
      if ((i>>(j-1)) % 2 == 1) {
        s += t;
        t = S[j] - '0';
      }
      else
        t = t * 10 + S[j] - '0';
    }
    s += t;
    sum += s;
  }
  cout << sum << endl;
}


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

int main()
{
    char A[20],B[20],C[20];
    int i,j;
    scanf("%s%s%s",A,B,C);

    i=strlen(A);
    j=strlen(B);
    
    if((A[i-1]==B[0]) && (B[j-1]==C[0]))
    printf("YES");
    
    else printf("NO");

    return 0;
}


Measured memory_bytes: 1732
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 r, D, x;
	cin >> r >> D >> x;
	i64 ans = x;
	FOR(i, 2001, 2011)
	{
		ans = r * ans - D;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b)
{
  if (!b)
    return a;
  return gcd(b, a % b);
}
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x %= p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll po(ll base, ll powerRaised)
{
  if (powerRaised != 0)
    return (base * po(base, powerRaised - 1));
  else
    return 1;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long double h, a;
  cin >> h >> a;
  cout << (ceil)(h / a);
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//ll mod = 1000000007;
ll mod = 998244353;

signed main()
{
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> v;
    vector<vector<int>> c(h, vector<int>(w));
    rep(i, n)
    {
        int a;
        cin >> a;
        rep(j, a)
        {
            v.push_back(i);
        }
    }
    rep(i, h * w)
    {
        c[i / w][i % w] = v[i];
    }
    rep(i, h)
    {
        if (i % 2 == 1)
        {
            per(j, w)
            {
                cout << c[i][j] + 1 << " ";
            }
        }
        else
        {
            rep(j, w)
            {
                cout << c[i][j] + 1 << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[212345], t[212345];

int main(){
	scanf("%s%s", s, t);
	int n = strlen(s);
	int ans = 0;
	REP(i, n) ans += s[i] != t[i];
	printf("%d\n", ans);
}


Measured memory_bytes: 4212
import math

a, b, n = map(int, input().split())

if n+1 >= b:
    x = b
else:
    x = n

ans = [math.floor(a*x/b) - a*math.floor(x/b)]
ans.append(math.floor(a*(x-1)/b) - a*math.floor((x-1)/b))
if x < n:
    ans.append(math.floor(a*(x+1)/b) - a*math.floor((x+1)/b))

print(max(ans))

Measured memory_bytes: 8972
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
  public static void main(final String[] args) throws Exception {
    try (BufferedReader r = new BufferedReader(new InputStreamReader(System.in))) {
      String s = r.readLine();
      String[] a = s.split(" ");
      int sheeps = Integer.parseInt(a[0]);
      int wolves = Integer.parseInt(a[1]);
      if (wolves >= sheeps) {
        System.out.println("unsafe");
      } else {
        System.out.println("safe");
      }
    }
  }
}

Measured memory_bytes: 32416
#include <bits/stdc++.h>
#define MOD 10000007
using namespace std;

int main() {
  	long long int x; cin >> x;
  	
  	long long int start = 100;
   	int count = 0;
  	while (x > start){
      start += start / 100;
      count++;
    }
  	cout << count << "\n";
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
 
int main(void)
{
   int k, i;
   char s[101];
 
   scanf("%d",&k);
   scanf("%s",s);
 
   if(k>=strlen(s))printf("%s",s);
   else{
      for(i=0;i<k;i++)
         printf("%c",s[i]);
      printf("...\n");
   }
 
   return 0;
}

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

int main(void){
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> p.at(i);
  }

  int ans = 1;
  int threshold = p.at(0);
  for(int i = 1; i < N; i++){
    if(p.at(i) > threshold){
      continue;
    }else{
      ans++;
      threshold = p.at(i);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)



int main(void) {
	int N, M;
	int count=0;
	string s;
	map<string, int> m;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> s;
		m[s]++;
		count++;
		if (m[s] == 2) { count--; m[s] = 1; }
	}
	
	cout << count;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<math.h>

typedef long long int ll;

using namespace std;

int main(void){

    ll n;
    ll ans = 0;
    ll tmp = 0;
    ll min = 10000000000000;

    cin >> n;


    if(n == 1){
        cout << ans << endl;
    }else{
        for(ll i = 1;i <= sqrt(n);i++){
            if(n % i == 0){
                ll a = i;
                ll b = n/i;
                if(a == 1) tmp = b - 1;
                else if(b == 1) tmp = a - 1;
                else tmp = a + b - 2;

                if(min > tmp) min = tmp;
            }
        }
    }

    cout << min << endl;

    return 0;
}

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

using namespace std;

#define sd(x) scanf("%d", &x)
#define boost ios_base::sync_with_stdio(false);
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define f first
#define s second
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << 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(...)
#endif

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <vector <ll>> matrix;

const int mod = 1000000007;
const int inf = 50000000;
const int maxn = 1005;

int n, a, b, c, d;
int dp[maxn][maxn];
ll fact[maxn];

ll modpow(ll a, ll b) {
	ll x = 1, y = a;
	while (b) {
		if (b & 1) {
			x = (x * y) % mod;
		}
		y = (y * y) % mod;
		b /= 2;
	}
	return x;
}

int solve(int x, int y) {
	if (x == 0) {
		return 1;
	}
	if (y > b) {
		return 0;
	}
	if (dp[x][y] != -1) {
		return dp[x][y];
	}
	int ret = solve(x, y + 1);
	for (int i = c; i <= d && (i * y) <= x; i++) {
		int z = i * y;
		int tmp = (modpow(fact[i], mod - 2) * fact[x]) % mod;
		int inv = modpow(fact[y], i);
		tmp = (1LL * tmp * modpow(inv, mod - 2)) % mod;
		tmp = (1LL * tmp * modpow(fact[x - z], mod - 2)) % mod;
		assert(tmp >= 0);
		ret = (ret + (1LL * tmp * solve(x - (i * y), y + 1)) % mod) % mod;
	}
	return dp[x][y] = ret;
}

int main() {
	// freopen("i.txt", "r", stdin);
	// freopen("o.txt", "w", stdout);
	memset(dp, -1, sizeof(dp));
	fact[0] = 1;
	for (int i = 1; i < maxn; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	int ans = solve(n, a);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N; cin >> N;
int d = (int)log10(N) + 1;
if (d == 1) cout << N << endl;
else {
    int64_t n = N / pow(10, d-1), m = n;
    int64_t N9999 = n;
    rep(i, 0, d-1) (n *=10) += 9;
    if (N == n) cout << 9 * (d-1) + m << endl;
    else cout << 9 * (d-1) + m - 1 << endl;
}
}

// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

static const int N = 100;
static const int White = 0;
static const int Gray = 1;
static const int Black = 2;
int d[N], f[N],tt;
int color[N],n,M[N][N];
int nt[N];

int next(int u) {
	for (int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if (M[u][v]) {
			return v;
		}
	}
	return -1;
}

void dfs_visit(int u) {
	stack<int> S;
	S.push(u);
	color[u] = Gray;
	d[u] = ++tt;
	while (!S.empty()) {
		int u = S.top();
		int v = next(u);
		if (v != -1) {
			if (color[v] == White) {
				color[v] = Gray;
				d[v] = ++tt;
				S.push(v);
			}
		}
		else {
			color[u] = Black;
			S.pop();
			f[u] = ++tt;
		}
	}
}

void dfs() {
	int u;
	rep(u, n)color[u] = White;
	rep(u, n) {
		if (color[u] == White) dfs_visit(u);
	}
	rep(u, n) {
		cout << u + 1 << ' ' << d[u] << ' ' << f[u] << '\n';
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> n;
	int i;
	rep(i, n) {
		int u, k, v;
		cin >> u >> k;
		u--;
		int j;
		rep(j, k) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	dfs();
	return 0;
}


Measured memory_bytes: 3244
n = gets.to_i
string = gets.chomp
arr = []
mod = n % 26
string.each_char do |st|
  val = st.ord + mod
  if val > 90
    arr.push(('A'.ord + val - 90 - 1).chr)
  else
    arr.push((st.ord + mod).chr)
  end
end

print arr.join('')

Measured memory_bytes: 2428
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,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())

class UnionFind:
    def __init__(self,N): # 頂点数 N
        self.table = [i for i in range(N)]    # 親 table[x] == x で根
        self.rank  = [1 for i in range(N)]    # 木の長さ
        self.size  = [1 for i in range(N)]    # 集合のサイズ

    def Find(self,x):    #xの根を返す
        if self.table[x] == x:
            return x
        else:
            self.table[x] = self.Find(self.table[x]) #親の更新
            self.size[x] = self.size[self.table[x]]
            return self.table[x]

    def Unite(self,x,y): #xとyをdiff(x,y)=W で繋げる
        x,y = self.Find(x), self.Find(y)
        sx,sy = self.Size(x), self.Size(y)
        if x == y: return
        if self.rank[x] > self.rank[y]:
            self.table[y] = x
            self.size[x] = sx + sy
        else:
            self.table[x] = y
            self.size[y] = sx + sy
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def Check(self,x,y):
        return self.Find(x) == self.Find(y)

    def Size(self,x):
        return self.size[self.Find(x)]


N = inp()
AA = inpl()
BB = inpl()

BA = []
for i in range(N):
    BA.append((BB[i],AA[i]))


BA.sort()
act_AA = [(A,ai) for ai,(B,A) in enumerate(BA)]

sorted_AA = sorted(act_AA)

UF = UnionFind(N)

# print(sorted_AA)

for i,(A,ai) in enumerate(sorted_AA):
    UF.Unite(i,ai)


if UF.Size(0) != N:
    for i in range(N):
        A = sorted_AA[i][0]
        B = BA[i][0]
        if A <= B:
            continue
        else:
            print("No")
            sys.exit()
    print("Yes")
else:

    for i in range(N):
        A = sorted_AA[i][0]
        B = BA[i][0]
        if A <= B:
            continue
        else:
            print("No")
            sys.exit()

    for i in range(N-1):
        A1 = sorted_AA[i][0]
        A2 = sorted_AA[i+1][0]
        B1 = BA[i][0]
        B2 = BA[i+1][0]
        if A1 <= B2 and A2 <= B1:
            print("Yes")
            sys.exit()

    print("No")


Measured memory_bytes: 37720
#include<stdio.h>
int main()
{
  int p, q, r, sum1, sum2, sum3, min;
  scanf("%d %d %d", &p, &q, &r);
  sum1=p+q;
  sum2=p+r;
  sum3=q+r;
  min=sum1;
  if(min>sum2){
    min=sum2;}
  if(min>sum3){
    min=sum3;}
  
  printf("%d", min);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 3010
using namespace std;
ll n,dp[N][N],a[N],qdh[N],sum=0;
ll dfs(ll l,ll r)
{
	if(l>r)
	{
		return 0;
	}
	if(dp[l][r]!=-1)
	{
		return dp[l][r];
	}
	dp[l][r]=max(dp[l][r],qdh[r+1]-qdh[l]-dfs(l+1,r));
	dp[l][r]=max(dp[l][r],qdh[r+1]-qdh[l]-dfs(l,r-1));
	return dp[l][r];
}
int main(){
	ll i,j;
	cin>>n;
	qdh[0]=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		qdh[i+1]=qdh[i]+a[i];
		sum+=a[i];
	}
	memset(dp,-1,sizeof(dp));
	i=dfs(0,n-1);
	cout<<i-(sum-i)<<endl;
	return 0;
}

Measured memory_bytes: 71168
def solve():
    cands = []
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            is_center = True
            temp_h = -1
            for x, y, h in m:
                if h != 0:
                    calc_h = h + abs(cx - x) + abs(cy - y)
                    if temp_h == -1:
                        temp_h = calc_h
                    else:
                        if temp_h != calc_h:
                            is_center = False
                            break
            if is_center:
                cands.append((cx, cy, temp_h))

    for cx, cy, temp_h in cands:
        is_answer = True
        for x, y, h in m:
            if h == 0:
                if temp_h - abs(cx - x) - abs(cy - y) > 0:
                    # h=0の位置では、計算された高さは0以下の必要がある
                    is_answer = False
                    break
        if is_answer:
            return cx, cy, temp_h

    return -1, -1, -1


n = int(input())
m = tuple(tuple(map(int, input().split())) for _ in range(n))
print(*solve())


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<17;

int main(){
    int d,w;
    while(cin >> d >> w){
        if(d==0&&w==0) break;
        int st[d][w];
        for(int i=0;i<d;i++){
            for(int j=0;j<w;j++){
                cin >> st[i][j];
            }
        }
        int ans=0;
        for(int i=0;i<d;i++){
            for(int j=0;j<w;j++){
                for(int y=3;y<=d;y++){
                    for(int x=3;x<=w;x++){
                        int mini=INF,maxi=-1;
                        if(d<i+y||w<j+x) continue;
                        int sum=0;
                        for(int s=0;s<y;s++){
                            for(int t=0;t<x;t++){
                                if(s==0||s==y-1||t==0||t==x-1){
                                    mini=min(mini,st[i+s][j+t]);
                                }
                                else{
                                    sum+=st[i+s][j+t];
                                    maxi=max(maxi,st[i+s][j+t]);
                                }
                            }
                        }
                    if(maxi<mini) ans=max(ans,mini*(x-2)*(y-2)-sum);
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
n,m = map(int,input().split())
value_sum = [[0]*n for i in range(8)]
ans = [0]*8
for i in range(n):
    value = list(map(int,input().split()))
    for j in range(8):
        for k in range(3):
            if ((j>>k)&1):
                value_sum[j][i] += value[k]
            else:
                value_sum[j][i] -= value[k]
for i in range(8): 
    value_sum[i].sort(reverse=True)
    ans[i] = sum(value_sum[i][:m])
print(max(ans))

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

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

    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i] -= x;
        if (a[i] < 0)
            a[i] *= -1;
    }
    int ans = a[0];
    for (int i = 1; i < n; i++)
    {
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}

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

int main() {
  long long A,B,N;
  cin >> A >> B >> N;
  long long x;
  if(N>=B) x = B-1;
  else x = N;
  
  long long a,b;
  a = A*x/B;
  b = x/B;
  cout<<a-b<<endl;
      
}



Measured memory_bytes: 3580