akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include<unordered_map>
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define P complex<ld>
#define X real()
#define Y imag()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(i,s,n)   for(int i=s;i<=n;i++)
#define print(v) {for(auto i:v)cout<<i<<" ";cout<<"\n";}
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll amr_abdelazim;cin>>amr_abdelazim;while(amr_abdelazim--)
#define popcnt(x) __builtin_popcount(x)
#define EPS 1e-9
#define INF 1000000000000000009
using namespace std;
//freopen("output.txt", "w", stdout);
//freopen("input.txt", "r", stdin);
const int mod = 1000000007;
const int N = 2 * 100000 + 9;
const double pi = acos(-1);
class cmp{
public:
	bool operator() (ll &A, ll &B){
		return A > B;
	}
};
bool by_sec(const pll &a, const pll &b){
	if ((abs(a.first) == abs(b.first)))
		return (abs(a.second) < abs(b.second));
	return (abs(a.first) < abs(b.first));
}
bool byth(const tuple<ll, ll, ld>& a, const tuple<ll, ll, ld>& b){
	return (get<2>(a) < get<2>(b));
}
ld dist(P a, P b){
	return (ld)abs(a - b);
}
ll fact[1000009], inv[1000009];
ll fp(ll a, ll b){
	if (b == 0)
		return 1;
	ll ans = fp(a, b / 2);
	ans = (ans * ans) % mod;
	if (b % 2 != 0)
		ans = (ans * (a % mod)) % mod;
	return ans;
}
void FacInv(ll n){
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = ((i%mod) * fact[i - 1] % mod) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}
ll ncr(ll n, ll r){
	return (((fact[n] * inv[r]) % mod) * inv[n - r]) % mod;
}
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll max(ll a, ll b){
	if (a >= b)return a;
	else return b;
}
ll min(ll a, ll b){
	if (a <= b)return a;
	else return b;
}

vvll gr(N);
bool vis[N][4];
vll en;
void dfs(ll n, ll c){
	vis[n][c] = 1;
	if (c == 0){
		if (!vis[n][3]){
			vis[n][3] = 1;
			en.push_back(n);
		}
		return;
	}
	for (auto i : gr[n]){
		if (!vis[i][c-1])
		dfs(i, c - 1);
	}
}

int main()
{
	Amr_Abdelazim

		ll x, y, a, b;
	cin >> x >> y >> a >> b;
	ll dx = a - x, dy = b - y;
	cout << a - dy << " " << b + dx << " ";
	cout << x - dy << " " << y + dx << "\n";
	return 0;
}

Measured memory_bytes: 7724
N = int(input())
S = str(input())

l, r = 0, 0
p, m = 0, 0
for i in range(N):
  if S[i] == "(":
    l += 1
  else:
    r += 1
  if l < r:
    p += 1
    l += 1

m = l - r

for i in range(p):
  print("(", end = "")
print(S, end ="")
for i in range(m):
  print(")", end = "")

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

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int r=Integer.parseInt(st.nextToken());
        int c=Integer.parseInt(st.nextToken());
        int[][] matrix=new int[r+1][c+1];
        int sum;
        for(int i=0;i<r;i++){
            st=new StringTokenizer(br.readLine());
            sum=0;
            for(int j=0;j<c;j++){
                matrix[i][j]=Integer.parseInt(st.nextToken());
                sum+=matrix[i][j];
            }matrix[i][c]=sum;
        }for(int i=0;i<c+1;i++){
            sum=0;
            for(int j=0;j<r;j++){
                sum+=matrix[j][i];
            }matrix[r][i]=sum;
        }
        for(int i=0;i<r+1;i++){
            for(int j=0;j<c;j++){
                System.out.print(matrix[i][j]+" ");
            }System.out.println(matrix[i][c]);
        }
    }
}

Measured memory_bytes: 29984
fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn main() {
    let n = read::<i32>()[0];
    let query: Vec<_> = (0..n).map(|_| read::<i32>()).collect();
    for cx in 0..101 {
        for cy in 0..101 {
            let q = query.iter().find(|t| (**t)[2] > 0).unwrap();
            let height = (q[0] - cx).abs() + (q[1] - cy).abs() + q[2];

            if query
                .iter()
                .all(|q| std::cmp::max(height - (q[0] - cx).abs() - (q[1] - cy).abs(), 0) == q[2])
            {
                println!("{} {} {}", cx, cy, height);
                return;
            }
        }
    }
}


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

int main(void){
    char s[27], *a = "yes";
    int flag = 0;

    scanf("%s", s);
    for(int i = 0; i < strlen(s); i++){
        for(int j = i+1; j < strlen(s); j++){
            if(s[i] == s[j]){
                a = "no";
                flag = 1;
                break;
            }
        }
        if(flag == 1) break;
    }

    printf("%s", a);
    
    return 0;
}

Measured memory_bytes: 1732
<?php

fscanf(STDIN, '%d', $n);
$input = [];
for ($i = 0;$i < $n; $i++){
    $input[] = explode(' ',rtrim(fgets(STDIN), PHP_EOL));
}

