akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
from itertools import product
def main():
    x = int(input())
    n5 = [i**5 for i in range(201)]

    c = product(n5, repeat=2)
    for ce in c:
        if ce[0] + ce[1] == x:
            r = (int(ce[0]**0.2), int(ce[1]**0.2)* -1)
            break
        elif ce[0] - ce[1] == x:
            r = (int(ce[0] ** 0.2), int(ce[1] ** 0.2))
            break
    print(*r, sep=' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 27028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll n;cin>>n;
    vector<ll> a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n)cin >> b[i];

    ll ans = 0;
    rep(i,n){
        ll mn = min (a[i],b[i]);
        ans += mn;
        a[i]-=mn;
        b[i]-=mn;
        mn = min(a[i+1],b[i]);
        ans += mn;
        a[i+1]-=mn;
        b[i] -=mn;
    }
    cout << ans<<endl;


}



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

int main() {
    
    int N;
    cin >> N;
    
    vector<int> circle(N);
    for (int i = 0; i < N; i++){
        cin >> circle.at(i);
    }
    
    sort(circle.begin(),circle.end());
    
    int a = 1;
    for (int j = 0; j < N - 1; j++){
        if (circle.at(j) != circle.at(j + 1)){
            a++;
        }
    }
    
    cout << a << endl;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    if (a < b) {
        console.log('a < b');
    } else if (a > b) {
        console.log('a > b');
    } else if (a === b) {
        console.log('a == b');
    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int kinds = 3;
    int N = sc.nextInt();
    int[][] arrays = new int[N][kinds];
    for(int i = 0; i < N; i++){
      for(int j = 0; j < kinds; j++){
        arrays[i][j] = sc.nextInt();
      }
    }
    System.out.println(solve(arrays));
  }
  
  public static long solve(int[][] as){
    int N = as.length;
    for(int i = 1; i < as.length; i++){
      int[] tmps = Arrays.copyOf(as[i], as[i].length);
      for(int j = 0; j < as[i].length; j++){
        as[i][j] = tmps[j] + Math.max(as[i-1][(j+1) % 3], as[i-1][(j+2) % 3]);
      }
    }
    return Math.max(as[N-1][0], Math.max(as[N-1][1], as[N-1][2]));
  }
}

Measured memory_bytes: 96580
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var A = sc.nextInt();
	var B = sc.nextInt();
	var H = sc.nextInt();
	var M = sc.nextInt();
	
	var radH = H * 30 + M * 0.5;
	var radM = M * 6;
	var radC = radH - radM;
	if (radC < 0) radC = -1 * radC;
	
	C2 = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * Math.cos(radC * (Math.PI / 180));
	C = Math.sqrt(C2);
	
	console.log(C);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("10 1 2 5 3 4 6 7 3 2 4 1 2 2 3 3 4 4 5 3 6 6 7 1 8 8 9 9 10"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延
// console.log(wrtnNos); return;


Measured memory_bytes: 29836
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int ans[30000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            int d;
            if(i <= X && j >= Y){
                d = j-i-(Y-X-1);
            }else{
                d = min(j-i, abs(X-i)+abs(Y-j)+1);
            }
            ans[d]++;
        }
    }
    for(int i = 1; i <= N-1; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] p = new int[n+1];
      int cnt = 0;
      for(int i = 1;i <= n;i++)p[i]=sc.nextInt();
      for(int i = 1;i <= n-1;i++){
      	if(p[i]==i){
          int t = p[i+1];
          p[i+1]=p[i];
          p[i]=t;
          cnt++;
        }
      }
      if(p[n]==n)cnt++;
      System.out.println(cnt);
    }
}

Measured memory_bytes: 52512
#include<bits/stdc++.h>
#define sag (root+root+1)
#define sol (root+root)
#define ort  ((bas+son)/2)
#define mod 1000000007

using namespace std;
typedef long long ll;




