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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n;
int a[N] , b[N];


void solve(int testCase){

    scanf("%d" , &n);

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

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

    for(int i = 0 ; i < n / 2 ; i ++) {
            swap(b[i] , b[n - i - 1]);
    }

    int l = -1 , r = -1;

    for(int i = 0 ; i < n ; i ++) {
            if(a[i] == b[i]) {
                    if(l == -1) l = i;
                    r = i;
            }
    }

    for(int i = 0 ; i < n && l <= r && l != -1 ; i ++) {
            if(i >= l && i <= r) continue;

            if(b[i] != b[l] && a[i] != b[l]) {
                    swap(b[i] , b[l]);
                    l ++;
            }
    }

    if(l <= r && l != -1) {
            printf("No\n");
    }
    else {
            printf("Yes\n");
            for(int i = 0 ; i < n ; i ++) {
                    printf("%d%c" , b[i] , i == n-1 ? '\n' : ' ');
            }
    }

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 5392
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>



using namespace std;


int main() {
    double r;
    double M_PI = 3.14159265358979;
    cin >> r;
    cout << fixed << setprecision(10) <<  M_PI * r * r <<" " << setprecision(10) << M_PI * 2 * r <<endl;
   
    
}


Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    ll X; cin >> X;

    int i = 1;
    ll sum = 100;
    while(true) {
        sum *= 1.01;
        if (sum >= X) break;
        i++;
    }

    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3596
var main = function(s) {
s=s.split('');
  var count=0;
  for(var i=0;i<4;i++){
  if(s[i] === '+'){
	count++;
  } else{
    count--;
  }
  }
  var output = count;
    console.log(output);
    return 0; 
}

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


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
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)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

ll const mod = 1e9+7;