$before_t = 0;
$before_x = 0;
$before_y = 0;


foreach ($input as $value) {
    $diff_t = abs($value[0] - $before_t);
    $diff_p = abs(($value[1]-$before_x) + ($value[2] - $before_y));

//    var_dump($diff_t, $diff_p,$diff_t < $diff_p);
    if ($diff_t < $diff_p) {
        echo 'No' . PHP_EOL;
        return;
    }

    if ($diff_t % 2 !== 0 && $diff_p %2 === 0) {
        echo 'No'.PHP_EOL;
        return;
    } elseif ($diff_t %2 === 0 && $diff_p %2 !== 0) {
        echo 'No'.PHP_EOL;
        return;
    }

    $before_t = $value[0];
    $before_x = $value[1];
    $before_y = $value[2];
}
echo 'Yes'.PHP_EOL;


Measured memory_bytes: 54132
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int n;cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>b(n+1,0);
    int s=0;
    for(int i=n;i>0;i--)
    {
        int sum=0;
        for(int j=i+i;j<=n;j+=i)
        {
            sum+=b[j];
        }sum%=2;
        if(sum!=a[i]) b[i]=1;
    }
    for(int i=1;i<=n;i++)s+=b[i];
    cout<<s<<endl;
    for(int i=1;i<=n;i++)if(b[i])cout<<i<<" ";
}

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int A;
    long long int B, N;
    cin >> A >> B >> N;
    if(N >= B){
    cout << floor((A*B-A-B)/B)+1 << endl;
    }
    else{
        int f = floor(A*N/B);
        cout << f << endl;
    }
}

Measured memory_bytes: 3788
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

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

    typedef pair<ll, ll> P;
    vector<P> c_b;
    
 
    for (ll i = 0; i < n; i++) {
        ll a; cin >> a;
        c_b.push_back(P(a, 1));
    }


    for (ll i = 0; i < m; i++) {
        ll b, c;    
        cin >> b >> c;
        c_b.push_back(P(c, b));
    }

    sort(c_b.begin(), c_b.end(), greater<P>());


    ll cnt = 0, ans = 0, i = 0;

    while (cnt < n) {
        ll y = c_b[i].second;
        ll x = c_b[i].first;
        i++;
        if (cnt + y <= n) {
            ans += x*y;
            cnt += y;
        }
        else {
            y = n-cnt;
            ans += x*y;
            cnt += y;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6384
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define NMAX 100000
struct node {
  int id;
  int weight;
  struct node *next;
};
struct point {
  int id;
  int x;
  int y;
};
struct node *list[NMAX];
struct point pos[NMAX];
int key[NMAX], visit[NMAX], heap[NMAX], heap_index[NMAX], heapsize; 

int comparex(const void *a, const void *b);
int comparey(const void *a, const void *b);
void Insert(int, int, int);
void downheap(int);
void upheap(int);
void PQ_init(int);
void PrimPQ(int, int);
int main(void)
{
  int i, j, n, x, y;
  long long int cost = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) list[i] = NULL;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    pos[i].id = i;
    pos[i].x = x;
    pos[i].y = y;
  }
  qsort(pos, n, sizeof(struct point), comparex);
  for (i = 0; i < n - 1; i++) Insert(pos[i].id, pos[i+1].id, abs(pos[i].x - pos[i+1].x));
  qsort(pos, n, sizeof(struct point), comparey);
  for (i = 0; i < n - 1; i++) Insert(pos[i].id, pos[i+1].id, abs(pos[i].y - pos[i+1].y));
  PrimPQ(0, n);
  for (i = 0; i < n; i++) {
    cost += key[i];
    free(list[i]);
  }
  printf("%lld\n", cost);
}
int comparex(const void *a, const void *b)
{
  int ax = ((struct point*)a)->x, bx = ((struct point*)b)->x;
  return ax - bx;
}
int comparey(const void *a, const void *b)
{
  int ay = ((struct point*)a)->y, by = ((struct point*)b)->y;
  return ay - by;
}
void Insert(int a, int b, int weight)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->weight = weight;
  p->id = b;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->weight = weight;
  p->id = a;
  p->next = list[b];
  list[b] = p; 
}
void downheap(int k)
{
  int j, v = heap[k];
  while (k < heapsize / 2) {
    j = 2 * k + 1;
    if (j < heapsize - 1 && key[heap[j]] > key[heap[j+1]]) j++;
    if (key[v] <= key[heap[j]]) break;
    heap[k] = heap[j];
    heap_index[heap[j]] = k;
    k = j;
  }
  heap[k] = v;
  heap_index[v] = k;
}
void upheap(int j)
{
  int k, v = heap[j];
  while (j > 0) {
    k = (j + 1) / 2 - 1;
    if (key[v] >= key[heap[k]]) break;
    heap[j] = heap[k];
    heap_index[heap[k]] = j;
    j = k;
  }
  heap[j] = v;
  heap_index[v] = j;
}
void PQ_init(int size)
{
  int i;
  heapsize = size;
  for (i = 0; i < size; i++) {
    heap[i] = heap_index[i] = i;
  }
  for (i = size / 2 - 1; i >= 0; i--) {
    downheap(i);
  }
}
void PrimPQ(int p, int size)
{
  int i;
  for (i = 0; i < size; i++) {
    key[i] = INT_MAX;
    visit[i] = 0;
  }
  key[p] = 0;
  PQ_init(size);
  while (heapsize > 0) {
    struct node *n;
    int u = heap[0];
    visit[u] = 1;
    heap[0] = heap[heapsize - 1];
    heap_index[heap[heapsize - 1]] = 0;
    heapsize--;
    downheap(0);
    for (n = list[u]; n != NULL; n = n->next) {
      int v = n->id, w = n->weight;
      if (visit[v] == 0 && w < key[v]) {
	key[v] = w;
	upheap(heap_index[v]);
      }
    }
  }
}

