akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        char prev = ' ';
        HashSet<String> set = new HashSet<>();
        boolean answer = true;
        for (int i = 0; i < N; i++) {
            String s = scan.next();
            char[] d = s.toCharArray();
            if (prev != ' ') {
                if (d[0] != prev) {
                    answer = false;
                    break;
                }
            }
            if (set.contains(s)) {
                answer = false;
                break;
            }
            set.add(s);
            prev = d[d.length-1];
        }
        System.out.println(answer ? "Yes" : "No");
    }
}


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

int main() {
	int N, Q;
	string S;
	int l, r;
	cin >> N >> Q;
	cin >> S;
	int sum_AC = 0;
	int left_AC[100001] = { 0 };
	int right_AC[100001] = { 0 };
	for (int i = 0; i < N; i++) {
		left_AC[i + 1] = left_AC[i];
		right_AC[N - 2 - i] = right_AC[N - 1 - i];
		if (S[i] == 'A'&&S[i + 1] == 'C') {
			sum_AC++;
			left_AC[i + 1]++;
		}
		if (S[N - 2 - i] == 'A'&&S[N - 1 - i] == 'C') {
			right_AC[N - 2 - i]++;
		}
	}
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << sum_AC - left_AC[l - 1] - right_AC[r - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N=1000;
int n,a[2010],cnt[2010][2010];
long long ans=0;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=n;i;i--) {
	  for (int j=1;j<=2*N;j++)
	    cnt[i][j]=cnt[i+1][j];
	  for (int j=a[i];j<=2*N;j++)
	    cnt[i][j]++;
	}
	for (int i=1;i<=n;i++) {
		//if (a[i]==a[i-1]) continue;
	  for (int j=i+1;j<=n;j++) {
	  //	if (a[j]==a[j-1]) continue;
	  	ans+=cnt[j+1][a[i]+a[j]-1]-cnt[j+1][abs(a[i]-a[j])];
	  }
	}
	cout<<ans;
	return 0;
}

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

