akhauriyash/Code-Regression huggingface dataset:
using System;

namespace B
{
    class Partition
    {
        public int partition(ref int[] A, int p, int r)
        {
            int x = A[r];
            int i = p-1, j, change;
            for (j=p; j<r; j++)
            {
                if (A[j] <= x)
                {
                    i++;
                    change = A[i];
                    A[i] = A[j];
                    A[j] = change;
                }
            }
            change = A[i + 1];
            A[i + 1] = A[r];
            A[r] = change;
            return i + 1;
        }
    }

    class B
    {
        static void Main(string[] args)
        {
            string input1;
            string[] input2 = new string[100000];
            int i, n, index;
            int[] A = new int[100000];
            Partition partition = new Partition();
            input1 = Console.ReadLine();
            n = int.Parse(input1);
            input2 = Console.ReadLine().Split(' ');
            for (i=0; i<n; i++)
            {
                A[i] = int.Parse(input2[i]);
            }

            index = partition.partition(ref A, 0, n-1);
            for (i = 0; i < n; i++)
            {
                if (i != 0)
                {
                    Console.Write(" ");
                }
                if (i==index)
                {
                    Console.Write("[");
                }
                Console.Write(A[i]);
                if (i==index)
                {
                    Console.Write("]");
                }
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 17128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;


class dlink {
public:
	dlink(int k) : prev(NULL), next(NULL), key(k) {}

	dlink *prev;
	dlink *next;
	int key;
};

class list {
public:
	list() : head(NULL), tail(NULL) {}

	dlink *head;
	dlink *tail;

	void ins(int k) {
		dlink *d = new dlink(k);
		if (head) {
			head->prev = d;
			d->next = head;
		} else {
			d->prev = NULL;
			d->next = NULL;
			tail = d;
		}
		head = d;
	}
	void del(int k) {
		dlink *d = head;
		while (d) {
			if (d->key == k) {
				dlink *p = d->prev;
				dlink *n = d->next;
				if (p) p->next = n;
				if (n) n->prev = p;
				if (d == head) head = d->next;
				if (d == tail) tail = d->prev;
				delete d;
				break;
			}
			d = d->next;
		}
	}
	void delFirst() {
		dlink *d = head;
		if (d) {
			head = head->next;
			if (head) {
				head->prev = NULL;
			} else {
				tail = NULL;
			}
			delete d;
		}
	}
	void delLast() {
		dlink *d = tail;
		if (d) {
			tail = tail->prev;
			if (tail) {
				tail->next = NULL;
			} else {
				head = NULL;
			}
			delete d;
		}
	}
};

int main() {
	int n;
	cin >> n;
	list lst;
	char cmd[20];
	int m;
	for (int i = 0; i < n; i++) {
		scanf("%s", cmd);
		if (strcmp(cmd, "insert") == 0) {
			scanf("%d", &m);
			lst.ins(m);
		} else if (strcmp(cmd, "delete") == 0) {
			scanf("%d", &m);
			lst.del(m);
		} else if (strcmp(cmd, "deleteFirst") == 0) {
			lst.delFirst();
		} else if (strcmp(cmd, "deleteLast") == 0) {
			lst.delLast();
		}
	}

	dlink *p = lst.head;
	while (p != NULL) {
		if (p != lst.head) {
			cout << " ";
		}
		cout << p->key;
		p = p->next;
	}
	cout << endl;
}

Measured memory_bytes: 32420
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int N; 
    cin >> N;
    vector<double> gaku(N);
    vector<string> taipu(N);
    double otosidama=0.0;
    for(int i=0; i<N; i++){
        cin >> gaku.at(i);
        cin >> taipu.at(i);
        if(taipu.at(i) == "JPY"){
            otosidama += gaku.at(i);
        }
        else{
            otosidama += gaku.at(i) * 380000.0;
        }
    }
    cout << fixed <<setprecision(8) << otosidama << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    double r; cin >> r;
    double ans=r*2*PI;
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3788
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def main():
    while 1:
        D, N = map(int, readline().split())
        if D == N == 0:
            break
        P = [list(map(int, readline().split())) for i in range(N)]
        P.sort(key=lambda x: x[2])
        INF = 10**9

        memo = [[INF]*101 for i in range(D+1)]
        memo[D][0] = 0
        for i in range(D, 0, -1):
            P0 = [(max(i-a, 0), e, r) for a, e, r in P]
            for j, v in ((j, e+1) for j, e in enumerate(memo[i]) if e < INF):
                for A0, e, r in P0:
                    if j < r:
                        break
                    E0 = min(j+e, 100)
                    if v < memo[A0][E0]:
                        memo[A0][E0] = v
        res = min(memo[0])
        if res == INF:
            write("NA\n")
        else:
            write("%d\n" % res)
main()


Measured memory_bytes: 5812
is_prime = Array.new(50001, true)
is_prime[0] = is_prime[1] = false
(2..223).each{|p|
  if is_prime[p]
    (p*2).step(50000,p){|i|
      is_prime[i] = false
    }
  end
}

f = ->n{
  return (is_prime[n-2] ? 1 : 0) if n.odd?
  (2..(n/2)).count{|i| is_prime[i] and is_prime[n-i]}
}

loop{
  n = gets.to_i
  break if n==0
  p f[n]
}


Measured memory_bytes: 7416
<?php
$num=trim(fgets(STDIN));
$array=explode(" ",trim(fgets(STDIN)));
$sub=[];

for($i=0;$i<$num-1;$i++){
    for($j=$i+1;$j<$num;$j++){
        $sub[]=abs($array[$i]-$array[$j]);
    }
}

echo max($sub);
?>

Measured memory_bytes: 4728
#include<cstdio>
#define MAXN 26
int num[5];
int main(){
	for(int i=1;i<=3;i++){
		char x;
		scanf("%c",&x);
		num[x-'a']++;
	}
	for(int i=0;i<3;i++)
		if(!num[i]){
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int a,b,c,d;
    string s,t,u;
    cin>>a;
    if(a%1000==0) cout<<0<<endl;
    else cout<<1000-a%1000<<endl;

    return 0;
}


Measured memory_bytes: 3624
while True:
    a,op,b = input().split()
    a=int(a)
    b=int(b)
    
    
    if op=="?":
        break
    elif op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

int n;
int a[MAX_N];

int duplicate;
int duplicate_ind_fst;
int duplicate_ind_snd;

/////////////////////////////////////////////////////////////
class CombinationModulo {
public:
  static const int MAX_N_LIB = (int)(1e5 + 100);
  static const ll MOD_LIB = (ll)(1e9 + 7);

  ll fact[MAX_N_LIB];
  ll inv[MAX_N_LIB];
  ll fact_inv[MAX_N_LIB];

  CombinationModulo(int n) {
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD_LIB - (MOD_LIB / i) * inv[MOD_LIB % i] % MOD_LIB) % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD_LIB;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0;
  	return fact[n] * fact_inv[r] % MOD_LIB * fact_inv[n - r] % MOD_LIB;
  }
};
/////////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%d", &n);

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

  set<int> visited;

  visited.insert(a[0]);

  for (int i = 1; i < n + 1; ++i) {
    if (visited.find(a[i]) != visited.end()) {
      duplicate = a[i];
      duplicate_ind_snd = i;
      break;
    }
    visited.insert(a[i]);
  }

  for (int i = 0; i < n + 1; ++i) {
    if (a[i] == duplicate) {
      duplicate_ind_fst = i;
      break;
    }
  }

  CombinationModulo comb_mod(n + 5);

  int available = (n + 1 - duplicate_ind_snd) + (duplicate_ind_fst + 1) - 1;

  for (int i = 1; i <= n + 1; ++i) {
    if (i == 1) {
      printf("%lld\n", n);
    }
    else {
      ll whole = comb_mod.comb(n + 1, i);

      if (i <= available) {

        ll minus = comb_mod.comb(available - 1, i - 1);
        // printf("----%d:%d:%lld\n", i, available, minus);

        whole -= minus;
        whole %= MOD;
        if (whole < 0) whole += MOD;
      }

      printf("%lld\n", whole);
    }
  }

  return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int N;
vll A;

bool check(ll k) {
    ll sum = 0;
    rep(i,A.size()) {
        sum += (A[i]+k+1)/(N+1);
    }
    return sum <= k;
}

int main() {
    cin >> N;
    A.resize(N);
    rep(i,N) cin >> A[i];
    ll sum = 0;
    rep(i,N) sum += A[i];
    for (ll i = sum-N*(N-1); ; i++) {
        if (check(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main (){
    int n, m, l;
    cin >> n >> m >> l;
    int a[100][100] ;
    int b[100][100] ;
    long long c[100][100] = {} ;
    int i, j, k;
    
     for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    
     for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            for(k = 0; k < m; k++){
                c[i][j] += a[i][k] * b[k][j] ;
                
            }
            cout << c[i][j];
            if(j != l - 1){
                cout << " ";
            } 
        }
        cout << endl;
 
    }
    
   
   
    return 0;
}


Measured memory_bytes: 3232
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll n,a,b;
	cin >> n >> a >> b;

	cout << a * (n / (a+b)) +  min(n % (a+b),a);


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL n,s,p,ans;
char s1[55],s2[55];
int main()
{
	scanf("%lld",&n);getchar();
	scanf("%s%s",s1+1,s2+1);
	if(n==1) return puts("3"),0;
	if(s1[1]==s2[1]) p=2,ans=3,s=1;
	else p=3,ans=6,s=2;
	while(p<=n)
	{
		LL t;
		if(s1[p]==s2[p]) p++,t=1;
		else p+=2,t=2;
		if(s==1) (ans*=2)%=mod;
		else if(t!=1) (ans*=3)%=mod;
		s=t;
	}
	printf("%lld",ans);
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
    int n,x,y=0;
    int i,j;
    int all[300]={0},taro[300]={0},hana[300]={0};
    int check_t[300]={0},check_h[300]={0};
    int cnt_t=0,cnt_h=0;
    int stage = 0;
    int flg = 0,f = 0,count = 0;

    while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(i = 0;i < n; i++){
        scanf("%d",&taro[i]);
        all[taro[i]] = 1;
    }

    j=0;
    for(i = 1;i <= 2*n; i++){
        if(all[i] == 0){
            hana[j] = i;
            j++;
        }
    }

    //太郎ソート
    for(i = 0;i < n; i++){
        for(j = 0;j < n; j++){
            if(taro[i] < taro[j]){
                x = taro[i];
                taro[i] = taro[j];
                taro[j] = x;
            }
        }
    }
    //花子ソート
    for(i = 0;i < n; i++){
        for(j = 0;j < n; j++){
            if(hana[i] < hana[j]){
                x = hana[i];
                hana[i] = hana[j];
                hana[j] = x;
            }
        }
    }
    //判定
    for(;;){
        hoge:
        if(cnt_t == n){
            f = 1;
            for(i = 0;i < n; i++){
                //printf("%d\n",check_h[i]);
                if(check_h[i] == 0){
                count++;
            }
            }
            break;
        }
        else if(cnt_h == n){
            for(i = 0;i < n; i++)if(check_t[i] == 0)count++;
            break;
        }
        if(flg == 0){
        for(i = 0;i < n; i++){
            if(check_t[i] == 0){
                if(stage < taro[i]){
                    stage = taro[i];
                    check_t[i] = 1;
                    cnt_t += 1;
                    flg = 1;
                    y = 0;
                    goto hoge;
                }
                else if(y == n){
                    stage = 0;
                    flg = 1;
                    y = 0;
                    goto hoge;
                }
                else y++;
            }
        }
        }
        else {
            for(i = 0;i < n; i++){
                if(check_h[i] == 0){
                    if(stage < hana[i]){
                        stage = hana[i];
                        check_h[i] = 1;
                        cnt_h += 1;
                        flg = 0;
                        y = 0;
                        goto hoge;
                    }
                    else if(y == n){
                        stage = 0;
                        flg = 0;
                        y = 0;
                        goto hoge;
                    }
                    else y++;
                }
            }
        }
    }


    if(f == 1)printf("%d\n0\n",count);
    else printf("0\n%d\n",count);
    flg = 0,f = 0,count = 0;
    cnt_t=0,cnt_h=0;
    stage = 0;
    y = 0;
    for(i = 0;i < 300; i++){
        all[i]=0;
        taro[i]=0;
        hana[i]=0;
        check_h[i]=0;
        check_t[i]=0;
    }
    }
    return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
class solution {
private:
	long long int dp[100005];
	int n, w, c;
	long long int b;
	void reset() {
		for (int i = 0; i < 100005; i++) {
			dp[i] = ~(1ll << 63);
		}
	}
	long long int min(long long int a, long long int b) {
		if (a < b) return a;
		return b;
	}
public:
	solution() {
		scanf("%d %d", &n, &w);
		reset();
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			scanf("%lld %d", &b, &c);
			for (int j = 100004; j >= c; j--) {
				if (dp[j - c] != (~(1ll << 63))) {
					dp[j] = min(dp[j], dp[j - c] + b);
				}
			}
		}
		for (int i = 100004; i >= 0; i--) {
			if (dp[i] <= w) {
				printf("%d\n", i);
				break;
			}
		}
	}
};

#ifndef L0C4L
int main() {
	solution();
	return 0;
}
#endif

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int js,a[100010],to[100010];
int n,m,c,b,ans,sum,dp[100010];
vector <int> v[100010];
vector <int> vv[100010];
inline void topsort()
{
	queue <int> q;
	for(int i=1;i<=n;++i){
		if(!to[i])q.push(i);
	}
	while(!q.empty()){
		int x=q.front();
		q.pop();
		if(to[x]==0)a[++js]=x;
		for(int i=0;i<v[x].size();++i){
			to[v[x][i]]--;
			if(to[v[x][i]]==0)q.push(v[x][i]);
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		scanf("%d%d",&c,&b);
		v[c].push_back(b);
		vv[b].push_back(c);
		to[b]++;
	}
	topsort();
	for(int i=1;i<=n;++i){
		int k=a[i];
		for(int j=0;j<vv[k].size();++j){
			dp[k]=max(dp[k],dp[vv[k][j]]+1);
			ans=max(ans,dp[k]);
		}
	}
	cout<<*max_element(dp+1,dp+n+1);
	return 0;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
using namespace std;

int main(){
    // fast i/o
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

//    int t;
//    cin>>t;
//    while(t--){

//    }
    int k,n;
    cin>>k>>n;
    int arr[n];
    ll dis[n];
    dis[0]=0;
    fo(i,n){
        cin>>arr[i];
        if(i>0){
            dis[i]=dis[i-1]+arr[i]-arr[i-1];
        }
    }

    ll mn=dis[n-1];
    for(int j=1;j<n;j++){
        ll init = k-arr[n-1]+arr[0]+dis[j-1];
        mn = min(mn,dis[n-1]-dis[j]+init);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 2560
def ball(x,y):
    if x>1 and y>1:
        print((x*(x-1)+y*(y-1))//2)
    elif x<=1 and y>1:
        print((y*(y-1))//2)
    elif x>1 and y<=1:
        print((x*(x-1))//2)
    else:
        print(0)


n,m=list(map(int,input().split()))
ball(n,m)

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;

    for (int i = a; i < c; i++) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No" << endl;
            ret();
        }
    }

    for (int i = b; i < d; i++) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No" << endl;
            ret();
        }
    }


    // ふぬけ君がみぎでゴールするなら問題ない
    if (c < d) {
        cout << "Yes" << endl;
        ret();
    }


    // 追越し可能か
    for (int i = b; i <= d; i++) {
        if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
            cout << "Yes" << endl;
            ret();
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 640
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

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

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := readInt(), readInt()
	p := make([]int, n)
	for i, _ := range p {
		p[i] = readInt()
	}
	sort.Sort(sort.IntSlice(p))
	prices := p[0:k]

	ans := 0
	for _, price := range prices {
		ans += price
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


A,B = MI()
S = LS2()

for i in range(A+B+1):
    if i == A:
        if S[i] != '-':
            print('No')
            break
    else:
        if S[i] == '-':
            print('No')
            break
else:
    print('Yes')


Measured memory_bytes: 61900
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,A,B;cin>>N>>A>>B;
  cout << min(A,B) << " " << max(0,(A+B)-N) << endl;
  return 0;
}


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

int main() {
    int n; cin >> n;
    pair<string, int> sp[100];
    rep(i,n) {
        cin >> sp[i].first >> sp[i].second;
        sp[i].second = sp[i].second * 1000 + (i+1);
    }
    sort(sp,sp+n);
    int pre = 0;
    string pres = sp[0].first;
    rep(i,n) {
        if (sp[i].first != pres) {
            sort(sp+pre, sp+i, greater<pair<string, int>>());
            pre = i;
            pres = sp[i].first;
        }
    }
    sort(sp+pre, sp+n, greater<pair<string, int>>());
    rep(i,n) {
        cout << sp[i].second % 1000 << endl;
    }
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

int n,a;

int main(){
    scanf("%d",&n);
    scanf("%d",&a);
    printf("%d\n",n*n-a);
    
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] l = new long[n];
		Arrays.setAll(l, i -> sc.nextLong());
		
		int cnt = 0;
		for (int i = 0; i < n - 2; i++) {
			for (int j = i + 1; j < n - 1; j++) {
				for (int k = j + 1; k < n; k++) {
					
					long[] t = new long[3];
					t[0] = l[i];
					t[1] = l[j];
					t[2] = l[k];
					
					Arrays.sort(t);
					if (t[0] + t[1] > t[2]
							&& t[0] != t[1] && t[1] != t[2] && t[2] != t[0]) {
						cnt++;
					}
				}
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
}




Measured memory_bytes: 38880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int N,A,B,C;
int dfs(vector<int> l){
  sort(ALL(l));
  if(l.size()==3){
    return abs(C-l[0])+abs(B-l[1])+abs(A-l[2]);
  }else{
    int MIN = INF;
    REP(i,sz(l)){
      REP(j,sz(l)){
        REP(k,sz(l)){
          if(i!=j&&j!=k&&i!=k){
            MIN=min(MIN,abs(C-l[i])+abs(B-l[j])+abs(A-l[k]));
          }
        }
      }
    }
    REP(i,sz(l)){
      REP(j,i){
        vector<int> x;
        int y = l[i]+l[j];
        REP(k,sz(l)){
          if(k!=i&&k!=j){
            x.push_back(l[k]);
          }
        }
        x.push_back(y);
        MIN=min(MIN,dfs(x)+10);
      }
    }

    return MIN;
  }
}

int main()
{
  cin >> N >> A >> B >> C;
  vector<int> D(N);
  REP(i, N){
    cin >> D[i];
  }
  
  cout << dfs(D) << endl;
}

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

 
int main() {
  int n, m, a, b, ans = 0;
  cin >> n >> m;
  vector<int> H(n), v(n, 0);
  
  for (int i = 0; i < n; i++) {
    cin >> H.at(i);
  }
  
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (H.at(a-1) == H.at(b-1)) {
      v.at(a-1)++;
      v.at(b-1)++;
    }
    
    else if (H.at(a-1) < H.at(b-1)) {
      v.at(a-1)++;
    }
    
    else
      v.at(b-1)++;
  }
  
  for (int i = 0; i < n; i++) {
    if (v.at(i) == 0)
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3988
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        ll n,m; cin >> n >> m;
        //for 2
        m/=2;
        if(n>=m)cout<<m<<endl;
        else{
            ll k = m - n;
            cout<<n+(k/2)<<endl;

        }
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
long long A,B,K;
long long i;
scanf("%lld %lld %lld",&A,&B,&K);

if (A>=K) printf("%lld %lld\n",A-K,B);
else if(A+B>=K)  printf("0 %lld\n",B-K+A);
else printf("0 0");
return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

var N, D, X int
var A []int

func main() {
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d %d", &D, &X)

	A = make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	ans := X
	for i := 0; i < D; i++ {
		for j := 0; j < N; j++ {
			if i%A[j] == 0 {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n#ペナ数
rig=[0]*n#ACorWA

for i in range(m):
    if ps[i][1]=="AC":
        rig[int(ps[i][0])-1]=1
    else:
        if rig[int(ps[i][0])-1]==0:
            pen[int(ps[i][0])-1]+=1
cnt1,cnt2=0,0
for i in range(n):
    if rig[i]==1:
        cnt1+=rig[i]
        cnt2+=pen[i]

print(str(cnt1)+" "+str(cnt2))

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

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int d=a-b;
    if(c>=d){
        cout << c-d << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# グラフに辺を追加する
def addEdge(adjL, vFr, vTo, cap):
    adjL[vFr].append([vTo, cap, len(adjL[vTo])])
    adjL[vTo].append([vFr, 0, len(adjL[vFr]) - 1]) # 逆辺


# Ford-Fulkerson法（最大フローを求める）
def Ford_Fulkerson(adjL, vSt, vEn):

    # 残余グラフの始点から終点までの経路（増加パス）を、DFSで探索する
    def DFS(vNow, vEn, fNow):
        if vNow == vEn:
            # 終点に到達したら、フローの増加量を返す
            return fNow

        used[vNow] = True

        for i, (v2, cap, iRev) in enumerate(adjL[vNow]):
            if not used[v2] and cap > 0:
                # 未探索の頂点への辺の容量に空きがある場合、探索する
                df = DFS(v2, vEn, min(fNow, cap))
                if df > 0:
                    # 始点から終点までの経路を遡って、辺のフローを変更する
                    adjL[vNow][i][1] -= df
                    adjL[v2][iRev][1] += df
                    return df

        # 現在の頂点からの探索先がない場合、ゼロを返す
        return 0


    numV = len(adjL)
    MaximumFlow = 0
    while True:
        # 残余グラフの始点から終点までの経路（増加パス）を、DFSで探索する
        used = [False] * numV
        df = DFS(vSt, vEn, float('inf'))

        if df == 0:
            # 経路が見つからない場合、最大フローの値を返す
            return MaximumFlow

        # フローを加算する
        MaximumFlow += df


N = int(input())
As = list(map(int, input().split()))

adjList = [[] for v in range(N + 2)]
for i, A in enumerate(As, 1):
    if A <= 0:
        addEdge(adjList, 0, i, -A)
    else:
        addEdge(adjList, i, N + 1, A)

for i in range(1, N + 1):
    for j in range(2 * i, N + 1, i):
        addEdge(adjList, i, j, float('inf'))

# Ford-Fulkerson法（最大フローを求める）
mf = Ford_Fulkerson(adjList, 0, N + 1)
print(sum([A for A in As if A > 0]) - mf)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }

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

  ll N, Q;
  std::cin >> N >> Q;
  std::vector< ll > va(N, 0LL);
  std::vector< ll > vq(Q, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }
  for (ll i = 0; i < Q; i++) {
    std::cin >> vq[i];
  }

  for (ll q = 0; q < Q; q++) {
    ll x = vq[q];
    ll right = 0;
    ll sum = 0;
    ll result = 0;
    for (ll left = 0; left < N; left++) {
      while (right < N && sum + va[right] <= x) {
	sum += va[right];
	right++;
      }

      result += right - left;

      if (right == left) right++;
      else sum -= va[left];
    }

    print(result);
  }

  return 0;
}



Measured memory_bytes: 3524
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> v(h);
  vector<vector<int>> res(h, vector<int> (w, 1));
  // bool all_white = true;
  vector<bool> all_white(h, true);
  int start = -1;
  rep(i, h){
    cin >> v[i];
    rep(j, w) if(v[i][j] == '#'){
      all_white[i] = false;
      if(start == -1) start = i;
    }
  }
  int count = 1;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      res[i][j] = count;
      if(v[i][j] == '#'){
        count++;
      }
    }

    if(!all_white[i]){
      for (int k = w-1; k >= 0; k--) {
        if(res[i][k] == count-1) break;
        res[i][k] = count-1;
      }
    }
  }

  for (int i = start+1; i < h; i++) {
    if(all_white[i]){
      for (int j = 0; j < w; j++) {
        res[i][j] = res[i-1][j];
      }
    }
  }
  for (int i = start-1; i >= 0; i--) {
    if(all_white[i]){
      for (int j = 0; j < w; j++) {
        res[i][j] = res[i+1][j];
      }
    }
  }

  rep(i, h){
    rep(j, w){
      cout << res[i][j] << '\t';
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
h, n = map(int, input().split())

ab = []
for i in range(n):
  a,b = map(int, input().split())
  ab.append([a, b])


dp = [10**9 for i in range((h+1)+10000)]
dp[0] = 0
for i in range(1, (h+1)+10000):
  for j in range(n):
    a, b = ab[j]
    if a > i:
      continue
    dp[i] = min(dp[i], dp[i-a]+b)

x = min(dp[h:])
print (x)

Measured memory_bytes: 74604
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {FIN
    
    ll n, m, l, i, j, k, s;
    cin >> n >> m >> l;
    vvll a(n, vll(m)), b(m, vll(l));
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) cin >> a[i][j];
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j < l; j++) cin >> b[i][j];
    }
    for (i = 0; i < n; i++) {
        for (k = 0; k < l; k++) {
            s = 0;
            for (j = 0; j < m; j++)
                s += a[i][j] * b[j][k];
            if (k > 0) cout << " ";
            cout << s;
        }
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, V;

bool same(int n){
	string s = to_string(n);
	for(int i = 1; i < s.length(); i++)
		if(s[i] != s[0]) return false;
	return true;
}

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = N; i <= 1111; i++)
		if(same(i)){
			V = i;
			break;
		}
	printf("%d\n", V);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int a, b; cin  >> a >> b;
    int s = a+b;
    if (s%2) printf("IMPOSSIBLE");
    else pd(s/2);

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

bool prime[1000005];
ve<ll> a;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=1000000; p++) 
        if (prime[p]) 
            for (int i=p*p; i<=1000000; i += p) 
                prime[i] = false; 
    for(ll i=2;i<=1000000;i++)
        if(prime[i])
            a.pb(i);
} 

ll countDivisors(ll n) 
{ 
    if (n == 1) 
        return 1; 
    ll ans = 1;
    for (ll i = 0;; i++) 
    { 
        if (a[i] * a[i] * a[i] > n) 
            break; 
        ll cnt = 1; 
        while (n % a[i] == 0)  
        { 
            n = n / a[i]; 
            cnt = cnt + 1;  
        } 
        ans = ans * cnt; 
    } 
    
    if (prime[n]) 
        ans = ans * 2; 
        
    else if (n == ((ll)sqrt(n))*((ll)sqrt(n)) && prime[(ll)sqrt(n)]) 
        ans = ans * 3; 
        
    else if (n != 1) 
        ans = ans * 4; 
        
    return ans; 
} 

ll primefactor(ll n)
{
    ll ans=1;
    ll b=1;
    while (n % 2 == 0)  
    {  
        b++;
        n = n/2;  
    }  
    ans*=b;
    b=0;
    for (ll i = 3; i*i <= n; i = i + 2)  
    {   
        b=1;
        while (n % i == 0)  
        {  
            b++;
            n = n/i;  
        }  
        ans*=b;
    }  
    if (n > 2)  
        ans*=2;
    return ans;
}

int main()
{
    FAST;
    SieveOfEratosthenes();
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<n;i++)
        ans+=primefactor(i);
    cout<<ans;
    subt;
    return 0;
}


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

using namespace std;

const int maxn = 2e5 + 5;
int n, a[maxn];
long long sum[maxn];

long long F(int left, int m, int right) {
	return abs(sum[right]-2*sum[m]+sum[left]);
}

int find(int l, int r) {
	int left = l-1, right = r+1;
	while (r-l >= 3) {
		int m1 = l + (r-l)/3;
		int m2 = r - (r-l)/3;
		if (F(left, m1, right) < F(left, m2, right)) r = m2;
		else l = m1; 
	}
	if (l == r) return l;
	else if (l == r+1) {
		if (F(left, l, right) < F(left, l+1, right)) return l;
		else return l+1;
	}
	else {
		if (F(left, l, right) < F(left, l+1, right) && F(left, l+2, right))
			return l;
		else if (F(left, l+1, right) < F(left, l+2, right))
			return l+1;
		else return l+2;
	}
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	sum[0] = 0;
	for (int i = 1; i <= n; ++i)
		sum[i] = sum[i-1] + a[i];
	long long ans = 1e17;
	for (int i = 2; i <= n-2; ++i) {
		int j = find(1, i-1);
		int k = find(i+1, n-1);
		long long maxt = max(sum[j], max(sum[i]-sum[j], max(sum[k]-sum[i], sum[n]-sum[k])));
		long long mint = min(sum[j], min(sum[i]-sum[j], min(sum[k]-sum[i], sum[n]-sum[k])));
		ans = min(ans, maxt-mint);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int m = sc.nextInt(), n = sc.nextInt();
            if ((m | n) == 0)
                break;
            List<Integer> l = new ArrayList<>();
            for (int i = 1; i <= m; i++) {
                l.add(i);
            }
            int p = 0;
            for (int i = 1; i <= n; i++) {
                String s = sc.next();
                String a = "";
                if (i % 3 == 0) {
                    a = "Fizz";
                }
                if (i % 5 == 0) {
                    a += "Buzz";
                }
                if (a.equals("")) {
                    a = String.valueOf(i);
                }
                if (s.equals(a)) {
                    p = (p + 1) % l.size();
                } else if (l.size() > 1) {
                    l.remove(p);
                    p %= l.size();
                }
            }
            for (int i = 0; i < l.size(); i++) {
                System.out.print(l.get(i) + (i < l.size() - 1 ? " " : "\n"));
            }
        }
    }
}


Measured memory_bytes: 73852
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int A,B,C,D,E,F,t[6010];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> A >> B >> C >> D >>E >> F;

    int i,j;
    for (i=0; i<=2*F; i++){
        t[i]=0;
        if (C<=i) t[i]=max(t[i],C+t[i-C]);
        if (D<=i) t[i]=max(t[i],D+t[i-D]);
    }

    ld val=-1;
    int tot=0,s=0;
    for (i=0; i*100*A<=F; i++)
        for (j=0; 100*(i*A+j*B)<=F; j++){
            int w=100*(i*A+j*B);

            int cnt=t[min(E*w/100,F-w)];
            ld d=1.0*cnt/(cnt+w);

            if (d>val){
                tot=cnt+w,s=cnt;
                val=1.0*cnt/(cnt+w);
            }
        }

    cout << tot << " " << s << "\n";
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll res = k;
  ll sum = 0;
  if (res > 0)
  {
    ll aa = min(a, res);
    sum += aa;
    res -= aa;
  }

  if (res > 0)
  {
    ll bb = min(b, res);
    res -= bb;
  }

  if (res > 0)
  {
    sum -= res;
  }

  cout << sum << endl;
  return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> vec(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> vec[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > vec[i]) {
      ans += 1ll * vec[i];
      x -= vec[i];
      ans += 1ll * min(x, vec[i + 1]);
      vec[i + 1] -= x;
      vec[i + 1] = max(0, vec[i + 1]);
    } else {
      ans += 1ll * x;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
n = int(input())
w = list(map(int, input().split()))
diff_min = sum(w)
for i in range(len(w)):
    s1 = sum(w[:i + 1])
    s2 = sum(w[i + 1:])
    diff = abs(s1 - s2)
    if diff < diff_min:
        diff_min = diff
print(diff_min)

Measured memory_bytes: 63204
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

vector<vector<int>> adj(100005, vector<int>());
vector<int> path(100005, -1);

int dfs(int src) {
	if (path[src] != -1)return path[src];
	int y = 0;
	for (int x : adj[src]) {
		if(path[x]==-1)y = max(y, dfs(x));
		else y = max(y, path[x]);
	}
	return path[src] = 1 + y;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,m; cin >> n>>m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; adj[a].push_back(b);
	}
	for (int i = 1; i <= n; i++) {
		if (path[i] == -1)dfs(i);
	}
	int x = -1;
	for (auto a : path)x = max(x, a);
	cout << x-1;
	//system("PAUSE");
}


Measured memory_bytes: 8832
#coding: utf-8

n = list(map(int, input().split()))
s_list = []
for i in range(0, n[0]):
    s_list.append(input())
s_list = sorted(s_list)

s = ""
for i in range (0, len(s_list)):
    s += s_list[i]

print(s)

Measured memory_bytes: 3060