Measured memory_bytes: 16232
# B - Buffet
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
for i in range(len(A)):
    j = A[i]
    ans += B[int(j-1)]
    if i == 0:
        pass
    else:
        if A[i]-A[i-1] == 1:
            ans += C[int(j-2)]
print(ans)

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

int main(){
	int a,b;
	string op;
	while(1){
		cin >> a >> op >> b;
		if(op == "+"){
			cout << a + b << endl;
		}else if(op == "-"){
			cout << a - b << endl;
		}else if(op == "*"){
			cout << a * b << endl;
		}else if(op == "/"){
			cout << a / b << endl;
		}else{
			break;
		}
	}
	return 0;
}			

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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int MAXN = 1E5 + 10;

int n;
unsigned a[MAXN], b[MAXN];
int ans;

void solve(int l, int r){
	for (int j, i = l; i < r; )
		if (a[i] <= b[i])
			++i;
		else{
			b[i] <<= 1;
			for (j = i + 1; j < r && a[j] > b[j]; ){
				b[j] <<= 1, ++j;
				if (b[j - 1] > a[j - 1])
					break;
			}
			++ans;
			solve(i, j);
			i = j;
		}
}

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%u", a + i), b[i] = 1;
	solve(0, n);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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 int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	int n, k;
	cin >> n >> k;
	Vl A(n);
	rep(i, n)  cin >> A[i];
	
	int i = k;
	for (i; i < n; i++) {
		if (A[i] > A[i - k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 4824
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ

        Scanner sc = new Scanner(System.in);


        int N = sc.nextInt();
        int Y = sc.nextInt();
        int sum = 0;
        int man = 0;
        int gosen = 0;
        int sen = 0;
        int flag = 0;
        for (int i = 0; i < N + 1; i++) {
            man = i;
            for (int j = 0; j < N - i + 1; j++) {
                gosen = j;
                sen = N - man - gosen;
                sum = man * 10000 + gosen * 5000 + sen * 1000;
                if (sum == Y) {
                    System.out.print(man);
                    System.out.print(" ");
                    System.out.print(gosen);
                    System.out.print(" ");
                    System.out.print(sen);
                    flag = 1;
                    break;
                }
            }
            if (flag == 1) break;
        }
        if (flag == 0) {
            System.out.println("-1 -1 -1");
        }


    }

}

Measured memory_bytes: 23636
# -*- coding: utf-8 -*-
n,d=map(int,input().split())
x=[]
for _ in range(n):
    x.append(list(map(int,input().split())))
count=0
distance=0
for i in range(n):
    for j in range(i+1,n):
        distance=[(x[i][m]-x[j][m])**2 for m in range(d)]
        if sum(distance)**(1/2)==int(sum(distance)**(1/2)):
            count=count+1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    string s,t;
    cin >> s >> t;
    int mn = INF, change;
    for(int i = 0; i <= s.length()-t.length(); ++i){
    	change = 0;
    	for(int j = i; j < i+t.length(); ++j){
    		if(s[j]!=t[j-i]){
    			change++;
    		}
    	}
    	mn = min(mn, change);
    }
    cout << mn << '\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-


def main():
    """Function."""
    x, y = map(int, input().split())

    if x > 0 and y > 0:
        if y > x:
            print(y - x)
        else:
            print(x - y + 2)
    elif x < 0 and y < 0:
        if y > x:
            print(y - x)
        else:
            print(x - y + 2)

    elif x == 0:
        if y > 0:
            print(y)
        else:
            print(-y + 1)
    elif y == 0:
        if x > 0:
            print(x + 1)
        else:
            print(-x)
    else:
        print(max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1)


if __name__ == "__main__":
    main()


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

int main(){
  int A, B;
  cin>> A>> B;
  int curtain = B*2;
  
  if(A<=curtain){
    cout<< "0"<< endl;
  }
  else{
    cout<< A-curtain<< endl;
  }
}

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

int main() {

    int x, y;
    int a1 = 0, b2 = 0, c3 = 0;
    int a[7] = {1,3,5,7,8,10,12};
    int b[4] = {4,6,9,11};
    int c[1] = {2};

    cin >> x >> y;
    for (int i = 0; i < 7; i++) {
        if (x == a[i] || y == a[i]) a1++;
        else;
    }
    

    for (int i = 0; i < 4; i++) {
        if (x == b[i] || y == b[i]) b2++;
        else;
    }
    

    for (int i = 0; i < 1; i++) {
        if (x == c[i] || y == c[i]) c3++;
        else;
    }
    

    if (a1 == 2 || b2 == 2 || c3 == 2) {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;

}

Measured memory_bytes: 256
from collections import deque
K = int(input())

L = {i: 10**6 for i in range(K)}
L[1] = 1
biq = deque()
biq.append(1)

while len(biq) > 0:
    i = biq.popleft()
    if i == 0:
        break
    j = (i * 10) % K
    if L[j] > L[i]:
        L[j] = L[i]
        biq.appendleft(j)
    k = 0 if i == K - 1 else i + 1
    if L[k] > L[i]:
        L[k] = L[i] + 1
        biq.append(k)

print(L[0])


Measured memory_bytes: 15468
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, i, j, minv=100000000, p, W=0, E=0, w=0, e=0;
	int righte=0, rightw=0, righttotal=0, lefttotal=0, leftw=0, lefte=0;
	string s, s1, s2;
	cin >> n >> s;
	int a[n]={0}, b[n]={0}, c[n]={0};
	for (i=0; i<n; i++)
	{
		if (s[i]=='E')	E++;
		else	W++;
	} 
	if(s[0] == 'E')
	{
		righte = E - 1;
		rightw = W;
	}
	else if(s[0] == 'W')
	{
		righte = E;
		rightw = W -1 ;
	}
	righttotal = righte ;
	lefttotal = 0;
	minv = righttotal + lefttotal;
	for (i=0; i<n; i++)
	{
		if(s[i-1] == 'W')
		{
			lefttotal ++;
			leftw ++;
		}
		else if(s[i-1] == 'E')
		{
			lefte ++;
		}
		if(s[i] == 'E')
		{
			righte = E - lefte - 1;
			rightw = W - rightw;
		}
		else if(s[i] == 'W')
		{
			righte = E - lefte;
			rightw = W - leftw - 1;
		}
		//cout << righte << ' ' << leftw << endl;
		p=righte+leftw;
		if (p<minv)
		{
			minv=p;
			//cout << i << endl;
		}
	}
	cout << minv << endl;
	return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N; string S;
    cin >> N >> S;
    ll ans = 0;
    rep(i, 1000) {
        int c[3] = {i / 100, (i / 10) % 10, i % 10};
        int f = 0;
        rep(j, N) {
            if(S[j] == (c[f] + '0')) f++;
            if(f == 3) break;
        }
        if(f == 3) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] a = new int[N];
		int sum_log2 = 0;
		for(int i=0;i<N;i++) {
			a[i] =sc.nextInt();
			sum_log2 += log2(a[i]);
		}

		System.out.println(sum_log2);
	}

	public static int log2(int a) {

		if(a % 2 != 0) {
			return 0;
		}else {
			return 1 + log2(a/2);
		}
	}

}