int main(){
    string s; cin >> s;
    string answer="";
    for (char c: s){
        if (c=='B' && answer!=""){
            answer.erase(answer.size()-1);
        } else if (c=='0' || c=='1'){
            answer+=c;
        }
    }
    cout << answer;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
ll dp[100005];
int main()
{ quick;

    ll n,k;
    cin>>n>>k;
    ll a[n];
    fab(0,n,i)
    cin>>a[i];
    ll small=*min_element(a,a+n);
    
    fab(0,n,i) 
    {
        
        fab(a[i],small+a[i] and j<k+1,j)
        {
            dp[j]=1;
        }


    }
    fab(0,k+1,i)
    {
         
        fab(0,n,j)
        {
            if(i-a[j]>=0 and dp[i-a[j]]==0)
            {
                dp[i]=1;

            }
        }


    }
   
    if(dp[k])
        cout<<"First\n";
    else
        cout<<"Second\n";


 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 4420
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
typedef long long LL;
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rel(i,n) for(int (i)=1;(i)<=(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
const int INF = 0x3f3f3f3f;const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN=1e5+5;const long long MOD=10007;
typedef vector<int> vci; typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
int main()
{
    LL n,m,ans;//n s,m c,scc
    cin>>n>>m;
    
        if(n*2>m) ans=m/2;
        else ans=n+(m-2*n)/4;
        cout<<ans<<endl;
    
    return 0;
}


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

// why am I so weak

long long x;

int main() {
	cin >> x;

	if (x <= 6) {
		puts("1");
	} else if (x <= 11) {
		puts("2");
	} else {
		long long left = x - 11;
		long long cnt = 2;

		cnt += left / 11 * 2;

		left %= 11;

		if (left != 0 && left <= 6) cnt++;
		else if (left != 0) cnt += 2;

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

	return 0;
}


Measured memory_bytes: 256
//
// Created on 2020/09/17.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    int a,b;
    cin>>a>>b;
    int ans = a*b-a-b+1;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int n, a[101], sum=0;
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>a[i];
		sum += a[i];
	}
	for (int i=0; i<n; i++) {
		if (sum - a[i] <= a[i]) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  vector<int> v(5);
  for (int i = 0; i < 5; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int ans = INF;
  do {
    int res = 0;
    for (int i = 0; i < 4; i++) res += (v[i] + 9) / 10 * 10;
    res += v[4];
    ans = min(ans, res);
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * Author: Behradm
 * Created: 04-04-2020 13:53:21
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout.precision(6);
	cout << fixed;
	int n;
	cin >> n;
	ll res = 1000LL*(n/500LL);
	n -= 500*(n/500);
	res += 5LL*(n/5LL);
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 256
D,G = map(int, input().split())
li=[]
for i in range(D):
    li.append(list(map(lambda x: int(x), input().split())))
def bit():
    ans=10000040000
    for i in range(2 **D):
        #問題数n　得点p
        n=0
        p=0
        for j in range(D):
            if ((i >> j) & 1):
                n += li[j][0]
                p += li[j][1] 
                p += li[j][0] *100*(j+1)
        
        if p >= G:
            if n <= ans:
                ans=n
        
        for j in reversed(list(range(D))):
            if ((i >> j) & 1):
                continue
            else:
                for k in range(li[j][0]):
                    if p < G:
                        n += 1
                        p += 100*(j+1)
                    else:
                        if n <= ans:
                            ans=n
                            break
    print(ans)

bit()

Measured memory_bytes: 43504
#
# abc046 a
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 1 4"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 3 33"""
        output = """2"""
        self.assertIO(input, output)


def resolve():
    a, b, c = map(int, input().split())

    ans = 0
    if a == b == c:
        print("1")
    elif a == b or b == c or c == a:
        print("2")
    else:
        print("3")


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    double l = 0, r = 1000000005;
    rep(i,100){
        double mid = (l+r)/2;
        ll cnt = 0;
        rep(i,N) {
            cnt += (ll)ceil(v[i]/mid)-1;
        }
        if(cnt>K) l = mid;
        else r = mid;
    }
    cout<<(ll)ceil(r)<<endl;
}

Measured memory_bytes: 4780
using System;
using System.Linq;

namespace Problem_B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var count = 0;
            var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for (var i = input[0]; i <= input[1]; i++)
            {
                var numStr = i.ToString();
                if (numStr.Equals(string.Concat(numStr.Reverse()))) count++;
            }
            Console.WriteLine($"{count}");
        }
    }
}

Measured memory_bytes: 17464
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

typedef vector<vector<int> > Matrix;

void warshall_floyd(int n, Matrix& dist) {
  rep(i, n) rep(j, n) rep(k, n)
    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
}

int main() {
  int N, M;
  ll L;
  cin >> N >> M >> L;
  Matrix dist = Matrix(N, vector<int>(N, inf));
  rep(i, N) dist[i][i] = 0;
  rep(i, M) {
    int A, B;
    ll C;
    cin >> A >> B >> C;
    A--, B--;
    dist[A][B] = C;
    dist[B][A] = C;
  }
  warshall_floyd(N, dist);
  Matrix dist2 = Matrix(N, vector<int>(N, inf));
  rep(i, N) dist[i][i] = 0;
  rep(i, N) rep(j, N)
    if(i != j && dist[i][j] <= L)
      dist2[i][j] = 1;
  warshall_floyd(N, dist2);
  int Q;
  cin >> Q;
  rep(i, Q) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    cout << (dist2[s][t] == inf ? -1 : dist2[s][t]-1) << endl;
  }
  return 0;
}



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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    int koma[2020] = {};
    int mz[2020] ={};
    cin>>n;
    //vi x(n);
    REP(i,n){
        int x;
        cin>>x;
        koma[i+1] = x;
        mz[x] = i+1;
    }
    cin>>m;

    REP(i,m){
        int a;
        cin>>a;

        int pos = koma[a];
        if(mz[pos+1] == 0 && pos!=2019){
            koma[a]++;
            mz[pos+1] = a;
            mz[pos] = 0;
        }
    }

    FOR(i,1,n+1){
        cout<<koma[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3204
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

rx = 0
ry = 0
rt = 0
for t, x, y in txy:
  d = abs(x - rx) + abs(y - ry)
  dt = t - rt
  if dt < d or dt % 2 != d % 2:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 27380
/*input
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
*/

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

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

  vector<int> b(n), c(n);
  rep(i, n) {
    b[i] = -a[i]-i;
    c[i] = a[i]-i;
  }
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n) {
    ll now = upper_bound(c.begin(), c.end(), b[i])
      -lower_bound(c.begin(), c.end(), b[i]);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5616
S = input()
T = input()

t_len = len(T)
found = False
for i in range(len(S)-len(T), -1,-1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
    else:
        if i + t_len == len(S):
            S = S[:i] + T
        else:
            S = S[:i] + T + S[i+t_len:]
        found = True
    if found:
        print(S.replace('?','a'))
        break
else:
    print('UNRESTORABLE')



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll h;
  	cin>>h;
  	ll t = 0;
  	ll k = 1;
  	while( h>0){
    	t += k;
      	h /= 2;
      	k *= 2;
    
    }
  	cout<<t<<endl;
  
  return 0;
 
}

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

void solve() 
{
    int n;cin>>n;
    char s;REP(i,n){
        cin>>s;
        if(s=='Y'){
            cout<<"Four"<<endl;return;
        }
    }cout<<"Three"<<endl;
}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

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

        a = a.OrderBy(num => num).ToArray();
        long count = a.Count();

        long mid = count % 2 == 0 ? (a[count / 2 - 1] + a[count / 2]) / 2 : a[count / 2];

        long answer = a.Select(num => Math.Abs(num - mid)).Sum();

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 51540
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    double L;
    cin >> L;
    cout << setprecision(10) << L*L*L/27 << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    vector <int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    k--;
    cout<<a[k];




}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll X, x[Nmax];

ll find_gcd(ll x, ll y){
	while(y > 0){
		ll tmp = x % y;
		x = y;
		y = tmp;
	}
	return x;
}

int main(){
	cin >> N >> X;
	for(int i=0; i<N; i++) cin >> x[i];

	vector<ll> dist(N);
	for(int i=0; i<N; i++) dist[i] = abs(x[i]-X);

	if(N==1){
		cout << dist[0] << endl;
		return 0;
	}

	ll gcd = find_gcd(dist[0], dist[1]);
	for(int i=2; i<N; i++) gcd = find_gcd(gcd, dist[i]);

	cout << gcd << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] pArray = new int[N];
    int[] x = new int[M];
    int[] y = new int[M];
    for (int i = 0; i < N; i++){
      pArray[i] = scanner.nextInt() - 1;
    }
    UnionFind uf = new UnionFind(N);
    for (int i = 0; i < M; i++){
      x[i] = scanner.nextInt() - 1;
      y[i] = scanner.nextInt() - 1;
      uf.unite(x[i], y[i]);
    }
    int count = 0;
    for (int i = 0; i < N; i++){
      if(uf.same(i, pArray[i])) count++;
    }
    System.out.println(count);
  }
}

class UnionFind{
  int[] parent;

  public UnionFind(int N){
    this.parent = new int[N];
    for (int i = 0; i < N; i++){
      parent[i] = i;
    }
  }

  public int root(int x){
    if (parent[x] == x) return x;
    else{
      return parent[x] = root(parent[x]);
    }
  }
  public void unite(int x, int y){
    if (same(x, y)) return;
    int xroot = root(x);
    int yroot = root(y);
    parent[xroot] = yroot;
    return;
  }
  public boolean same(int x, int y){
    return (root(x) == root(y));
  }
}

Measured memory_bytes: 91508
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let h:usize = read();
    let w:usize = read();
    let mut a:Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        a.push(read::<String>().chars().collect::<Vec<char>>());
    }

    let mut map_h = HashMap::new();
    let mut map_w = HashMap::new();

    for i in 0..h {
        let mut f:bool = true;
        let ch = '.';
        for j in 0..w {
            if ch != a[i][j] {f=false}
        }
        //debug!(i,f);
        if !f {map_h.insert(i,true);}
    }
    for j in 0..w {
        let mut f:bool = true;
        let ch = '.';
        for i in 0..h {
            if ch != a[i][j] {f=false}
        }
        //debug!(j,f);
        if !f {map_w.insert(j,true);}
    }

    for i in 0..h {
        let mut f:bool = false;
        for j in 0..w {
            //debug!(map_h.get(&i));
            if !match map_h.get(&i) {
                Some(v) => *v,
                None => false,
            }
            {continue;}
            if !match map_w.get(&j) {
                Some(v) => *v,
                None => false,
            }
            {continue;}
            f = true;
            print!("{}", a[i][j]);
        }
        if f {println!("");}
    }
}