int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    while(n/k){
        n/=k;
        ans++;
    }
    cout << ans+1;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    long long N;
    int M;
    cin >> N >> M;

    for (int i = 0; i < M; ++i) {
        int A;
        cin >> A;

        N -= A;
    }

    cout << (N >= 0 ? N : -1) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int N,K;
    cin >> N >> K;
    vector<pair<ll,ll> > ev;
    vector<ll> X,Y;

    rep(i,0,N){
        ll x,y;
        cin >> x >> y;
        ev.emplace_back(x,y);
        X.push_back(x);
        Y.push_back(y);
    }
    sort(all(X));
    sort(all(Y));
    ll ans = -1;
    rep(i,0,X.size()){
        rep(j,i+1,X.size()){
            rep(k,0,Y.size()){
                rep(l,k+1,Y.size()){
                    int cnt = 0;
                    for(pair<ll,ll> e : ev){
                        if(e.first >= X[i] && e.first <= X[j] && e.second >= Y[k] && e.second <= Y[l]){
                            cnt++;
                        }
                    }
                    if(cnt >= K){
                        if(ans == -1){
                            ans = (X[j] - X[i]) * (Y[l] - Y[k]);
                        }else{
                            ans = min(ans,(X[j] - X[i]) * (Y[l] - Y[k]));
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 gcd(i64 x, i64 y) {
    return x % y == 0 ? y : gcd(y, x % y);
}
i64 lcm(i64 x, i64 y) {
    return x * y / gcd(x, y);
}

int main() {
    i64 a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 200005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

void solve(int kk)
{

   int n, need,cc;
   cin >> n >> need;

   cc = need;

   ll a[n+10], tot=0, c;

   for(int i=1; i<=n; i++) cin >> a[i], tot+=a[i];


   for(int i=1; i<=n; i++){
       c = a[i]*4*need;
       if(c>=tot) --cc;
   }
   cc <= 0 ? cout << "Yes\n" : cout << "No\n";



}

int main()
{
   fast;
   int kk=0;
//   cin >> tc;
   while(++kk<=tc) solve(kk);

   return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace  std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
vector<vector<ll>>dp(100111, vector<ll>(13, -1));
string S;
int n;
vector<int>mods={1,10,9,12,3,4};
ll rec(ll curr, int mod)
{
	if(curr==-1)
	{
		//cout<<curr<<" "<<mod<<endl;
		if(mod==5)return 1;
		return 0;
	}
	if(dp[curr][mod]!=-1)return dp[curr][mod];
	int h=n-curr-1;
	h%=6;
	ll rslt=0;
	
	if(S[curr]=='?')
	{
		rep(i,0,10)
		{
			rslt+=rec(curr-1, (mod+mods[h]*i)%13);
			rslt%=1000*1000*1000+7;
		}
	}
	else
	{
		rslt+=rec(curr-1, (mod+mods[h]*(S[curr]-'0'))%13);
			rslt%=1000*1000*1000+7;
	}
	return dp[curr][mod]=rslt;
}
int main()
{
	cin>>S;
	n=S.size();
	cout<<rec(n-1, 0)<<endl;
}


Measured memory_bytes: 21632
from fractions import gcd
import math
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    a=list(input().split())
    b = n - len(set(a))
    b = b if b % 2 == 0 else b + 1
    print(n - b)
main()


Measured memory_bytes: 18536
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> arr(n);
    F0R(i,n)
        cin >> arr[i];
    int tot=0;
    F0R(i,n)
        tot^=arr[i];
    vector<int> res(n);
    F0R(i,n)
        res[i]=tot^arr[i];
    F0R(i,n)
        cout << res[i] << " ";

    return 0;
}


Measured memory_bytes: 4700
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007

void solve()
{
 ll n;
 cin>>n;
 ll a[n];
 fr(n)
 {
  cin>>a[i];
 }
 ll dp[n+1][n+1];
 ll flag=(n%2);
 fr(n+1)
 {
  if(i==0)
    continue;
  
    rep(j,0,n+1-i)
    {
      if(i==1){
        if(i%2==flag)
        dp[j][j+i-1]=a[j];
      else
        dp[j][j+i-1]=-a[j];
      }
      else{
        if(i%2==flag)
      dp[j][j+i-1]=max(dp[j+1][j+i-1]+a[j],dp[j][j+i-2]+a[j+i-1]);
    else
      dp[j][j+i-1]=min(dp[j+1][j+i-1]-a[j],dp[j][j+i-2]-a[j+i-1]);
    }
    //cout<<dp[j][j+i-1]<<" ";
    }
//cout<<endl;
  
 }
 cout<<dp[0][n-1];
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 49716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		char[] c = sc.next().toCharArray();
		sc.close();

		int min = a.length + b.length + c.length;
		min = Math.min(min, mins3(a, b, c));
		min = Math.min(min, mins3(a, c, b));
		min = Math.min(min, mins3(b, a, c));
		min = Math.min(min, mins3(b, c, a));
		min = Math.min(min, mins3(c, a, b));
		min = Math.min(min, mins3(c, b, a));
		System.out.println(min);
	}

	static int mins3(char[] x, char[] y, char[] z) {
		int min = x.length + y.length + z.length;
		int yzmax = Math.max(y.length, z.length);
		for ( int i = 0 ; i < x.length ; i++ ) {
			if ( min <= Math.max(x.length, i + yzmax) ) {
				return min;
			}
			boolean match = true;
			for ( int j = 0 ; j < y.length ; j++ ) {
				if ( i + j >= x.length ) {
					break;
				}
				if ( x[i + j] != '?' && y[j] != '?' && x[i + j] != y[j] ) {
					match = false;
					break;
				}
			}
			if ( match ) {
				min = Math.min(min, mins2(x, y, z, i));
			}
		}
		min = Math.min(min, mins2(x, y, z, x.length));
		return min;
	}

	static int mins2(char[] x, char[] y, char[] z, int start) {
		int xyend = Math.max(x.length, start + y.length);
		for ( int i = start ; i < xyend ; i++ ) {
			boolean match = true;
			for ( int j = 0 ; j < z.length ; j++ ) {
				if ( i + j >= xyend ) {
					break;
				}
				if ( i + j < x.length && x[i + j] != '?' && z[j] != '?' && x[i + j] != z[j] ) {
					match = false;
					break;
				}
				if ( i + j < start + y.length && y[i + j - start] != '?' && z[j] != '?' && y[i + j - start] != z[j] ) {
					match = false;
					break;
				}
			}
			if ( match ) {
				return Math.max(xyend, i + z.length);
			}
		}
		return xyend + z.length;
	}
}


Measured memory_bytes: 23892
#include <iostream>
using namespace std;
int d[10000],e[10000];
int main(void){
	for (;;){
		long a,b,c,g=0;
		cin>>a>>b;
		if (a==0&&b==0) break;
		long f[501]={0};
		for (c=0;c<b;c++){
			cin>>d[c]>>e[c];
				if (d[c]==1)f[e[c]]=2;
		}
		for(c=0;c<b;c++){
			if(f[d[c]]==2&&f[e[c]]==0)f[e[c]]=3;
			if(f[e[c]]==2&&f[d[c]]==0)f[d[c]]=3;
		}
		for (c=2;c<=a;c++){
			if (f[c]!=0)g++;
		}
		cout<<g<<endl;
	}
	return 0;
}

Measured memory_bytes: 3168
from math import sqrt
n, m = list(map(int, input().split()))
i = 1
lst = []
while i <= sqrt(m):
    if m % i == 0:
        j = m // i
        if i >= n:
            lst.append(i)
        if j >= n:
            lst.append(j)
    i += 1
print(m//min(lst))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

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

	ull cnt = 0;
	ull money = 100;
	while (money < X) {
		++cnt;
		money = money + (money / 100);
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>



#define ll long long
using namespace std;


ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, w;
    cin >> n >> w;
    ll arr[n][2];
    ll dp[n + 1][w + 1];
    for (ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < 2; j++)
        {
            cin >> arr[i][j];
        }
    }
    for (ll i = 0; i <= w; i++)
        dp[0][i] = 0;

    for (ll i = 1; i <= n; i++)
    {

        for (ll j = 0; j <= w; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j - arr[i - 1][0] >= 0)
                dp[i][j] = max(dp[i - 1][j - arr[i - 1][0]] + arr[i - 1][1], dp[i][j]);
        }
    }
    cout << dp[n][w];

    return 0;
}


Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi a(7);
    rep(i,7)a[i]=i;
    int ans=0;
    rep(i,n){
      string s;
      cin>>s;
      if(s=="South"){
	a[0]=a[2];
	a[2]=a[1];
	a[1]=a[5];
	a[5]=a[6];
	a[6]=a[0];
      }else if(s=="West"){
	a[0]=a[4];
	a[4]=a[1];
	a[1]=a[3];
	a[3]=a[6];
	a[6]=a[0];
      }else if(s=="East"){
	a[0]=a[3];
	a[3]=a[1];
	a[1]=a[4];
	a[4]=a[6];
	a[6]=a[0];
      }else if(s=="North"){
	a[0]=a[5];
	a[5]=a[1];
	a[1]=a[2];
	a[2]=a[6];
	a[6]=a[0];
      }else if(s=="Left"){
	a[0]=a[3];
	a[3]=a[2];
	a[2]=a[4];
	a[4]=a[5];
	a[5]=a[0];
      }else if("Right"){
	a[0]=a[4];
	a[4]=a[2];
	a[2]=a[3];
	a[3]=a[5];
	a[5]=a[0];
      }
      ans+=a[1];
    } 
    cout<<1+ans<<endl;
  }
}

Measured memory_bytes: 3196
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int INF = 0xfffffff;

struct edge {
	int to, cap, rev;
	edge(int t, int c, int r):to(t), cap(c), rev(r){}
};

vector<vector<edge> > G;
vector<int> level;
vector<int> iter;

inline void init(int V) {
	G.clear();
	G.resize(V);
	level.clear();
	level.resize(V);
	iter.clear();
	iter.resize(V);
}

inline void add_edge(int from, int to, int cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

void bfs(int s) {
	fill(level.begin(), level.end(), -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		for(int i = 0; i < G[v].size(); ++i) {
			const edge& e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f) {
	if(v == t)
		return f;

	for(int& i = iter[v]; i < G[v].size(); ++i) {
		edge& e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]) {
			const int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}

	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;

	for(;;) {
		bfs(s);
		if(level[t] < 0)
			return flow;

		fill(iter.begin(), iter.end(), 0);
		int f;
		while((f = dfs(s, t, INF)) > 0)
			flow += f;
	}
}

typedef complex<double> point;
inline istream &operator>> (istream &is, point &p) {
	point::value_type x, y;
	is >> x >> y;
	p.real(x);
	p.imag(y);
	return is;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.flags(ios::fixed);
	cout.precision(10);

	for(int n, m; cin >> n >> m && n;) {
		init(n + m + 2);
		const int source = n + m;
		const int sink = source + 1;

		vector<int> v(n);
		vector<point> troops(n), bases(m);

		for(int i = 0; i < n; ++i) {
			cin >> troops[i] >> v[i];
			add_edge(source, i, 1);
		}

		for(int i = 0; i < m; ++i) {
			cin >> bases[i];
			add_edge(i + n, sink, 1);
		}

		vector<vector<double>> use_time(n, vector<double>(m));
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m; ++j) {
				use_time[i][j] = abs(troops[i] - bases[j]) / v[i];
			}
		}

		double low = 0.0, high = 1e5;
		for(int i = 0; i < 50; ++i) {
			const double middle = (low + high) / 2.0;
			const auto tmp = G;
			for(int i = 0; i < n; ++i) {
				for(int j = 0; j < m; ++j) {
					if(use_time[i][j] <= middle) {
						add_edge(i, j + n, 1);
					}
				}
			}

			if(max_flow(source, sink) == m) {
				high = middle;
			}
			else {
				low = middle;
			}

			G = move(tmp);
		}

		cout << low << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1768
#include <stdio.h>
int main(){
  int v1,v2;
  int i,j;
  int l[11],sum,sum2;
  int ans;
  while(scanf("%d,",&l[1])!=EOF){
    sum=0;sum2=0;ans=0;
    sum+=l[1];
    for(i=2;i<=10;i++){
      scanf("%d,",&l[i]);
      sum+=l[i];
    }
    scanf("%d,%d",&v1,&v2);
    ans=v1*sum;
    for(i=1;i<=10;i++){
      sum2+=l[i];
      if(sum2*(v1+v2)>=ans)break;
    }
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 592
package main

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

func main() {
	N := ReadInt()
	A := make([]string, N)
	for i := 0; i < N; i++ {
		A[i] = ReadString()
	}

	p2 := make([]int, N)
	p5 := make([]int, N)
	m := [19][19]int{}
	for i := 0; i < N; i++ {
		d := 9
		parts := strings.Split(A[i], ".")
		v, _ := strconv.Atoi(parts[0])
		if len(parts) == 2 {
			d -= len(parts[1])
			v, _ = strconv.Atoi(parts[0] + parts[1])
		}
		for j := 0; j < d; j++ {
			v *= 10
		}
		for v%2 == 0 {
			p2[i]++
			v /= 2
		}
		for v%5 == 0 {
			p5[i]++
			v /= 5
		}
		if p2[i] > 18 {
			p2[i] = 18
		}
		if p5[i] > 18 {
			p5[i] = 18
		}
		m[p2[i]][p5[i]]++
	}

	ans := 0
	for i := 0; i < N; i++ {
		tp2 := 18 - p2[i]
		tp5 := 18 - p5[i]
		for j2 := tp2; j2 < 19; j2++ {
			for j5 := tp5; j5 < 19; j5++ {
				ans += m[j2][j5]
			}
		}
		if p2[i] >= tp2 && p5[i] >= tp5 {
			ans--
		}
	}
	fmt.Println(ans / 2)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 18988
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 1e6+10;  
int n,k;
char x;

int main(){
	cin>>x;
	if(x>='a'&&x<='z'){
		cout<<"a"<<endl; 
	} 
	else cout<<"A"<<endl;
}

Measured memory_bytes: 3592
// agrawal117
//chahat agarwal
#include<bits/stdc++.h>  
#define mod 1000000007
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
ll dp[300000];
int main()
{
    ll n;
    cin>>n;
    ll arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    ll sum=0;
    for(int i=n;i>=1;i--){
        sum=0;
        for(int j=i;j<=n;j+=i){
            sum+=dp[j];
        }
        sum%=2;
        if(arr[i]==0){
            if(sum==0) dp[i]=0;
            else dp[i]=1;
        }
        else {
            if(sum==0) dp[i]=1;
            else dp[i]=0;
        }
    }
    ll cnt=0;
    for(int i=1;i<=n;i++) if(dp[i]) cnt++;
    cout<<cnt<<endl;
    for(int i=1;i<=n;i++) if(dp[i]) cout<<i<<" ";
}


Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int dp[2][1<<20];

int main(void){

	int n;
	cin >> n;
	for(int tc=1;tc<=n;tc++){
		int h,w;
		cin >> w >> h;

		int r[20][20];
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)cin >> r[i][j];

		fill(dp[0],dp[2],0);
		for(int i=0;i<h*w;i++){
			for (int j=0;j<(1<<w);j++)dp[(i+1)&1][j]=0;
			for(int S=0;S<(1<<w);S++){
				int x=i%w,y=i/w,nx=(S<<1)&((1<<w)-1);
				if((x==0 && (S>>(w-1)&1)) || (y==0 && (S&1)) || (x!=0 && y!=0 && ((S&1) || (S>>(w-1)&1)))){
					dp[(i+1)&1][nx]=max(dp[(i+1)&1][nx],dp[i&1][S]);
				}
				else {	
					dp[(i+1)&1][nx]=max(dp[(i+1)&1][nx],dp[i&1][S]);					
					dp[(i+1)&1][nx|1]=max(dp[(i+1)&1][nx|1],dp[i&1][S]+r[y][x]);
				}
			}
		}
		int ans=0;
		for(int i=0;i<(1<<w);i++)ans=max(ans,dp[(h*w)&1][i]);
		cout << "Case " << tc << ": " << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9352
#include<stdio.h>

int main(void)
{
  int i,j,n,m,p[1000],S,S1;

  while(1)
    {
      scanf("%d%d",&n,&m);
      if(n==0&&m==0) break;
      for(i=0;i<=n-1;i++)
	{
	  scanf("%d",&p[i]);
	}
      S1=0;
      for(i=0;i<=n-1;i++)
	{
	  for(j=i+1;j<=n-1;j++)
	    {
	      S=p[i]+p[j];
	      if(S<=m && S1<S) S1=S;
	    }
	}
      if(S1==0) printf("NONE\n");
      else printf("%d\n",S1);
    }
  return 0;
}

Measured memory_bytes: 1752
class Dice:
    def __init__(self,u,w,r,s,t,y):
        self.s1 = u
        self.s2= w
        self.s3= r
        self.s4= s
        self.s5 = t
        self.s6= y
    def right_s3(self):
        prev_s3 = self.s3
        self.s3 = prev_s3
    def right_s4(self):
        prev_s4 = self.s4
        self.s3 = prev_s4
    def right_s5(self):
        prev_s5 = self.s5
        self.s3 = prev_s5
    def right_s6(self):
        prev_s6 = self.s6
        self.s3 = prev_s6
    def right_s1(self):
        prev_s1 = self.s1
        self.s3 = prev_s1
    def right_s2(self):
        prev_s2 = self.s2
        self.s3 = prev_s2
    def top(self):
        return self.s3
s1,s2,s3,s4,s5,s6 = map(int,input().split())
order = int(input())
for c in range(order):
    dice = Dice(s1,s2,s3,s4,s5,s6)
    new_s1 , new_s2 = map(int,input().split())
    if (new_s1 == s1 and new_s2 == s2) or (new_s1 ==s2 and new_s2 == s6) or (new_s1 == s6 and new_s2 ==s5) or (new_s1==s5 and new_s2 == s1):
        dice.right_s3()
    elif (new_s1 == s1 and new_s2 == s5) or (new_s1 ==s5 and new_s2 == s6) or (new_s1 == s6 and new_s2 ==s2) or (new_s1==s2 and new_s2 == s1):
        dice.right_s4()
    elif (new_s1 == s1 and new_s2 == s3) or (new_s1 ==s3 and new_s2 == s6) or (new_s1 == s6 and new_s2 ==s4) or (new_s1==s4 and new_s2 == s1):
        dice.right_s5()
    elif (new_s1 == s2 and new_s2 == s4) or (new_s1 ==s4 and new_s2 == s5) or (new_s1 == s5 and new_s2 ==s3) or (new_s1==s3 and new_s2 == s2):
        dice.right_s6()
    elif (new_s1 == s2 and new_s2 == s3) or (new_s1 ==s3 and new_s2 == s5) or (new_s1 == s5 and new_s2 ==s4) or (new_s1==s4 and new_s2 == s2):
        dice.right_s1()
    elif (new_s1 == s1 and new_s2 == s4) or (new_s1 ==s4 and new_s2 == s6) or (new_s1 == s6 and new_s2 ==s3) or (new_s1==s3 and new_s2 == s1):
        dice.right_s2()
    print(dice.top())


Measured memory_bytes: 5616
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()

#define equal equalll
#define less lesss
const int N = 1e6 + 10;
const long long INF = 1e9 + 19;

int n, m;
int q;
int a[N];

void read() {
	if (scanf("%d%d%d", &n, &m, &q) != 3)
		exit(0);
	for (int i = 0; i < q; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}
}


void solve() {
	vector < bool > use(m);
	vector < int > answer;
	for (int i = q - 1; i >= 0; i--) {
		if (!use[a[i]]) {
			answer.pb(a[i]);
			use[a[i]] = 1;
		}
	}
	int r = answer.size();
	for (int i = 0; i < m; i++)
		if (!use[i])
			answer.pb(i);

	//for (auto x: answer)
		//cerr << x << " ";
	//cerr << endl;

	int l = r;
	//db(r);
	//db(m);
	for (; ;) {
		if (l == 0) break;
		if (l < m) {
			if (!(answer[l - 1] < answer[l]))
				break;
		}
		l--;
	}
			//l > 0 && ((l == m && answer[l - 1] == m - 1) || answer[l - 1] < answer[l]); l--);
	//db2(l, r);
	vector < int > b(n, -1);
	vector < int > rev(m);
	for (int i = 0; i < m; i++)
		rev[answer[i]] = i;

	for (int i = q - 1; i >= 0; i--) {
		int x = a[i];
		int pos = rev[x] - 1;
		//db2("find: ", pos);
		int posB = upper_bound(b.begin(), b.end(), pos) - b.begin() - 1;
		if (posB != -1 && b[posB] == pos) {
			b[posB]++;	
		}
	}

	//cerr << "b: ";
	//for (int i = 0; i < n; i++)
		//cerr << b[i] << " ";
	//cerr << endl;

	bool flag = 1;
	for (int i = 0; i < n; i++)
		flag &= l - 1 <= b[i];

	
	if (flag)
		puts("Yes");
	else
		puts("No");


}

void stress() {

}

int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1000;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}



Measured memory_bytes: 1916
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

    ll n;cin>>n;
    ll num=0;
    vector<char> c(n);
    rep(i,n){
        cin>>c[i];
        if(c[i]=='R') num++; 
    }

    int cnt=0;
    rep(i,num){
        if(c[i]=='W'){
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    string X;
    cin >> N >> X;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(X[i] == '1') cnt++;
    }
    vector<long long> modm(N);
    vector<long long> modp(N);
    int cntm = cnt - 1, cntp = cnt + 1;
    int flag = 0;
    if(cntm == 0) {
        flag = 1;
        cntm++;
    }
    modm[0] = 1 % cntm;
    modp[0] = 1 % cntp;
    long long tm = 1, tp = 1;
    for(int i = 0; i < N - 1; i++){
        tm *= 2;
        tp *= 2;
        modm[1 + i] = tm % cntm;
        modp[1 + i] = tp % cntp;
        tm %= cntm;
        tp %= cntp;
    }
    long long tempm = 0, tempp = 0;
    for(int i = 0; i < N; i++){
        if(X[i] == '1') {
            tempm = (tempm + modm[N - 1 - i]) % cntm;
            tempp = (tempp + modp[N - 1 - i]) % cntp;
        }
    }
    for(int i = 0; i < N; i++){
        if(flag == 1 && X[i] == '1'){
            cout << 0 << endl;
            continue;
        }
        long long res = 0;
        if(X[i] == '0') {
            res += tempp;
            res += modp[N - 1 - i];
            res %= cntp;
        }
        else{
            res += tempm;
            res -= modm[N - 1 - i];
            res = (res + cntm) % cntm;
        }
        int ans = 1;
        while(res > 0){
            int cnti = 0;
            long long te = res;
            while(te > 0){
                if(te & 1) cnti++;
                te >>= 1;
            }
            res %= cnti;
            ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 6760
/*raghav0307 - Raghav Gupta*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
 
signed main(){
	fast_io();
	map<int, int> mp;
  	int s = 0;
  	mp[s]++;
  	int n;
  	cin >> n;
  	for(int i = 0; i < n; i++){
      int x;
      cin >> x;
   	  s += x;
      mp[s]++;
    }
  	int ans = 0;
  	for(auto x : mp){
      ans += (x.ss*(x.ss-1))/2;
    }
  	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>

int main(void)
{
    int A,B,C;
    scanf("%d",&A);
    if (A%100 < (A/100)*10+A/100){
        printf("%d",(A/100)*100+(A/100)*10+A/100);
    } else if (A%100 == (A/100)*10+A/100)
    {
        printf("%d",A);
    } else
    {
        printf("%d",(A/100+1)*100+(A/100+1)*10+A/100+1);
    }
    
    

}

Measured memory_bytes: 128
#include<stdio.h>

int solve(int,int);

int A[2000],m[200],n;
int main(){
  int flag=0,i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    flag=solve(0,m[i]);
    if(flag==1){
      printf("yes\n");
      continue;
    } else if(flag==0)printf("no\n");
    flag=0;
  }
  return 0;
}
  
  
int solve(int i,int m){
  if(m==0) return 1;
  else if (i > n) return 0;
  if(solve(i+1,m-A[i])==1)return 1;
  if(solve(i+1,m)==0)return 0;
}
    
    



Measured memory_bytes: 2108
import sys

N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

t_max = [0] * N
t_min = [1] * N
tmp = -1
for i in range(N):
    t = T[i]
    if t > tmp:
        t_max[i] = t
        t_min[i] = t
    elif t == tmp:
        t_max[i] = t
    else:
        print(0)
        sys.exit(0)
    tmp = t

a_max = [0] * N
a_min = [1] * N
tmp = -1
for i in range(N-1, -1, -1):
    a = A[i]
    if a > tmp:
        a_max[i] = a
        a_min[i] = a
    elif a == tmp:
        a_max[i] = a
    else:
        print(0)
        sys.exit(0)
    tmp = a

answer = 1
for i in range(N):
    tmp = min(t_max[i], a_max[i]) - max(t_min[i], a_min[i])
    if tmp < 0:
        answer = 0
        break
    answer *= tmp + 1
    answer %= MOD

print(answer)


Measured memory_bytes: 83940
n,k=map(int,input().split())
d=list(map(int,input().split()))

ds = []

for i in range(0,n):
    sum = 0
    for j in range(i,n):
        sum += d[j]
        ds.append(sum)
        #print(str(sum) + " ",end='')
    #print()

ds.sort(reverse=True)

sum = 0
for i in range(40,-1,-1):
    count = 0
    o = []
    for dss in ds:
        if dss & (1 << i) > 0 :
            count += 1
            o.append(dss)

    if count >= k :
        sum += 1 << i
        ds = o

print(sum)

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

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    long long Rnum = 0;
    long long Gnum = 0;
    long long Bnum = 0;
    for (int i = 0; i < N; i++)
    {
        if ((S[i] == 'R'))
            Rnum++;
        if ((S[i] == 'G'))
            Gnum++;
        if ((S[i] == 'B'))
            Bnum++;
    }
    long long minus = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            if(j >= N) continue;
            if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R'))
            {
                int d = j - i;
                if (i - d >= 0 && S[i - d] == 'B')
                    minus++;
                if (j + d < N && S[j + d] == 'B')
                    minus++;
                if (d % 2 == 0 && S[i + d / 2] == 'B')
                    minus++;
            }
        }
    }
    cout << Rnum * Gnum * Bnum - minus << endl;
}


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

int main(void) {
	char t[100],h[100];
	int n,p=0,q=0,r;
	scanf("%d",&n);
	for(;n;n--){
		scanf("%s %s",t,h);
		r=strcmp(t,h);
		if(!r){
			p++;
			q++;
		}else if(r>0){
			p+=3;
		}else{
			q+=3;
		}
	}
	printf("%d %d\n",p,q);
	return 0;
}

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

using namespace std;


int main()
{
    /*  
    
    h        
      +---------+ (w, h)
      |         |
      |    +    |
      |  *(x,y) |
    0 +---------+ w
    
    line pass on (x,y) and "+" given max of smaller area(area = w*h/2) 

    */
    double w=-1, h=-1, x=-1, y=-1;
    cin >> w >> h >> x >> y;
    assert(1 <= w && w <= 1000000000);
    assert(1 <= h && h <= 1000000000);
    assert(0 <= x && x <= w);
    assert(0 <= y && y <= h);

    cout << fixed << w * h / 2.0 << " " << (x + x == w && y + y == h) << endl; // answer is "failed" judge by online-judge, but "area" value is correct...

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#include<queue>
#define mod 998244353
#define pb push_back
#define ll long long
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>0 && b>0){
		cout<<"Positive"<<endl;
		return 0;
	}
	else if(a <= 0 && b>=0){
		cout<<"Zero"<<endl;
		return 0;
	}
	else if(a < 0 && b < 0){
		if( (b-a)%2 == 0){cout<<"Negative"<<endl; return 0;}
		else{ cout<<"Positive"<<endl; return 0;}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define mk make_pair
int a[56][56],x[100],y[100],n,m;
bool used[100];
void dfs(int v){
  used[v]=1;
  r(i,n){//cout<<m<<endl;
    if(a[v][i])if(!used[i]){
      used[i]=1;//cout<<v<<' '<<i<<endl;
      dfs(i);//cout<<i<<endl;
    }
  }
}
int main(){
  int ans=0;
  cin>>n>>m;
  r(i,m){
    cin>>x[i]>>y[i];x[i]--,y[i]--;
    a[x[i]][y[i]]=a[y[i]][x[i]]=1;
  }//return 0;
  r(i,m){
    memset(used,0,sizeof(used));
    a[x[i]][y[i]]=a[y[i]][x[i]]=0; //cout<<i<<endl;
    dfs(0);
    int f=0;//return 0;
    r(j,51)if(used[j])f++;//return 0;
    if(f!=n)ans++;//cout<<i<<endl;
    a[x[i]][y[i]]=a[y[i]][x[i]]=1;
  }//return 0;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    let input: Vec<String> = read_to_vec();

    println!("{}{}{}", "A", input[1].chars().nth(0).unwrap(), "C");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Yes(f) puts((f)? "Yes" : "No")
int main(){
	string s, t; cin >> s >> t;
    bool f = true;
	rep(i, s.length()) if(s[i] != t[i]) f = false;
    Yes(f);
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
 
using namespace std;
 
int main()
{
    int A,B;
    cin >> A >> B;

    int result = A-(B*2);
    if (result<0) {result = 0;}

    cout << result;
 
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

	a, b := nextInt(), nextInt()
	sum := 0
	for i := 1; i < b-a; i++ {
		sum += i
	}

	fmt.Println(sum - a)
}


Measured memory_bytes: 640
typedef long unsigned int size_t;
extern int printf (const char *__restrict __format, ...);
extern int scanf (const char *__restrict __format, ...) ;
extern int getchar (void);
extern int putchar (int __c);
int nextInt(){int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
short int nextShort(){short f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
long long int nextLong(){long long int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
void println(){putchar(10);}
void print(char *f){while(*f){putchar(*f);f++;}}
void printInt(int f){char c[10];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
void printLong(long long int f){char c[19];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
typedef int (*__compar_fn_t) (const void *, const void *);
extern void *bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar)__attribute__ ((__nonnull__ (1, 2, 5))) ;
extern void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
int compare_long(const void *a, const void *b){if(*(long long int*)a - *(long long int*)b < 0){return -1;}else if(*(long long int*)a - *(long long int*)b > 0){return 1;}else{return 0;}}
int n, i, j;
int b[101][2];
int a[101];
int d, d1;
int main(){
 n = nextInt();
 for(i=1; i<=n; i++){
  b[i][0] = nextInt();
  b[i][1] = i;
 }
 qsort(b+1, n, sizeof(long long int), compare_long);
 for(i=n; i>=1; i--){
  if(b[i][0]>i){print("-1\n"); return 0;}
 }
 for(i=n; i>=1; i--){
  d=1;
  while(1){
   d1=b[i][0];
   for(j=d+1; j<=n; j++){
    if(a[j]<=d1){d1++;}
   }
   if(d1==b[i][1]){break;}
   d++;
  }
  a[d] = b[i][0];
 }
 for(i=1; i<=n; i++){
  printInt(a[i]); println();
 }
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vll b(N);
    for(int i = 0; i < N; i++) {
        cin >> b[i];
    }
    vll ans;
    for(int i = 0; i < N; i++) {
        ll tmp = -1;
        for(int j = 0; j < N - i; j++) {
            if(b[j] == j + 1) {
                tmp = j + 1;
            }
        }
        if(tmp < 0) {
            cout << -1 << endl;
            return 0;
        }
        b.erase(b.begin() + tmp - 1);
        ans.push_back(tmp);
    }
    for(int i = N - 1; i >= 0; i--) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pii> vii;

#define rep(x,n) for (int i = x; i < (n); ++i)
#define size(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define fr first
#define sc second
#define Fast_IO ios::sync_with_stdio(false) ,cin.tie(0) ,cout.tie(0)

int binarySearch(long long a[], int beg, int end, int item)
{
    int mid;
    if(end >= beg)
    {
        mid = (beg + end)/2;

        if(a[mid] == item)
            return mid+1;
        else if(a[mid] < item)
        {
            if (a[mid+1] == item)
                return mid+2;
            else if (a[mid+1] > item)
                return mid+1;
            else
                return (binarySearch(a,mid+1,end,item));
        }
        else
        {
            if (a[mid-1] < item)
                return mid;
            else if(a[mid-1] == item)
                return mid;
            else
                return binarySearch(a,beg,mid-1,item);
        }
    }
    return beg;
}

int main()
{
    Fast_IO;
    int n ,m ,k;
    cin >> n >> m >> k;
    ll arr1[n] ,arr2[m] ,pfx2[m+1]={0};

    rep(0 ,n) cin >> arr1[i];
    rep(0 ,m) cin >> arr2[i];
    pfx2[0] = arr2[0];
    rep(1 ,m) pfx2[i] = pfx2[i-1]+arr2[i];
    pfx2[m] = LONG_LONG_MAX;
    int i = 0 ,res = (k < pfx2[0]) ? 0 :binarySearch(pfx2 ,0 ,m ,k);
    while(i<n && k-arr1[i] >= 0)
    {
        int temp = i+1;
        k -= arr1[i++];
        temp += binarySearch(pfx2 ,0 ,m ,k);
        res = max (res , temp);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 8300
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
/*while(a)
    {
        if(a%2==0)
            dvi.push_back(0);
        else
            dvi.push_back(1);
        a/=2;
    }
    reverse(dvi.begin(),dvi.end());*/
#include<bits/stdc++.h>
using namespace std;
#define MAX 35000
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool fk[1000001];

int main()
{
    makefast__
    string str;
    ll a,c,d,e,f,x,y,t,A=0,B=0,L,j,i,l,r,m,n,C=0,ans=0,sum=0,sum1=0;
    vector<ll>v,v1;
    queue<ll>qu;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>aarray[i];
        A+=aarray[i];
    }
    A-=n;
    cout<<A<<endl;

}



Measured memory_bytes: 256