Measured memory_bytes: 36184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}

vector<int> p, r;
vector<vector<int>> e;
vector<bool> vst;

// int find(int x){
//     if(p[x] == x){
//         return x;
//     }
//     find(p[x]);
// }

int main()
{
    int n, m;
    cin >> n >> m;
    e.resize(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        e[a-1].push_back(b-1);
        e[b-1].push_back(a-1);
    }

    vst.resize(n);
    FOR(i, 0, n) vst[i]=false;
    vst[0] = true;

    p.resize(n); r.resize(n);
    rep(i, n) {
        p[i] = i;
        r[i] = 1;
    }

    vector<int> ans(n);
    rep(i, n) ans[i] = -1;
    vector<int> vset[n];
    vset[0].push_back(0);
    int vset_wholesize = 1;

    int k = 0;
    while(1){
        // printvec(vset[k]);
        if(vset_wholesize==n) break;
        for(auto i=vset[k].begin(); i!=vset[k].end(); i++){
            int from = *i;
            for(auto to=e[from].begin(); to!=e[from].end(); to++){
                if(vst[*to] == true) continue;
                ans[*to] = from;
                vset[k+1].push_back(*to);
                vst[*to] = true;
                vset_wholesize++;
            }
        }
        k++;
    }

    if(vset_wholesize < n){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    FOR(i, 1, n){
        printf("%d\n", ans[i]+1);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 15320
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
class edge{
public:
	int to;
	double dist;
	int bit;
	edge(){}
	edge(int _to,double _dist,int _bit){
		to = _to;
		dist = _dist;
		bit = _bit;
	}
	bool operator<(const edge &a)const{
		return dist>a.dist;
	}
};

int main(){
    int N,M,P,a,b;
    while(true){
    	vector < edge > G[32];
    	scanf("%d %d %d %d %d",&N,&M,&P,&a,&b);
    	if(N+M+P+a+b == 0)break;
    	a--;b--;
    	int horse[12];
    	rep(i,N){
    		scanf("%d",&horse[i]);
    	}
    	rep(i,P){
    		int from,to;
    		double dist;
    		scanf("%d %d %lf",&from,&to,&dist);
    		from--;to--;
    		G[from].PB(edge(to,dist,0));
    		G[to].PB(edge(from,dist,0));
    	}
    	priority_queue < edge > Q;
    	double d[1<<9][32];
    	rep(i,1<<9){
    		rep(j,32){
    			d[i][j] = INF;
    		}
    	}
    	Q.push(edge(a,0,0));
    	while(!Q.empty()){
    		edge e = Q.top();Q.pop();
    		if(d[e.bit][e.to] != INF)continue;
    		d[e.bit][e.to] = e.dist;
    		rep(i,G[e.to].size()){
    			rep(j,N){
    				if(!(e.bit>>j & 1)){
    					double distance = (double)G[e.to][i].dist/horse[j]+d[e.bit][e.to];
    					Q.push(edge(G[e.to][i].to,distance,e.bit|1<<j));
    				}
    			}
    		}
    	}
    	double ans = INF;
    	rep(i,1<<N){
    		ans = min(ans,d[i][b]);
    	}
    	if(ans == INF)puts("Impossible");
    	else printf("%.3lf\n",ans);
    }
    return 0;
}

Measured memory_bytes: 27756
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
using namespace std;

long long r,d,x;

int main(){
  cin >> r >> d >> x;
  for(int i=0;i<10;i++){
    x = r*x - d;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e16;
typedef long long ll;
ll mod = 1e9+7;
ll fast_exp(ll a, ll b)
{
    if(b == 0)
        return 1;
    else
    {
        ll res = 1;
        res = fast_exp(a,b/2);
        res = (res*res)%mod;
        if(b%2 == 1)
            res = (res*a)%mod;
        return res;
 
    }
}
 const ll N = 1e6+5;
ll fact[N];

ll bin(ll n, ll k)
{
  ll a = n-k;
   a = fact[a];
   a = fast_exp(a,mod-2);
   k = fact[k];
   k = fast_exp(k,mod-2);
  n = fact[n];

  ll temp = (n*k)%mod;
  temp = (temp*a)%mod;
  return temp;
}
 
int main()
{
   // ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
   ll x,y;
   cin>>x>>y;
   ll ways = 1;
   ll moves = (x+y)/3;
   
   fact[0] = 1;
   if(x<moves || y<moves || (x+y)%3 != 0)
   {
      cout<<0<<endl;
      return 0;
   }
   x = x-moves;
   y = y-moves;
   for(ll i = 1; i<N ; i++)
    fact[i] = (i*fact[i-1])%mod;


  cout<<bin(moves,x)<<endl;


 return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <math.h>
#define LL long long int
#define N 1000
int main()
{
    int n,t,i,flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&t);
        if(t%2==0){
            if(t%5!=0&&t%3!=0)
                flag=1;
        }
    }
    if(flag)
        printf("DENIED");
    else printf("APPROVED");
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  if(n < 10){
    cout << n << endl;
    return 0;
  }
  int x = n , y = n - 1, d = 0;
  while(x > 0){
    x /= 10;
    ++d;
  }
  while(y > 0){
    y /= 10;
    --d;
  }
  if(d == 0){
    int ans = 0;
    while(n > 0){
      ans += n % 10;
      n /= 10;
    }
    cout << ans << endl;
  }else{
    cout << 10 << endl;
  }
}

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

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];

int main(void){

  cin.tie(0);
  ios::sync_with_stdio(false);

  string O;
  string E;

  cin >> O >> E;

  if(O.length() == E.length()){
    REP(i, O.length()-1) cout << O[i] << E[i];
    cout << O[O.length()-1] << E[O.length()-1] << endl;;
  }else{
    REP(i, O.length()-1) cout << O[i] << E[i];
    cout << O[O.length()-1] << endl;
  }
  return 0;

}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if ((S[2]==S[3]) && (S[4]==S[5])) cout << YES <<endl;
    else cout << NO << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, temp;
  int A[N+1];
  int count=0;
  scanf("%d", &n);

  for (i=0;i<n;i++) scanf("%d", &A[i]);

  for (i=0;i<n;i++)
  {
    int min=i;
    for (j=i;j<n;j++)
      if (A[j]<A[min])
        min=j;
    if (min != i)
    {
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
    count++;
    }
  }

  trace(A, n);

  printf("%d\n",count);
  
  
  return 0;
}

Measured memory_bytes: 1864
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int A, B;
  scanf("%d", &A);
  scanf("%d", &B);
  for (int x=(int)((double)(A+0.07999)/0.08); x<(double)(A+1)/0.08; x++){
    if (x*0.1>=B && x*0.1<B+1){
      printf("%d\n", x);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 888
use text_io::*;
use std::process::exit;

fn main(){
    let mut a:usize = read!();
    a = a%10;
    let mut b:&str = "hon";
    if a==0 || a==1 || a==6 || a==8 {
        b = "pon";
    }
    else if a==3{
        b = "bon";
    }
    println!("{}",b);
}

Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = min(b - 1, n - a);
    if ((b - a) % 2 == 0)
    {
        ans = min(ans, (b - a) / 2);
    }
    else
    {
        ans = min(ans, min(n - b + 1, a) + (b - a) / 2);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ASSERT(C, ...) assert( (C) || (PRINT(__VA_ARGS__), false) )
template <class Head> void PRINT(Head head) {
    std::cout << head << "\n";
}
template <class Head, class... Tail> void PRINT(Head head, Tail... tail) {
    std::cout << head << " ";
    PRINT(tail...);
}

ll solve1(ll N, ll M, ll V, ll P, vector<ll>& A) {
    sort(A.begin(), A.end());
    if ( P >= V ) {
        //ll cr = A[N-1-(V-1)] - M;
        ll cr = A[N-P] - M;
        ll i = lower_bound(A.begin(), A.end(), cr) - A.begin();
        return N - i;
    } else {
        ll cr = A[N-1-(P-1)] - M;
        ll i0 = lower_bound(A.begin(), A.end(), cr) - A.begin();
        if ( i0 > V - P ) {
            return N - i0;
        } else {
            vector<ll> ca(N);
            ll sm = 0;
            for ( int i = 0; i < N; i++ ) {
                sm += A[i];
                ca[i] = sm;
            }
            for ( ll j = i0; j < N-P; j++ ) {
                ll rm = (V - P - j) * M;
                ll f = (A[j]+M) * (N-P-j) - (ca[N-P] - ca[j]);
                if ( f >= rm ) {
                    return N - j;
                }
            }
            return P;
        }
    }
    return -1;
}

ll solve2(ll N, ll M, ll V, ll P, vector<ll>& A) {
    sort(A.begin(), A.end(), greater<>());

    auto check = [&](ll x) {
        if ( x < P ) return true;
        ll c = (P-1) * M;
        if ( A[P-1] > A[x] + M ) return false;
        c += (N - x) * M;
        for ( int i = P-1; i < x; i++ ) {
            c += A[x] + M - A[i];
        }
        return c >= V * M;
    };

    ll l = 0, r = N;
    while ( r - l > 1 ) {
        ll m = (l + r) / 2;
        if ( check(m) ) l = m;
        else r = m;
    }
    return l + 1;
}
int test() {
    mt19937_64 mt64(0);
    uniform_int_distribution<ll> rnd(1, 100);
    uniform_int_distribution<ll> rnd1(1, 10);
    uniform_int_distribution<ll> rnd2(1, 10000);

    ll tmax = 100;
    for ( int t = 0; t < tmax; t++ ) {
        ll n = 1 + rnd(mt64);
        ll m = t < tmax/2 ? rnd1(mt64) : rnd2(mt64);
        ll v = 1 + rnd(mt64) % (n-1);
        ll p = 1 + rnd(mt64) % (n-1);
        vector<ll> a(n);
        for ( int i = 0; i < n; i++ ) {
            a[i] = (t < tmax/2 ? rnd1(mt64) : rnd2(mt64)) - 1;
        }
        if ( t == 16 ) {
            ll z = 1;
        }
        ll ans1 = solve1(n,m,v,p,a);
        ll ans2 = solve2(n,m,v,p,a);
        ASSERT(ans1 == ans2, t, ans1, ans2);
    }

    return 0;
}

int main() {
    //test();

    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    auto ans = solve1(N, M, V, P, A);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
using System;
class SS
{
  static void Main()
  {
    var lines=Console.ReadLine().Split(' ');
    long M=long.Parse(lines[0]);
    long N=long.Parse(lines[1]);
    long syo=M/N;
    //Console.WriteLine(syo);
    long a1=ABS(N*syo-M);
    long a2=ABS(N*syo+N-M);
    if(a1<a2)
      Console.WriteLine(a1);
    else
      Console.WriteLine(a2);
  }
  static long ABS(long n)
  {
    if(n<0)
      return n*-1;
    else
      return n;
  }
}


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

int main()
{
  string s;
  cin >> s;
  
  int price = 700;
  if (s.at(0) == 'o') price += 100;
  if (s.at(1) == 'o') price += 100;
  if (s.at(2) == 'o') price += 100;
  
  cout << price;
  return 0;
}

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

#define ll long long

using namespace std;


int main(){
    int A, B;
    cin >> A;
    cin >> B;
    if(A > B){
        int tmp = A;
        A = B;
        B = tmp;
    }
    if(A == 1 && B == 2) cout << 3 << endl;
    else if(A == 2 && B == 3) cout << 1 << endl;
    else cout << 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        final double pi = 3.14159265358979323846;
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();

        double dist = A*A + B*B - A*B*Math.cos(2*pi*(M/60 - (H*60+M)/720))*2;

        System.out.println(Math.sqrt(dist));
    }
}


Measured memory_bytes: 37528
N = int(input())

k = 1
while k * (k + 1) // 2 < N:
    k += 1

ans = list(range(1, k+1))
v = k * (k + 1) // 2 - N
if v > 0:
    ans.remove(v)

for i in ans:
    print(i)
    

Measured memory_bytes: 9184
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> d;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        d.push_back(b);
    }
    
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    cout << d.size();

}

Measured memory_bytes: 256
r, c = map(int, input().split())
arr = []
for _ in range(r):
    arr.append(list(map(int,input().split())))
for i in range(r):
    for j in range(c):
            print(arr[i][j],"",end="")
    print(sum(arr[i]),sep="")
bottom = []
for i in range(c):
    tmp = 0
    for j in range(r):
        tmp += arr[j][i]
    bottom.append(tmp)
for i in bottom:
    print(i,"",end = "")
print(sum(bottom))


Measured memory_bytes: 6740
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a, b = MAP()
if (a * b) % 2:
    print('Odd')
else:
    print('Even')

Measured memory_bytes: 59884
from operator import itemgetter
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
l=sorted(l,key=itemgetter(1))
bridge=0
ct=0
for i in range(m):
  if bridge<l[i][0] or l[i][1]<=bridge:
    bridge=l[i][1]-1
    ct+=1
print(ct)

Measured memory_bytes: 29920
#include <iostream>
#include<set>

using namespace std;

int main()
{
	long long int N;
	cin >> N;
	set<long long int>S;
	for (size_t i = 0; i < N; i++)
	{
		long long int A;
		cin >> A;
		if (S.count(A))
		{
			S.erase(A);
		}
		else {
			S.insert(A);
		}
	}
	cout << S.size() << endl;
	return 0;
}



Measured memory_bytes: 4864
fun main(args: Array<String>) {
  val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
  solve(sc)
}

fun solve(sc: java.util.Scanner) {
  val N = sc.nextInt()
  val a = IntArray(N) { sc.nextInt() }
  val r = mutableMapOf<Int, Int>()
  a.forEach {
    r[it] = (r[it] ?: 0) + 1
    r[it - 1] = (r[it - 1] ?: 0) + 1
    r[it + 1] = (r[it + 1] ?: 0) + 1
  }
  println(r.maxBy { it.value }?.value)
}


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

using namespace std;

double dp[5555];
vector <int> z[5555];

int main() {
    int n, m, a, b;
    cin >> n >> m;
    for(int i=0;i<m;i++) {
        scanf("%d %d", &a, &b);
        z[a].push_back(b);
    }
    double p = 1e9;
    for(int k=1;k<n;k++) {
        memset(dp,0,sizeof(dp));
        for(int i=n;i>0;i--) {
            int s = z[i].size();
            double v = 0;
            for(int j=0;j<s;j++) {
                v = max(v,dp[z[i][j]]);
                dp[i] += (dp[z[i][j]]+1)/s;
            }
            if(i == k && s > 1) {
                dp[i] -= (v+1)/s;
                dp[i] *= (1.0*s)/(s-1);
            }
        }
        p = min(p,dp[1]);
    }
    printf("%.10lf\n", p);
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
ll a,b,n; 
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>a>>b>>n;
	cout<<min(b-1,n)*a/b<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
  int input[10];
  int cnt, tmp, flag;

  for(cnt = 0; cnt < 10; ++cnt) {
    scanf("%d", &input[cnt]);
  }


  do {
    flag = 0;
    for(cnt = 0; cnt < 9; ++cnt) {
      tmp = 0;
      if(input[cnt] < input[cnt + 1]) {
        tmp = input[cnt];
        input[cnt] = input[cnt + 1];
        input[cnt + 1] = tmp;
        flag = 1;
      }
    }
  } while(flag != 0);

  for(cnt = 0; cnt < 3; ++cnt) {
    printf("%d\n", input[cnt]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> g(H);
  for (int i = 0; i < H; i++) {
    cin >> g.at(i);
  }

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (g.at(y).at(x) != '#') continue;

      // 4方向探索して#が見つからなかったらNo
      bool found = false;
      for (int i = 0; i < 4; i++) {
        int ty = y + dy[i], tx = x + dx[i];
        if (ty < 0 || ty > H - 1 || tx < 0 || tx > W - 1) continue;
        if (g.at(ty).at(tx) != '.') {
          found = true;
          g.at(ty).at(tx) = 'x';  // もう探索不要としてマーク
          break;
        }
      }
      if (!found) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

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

void solve(long long N, std::string S) {
    size_t ans = 0;
    for (ll i = 1; i < N; i++) {
        string X = S.substr(0, i);
        string Y = S.substr(i);
        set<char> xset;
        set<char> yset;
        set<char> result;
        rep(j, X.length()) { xset.insert(X[j]); }
        rep(j, Y.length()) { yset.insert(Y[j]); }
        set_intersection(xset.begin(), xset.end(), yset.begin(), yset.end(), inserter(result, result.end()));
        ans = max(ans, result.size());
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
integer N
integer,allocatable,dimension(:)::ans
integer anssum
read*,N
allocate(ans(N))
ans=0
anssum=0
do i=1,N
  if(anssum>=N)exit
  ans(i)=1
  anssum=anssum+i
end do
if(anssum>N)ans(anssum-N)=0
do i=1,N
  if(ans(i)==1)print"(I0)",i
end do
end

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

#define ll long long

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

    int n,m,k;
    cin >> n >> m >> k;
    vector<string>  arr(n);
    for (int i=0;i<n;i++) {
        cin >> arr[i];
    }

    int ans = 0;
    for (int mi=0;mi<(1<<n);mi++) {
        for (int mj=0;mj<(1<<m);mj++) {
            int b = 0;
            for (int i=0;i<n;i++) {
                for (int j=0;j<m;j++) {
                    if ((((mi>>i) & 1) == 0) && (((mj>>j)&1) == 0) && arr[i][j] == '#')
                        b++;
                }
            }
            if (b == k) ans++;
        }
    }

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


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	long long k,a,b;
	scanf("%lld%lld%lld",&k,&a,&b);
    if(k<=a) return puts("1"),0;//按思路特判
    else if(a<=b) return puts("-1"),0;//按思路特判
    else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
    //按思路求解，此处的位运算<<1=*2,|1=+1
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int w;
int a;
int b;
scanf("%d%d%d",&w,&a,&b);
if(!((a<=b&&b<=a+w)||(b+w>=a&&b+w<=a+w))){
	if(b+w<a){
		
		
		printf("%d\n",a-(b+w));
		
	}
	
	if(b>a+w){
		printf("%d\n",b-(a+w));
		
		
	}
	
	
	
}else{
	
printf("0\n");
}
	
	return 0;
}

Measured memory_bytes: 128
from operator import itemgetter

number = int(input())

listInput = [input() for i in range(number)]

record = []

for i in range(len(listInput)):
	tumple = listInput[i].split()
	record.append((tumple[0], int(tumple[1]), i + 1))

sort1 = sorted(record, key = itemgetter(1), reverse = True)
sort2 = sorted(sort1, key = itemgetter(0))

for a,b,c in sort2:
	print(c)

Measured memory_bytes: 3188
#!/usr/bin/env python3

from typing import Tuple
from typing import Optional
from typing import List
from enum import Enum, auto

Result = Tuple[int, int, int]


class Coin(Enum):
    COIN_500 = auto()
    COIN_100 = auto()
    COIN_50 = auto()


def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    tempResult = minResult(X)
    if tempResult is None:
        print(0)
        return

    allResultList = set(parseResult(tempResult, Coin.COIN_500))
    resultList = list(
        filter(lambda x: x[0] <= A and x[1] <= B and x[2] <= C, allResultList)
    )
    print(len(resultList))


def minResult(value: int) -> Optional[Result]:
    remain = value
    minA = value // 500
    remain -= 500 * minA
    minB = remain // 100
    remain -= 100 * minB
    minC = remain // 50
    remain -= 50 * minC

    if remain == 0:
        return minA, minB, minC
    else:
        return None


def newResult(result: Result, target: Coin) -> Result:
    a, b, c = result
    if target == Coin.COIN_500:
        return a - 1, b + 5, c
    elif target == Coin.COIN_100:
        return a, b - 1, c + 2
    elif target == Coin.COIN_50:
        return result


def parseResult(result: Result, target: Coin) -> List[Result]:
    a, b, c = result
    resultList: List[Result] = []

    if target == Coin.COIN_500:
        resultList = resultList + parseResult(result, Coin.COIN_100)
        resultList = resultList + parseResult(result, Coin.COIN_50)
        if a > 0:
            new = newResult(result, target)
            resultList = resultList + parseResult(new, Coin.COIN_500)
            resultList = resultList + parseResult(new, Coin.COIN_100)
            resultList = resultList + parseResult(new, Coin.COIN_50)
    elif target == Coin.COIN_100:
        resultList = resultList + parseResult(result, Coin.COIN_50)
        if b > 0:
            new = newResult(result, target)
            resultList = resultList + parseResult(new, Coin.COIN_100)
            resultList = resultList + parseResult(new, Coin.COIN_50)
    elif target == Coin.COIN_50:
        resultList.append(result)

    return resultList


if __name__ == "__main__":
    main()


Measured memory_bytes: 10924
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (((x*f(x,y/2))%mod)*f(x,y/2))%mod;

}
int main(){
int64_t N,K;
  cin>>N>>K;
  vector<int64_t>A(N);
  for(int64_t i=i;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  int64_t a=1;
  for(int64_t i=K;i<=N;i++){
  ans=(ans+(a*(mod+A.at(i-1)-A.at(N-i)))%mod)%mod;
  a=(((a*i)%mod)*f(i-K+1,mod-2))%mod;
  
  }cout<<ans<<endl;
  
    return 0;
}


Measured memory_bytes: 1024
use std::io::Read;
 
fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a = iter.next().unwrap().parse::<usize>().unwrap();
    let b = iter.next().unwrap().parse::<usize>().unwrap();

    let m = std::cmp::max(a, b);
    let n = std::cmp::min(a, b);
    for _ in 0..m {
        print!("{}", n);
    }
}


Measured memory_bytes: 4352