Measured memory_bytes: 4352
a,b,c,k = gets.split(" ").map(&:to_i)
#a_cnt,b_cnt,c_cnt = 0
sum = 0

if a <= k
  sum += a * 1
  k = k-a
  
  if b <= k
    sum += b * 0
    k = k-b
    
    if c <= k
      sum += c * (-1)
      k = k-c
    else
      sum += k * (-1)
    end
    
  else
    sum += k * 0
  end
  
else
  sum += k * 1
end

puts sum

Measured memory_bytes: 14360
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        boolean boo = false;
        String s = sc.next();
        String t = sc.next();
        String str[] = t.split("");
        List<String> list = Arrays.asList(str);
        List<String> list2 = new ArrayList<>(list);
        for(int i=0; i<s.length(); i++){
            String ans = "";
            for(int j=0; j<list2.size(); j++){
                ans += list2.get(j);
            }
            if(ans.equals(s)){
                boo = true;
                break;
            }
            list2.add(list2.get(0));
            list2.remove(0);
        }
        if(boo) System.out.println("Yes");
        else System.out.println("No");
    }
}

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



// last submission

typedef long long  int ll;
#define s(n) scanf("%lld",&n)
#define s2(n,m) scanf("%lld%lld",&n,&m)
int ans[1003][1003],con[1003];
int main()
{

    int n;
    cin>>n;
    int z,x,y;
    for(int i=1; i<=n; i++)
    {
        z = (i*(i+1))/2;
        if(z==n)
        {
            x = i;
            y= x+1;
            break;
        }

        if(z>n)
        {
            puts("No");
            return 0;
        }

    }


    for(int i=1; i<=x; i++)
        ans[1][i] = i,ans[i+1][1] = i;

    for(int i=1; i<=y; i++) con[i] = 2;
    int i,j,v = x+1;
    i = 2;
    j = 3;
    while(v<=n)
    {
        ans[i][con[i]++] = ans[j][con[j]++] = v++;
        j++;
        if(con[i]>x) i++,j=i+1;

    }

    printf("Yes\n%d\n",y);

    for(int i=1; i<=y; i++)
    {
        printf("%d",x);

        for(int j = 1; j<=x; j++)
            printf(" %d",ans[i][j]);

        printf("\n");
    }






}