int main() {
  ll X,now=100;
  cin >> X;
  rep2(i,1,1000000) {
    now += now/100;
    if (now>=X) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int ju=0;
			int N=in.nextInt();
			int K=in.nextInt();
			if((N|K)==0)
				return;
			int s[]=new int[K];
			for(int i=0;i<K;i++)
			s[i]=in.nextInt();
			for(int i=0;i<N;i++)
				for(int j=0;j<K;j++)
				{
					s[j]-=in.nextInt();
					if(s[j]<0)
						ju=1;
				}
			if(ju==0)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 12000
K = int(input())

a = [0] * 1000001
a[0] = 7 % K
for i in range(1000000):
    a[i+1] = (a[i] * 10 + 7) % K 
    
    if (a[i] == 0):
        break

if(i == 999999):
    print('-1')
else:
    print(i+1)
    

Measured memory_bytes: 48460
s = input()
n = len(s)
mod = 10 ** 9 + 7
amari = [1]
for i in range(n - 1):
    amari.append(amari[-1] * 10 % 13)
amari.reverse()
dp = [[0 for i in range(13)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            temp = 0
            for k in range(10):
                temp += dp[i][(j - amari[i] * k) % 13]
                temp %= mod
            dp[i + 1][j] = temp
        else:
            num = int(s[i])
            dp[i + 1][j] = dp[i][(j - amari[i] * num) % 13]
print(dp[n][5])

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

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

int main()
{
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    cout << (S[0] == S[1] && S[2] == S[3] && S[0] != S[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<(ll)ceil((long double)n/x)*t;
    return 0;
}



Measured memory_bytes: 3636
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int n;
string s1,s2;
vi z;
ll ans[53];

int main() {
    cin >> n >> s1 >> s2;
    F0R(i,n) if (i != n-1 && s1[i] == s1[i+1]) {
        z.pb(2);
        i++;
    } else z.pb(1);
    F0Rd(i,z.size()) {
        if (i == z.size()-1) {
            if (z[i] == 2) ans[i] = 6;
            else ans[i] = 3;
            continue;
        }
        if (z[i] == 2) {
            if (z[i+1] == 1) {
                ans[i] = 2*ans[i+1] % MOD;
            } else {
                ans[i] = 3*ans[i+1] % MOD;
            }
        } else {
            if (z[i+1] == 1) {
                ans[i] = 2*ans[i+1] % MOD;
            } else {
                ans[i] = ans[i+1] % MOD;
            }
        }
    }
    cout << ans[0];
}

// read!
// ll vs. int!

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int mod = 1e9 + 7;

vector<int> primefactors(int a) {
    vector<int> s;
    for (int i = 2; i * i <= a; i++) {
        if (a % i != 0) continue;
        while (a % i == 0) {
            a /= i;
            s.push_back(i);
        }
    }
    if (a > 1) s.push_back(a);
    return s;
}

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

    int N;
    cin >> N;

    map<int, int> cnt;
    FOR(n, 1, N) {
        auto v = primefactors(n);
        REP(i, v.size()) {
            cnt[v[i]]++;
        }
    }

    int ans = 1;
    for (auto kv : cnt) {
        ans = (ans * (kv.second + 1)) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
int main()
{
	int n;
	cin >> n;
	map<string,int> mp;
	for(int i = 0; i < n;i++){
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << "\n";
	cout << "WA x " << mp["WA"] << "\n";
	cout << "TLE x " << mp["TLE"] << "\n";
	cout << "RE x " << mp["RE"] << "\n";
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << (x - z) / (y + z) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>

using namespace std ;


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

	int M ;
	set< string > pair ;
	multiset< string > pair_data ;

	int i ,j ,k ;
	for( i = 0 ; i < N ; ++i )
	{
		vector< string > food ;

		scanf( "%d" ,&M ) ;
		for( j = 0 ; j < M ; ++j )
		{	string in ;	cin >> in ;	food.push_back( in ) ;	}
		
		sort( food.begin() ,food.end() ) ;

		for( j = 0 ; j < M ; ++j )
		{
			for( k = j + 1 ; k < M ; ++k )
			{
				string str1 ,str2 ;
				str1 = min( food[ j ] ,food[ k ] ) ;
				str2 = max( food[ j ] ,food[ k ] ) ;

				string union_str = str1 + ' ' + str2 ;

				pair.insert( union_str ) ;
				pair_data.insert( union_str ) ;
			}
		}
	}

	vector< string > output ;
	set< string >::iterator itr ;
	for( itr = pair.begin() ; itr != pair.end() ; ++itr )
	{
		int cnt = pair_data.count( *itr ) ;

		if( cnt > F )
		{	output.push_back( *itr ) ;	}
	}

	cout << output.size() << "\n" ;
	for( i = 0 ; i < output.size() ; ++i )
	{	cout << output[ i ] << "\n" ;	}

	return 0 ;
}


Measured memory_bytes: 4176
from heapq import heappush, heappop

n, m = map(int, input().split())
A = input().split()
hq = []
for a in A:
    heappush(hq, -1 * int(a))

for _ in range(m):
    tmp = -1 * heappop(hq)
    heappush(hq, -1 * (tmp // 2))

print(-sum(hq))

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

using namespace std;

int main()
{
    int n , C=1   ;
    cin>>n;
    vector<int> a(n);
    for(int i=0 ; i<n ; i++)
    {
        cin>>a[i];
    }
    int m=a[0];
    for(int i=1 ; i<n ; i++)
    {
        if( a[i] <= m  )
        {
            C++;
            m=a[i];
        }
    }
    cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<string>
using namespace std;
int  main()
{
  string s,k;
  cin>>s>>k;int cnt=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]==k[i])
      cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main(){
  while(1){
    int h;
    cin >> h;
    if(h==0) break;

    vector<vector<int> > board(h, vector<int>(5, 0));
    for(int i=0; i<h; i++){
      for(int j=0; j<5; j++){
        cin >> board[i][j];
      }
    }

    int point=0;
    bool flag = true;
    while(flag){
      
      flag = false;
      //disappear
      for(int i=0; i<h; i++){
        for(int j=0; j<3; j++){
          int col = board[i][j];
          int cnt = 1;
          if(col==0) continue;
          while(j+cnt<5 && col==board[i][j+cnt]){
            cnt++;
          }
          if(cnt<3) continue;
          for(int k=0; k<cnt; k++){
            board[i][j+k] = 0;
          }
          point += col*cnt;
          flag = true;
        }
      }
      
      //fall
      for(int i=0; i<5; i++){
        for(int j=0; j<h; j++){
          for(int k=h-1; k>j; k--){
            if(board[k][i]==0){
              swap(board[k-1][i], board[k][i]);
            }
          }
        }
      }
      
    }
    cout << point << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
#include <string.h>
using namespace std;
#define INF 11000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;


int main(){
    int N;
    ll M,ans=0;
    cin>>N>>M;
    for(ll i=1;i<=(ll)100000;i++){
        if(M%i==0){
            if(i*N<=M) ans=max(ans,i);
            ll x=M/i;
            if(x*N<=M) ans=max(ans,x);
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
h,w=map(int,input().split())
s=[]
for i in range(h):
    S=list(input().split())
    s.append(S)
alf=[]
num=65
for i in range(w):
    alf.append(chr(num))
    num+=1
for i in range(h):
    for j in range(w):
        if s[i][j]=="snuke":
            print(alf[j]+str(i+1))


Measured memory_bytes: 3060
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

lim = [a,b,c,d,e]
mint = min(lim)
if n%mint ==0:
  print(n//mint+4)
else:
  print(n//mint+5)

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

struct Card
{
    char suit, value;
};

void selectionSort(struct Card A[], int N)
{
    for (int i = 0; i < N; i++)
    {
        int minj = i;
        for (int j = i; j < N; j++)
        {
            if (A[j].value < A[minj].value)
                minj = j;
        }
        swap(A[i], A[minj]);
    }
}

void bubbleSort(struct Card A[], int N)
{
    bool flag = 1;
    for (int i = 0; flag; i++)
    {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--)
        {
            if (A[j].value < A[j - 1].value)
            {
                swap(A[j], A[j - 1]);
                flag = 1;
            }
        }
    }
}

bool isStable(struct Card A[], struct Card B[], int N)
{
    for (int i = 0; i < N; i++)
    {
        if (A[i].suit != B[i].suit)
            return false;
    }
    return true;
}

void printArr(struct Card A[], int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i != N - 1)
            cout << A[i].suit << A[i].value << " ";
        else
            cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

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

    Card C1[100], C2[100];
    char ch;

    for (int i = 0; i < n; i++)
        cin >> C1[i].suit >> C1[i].value;

    for (int i = 0; i < n; i++)
        C2[i] = C1[i];

    bubbleSort(C1, n);
    selectionSort(C2, n);

    printArr(C1, n);
    cout << "Stable" << endl;
    printArr(C2, n);
    if (isStable(C1, C2, n))
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	static long[]m = new long[5];
	static long Mod = 1000_000_007;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long min = 1000000000000000L;
		for(int i=0;i<5;i++) {
			m[i]=Long.parseLong(sc.next());
			if(m[i]<min)min=m[i];
		}
		sc.close();

		long res = 0;
		if(min<n) {
			res = n/min;
			if(n%min==0)res--;
		}
		res+=5;

		System.out.println(res);
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  ll four = 0;
  ll nottwo = 0;
  for(int i = 0;i < n;i++){
    ll m = 0;
    cin >> m;
    if(m % 4 == 0)four++;
    else if(m % 2 == 1)nottwo++;
  }
  if(n % 2 == 1 && nottwo == four + 1){
    if(nottwo + four == n)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else{
    if(four >= nottwo)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int X[200200];
long long ans;
int main()
{
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
    cin>>X[i];
  sort(X,X+N);
  for(int i=0;i<N-K;i++)
    ans+=X[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1e15+7;
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<int>> kake(vector<vector<int>> &tim1,vector<vector<int>> &tim2) {
	vector<vector<int>> res = vector<vector<int>>(tim1.size(),vector<int>(tim1[0].size(),0));
	REP (i,tim1.size()) {
		REP (j,tim1[0].size()) {
			REP (k,tim2[0].size()) {
				res[i][k] += tim1[i][j] * tim2[j][k];
				res[i][k] %= mod;
			}
		}
	}
	return res;
}

class UnionFind {
private:
	vector<int> par;
public:
	vector<int> color;
	UnionFind(int N) { par = vector<int>(N, -1LL); color = vector<int>(N,-1);}
	int find(int x);
	ll size(int x);
	bool unite(int x, int y);
	bool same(int x, int y);
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

bool UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
	if (color[x] != -1 && color[y] != -1 && color[x] != color[y]) return false;
	else if (color[x] == -1 && color[y] != -1) color[x] = color[y];
	return true; 
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

signed main() {
	int n,k; cin >> n >> k;
	string s;
	cin >> s;
	if (s[k-1] == 'A') s[k-1] = 'a';
	if (s[k-1] == 'B') s[k-1] = 'b';
	if (s[k-1] == 'C') s[k-1] = 'c';
	cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<char, int> pci;
typedef vector<pii> vp;
typedef vector<pci> vpc;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 50005;
int mx = -1e9 , mn = 1e9 ;

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> x(X + 1, 0);
    vector<long long> y(Y + 1, 0);
    vector<long long> z(Z + 1, 0);

    for (int i = 1; i <= X; ++i) {
        cin >> x[i];
    }
    for (int i = 1; i <= Y; ++i) {
        cin >> y[i];
    }
    for (int i = 1; i <= Z; ++i) {
        cin >> z[i];
    }

    x[0] = LLONG_MAX;
    y[0] = LLONG_MAX;
    z[0] = LLONG_MAX;
    sort(x.rbegin(), x.rend());
    sort(y.rbegin(), y.rend());
    sort(z.rbegin(), z.rend());

    priority_queue<long long> pq;
    for (int i = 1; i <= X; ++i) {
        for (int j = 1; j <= Y; ++j) {
            for (int k = 1; k <= Z; ++k) {
                if (i * j * k > K)
                    break;
                pq.push(x[i] + y[j] + z[k]);
            }
        }
    }

    while (K--){
        cout << pq.top() << '\n';
        pq.pop();
    }

    return 0;
}


Measured memory_bytes: 1404
#include <iostream>
using namespace std;
int main() {
    int n, W; cin >> n >> W;
    int dp[100100];
    fill(dp+1, dp+100100, 1<<30);
    dp[0] = 0;
    while (n--) {
        int w, v; cin >> w >> v;
        for (int u = 100000-v; u >= 0; u--)
            dp[u+v] = min(dp[u+v], dp[u] + w);
    }
    int ans = 0;
    for (int i = 0; i <= 100000; i++) if (dp[i] <= W) ans = i;
    cout << ans << endl;
}


Measured memory_bytes: 640
# 少しめんどくさい方法です。
import itertools
n, d = map(int, input().split())
x = []
s = []  # 組み合わせ用の変数。
for i in range(n):
    s.append(i)
    a = list(map(int, input().split()))
    x.append(a)
# 単純に組み合わせで判定する。
ans = 0
for v in itertools.combinations(s, 2):
    t = 0
    # 距離を判定する。
    for i in range(d):
        t += (x[v[0]][i] - x[v[1]][i])**2
    # 少数かどうか？
    if (t**0.5).is_integer():
        ans += 1
print(ans)


Measured memory_bytes: 9336
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if((a==5 && b==5 &&c==7) ||(a==5 && b==7 &&c==5)|| (a==7 && b==5 &&c==5) )
        printf("YES");
    else printf("NO");
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    
    cout << (long long) N*(N-1)/2 << endl;
    
    return 0;
}

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

long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
  return a / GCD(a, b) * b;
}

int main() {
  int N; cin >> N;
  vector<long long> T(N); for (int i = 0; i < N; i++) cin >> T[i];
  long long ans = T[0];
  for (int i = 1; i < N; i++) ans = LCM(ans, T[i]);
  cout << ans << endl;
  return 0;
}

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

string alp = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    int k;
    cin >> s >> k;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != 'a'){
            int t = 26 - (s[i] - 'a');
            if(k >= t) k -= t, s[i] = 'a';
        }
    }
    s[s.size() - 1] = alp[(s[s.size() - 1] - 'a') + k % 26];
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const int n = s.size();
	for(int i = 0; i < n; ++i){
		if(s[i] == '?'){ s[i] = 'D'; }
	}
	cout << s << endl;
	return 0;
}



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

using namespace std;

int N,M,K,L,R,H,W;
//long long int N,M,K,L,R,H,W;

//const long long int MOD=1000000007;
const int MOD=1000000007;
//const long long int MOD=998244353;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N,M;
	while(cin>>N>>M,N){
		vector<int>v(N);
		for(auto &i:v)cin>>i;
		sort(v.begin(),v.end());
		v.push_back(MOD);
		int L=v[0]-1;
		int R=v[N-1];
		while(R-L>1){
			//cout<<L<<" "<<R<<endl;
			int mid=(L+R)/2;
			int cnt=0;
			int index=0;
			int st=0;
			int level=1;
			//cout<<"mid "<<mid<<endl;
			while(index<N){
				while(v[index]<level+mid)index++;
				while(v[st]<level)st++;
				int add=0;
				if(index>st)add=max(add,max(1,mid-abs(v[st]-level)));
				if(st)add=max(add,max(1,mid-abs(v[st-1]-level)));
				//cout<<add<<endl;
				level+=add;
				cnt++;
				//cout<<cnt<<" "<<level<<endl;
			}
			if(cnt<M)R=mid;
			else L=mid;
		}
		if(L==v[0]-1)cout<<-1<<endl;
		else cout<<L<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3920
#include<iostream>

#define INF 100000;
using namespace std;


int main(){
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0){break;}
    int s_tim[m][m];
    int c_money[m][m];
    int a,b,cost,tim;

    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
        s_tim[i][j]=INF;
        c_money[i][j]=INF;
      }
    }
    for(int i=0;i<m;i++){
      s_tim[i][i]=0;
      c_money[i][i]=0;
    }
    for(int i=0;i<n;i++){
      cin>>a>>b>>cost>>tim;
      s_tim[a-1][b-1]=tim;s_tim[b-1][a-1]=tim;
      c_money[a-1][b-1]=cost;c_money[b-1][a-1]=cost;
    }

    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(s_tim[i][j]>s_tim[i][k]+s_tim[k][j]){
            s_tim[i][j]=s_tim[i][k]+s_tim[k][j];
          }
          if(c_money[i][j]>c_money[i][k]+c_money[k][j]){
            c_money[i][j]=c_money[i][k]+c_money[k][j];
          }
        }
      }
    }

    int contacts,p,q,r;
    cin>>contacts;

    for(int i=0;i<contacts;i++){
      cin>>p>>q>>r;
      if(r){cout<<s_tim[p-1][q-1];}
      else{ cout<<c_money[p-1][q-1];}
      cout<<endl;
    }
  }
}


Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    int mn = t;
    int ret = -INT_MAX;
    for (int i=1; i<n; ++i) {
        cin >> t;
        ret = max(ret, t - mn);
        mn = min(mn, t);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ary = new int[n];
		for(int i = 0; i < n; i++){
			ary[i] = sc.nextInt();
		}
		boolean can = true;
		boolean down1 = true;
		for(int i = 1; i < n; i++){
			int now = ary[i];
			int before = ary[i - 1];
			if(down1){
				before--;
			}
			if(before < now){
				down1 = true;
				continue;
			}
			if(before == now){
				down1 = false;
				continue;
			}
			if(before > now){
				can = false;
				break;
			}
		}
		System.out.println(can ? "Yes" : "No");
	}
}


Measured memory_bytes: 50484
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

struct Memo {
    int parent;
    int cnt;
    int minimum;
};

int dfs(int i, const std::vector<std::vector<int>>& edges, std::vector<Memo>& memo, int& cnt) {
    memo[i].cnt = cnt++;
    int minimum = memo[i].cnt;
    for(auto v: edges[i]) {
        if(memo[v].cnt < 0) {
            memo[v].parent = i;
            minimum = std::min(minimum, dfs(v, edges, memo, cnt));
        }
        else minimum = std::min(minimum, memo[v].cnt);
    }
    memo[i].minimum = minimum;
    return minimum;
}

int main() {
    int V, E;
    std::cin >> V >> E;

    std::vector<std::vector<int>> edges(V, std::vector<int>());
    std::vector<Memo> memo(V, Memo{-1, -1, -1});

    while(E--){
        int s, t;
        std::cin >> s >> t;
        edges[s].push_back(t);
        edges[t].push_back(s);
    }

    int cnt = 0;
    dfs(0, edges, memo, cnt);

    std::vector<int> ans;
    ans.reserve(V);

    for(int i = 0; i < memo.size(); ++i) {
        if(0 <= memo[i].parent && 0 <= memo[memo[i].parent].parent && memo[memo[i].parent].cnt <= memo[i].minimum) ans.push_back(memo[i].parent);
    }

    if(1 < std::count_if(begin(memo), end(memo), [](auto& val){return val.parent == 0;})) ans.push_back(0);
    std::sort(begin(ans), end(ans));
    auto itr = std::unique(begin(ans), end(ans));
    ans.erase(itr, end(ans));
    for(auto val: ans)
        std::cout << val << '\n';

    std::cout << std::flush;

    return 0;
}



Measured memory_bytes: 4688
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
//for (int i = 0; i < N; i++){}

int main() {
    long long N, Q;
	cin >> N >> Q;

    string S;
    cin >> S;

    long long l[Q];
    long long r[Q];
    for (long long i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
    }

    long long sumsList[S.size()];
    for (long long i = 0; i < S.size(); i++){
        sumsList[i] = 0;
    }

    long long sums = 0;
    for (long long i = 0; i < S.size(); i++){
        if(i==0){
            if(S[i] == 'C'){
                sumsList[i] = sums;
                continue;
            }
        }
        if(S[i] == 'C'){
            if(S[i-1] == 'A'){
                sums++;
            }
        }
        sumsList[i] = sums;
    }
    
    for (long long i = 0; i < Q; i++){
        cout << (sumsList[r[i]-1] - sumsList[l[i]-1]) << endl;
    }
    
}

Measured memory_bytes: 3456
fn main() {
    let a: [i32; 5] = {
        [
            read(),
            read(),
            read(),
            read(),
            read(),
        ]
    };

    let mut ans = 0;

    let mut v: Vec<i32> = a.into_iter()
    .map(|x| {
        let d = x / 10;
        ans += d * 10;
        x % 10
    })
    .filter(|&x| x != 0)
    .collect();

    v.sort();

    if v.len() != 0 {
        ans += v[0] + 10 * (v.len() as i32 - 1);
    }

    println!("{}", ans);
}

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

Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//F
//遠くにいく
//X,Yのabsの最大
int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    string res;

    if(a + b > c + d)
    {
        res = "Left";
    }
    else if(a+b < c+d)
    {
        res = "Right";
    }
    else
    {
        res = "Balanced";
    }
    
    cout <<res << endl;


    return 0;    

}



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

char s[110000];

int main() {
	int n; cin >> n;
	int sum = 0, cnt = 0, sn = 0;
	while (sum < n) {
		cnt++;
		sum += cnt / 2 + (cnt + 1) / 2;
		s[sn++] = ')';
	}
	for (int i = sn - 1; i >= 0; i--) s[sn++] = '(';
	if (sum > n) swap(s[sn / 2 - (sum - n)], s[sn / 2]);
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <algorithm>
#define MAX_V 190
#define INF 100000
using namespace std;
int go[MAX_V];
int back[MAX_V];
bool used[MAX_V];
int cost[MAX_V][MAX_V];
int n;

void dijkstra(int s, int d[]) {
	fill(d, d + n + 1, INF);
	fill(used, used + n + 1, false);
	d[s] = 0;

	while (1) {
		int v = -1;
		for (int i = 1; i <= n; ++i) {
			if (!used[i] && (v == -1 || d[i] < d[v])) v = i;
		}
		if (v == -1) break;
		used[v] = true;

		for (int i = 1; i <= n; ++i) {
			d[i] = min(d[i], d[v] + cost[v][i]);
		}
	}
}

int main() {
	int m, a, b, c, d, x1, x2, y1, y2;

	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		fill(cost[i], cost[i] + n + 1, INF);
	}
	while (m--) {
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		cost[a][b] = c; cost[b][a] = d;
	}
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	dijkstra(x1, go);
	dijkstra(x2, back);
	cout << y1 - (go[x2] + back[x1] + y2) << endl;
	return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;

ll Gcd(ll b, ll d){
  	if (d == 0) return b;
 	else return Gcd(d, b % d);
}
ll Lcm(ll m, ll n){
    if ((0 == m) || (0 == n)) return 0;
    return ((m / Gcd(m, n)) * n);
}

int main(void){
    
    scanf("%d", &N);
    ll ans = 1;
    for(int i = 0; i < N; ++i){
        ll t; scanf("%lld", &t);
        ans = Lcm(ans, t);
    }
    printf("%lld\n", ans);
    
    return 0;
}

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

using namespace std;

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

#define F first
#define S second

const ll INF = 2e18;

int t[3][3], _t[3][3];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	/*t[0][0] = t[1][1] = t[2][2] = 1;
	for (int i = 1; i < 10; i++){
		for (int j = 0; j < 3; j++){
			for (int w = 0; w < 3; w++)
				cout << t[j][w] << " ";
			cout << "\n";
		}
		cout << endl;

		memcpy(_t, t, sizeof(t));
		memset(t, 0, sizeof(t));
		for (int j = 0; j < 3; j++)
			for (int w = 0; w < 3; w++)
				for (int jj = 0; jj < 3; jj++)
					if (j^jj)
						t[j][w] += _t[jj][w];
	}
	return 0;*/

	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k&1){
		cout << b-a << endl;
	}
	else{
		cout << a-b << endl;
	}
	/*k = min(k, (ll)1e6);
	while (k--){
		ll _a = a, _b = b, _c = c;
		a = _b + _c;
		b = _a + _c;
		c = _a + _b;
		if (abs(a-b) >= INF){
			cout << "Unfair\n";
			return 0;
		}
	}*/
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int i,a,x,x1,b,c,d;
	while(1){
	scanf("%d",&a);
	if(a==0) break;
	x=0; x1=0;
	for(i=0;i<a;i++){
	scanf("%d %d %d",&b,&c,&d);
	if(x<c+d){
	x=c+d;
	x1=b;
	}
	}
	printf("%d %d\n",x1,x);
	}
	return 0;
	}

Measured memory_bytes: 600
N,M = map(int,input().split())
a=[]
b=[]
for i in range(1,N+1):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
c=[]
d=[]
for j in range(1,M+1):
    C,D = map(int,input().split())
    c.append(C)
    d.append(D)
for i in range(1,N+1):
    e=[]
    for j in range(1,M+1):
        E = abs(a[i-1]-c[j-1])+abs(b[i-1]-d[j-1])
        e.append(E)
    x = min(e)
    print(e.index(x)+1)

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

long long e(int a, int b){
    long long j = 1;
    rep(i, b){
        j *= a;
    }
    return j;
}

int main(){
    long long N, K;
    cin >> N >> K;
    long long A[N];
    rep(i, N){
        cin >> A[i];
    }
    int bit = 40;
    int k[bit];
    K++;
    rep(i, bit){
        k[i] = K % 2;
        K /= 2;
    }
    long long cnt[bit];
    fill_n(cnt, bit, 0);
    rep(i, N){
        rep(j, bit){
            cnt[j] += A[i] % 2;
            A[i] /= 2;
        }
    }
    long long mx[bit];
    long long nt[bit];
    rep(i, bit){
        if(k[i] == 0){
            nt[i] = cnt[i] * e(2,i);
        }
        else{
            nt[i] = (N - cnt[i]) * e(2,i);
        }
        mx[i] = max(cnt[i], N - cnt[i]) * e(2,i);
    }
    int n;
    for(int i = bit-1; i >= 0; i--){
        if(k[i] == 1){
            n = i;
            break;
        }
    }
    priority_queue<long long> que;
    rep(i, n+1){
        if(k[i] == 1){
            long long j = 0;
            rep2(k, i+1, bit){
                j += nt[k];
            }
            j += cnt[i] * e(2,i);
            rep(k, i){
                j += mx[k];
            }
            que.push(j);
        }
    }
    cout << que.top() << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
typedef unsigned long long int ll;
int N,K;
vector<int> s;

int main()
{
  int i,j;
  int d,A;
  int sum=0;

  cin >> N >> K;
  s.resize(N+1);

  for (i=1; i<=K; i++) {
    cin >> d;
    for (j=1; j<=d; j++) {
      cin >> A;
      s[A]++;
    }
  }
  for (i=1; i<=N; i++) {
    if (s[i] == 0) sum++;
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vc<pair<ll, char>> A(N), B, S;
    rep(i, N){
        string s;
        cin >> s;
        A[i] = {s[1] - '0', s[0]};
    }
    S = B = A;

    stable_sort(all(S), [&](pair<ll, char> p1, pair<ll, char> p2) { return p1.first < p2.first; });

    // rep(i, N) cout << S[i].second << S[i].first << (i == N - 1 ? '\n' : ' ');

    rep(i, N){
        reper(j, i, N - 1){
            if (A[j].first > A[j + 1].first) swap(A[j], A[j + 1]);
        }
    }

    rep(i, N){
        ll mi = i;
        repe(j, i + 1, N) if (B[j].first < B[mi].first) mi = j;
        swap(B[i], B[mi]);
    }

    rep(i, N) cout << A[i].second << A[i].first << (i == N - 1 ? '\n' : ' ');
    cout << (A == S ? "Stable" : "Not stable") << endl;

    rep(i, N) cout << B[i].second << B[i].first << (i == N - 1 ? '\n' : ' ');
    cout << (B == S ? "Stable" : "Not stable") << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll visited[100001], dp[100001];
vector<ll> g[100001];
void dfs(int n)
{
    if (visited[n])
    {
        return;
    }
    visited[n]=1;
    for(auto i: g[n])
    {
        if (!visited[i])
        {
            dfs(i);
        }
        dp[n]=max(dp[i], dp[n]);
    }
    dp[n]++;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        ll x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    ll ans=0;
    for (int i = 0; i < n+1; ++i)
    {
        if ((!visited[i]))
        {
            dfs(i);
        }
        ans=max(dp[i], ans);
    }
    cout << ans-1 <<"\n";
    return 0;
}

Measured memory_bytes: 9344
from fractions import gcd

a,b,c,d = map(int,input().split())

def f(n, m):
    return n // m

l = c * d // gcd(c, d)
res = f(b, c) + f(b, d) - f(b, l)
res -= f(a - 1, c) + f(a - 1, d) - f(a - 1, l)
print(b - a + 1 - res)

Measured memory_bytes: 5728
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;
}

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

int main() {
  ll a;
  cin >> a;
  double b;
  cin >> b;
  ll tmp = b * 100 + 0.5;
  ll ans = (a * tmp) / 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3728
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        var x = ReadInt();
        var n = ReadInt();
        if (n == 0)
        {
            Console.WriteLine(x);
            return;
        }
        var p = Enumerable.Range(0, 102).Except(ReadInt(n)).OrderBy(y => y).ToArray();
        var a = Array.BinarySearch(p, x);
        if (a >= 0)
        {
            Console.WriteLine(x);
            return;
        }
        var b = ~a - 1;
        var c = b + 1;
        if (x - p[b] <= p[c] - x)
        {
            Console.WriteLine(p[b]);
        }
        else
        {
            Console.WriteLine(p[c]);
        }
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();

    public static string Read()
    {
        if (!que.Any())
        {
            foreach (var s in Console.ReadLine().Split()) que.Enqueue(s);
        }
        return que.Dequeue();
    }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());

    public static IEnumerable<string> Read(long n)
    {
        for (long i = 0; i < n; i++) yield return Read();
    }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

Measured memory_bytes: 28688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int main(){
    string s; cin >> s;
    ll n = s.size();
    map<char, bool> mp;
    rep(i,n)mp[s[i]] = 1;;
    if(mp['N']^mp['S'] == 0 && mp['W']^mp['E'] == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  string X;
  cin >> N;
  cin >> X;

  vll f(N+1, 0), pamari(N, 0), mamari(N, 0);
  repi(i, 1, N+1){
    ll popcnt = 0;
    ll mask = 1LL;
    rep(_, 20){
      if(mask & i) popcnt++;
      mask <<= 1;
    }
    f[i] = f[i%popcnt] + 1;
  }

  ll popx = 0;
  rep(i, N) popx += X[i] - '0';

  ll pfamari = 0, mfamari = 0, ans;
  rrep(i, N){
    if(i == N-1){
      pamari[i] = 1 % (popx+1);
      if(popx-1 > 0) mamari[i] = 1 % (popx-1);
    }
    else{
      pamari[i] = pamari[i+1] * 2 % (popx+1);
      if(popx-1 > 0) mamari[i] = mamari[i+1] * 2 % (popx-1);
    }
    pfamari = (pfamari + (X[i]-'0') * pamari[i]) % (popx+1);
    if(popx-1 > 0) mfamari = (mfamari + (X[i]-'0') * mamari[i]) % (popx-1);
  }
  
  rep(i, N){
    if(X[i] == '0'){
      ans = f[(pfamari + pamari[i]) % (popx+1)] + 1;
    }
    else if(popx == 1){
      ans = 0;
    }
    else{
      ans = f[((mfamari - mamari[i]) % (popx-1) + (popx-1)) % (popx-1)] + 1;
    }
    cout << ans << endl;
  }
  // debug(f)
  // debug(pamari)
  // debug(mamari)


  return 0;
}



Measured memory_bytes: 8340
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)
	{
		cout << "Left" << endl;
	}
	else if (a + b == c + d)
	{
		cout << "Balanced" << endl;
	}
	else
	{
		cout << "Right" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	
	int N;
	vector<int> a(3);
	cin>>N;
	while(N>0){
		for(int i=0;i<3;i++)
			cin>>a[i];
		sort(a.begin(),a.end());
		if(pow(a[2],2.0)==pow(a[1],2.0)+pow(a[0],2.0))
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		N--;
	}
	}

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

int main()
{
    ll test=1;
    //  cin>>test;
    while(test--)
    {
        ll n,ans=0;
        cin>>n;
        vector<ll> ar(n),v(n);
        for(ll i=0;i<n;i++)
            cin>>v[i];
        sort(v.begin(),v.end());
        
        for(ll i=0;i<n-2;i++)
        {
            for(ll j=i+1;j<n-1;j++)
            {
                ll x = v[i]+v[j];
                auto it = lower_bound(v.begin(),v.end(),x);
                it--;
                ll len = it - v.begin();
                if(len<=j)
                    continue;
                ll res = len-j;
                ans += res;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a;cin>>a;
  int n=a.length();
  for(int i=1;i<n;i++)
  {
    if(a[i]==a[i-1])
    {cout<<"Bad";return 0;}
  }
  cout<<"Good";
  return 0;
}


Measured memory_bytes: 256
///Ug02-47-18-017
//#include<iostream>
//#include<conio.h>
#include<math.h>
#include<stdio.h>
//using namespace std;

int main()
{
    int r;
    double x;

    scanf("%d",&r);

    x = pow((double)r, 2);

    printf("%.0lf\n",x);

    return 0;
}


Measured memory_bytes: 128
n, m, x = map(int, input().split())

a_list = list()
c_list = list()

INF = 1001001001

for i in range(0, n):
    tmp = list(map(int, input().split()))
    c = tmp.pop(0)
    c_list.append(c)
    a_list.append(tmp)

ans = INF

for s in range(0, 1 << n):
    cost = 0
    d = [0]*m
    for i in range(0, n):
        if s >> i & 1:
            cost += c_list[i]
            for j in range(0, m):
                d[j] += a_list[i][j]
    ok = True
    for j in range(0, m):
        if d[j] < x:
            ok = False
    if ok:
        ans = min(ans, cost)

if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9256