Measured memory_bytes: 3200
def main():
  while True:
    h, w = map(int, input().split(' '))
    if h == 0 and w == 0:
      exit()
    
    for i in range(h):
      if i%2==0:
        for j in range(w):
          if j%2==0:
            print('#', end='')
          else:
            print('.', end='')
      else:
        for j in range(w):
          if j%2==0:
            print('.', end='')
          else:
            print('#', end='')
      print('')
    
    print('')
    
  
if __name__ == "__main__":
  main()



Measured memory_bytes: 7020
while True :
    H, W = map(int, input().split())
    if(H == 0 & W == 0) :
        break
    else :
        for i in range(H) :
            for j in range(W) :
                if((i + j) % 2 == 0) :
                    print("#", end = "")
                else :
                    print(".", end = "")
            print()
        print()


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
struct edge {
    int u, v;
    edge reverse() const { return {v, u}; }
    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.u << ", " << e.v << ")";
    }
};
template <bool Directed, typename TEdge, bool Index> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + Index) {}
    graph(int n, int m) : graph(n) { edges.reserve(m << not Directed); }
    TEdge& operator()(int e) { return edges[e]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - Index; }
    void add_edge(const TEdge& e) {
        adj[e.u].push_back(edges.size());
        edges.push_back(e);
        if(not Directed) {
            adj[e.v].push_back(edges.size());
            edges.push_back(e.reverse());
        }
    }
};
template <typename T = ll, bool Index> pair<vector<T>, vector<int>> longest_path(graph<1, edge, Index>& g,
const vector<int>& roots = vector<int>(),
const vector<T>& node_weight = vector<T>()) {
    vector<T> opt(g.adj.size(), -1);
    vector<int> arg(g.adj.size(), -1);
    auto weight = [&](int u) { return node_weight.empty() ? 0 : node_weight[u]; };
    function<T(int)> longest_path = [&](int u) {
        if(opt[u] == -1) {
            opt[u] = weight(u);
            for(int e : g[u]) {
                if(opt[u] < weight(u) + 1 + longest_path(g(e).v)) {
                    opt[u] = weight(u) + 1 + longest_path(g(e).v);
                    arg[u] = e;
                }
            }
        }
        return opt[u];
    };
    if(roots.empty()) {
        for(int u = Index; u < g.adj.size(); u++) {
            longest_path(u);
        }
    } else {
        for(int root : roots) {
            longest_path(root);
        }
    }
    return {opt, arg};
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    graph<1, edge, 1> g(n, m);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g.add_edge({u, v});
    }
    auto opt = longest_path(g).first;
    cout << *max_element(opt.begin(), opt.end()) << endl;
    return 0;
}


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

using int64 = long long;

const int64 mod = 1e9 + 7;

int64 pow_mod(int64 a, int64 x) {
    if (x == 0) return 1;
    else if (x % 2 == 0) {
        int64 b = pow_mod(a, x / 2);
        return (b * b) % mod;
    } else {
        return (a * pow_mod(a, x - 1)) % mod;
    }
}

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;

    static int64 dp[5010][5010];
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            if (j - 1 >= 0) (dp[i + 1][j - 1] += dp[i][j]) %= mod;
            else (dp[i + 1][j] += dp[i][j]) %= mod;
            (dp[i + 1][j + 1] += 2 * dp[i][j]) %= mod;
        }
    }

    int64 inv = pow_mod(2, mod - 2);
    cout << (dp[N][s.size()] * pow_mod(inv, s.size())) % mod << endl;

    return 0;
}

Measured memory_bytes: 194176
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("6");
            WillReturn.Add("ooxoox");
            //SSSWWS
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("oox");
            //-1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("10");
            WillReturn.Add("oxooxoxoox");
            //SSWWSSSWWS
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static string s;
    static int N;

    static void Main()
    {
        List<string> InputList = GetInputList();
        N = int.Parse(InputList[0]);
        s = InputList[1];

        string Wariate1 = DeriveWariate("SS");
        string Wariate2 = DeriveWariate("SW");
        string Wariate3 = DeriveWariate("WS");
        string Wariate4 = DeriveWariate("WW");

        if (Wariate1 != "-1") { Console.WriteLine(Wariate1); return; }
        if (Wariate2 != "-1") { Console.WriteLine(Wariate2); return; }
        if (Wariate3 != "-1") { Console.WriteLine(Wariate3); return; }
        if (Wariate4 != "-1") { Console.WriteLine(Wariate4); return; }
        Console.WriteLine(-1);
    }

    //最初の2匹を引数として、各動物の割り当てを返す
    static string DeriveWariate(string pSaisyo2)
    {
        int UB = N - 1;
        char[] WariateArr = new char[UB + 1];
        WariateArr[0] = pSaisyo2[0];
        WariateArr[1] = pSaisyo2[1];

        for (int I = 1; I <= UB - 1; I++) {
            char Prev = WariateArr[I - 1];
            char Curr = WariateArr[I];
            char Hatugen = s[I];

            char NextAnimal = DeriveNextAnimal(Prev, Curr, Hatugen);
            WariateArr[I + 1] = NextAnimal;
        }

        //最初の2匹が矛盾していないかチェック
        if (WariateArr[0] !=
            DeriveNextAnimal(WariateArr[UB - 1], WariateArr[UB], s[UB])) {
            return "-1";
        }
        if (WariateArr[1] !=
            DeriveNextAnimal(WariateArr[UB], WariateArr[0], s[0])) {
            return "-1";
        }

        return new string(WariateArr);
    }

    //前とカレントの動物と、カレントの動物の発言を引数として、カレントの次の動物を返す
    static char DeriveNextAnimal(char pPrev, char pCurr, char pHatugen)
    {
        if (pPrev == 'S' && pCurr == 'S') {
            if (pHatugen == 'o') return 'S';
            if (pHatugen == 'x') return 'W';
        }
        if (pPrev == 'S' && pCurr == 'W') {
            if (pHatugen == 'o') return 'W';
            if (pHatugen == 'x') return 'S';
        }
        if (pPrev == 'W' && pCurr == 'S') {
            if (pHatugen == 'o') return 'W';
            if (pHatugen == 'x') return 'S';
        }
        if (pPrev == 'W' && pCurr == 'W') {
            if (pHatugen == 'o') return 'S';
            if (pHatugen == 'x') return 'W';
        }
        return '\0';
    }
}


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

#define LL 100005

int head, tail, n;

typedef struct aa{
    char name[100];
    int ss;
}A;

A B[LL];

int min(int sss,int ttt){
    return sss<ttt?sss:ttt;
}

void enqueue(A s){
    B[tail] = s;
    tail = (tail+1)%LL;
}

A dequeue(){
    A s = B[head];
    head = (head+1)%LL;
    return s;
}

int main(){
    int elaps = 0;
    A m;
    int i, j, b;
    
    scanf("%d %d", &n, &j);
    for(i=1 ; i <= n ; i++){
        scanf("%s", B[i].name);
        scanf("%d",&B[i].ss);
    }
    
    tail = n+1;
    head = 1;
    
    while(head!=tail){
        m = dequeue();
        b = min(j,m.ss);
        m.ss -= b;
        elaps += b;
        
        if(m.ss>0){
            enqueue(m);
        }else{
            printf("%s %d\n", m.name, elaps);
        }   
    }
    
    return 0;
    
}


Measured memory_bytes: 11852
#include <bits/stdc++.h>
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int n ;
    cin >> n ;
    int a[n] ;
    rep(i, 0, n) cin >> a[i] ;
    int x = 0 ;
    rep(i, 0, n) {
        x ^= a[i] ;
    }
    rep(i, 0, n) {
        a[i] = x^a[i] ;
    }
    rep(i, 0, n) cout << a[i] << " " ;
    cout << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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


Measured memory_bytes: 5220
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    map<ll, ll> d;

    REP(i, n) {
        ll tmp;
        cin >> tmp;
        if (d.find(tmp) == d.end()) {
            d[tmp] = 1;
        } else {
            d[tmp]++;
        }
    }

    ll m; cin >> m;
    REP(i, m) {
        ll tmp;
        cin >> tmp;
        if (d.find(tmp) == d.end()) {
            cout << "NO" << endl;
            return 0;
        } else if (d[tmp] == 0) {
            cout << "NO" << endl;
            return 0;
        } else {
            d[tmp]--;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 16104
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
class dice
{
private:
  int men[10];
  string direction;
public:
  void set_num();
  void throw_dice(const char c);
  void show_dice();
};
void dice::throw_dice(const char c)
{
  int buf;
  switch(c)
  {
    case 'N':
    {
      buf = men[0];
      men[0] = men[1];
      men[1] = men[5];
      men[5] = men[4];
      men[4] = buf;
      break;
    }
    case 'S':
    {
      buf = men[0];
      men[0] = men[4];
      men[4] = men[5];
      men[5] = men[1];
      men[1] = buf;
      break;
    }
    case 'W':
    {
      buf = men[0];
      men[0] = men[2];
      men[2] = men[5];
      men[5] = men[3];
      men[3] = buf;
      break;
    }
    case 'E':
    {
      buf = men[0];
      men[0] = men[3];
      men[3] = men[5];
      men[5] = men[2];
      men[2] = buf;
      break;
    }
  }
}
void dice::set_num()
{
  for(int i = 0; i< 6; i++)
  {
    cin >> men[i];
  }
  cin >> direction;
  for(int i = 0 ; i< direction.size();i++)
  {
    throw_dice(direction[i]);
  }
}
void dice::show_dice()
{
  cout << men[0] << endl;
}
int main()
{
  dice dice1;
  dice1.set_num();
  dice1.show_dice();
  return 0;
}


Measured memory_bytes: 3184
#include <iostream>

bool judgeUruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

int flag = 0;

void printUruyear(int year_begin, int year_end)
{

    // saisyo ni kuu-gyou ga aruto okorareru
    if (flag == 1){
        std::cout << std::endl;
    }
    flag = 1;

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou
    for (int i = year_begin; i <= year_end; i++) {
        
        if (judgeUruyear(i)) {

            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }
    
}

int main()
{
    int year_begin, year_end;

    while (true) {

        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }

        printUruyear(year_begin, year_end);
    }
    
    return 0;
}

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1877346#1

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

int main() {
  string S;
  cin >> S;
  if (S == "AAA" || S == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
P=list(input().split())
Q=list(input().split())
P=int(''.join(P))
Q=int(''.join(Q))
n=[i for i in range(1,N+1)]
A=[]
def dps(n,A,me):
    if len(n)==0:
        A.append(me)
        return
    else:
        for i in range(0, len(n)):
            t=n.pop(i)
            dps(n, A, me*10+t)
            n.insert(i, t)
dps(n,A,0)
print(abs(A.index(P)-A.index(Q)))

Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int T, A, B;
  cin >> T >> A >> B;
  int plan1 = T * A, plan2 = B;
  if (plan1 < plan2) {
    cout << plan1 << endl;
  }
  else {
    cout << plan2 << endl;
  }
}


Measured memory_bytes: 384
s=require("fs").readFileSync("/dev/stdin","utf8").split('\n')
n=s[0].split(' ')[0]|0,k=s[0].split(' ')[1]|0
s.shift()
s=s.map(n=>n|0).sort((a,b)=>b-a)
console.log(Math.min(...[...Array(n-k+1)].map((_,i)=>s[i]-s[i+k-1])))

Measured memory_bytes: 30320
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

map<ll, ll> prime_factorization(ll n) {
    map<ll, ll> m;
    ll x = n;
    ll d = 2;
    while (x > 1 && d * d <= n) {
        if (x % d == 0) {
            m[d]++;
            x /= d;
        } else {
            d++;
        }
    }
    if (x != 1) m[x]++;
    return m;
}

void solve() {
    int n;
    cin >> n;
    int i = 1;
    while (i <= n) i *= 2;
    cout << i / 2 << endl;
}


Measured memory_bytes: 3664
while True:
    squares = [list(input()) for _ in range(8)]
    for i in range(8)[::-1]:
        if not squares[i].count('1'):
            del squares[i]
    for i in range(8)[::-1]:
        if not [line[i] for line in squares].count('1'):
            for j in range(len(squares)):
                del squares[j][i]
    if len(squares) == len(squares[0]):
        print('A')
    elif len(squares) == 4:
        print('B')
    elif len(squares) == 1:
        print('C')
    elif squares[0] == ['0', '1']:
        print('D')
    elif squares[0] == ['1', '1', '0']:
        print('E')
    elif squares[0] == ['1', '0']:
        print('F')
    elif squares[0] == ['0', '1', '1']:
        print('G')
    try:
        input()
    except:
        break

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

//三角形の２辺 a, b とその間の角 C から、その三角形の面積 S、
//周の長さ L, a を底辺としたときの高さ h を求めるプログラム
int main(){
    int a, b, c;
    double S, L, h, pi, radc;
    cin >> a >> b >> c;

    pi = acos(-1);
    radc = c * pi/180;

    S = 1.0/2 * a * b * sin(radc);
    L = a + b + sqrt(a*a + b*b - 2.0*a*b*cos(radc));
    h = 2.0 * S / a; 
    
    cout << fixed << S << endl;
    cout << fixed << L << endl;
    cout << fixed << h << endl;

    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+5],frr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    for(int i=0;i<n;i++)cin>>frr[i];

    int counter=0;

    for(int i=0;i<=pow(2,n);i++)
    {
        vector<int>v;
        vector<int>f;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                v.push_back(arr[j]);
                f.push_back(frr[j]);
            }
        }
        int sum=0;
        for(int i=0;i<v.size();i++)
        {
            sum+=(v[i]-f[i]);
        }
        counter=max(counter,sum);
      // cout<<endl;

    } cout<<counter<<endl;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(S == U){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B << el;
}



Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int n, p;
    cin >> n >> p;
    bool has_odd = false;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x & 1) has_odd = true;
    }
    if (!has_odd) {
        if (p == 0) cout << (1LL << n);
        else cout << 0;
    }
    else {
        cout << (1LL << (n - 1));
    }
    return 0;
}

Measured memory_bytes: 256
o = input()
e = input()
list = []
for i in range(len(o)-1):
  list.append(o[i] + e[i])
  
if len(e) == len(o):
  list.append(o[len(o)-1] + e[len(e)-1])
else:
  list.append(o[len(o)-1])
  
 
print(*list, sep='')

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long W = sc.nextLong();
		long w[] = new long[N+1];
		long v[] = new long[N+1];
		
		for(int i=1; i<=N; i++){
			w[i]=sc.nextLong();
			v[i]=sc.nextLong();
		}
		
		int a=0;
		int b=0;
		int c=0; 
		int d=0;
		
		long va[] = new long[N+1];
		long vb[] = new long[N+1];
		long vc[] = new long[N+1];
		long vd[] = new long[N+1];
		
		va[0]=0;
		vb[0]=0;
		vc[0]=0;
		vd[0]=0;
		
		for(int i=1; i<=N; i++){
			if(w[i]==w[1]){
				a++;
				va[a]=v[i];
			}
			if(w[i]==w[1]+1){
				b++;
				vb[b]=v[i];
			}
			if(w[i]==w[1]+2){
				c++;
				vc[c]=v[i];
			}
			if(w[i]==w[1]+3){
				d++;
				vd[d]=v[i];
			}
		}
		
		Arrays.sort(va);
		Arrays.sort(vb);
		Arrays.sort(vc);
		Arrays.sort(vd);
		
				
		long sum=0;
		long sumtmp=0;
		for(int i=0; i<=a; i++){
			for(int j=0; j<=b; j++){
				for(int k=0; k<=c; k++){
					for(int m=0; m<=d; m++){
						sum=0;
						for(int n=N; n>N-i; n--){
							sum = sum + va[n];
						}
						for(int n=N; n>N-j; n--){
							sum = sum + vb[n];
						}
						for(int n=N; n>N-k; n--){
							sum = sum + vc[n];
						}
						for(int n=N; n>N-m; n--){
							sum = sum + vd[n];
						}
						double y = 1;
						double x = (double)(w[1]/y)*i+(double)((w[1]+1)/y)*j+(double)((w[1]+2)/y)*k+(double)((w[1]+3)/y)*m;
						
						if(x<=(double)(W)/y){
							if(sum>sumtmp){
								sumtmp=sum;
							}
						}
					}
				}
			}
		}
		System.out.println(sumtmp);
	}
}

Measured memory_bytes: 22932