akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}
  
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol x;
  cin >> x;
  for(int i = -1e3;i <= 1e3;i ++){
    for(int j = -1e3;j <= 1e3;j ++){
      lol na = 1, su = 1;
      rep(nasu, 5){
	na *= i;
	su *= j;
      }
      if(na - su == x){
	cout << i << " " << j << '\n';
	//cout << na << " " << su << '\n';
	return 0;
      }
    }
  }
  return 0;
}


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

int main(){
  int n,ans=0;cin>>n;
  map<int,int> mp;
  REP(i,n){
    int a;cin>>a;
    mp[a]++;
  }
  for(auto itr=mp.begin();itr!=mp.end();++itr){
    if(itr->first<itr->second) ans+=itr->second-itr->first;
    else if(itr->first>itr->second) ans+=itr->second;
  }
  cout<<ans;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

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




void solve(){
	int x; cin>>x;
	x=1-x;
	cout<<x;	
}


int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
  	int t=1;// cin>>t;
  	while(t--) solve();
 	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin >> a >> b;
  if(a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a * b << endl;
  else cout << -1 << endl;
  }



Measured memory_bytes: 256
import numpy as np
n = int(input())
limit_list = []
time_list = []
for i in range(n):
    a,b = map(int,input().split())
    time_list.append(a)
    limit_list.append(b)
now_time = 0
flag = True
for i in np.argsort(limit_list):
    tmp =  limit_list[i] -time_list[i] -now_time
    if tmp >=0:
        now_time += time_list[i]
    else:
        flag = False
        break
if flag:
    print('Yes')
    
else:
    print('No')

Measured memory_bytes: 29680
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
    int parent, left, right;
}Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if(u==NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL){
        h1 = setHeight(T[u].left) + 1;
    }
    if(T[u].right != NIL){
        h2 = setHeight(T[u].right) + 1;
    }
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
        return T[T[u].parent].left;
    }
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
        return T[T[u].parent].right;
    }
    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));

    int deg = 0;

    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if(T[u].parent == NIL){
        printf("root\n");
    }else if(T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
}

int main(){
    int v, l, r, root = 0;
    scanf("%d", &n);

    for(int i=0; i<n; i++){
        T[i].parent = NIL;
    }

    for(int i=0; i<n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }

    for(int i=0; i<n; i++){
        if(T[i].parent == NIL){
            root = i;
        }
    }

    setDepth(root, 0);
    setHeight(root);

    for(int i=0; i<n; i++){
        print(i);
    }

    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int N, K;
    cin >> N >> K;
    
    ll cc = N / K;
    ll res = cc * cc * cc;
    if (K % 2 == 0 && N >= K / 2)
    {
        cc = (N - K / 2) / K + 1;
        res += cc * cc * cc;
    }
    cout << res << "\n";
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,K,Q;
    string S;
    cin >> N>>K>>Q;

    vector<ll> A(Q);
    REP(i, Q)
        cin >> A.at(i);

        ll point[N + 10];

    REPS(i,N){
        point[i] = 0;
    }

    REP(i,Q){
        point[A.at(i)]++;
    }

    REPS(i,N){
        if (K -Q+ point[i]<=0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
        
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;

double x[8], y[8];
double ans = 0;
double t = 0;

int main(){
  int n; cin >> n;
  rep(i,n) cin >> x[i] >> y[i];
  vector<int> num(n); 
  rep(i,n) num[i] = i+1;
  do{
    t++;
    rep(i,n-1) {
      ans+=sqrtl( (x[num[i]-1]-x[num[i+1]-1])*(x[num[i]-1]-x[num[i+1]-1])+(y[num[i]-1]-y[num[i+1]-1])*(y[num[i]-1]-y[num[i+1]-1]) );
      // cout << num[i] << " " << num[i+1] << "\n"; 
    }
  }while(next_permutation(num.begin(),num.end()));
  printf("%.9f\n", ans/t);
  // cout << ans << "  "<< t << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  ll N; cin >> N;
  vector<ll> B(N-1);
  REP(i, N-1) {
    cin >> B[i];
  }
  ll sum = B[0];
  REP(i, N-2) {
    sum += min(B[i], B[i+1]);
  }
  sum += B[N-2];
  cout << sum << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

int main() {
  string st;
  cin >> st;
  int n = 0,w = 0,s = 0,e = 0;
  rep(i,0,st.size()){
    if(st[i] == 'N') n++;
    if(st[i] == 'W') w++;
    if(st[i] == 'S') s++;
    if(st[i] == 'E') e++;
  }
  bool f = false;
  if((n == 0 && s != 0)||(n != 0 && s == 0)) f = true;
  if((w == 0 && e != 0)||(w != 0 && e == 0)) f = true;
  if(f) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  long long int N, M;
  cin >> N >> M;
  while(N < (M/2)){
    long long int div = ((M/2)-N)/2;
    N += div;
    M -= div*2;
    if (div == 0){
      break;
    }
  }
  cout << min(N, M/2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>arr(n),brr(m);
    for(int i=0;i<n;++i)
    {
        cin>>arr[i];
        if(i) arr[i]+=arr[i-1];
    }
    for(int i=0;i<m;++i)
    {
        cin>>brr[i];
        if(i) brr[i]+=brr[i-1];
    }
    int st1=upper_bound(arr.begin(),arr.end(),k)-arr.begin();
    int st2=upper_bound(brr.begin(),brr.end(),k)-brr.begin();
    int book=max(st1,st2);
    for(int i=0;i<n;++i)
    {
        if(arr[i]>k)
        {
            int st2=upper_bound(brr.begin(),brr.end(),k)-brr.begin();
            book=max(book,st2);
            break;
        }
        else
        {
            int rem=k-arr[i];
            int st2= upper_bound(brr.begin(),brr.end(),rem)-brr.begin();
            //cout<<st2<<' '<<i<<endl;
            book=max(book,i+st2+1);
        }
    }
    cout<<book<<endl;
}

int main()
{
    fast;
    int t;
    solve();
}




Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,m,n,flag=1;
	scanf("%d %d",&m,&n);
	for(a=m;a>=0&&flag;a--)
	{
		for(b=m-a;b>=0&&flag;b--)
		{
			for(c=m-a-b;c>=0&&flag;c--)
			{
				if(a+b+c==m&&a*10000+b*5000+c*1000==n)
				{
					printf("%d %d %d",a,b,c);
					flag=0;
				}
			}
		}
	}
	if(flag==1)
	{
		printf("-1 -1 -1");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <ctime>
#include <cstring>
#include <cmath>
#include <stack>
#include <set>
#include <unordered_map>
#define INF 0x3f3f3f3f
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define per(i, n) for(int i=n;i>=0;i--)
#define rep2(i, n) for(ll i=1;i<=n;i++)
#define pb(x) push_back(x)
#define clint(x, n) memset(x,n,sizeof(x))
#define mp make_pair
#define fi first
#define se second
#define IO std::ios::sync_with_stdio(false)
#define ull unsigned long long
#define ud long double
#define pii pair<int,int>
using namespace std;
const int maxn = 1e6+5;
const ll inf = 100000000000;
const int mod =998244353;
const int MAX = 123123;
const int N =1005;
inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}
ll max(ll a,ll b){
    if(a>b) return a;
    return b;
}
ll min(ll a,ll b){
    if(a<b) return a;
    return b;
}
vector<int> a[10];
int used[10];
int ans = 0;
int n;

void bfs(int x,int t){
    if(t==n){
        ans++;
        return;
    }
    for(int i=0;i<a[x].size();i++){
        if(used[a[x][i]]) continue;
        used[a[x][i]]=1;
        bfs(a[x][i],t+1);
        used[a[x][i]]=0;
    }
}
int main(){
    int m;
    cin>>n>>m;
    for(int i = 0; i < m;i++){
        int x,y;
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    used[1]=1;
    bfs(1,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
int main() 
{

    int a,b;
    char s[500];
    cin>>a>>b;
    cin>>s;
    bool flag=true;
    if(s[a]=='-')
    {
        int len=strlen(s);
        for(int i=0;i<a;i++)
        {
            if(s[i]<'0'||s[i]>'9')
            {
                flag=false;
                break;
            }
        }
        for(int i=a+1;i<len;i++)
        {
            if(s[i]<'0'||s[i]>'9')
            {
                flag=false;
                break;
            }
        }
    }
    else
        flag=false;
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class EDoubleFactorial {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;

        if(n%2==1) {
            out << 0 << endl;
            return;
        }

        ll now = 10;
        ll res = 0;
        while(n >= now){
            res += n / now;
            now *= 5;
        }

        out << res << endl;
	}
};


int main() {
	EDoubleFactorial solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define Ranger159 ios_base::sync_with_stdio(false);
#define PrintLater cin.tie(0);cout.tie(0);
#define ll long long
#define phb push_back
#define break break
#define pob pop_back()
#define continue continue
#define size size
#define insrt insert
#define fir first
#define true true
#define clear clear
#define vL vector<ll> 
#define resize resize
#define sec second
#define else else
#define reverse reverse
#define lbr1 cout<<"\n";
#define lbr2 cout<<"\n\n";
#define cin(v,n) for(ll i=0;i<n;i++) cin>>v[i];
#define cout(v,n) for(ll i=0;i<n;i++) cout<<v[i]<<" "; lbr1
const ll mod=1e9+7;

int main(int argc, char const *argv[])
{
	Ranger159
	// PrintLater
	ll test=1,n,i,j,qry,x,y,val,indx;
	// cin>>test;
	while(test--)
	{
		cin>>n;
		vector<ll> v={599, 799, 999, 1199, 1399, 1599,1799, 1999};
		ll ans=v.end()-lower_bound(v.begin(), v.end(),n);
		cout<<ans;
		lbr1
	}
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(void) {

	int a[100], n, i, j, k, key;
	/*printf("n???????????\????????????????????????\n");*/
	scanf("%d", &n);
	/*printf("%d??????????????\????????????????????????\n",n);*/
	for (i = 0; i < n; i++) 
	scanf("%d", &a[i]);

	for (k = 0; k < n; k++) {

		key = a[k];

		j = k-1;

		while (j >= 0 && a[j]>key) {
			a[j + 1] = a[j];
			j--;
		}
			a[j + 1]=key;
		for (i = 0; i < n; i++)
			printf("%d%c", a[i],i==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int &e : p) cin >> e;
	sort(p.begin(), p.end());
	
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
public class Main{
    public static void main(String[] args) throws IOException {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25488
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

#define sheep 'S'
#define wolf 'W'
#define T 'o'
#define F 'x'

char ring[4][100000];

int main() {
	ll n;
	string s;
	cin >> n;
	cin >> s;
	ring[0][1]= sheep;
	ring[1][1] = wolf;
	ring[2][1] = sheep;
	ring[3][1] = wolf;
	for (int i = 0; i < 2; i++) {
		ring[i][0] = sheep;
		ring[i + 2][0] = wolf;
	}
	for (ll i = 1; i < n - 1; i++) {
		if (s[i] == T) {
			for (int j = 0; j < 4; j++) {
				if (ring[j][i] == sheep) {
					ring[j][i + 1] = ring[j][i - 1];
				}
				else  {
					if (ring[j][i - 1] == sheep)ring[j][i + 1] = wolf;
					else ring[j][i + 1] = sheep;
				}
			}
		}
		else  {
			for (int j = 0; j < 4; j++) {
				for (int j = 0; j < 4; j++) {
					if (ring[j][i] == wolf) {
						ring[j][i + 1] = ring[j][i - 1];
					}
					else {
						if (ring[j][i - 1] == sheep)ring[j][i + 1] = wolf;
						else ring[j][i + 1] = sheep;
					}
				}
			}
		}
	}
	bool res[4];
	for (int i = 0; i < 4; i++) {
		if (s[n - 1] == T) {
			if (ring[i][n - 1] == sheep) {
				if (ring[i][n - 2] == ring[i][0])res[i] = true;
				else res[i] = false;
			}
			else {
				if (ring[i][n - 2] != ring[i][0])res[i] = true;
				else res[i] = false;
			}
		}
		else {
			if (ring[i][n - 1] == wolf) {
				if (ring[i][n - 2] == ring[i][0])res[i] = true;
				else res[i] = false;
			}
			else {
				if (ring[i][n - 2] != ring[i][0])res[i] = true;
				else res[i] = false;
			}
		}
	}	
	for (int i = 0; i < 4; i++) {
		if (res[i]) {
			if (s[0] == T) {
				if (ring[i][0] == sheep) {
					if (ring[i][n - 1] == ring[i][1])res[i] = true;
					else res[i] = false;
				}
				else {
					if (ring[i][n - 1] != ring[i][1])res[i] = true;
					else res[i] = false;
				}
			}
			else {
				if (ring[i][0] == wolf) {
					if (ring[i][n - 1] == ring[i][1])res[i] = true;
					else res[i] = false;
				}
				else {
					if (ring[i][n - 1] != ring[i][1])res[i] = true;
					else res[i] = false;
				}
			}
		}
	}
	bool flag = true;
	for (int i = 0; i < 4; i++) {
		if (res[i]) {
			for (ll j = 0; j < n; j++) {
				printf("%c", ring[i][j]);
			}
			printf("\n");
			flag = false;
			break;
		}
	}
	if (flag)cout << -1 << endl;
}



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

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) {
        cout << "+" << endl;
    } else if (a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
}


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

long long int N, a[200202], A, c;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", a + i + 1);
        a[i + 1] += a[i];
    }
    sort(a, a + N + 1);
    c = 0;
    a[N + 1] = 1000000000000000LL;
    for(int i = 0; i <= N + 1; ++i){
        if(a[i] != a[c]){
            A += (i - c) * (i - c - 1) / 2;
            c = i;
        }
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 1792
fn main() {
    let n: u64 = {
        let mut buffer = String::new();
        std::io::stdin().read_line(&mut buffer);

        buffer.trim().parse().unwrap()
    };

    let mut sum = 0;
    for i in 1..(n+1) {
        sum += i;
    }

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


Measured memory_bytes: 380
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
   
   while(test--)
   solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll f=n/(a+b);
    
    ll ans=a*f+min(n%(a+b),a);
    cout<<ans;
}    


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





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

#define LL long long
#define MAXN 10000

int main(){
	int n;
	cin>>n;
	LL sum=0;
	for(int i=0;i<n;i++){
		LL a,b;
		cin>>a>>b;
		sum+=b-a+1;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
K, S = gets.split.map(&:to_i)
cnt = 0
min_x = [0, S - 2*K].max
max_x = [K, S].min
min_x.upto(max_x) do |i|
    rest = S - i
    if rest <= K
        cnt += rest + 1
    else
        cnt += K - (rest - K) + 1
    end
end
puts cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,tle=0,wa=0,ac=0,re=0;
cin >>n;
string a;
for(int i=0;i<n;i++)
{
    cin>>a;
    if(a=="TLE")
    {
        tle++;
    }
    if(a=="RE")
    {
        re++;
    }
   if(a=="AC")
    {
        ac++;
    }
   if(a=="WA")
    {
        wa++;
    }
}
cout<<"AC x "<<ac<<endl;
cout<<"WA x "<<wa<<endl;
cout<<"TLE x "<<tle<<endl;
cout<<"RE x "<<re<<endl;
    
}


Measured memory_bytes: 3628
#include <iostream>
#include<algorithm>
#include <string>
#include<vector> 
#include<queue>
using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1')
			s[i] = '9';
		else
			s[i] = '1';
	}
	cout << s;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll  long long
ll ans[400000], a[400000];
double pi=acos(-1.0);
int main()
{
    IO;
    double i, j, n, m, m2, k, t,a1,a2, l, th, h, r, mx, pr=.000000001, x, y;
    cin>>n>>l>>h>>m;
    th = (m*2*pi)/60;
    h+=m/60;
    h=(h*2*pi)/12;
    th-=h;
    a1=n*n+l*l-2*cos(th)*n*l;
    cout<<fixed<<setprecision(12)<<sqrt(a1)<<endl;
    return 0;
}


Measured memory_bytes: 4148
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int A,B;
	cin>>A>>B;
	if(A+B==15)
		cout<<"+"<<endl;
	else if(A*B==15)
		cout<<"*"<<endl;
	else
		cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int H[250],i,n;

  scanf("%d",&n);

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

  for(i=1;i<n+1;i++)
    {
      printf("node %d: key = %d, ",i,H[i-1]);

      if(i/2 >= 1) printf("parent key = %d, ",H[i/2-1]);
      if(i*2 <= n) printf("left key = %d, ",H[i*2-1]);
      if(i*2+1 <= n) printf("right key = %d, ",H[i*2]);

      printf("\n");
    }

  return 0;
}
			  

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    string S;
    cin >> S;
    int ans1 = 0, ans2 = 0;
    rep(i, S.size())
    {
        if (i % 2 == 1)
        {
            if (S[i] == '0')
                ans1++;
        }
        else
        {
            if (S[i] == '1')
                ans1++;
        }
    }
    rep(i, S.size())
    {
        if (i % 2 == 1)
        {
            if (S[i] == '1')
                ans2++;
        }
        else
        {
            if (S[i] == '0')
                ans2++;
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 512
def main():
    R,G,B,N = map(int,input().split())
    
    count = 0
    for i in range(N//R+1):
        r = N-R*i
        for j in range(r//G+1):
            rr = r-G*j
            if rr%B == 0:
                count += 1
    
    print(count)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 40432
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define pi acos(-1.0)
#define N 1000000
#define LL long long
using namespace std;
int main()
{
    double  a;
    while(cin>>a)
    {

        double y,t=a/9.8;
        y=4.9*t*t;
       double fl=5*1-5;int i=2;
        //cout<<y<<" "<<fl<<endl;

        while(y>fl)
        {
            fl=5*i-5;
            i++;
        }
        //cout<<y<<" "<<fl<<endl;
        cout<<i-1<<endl;
    }

    return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b, k;
  set<int> result;
  cin >> a >> b >> k;
  rep(i, k) {
    if (a + i <= b) {
    result.insert(a + i);
    }
    if (b - i >= a) {
    result.insert(b - i);
    }
  }
  
  for (auto itr = result.begin(); itr != result.end(); itr++) {
    cout << *itr << endl;
  }
}

Measured memory_bytes: 256
N, M, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)

wk, C = 0, [0]
A.each{|a|
  wk += a
  break if wk > K
  C << wk
}
wk, D = 0, [0]
B.each{|b|
  wk += b
  break if wk > K
  D << wk
}
ans = []
(0...C.size).each{|i|
  wk = D.bsearch_index{|d| d > K-C[i]}
  wk = D.size if wk.nil?
  ans << i+wk-1
}

puts ans.max


Measured memory_bytes: 46396
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

ll digit(ll n){
  ll i=1;
  while(n/(ll)pow(10,i)>0){
    i++;
  }
  return i;
}

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

Measured memory_bytes: 4124
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int MAXN=1000005,MAXM=30000000;
int P;
#define L 1048576
#define real long double
#define eps 1e-9
char _buf[L],*S,*T,_buf1[L],*S1=_buf1;
inline char gc()
{
	if(S==T)
	{
		T=(S=_buf)+fread(_buf,1,L,stdin);
		if(S==T)return 0;
	}
	return *S++;
}
template<class T> void get(T &x)
{
	char c;
	for(c=gc();(c<'0'||c>'9')&&c!='-';c=gc());
	bool b=0;
	if(c=='-')
	{
		b=1;
		c=gc();
	}
	for(x=c^'0',c=gc();c>='0'&&c<='9';c=gc())x=(x<<3)+(x<<1)+(c^'0');
	if(b)x=-x;
}
inline void pc(char c)
{
	if(S1==_buf1+L)
	{
		fwrite(_buf1,1,L,stdout);
		S1=_buf1;
	}
	*S1++=c;
}
void out(ll x)
{
	if(x>9)out(x/10);
	pc(x%10^'0');
}
int Pow(int x,int y)
{
	int s=1;
	for(;y;y>>=1,x=(ll)x*x%P)if(y&1)s=(ll)s*x%P;
	return s;
}
int A(int x)
{
	return x<0?-x:x;
}
int n,i,j,p[2],a[MAXN],t[2][MAXN],s[2],f[MAXN],o[MAXN];
char c[MAXN];
int main()
{
	scanf("%d%s",&n,c);
	for(i=0;i<n;i++)a[i]=c[i]^'0';
	for(i=0;i<n;i++)p[0]+=a[i];
	p[1]=max(p[0]-1,1);
	p[0]++;
	t[0][0]=1%p[0];
	t[1][0]=(p[1]-1)%p[1];
	for(i=0;i<2;i++)for(j=1;j<=n;j++)t[i][j]=t[i][j-1]*2%p[i];
	for(i=0;i<2;i++)for(j=0;j<n;j++)s[i]=(s[i]*2+a[j])%p[i];
	for(i=1;i<=n;i++)o[i]=o[i>>1]+(i&1);
	for(i=1;i<=n;i++)f[i]=f[i%o[i]]+1;
	for(i=0;i<n;i++)
	{
		if(a[i]==1&&p[0]==2)out(0);
		else out(f[(s[a[i]]+t[a[i]][n-1-i])%p[a[i]]]+1);
		pc('\n');
	}
	fwrite(_buf1,1,S1-_buf1,stdout);
	return 0;
}

Measured memory_bytes: 8276
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int A,B;
	cin >> A >> B;
	string S;
	cin >> S;
	bool f = true;
	for (int i = 0; f && i < S.length(); ++i) {
		if (i == A) {
			if (S[i] != '-') {
				f = false;
			}
		}
		else {
			if (!(S[i] >= '0' && S[i] <= '9')) {
				f = false;
			}
		}
	}
	
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, k, q, mn=1e9, a[2005];
vector<int> t, z;

int main() {
	int i, j, x, y;
	cin>>n>>k>>q;
	for(i=0; i<n; i++) cin>>a[i];
	for(i=0; i<n; i++) {
		z.clear();
		for(x=0; x<n; x=y+1) {
			for(y=x; y<n && a[y]>=a[i]; y++);
			if(y-x<k) continue;
			t.clear();
			for(j=x; j<y; j++) t.push_back(a[j]);
			sort(t.begin(), t.end());
			for(j=0; j<=t.size()-k; j++) z.push_back(t[j]);
		}
		if(z.size()<q) continue;
		sort(z.begin(), z.end());
		mn = min(mn, z[q-1] - z[0]);
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 384
module Main (main) where

import Control.Monad
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n] <- readInts
  xs <- replicateM n readStrings
  print . solve $ concat xs

solve :: [String] -> Int
solve = sum . map (f . length) . group . sort . map sort
  where
    f n = (n * (n-1)) `div` 2 

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

readStrings :: IO [String]
readStrings = map C8.unpack . C8.words <$> C8.getLine

Measured memory_bytes: 106876
def main():
    n,m = map(int,input().split())
    l = [[] for _ in range(n+1)]
    lp = []
    for i in range(m):
        p,y = map(int,input().split())
        l[p].append([i,y])
        lp.append(p)
    
    for p in l:
        p.sort(key=lambda x: x[1])
        for no in range(0,len(p)):
            p[no].append(no+1)
        p.sort()

    pidx = [0 for x in range(n+1)]
    for p in lp:
        print("{:06}{:06}".format(p,l[p][pidx[p]][2]))
        pidx[p] += 1

if __name__ == '__main__':
    main()

Measured memory_bytes: 42912
H, W = map(int, input().split())
S = [input() for _ in range(H)]

T   = [[0] * W for _ in range(H)]
tmp = [[0] * W for _ in range(H)]

def countlight(dir):
    yrange = range(H - 1, -1, -1) if dir == 'down'  else range(H)
    xrange = range(W - 1, -1, -1) if dir == 'right' else range(W)
    nxt = {
        'left':  lambda xy: (xy[0] - 1, xy[1]),
        'right': lambda xy: (xy[0] + 1, xy[1]),
        'up':    lambda xy: (xy[0],     xy[1] - 1),
        'down':  lambda xy: (xy[0],     xy[1] + 1)
    }
    for y in yrange:
        for x in xrange:
            x1, y1 = nxt[dir]((x, y))
            tmp[y][x] = (tmp[y1][x1] if 0 <= x1 < W and 0 <= y1 < H else 0) \
                        + 1 if S[y][x] == '.' else 0
            T[y][x]  += tmp[y][x] - 1

for dir in ('left', 'right', 'up', 'down'):
    countlight(dir)

print(max(max(T[y]) for y in range(H)) + 1)

Measured memory_bytes: 123480
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	vector<ll> h(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	ll max = h[0], min = h[0];

	for (ll i = 1; i < n; i++)
	{
		if(h[i] > max)
			max = h[i];

		if (max - h[i] > 1)
		{
			cout << "No" << endl;
			exit(0);
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	cout << 32*n << endl;
}


Measured memory_bytes: 3140
s = input()
lst = []

if len(s) == 1:
    print(1)
    exit()

q = 0
while q <= len(s)-2:
    if s[q] == s[q+1]:
        lst.append(s[q])
        if q+1 != len(s)-1:
            lst.append(s[q+1:q+3])
        q += 3
    else:
        lst.append(s[q])
        q += 1
else:
    ans = len(lst)
    text = str(lst).replace('[','').replace(']','').replace(',','').replace("'",'').replace(" ",'')
    if text != s and s[-1] != lst[-1]:
        ans += 1
print(ans)

Measured memory_bytes: 9700
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

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

    map<string,int> memo;

    string S[N];
    for(int i=0;i<N;i++){
        cin >> S[i];
        memo[S[i]] += 1;
    }

    int maxv=0;
    for(auto x : memo){
        int v = x.second;
        maxv = max(v,maxv);
    }

    for(auto it=memo.begin(); it!=memo.end(); it++){
        if(it->second == maxv){
            cout << it->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 26752
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(){
    const double PI=acos(-1.0);
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double angleH = PI*(H+M/60)/6.0;
    double angleM = PI*M/30;
    double difAngle = angleM - angleH;
    cout << setprecision(30) << 
        sqrt(A*A + B*B - 2*A*B*cos(difAngle)) 
    << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  string s;
  cin >> s;
  if (s == "ani") {
    cout << "square1001" << endl;
  } else {
    cout << "e869120" << endl;
  }
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=7e5+50;
char a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,s1;
    cin>>(a+300005);
    int start=3e5+5;
    int len=strlen(a+300005);
    int endx=start+len-1;
    int flag=0;//0表示正 1表示逆
    int q;
    cin>>q;
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
           if(flag==0) flag=1;
           else flag=0;
        }
        else
        {
            int f;
            cin>>f;
            char d;
            cin>>d;
            if(f==1)
            {
                if(flag==0) //正序
                {
                    start--;
                    a[start]=d;
                }
                else
                {
                    endx++;
                    a[endx]=d;
                }
            }
            else
            {
                if(flag==0)
                {
                    endx++;
                    a[endx]=d;
                }
                else
                {
                    start--;
                    a[start]=d;
                }
            }
        }

    }
    if(flag==0)
    {
        for(int i=start;i<=endx;i++)
        {
            cout<<a[i];
        }
        cout<<'\n';
    }
    else
    {
        for(int i=endx;i>=start;i--)
            cout<<a[i];
        cout<<'\n';
    }








}











Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  cout << (N<=999?"ABC":"ABD") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
struct FlowGraph{
	struct edge{ int to, cap, rev; };
	
	int n, *level, *iter;
	vector<vector<edge> > G;
	
	FlowGraph(int sz) : n(sz){
		G.resize(n);
		iter = new int[n]; level = new int[n];
	}
	~FlowGraph(){
		delete [] iter; delete [] level;
	}
	
	void add(int s, int t, int cap){
		G[s].pb((edge){t, cap, (int)G[t].size()});
		G[t].pb((edge){s, 0, (int)G[s].size() - 1});
	}
	void bfs(int s){
		rep(i, n) level[i] = -1;
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while(!q.empty()){	
			int v = q.front();
			q.pop();
			rep(i, G[v].size()){
				edge &e = G[v][i];
				if(e.cap > 0 && level[e.to] < 0){
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v, int t, int f){
		if(v == t) return f;
		for(int &i = iter[v]; i < (int)G[v].size(); i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[v] < level[e.to]){
				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;
		while(1){
			bfs(s);
			if(level[t] < 0) return flow;
			rep(i, n) iter[i] = 0;
			int f;
			while((f = dfs(s, t, inf)) > 0) flow += f;
		}
	}
};
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	FlowGraph g(2 * n + 2);
	int s = 2 * n, t = 2 * n + 1;
	
	vi a(n), b(n), c(n), d(n);
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, n) cin >> c[i] >> d[i];
	
	rep(i, n) rep(j, n) if(a[i] < c[j] && b[i] < d[j]) g.add(i, j + n, 1);
	rep(i, n){
		g.add(s, i, 1);
		g.add(i + n, t, 1);
	}
	cout << g.max_flow(s, t) << endl;
	
	return 0;
}

Measured memory_bytes: 384
from collections import deque

s = input()
s_list = deque(list(s))

x_count = 0
flag = True
while len(s_list) > 1:

    s_head = s_list.popleft()
    s_tail = s_list.pop()

    if s_head == s_tail:
        continue
    elif s_head == "x":
        x_count += 1
        s_list.append(s_tail)
        continue
    elif s_tail == "x":
        x_count += 1
        s_list.appendleft(s_head)
        continue
    else:
        flag = False
        break

if flag:
    print(x_count)
else:
    print(-1)

Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
//#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

template<typename Weight>class PotentializedUnionFind{
public:
  vector<int> par,rnk,sz;
  vector<Weight> difweight;
  PotentializedUnionFind(int n):
    par(n,-1),rnk(n,0),sz(n,1),difweight(n,0){}

  int find(int x){
    if(par[x]<0){return x;}
    else{
      int r=find(par[x]);
      difweight[x]+=difweight[par[x]];
      return par[x]=r;
    }
  }
  Weight weight(int x){
    find(x);
    return difweight[x];
  }
  bool same(int x,int y){return find(x)==find(y);}

  bool unite(int x,int y,Weight w){
    w+=weight(x);w-=weight(y);
    x=find(x);y=find(y);
    if(x==y)return false;
    if(rnk[x]<rnk[y])swap(x,y),w=-w;
    if(rnk[x]==rnk[y])rnk[x]++;
    par[y]=x;
    difweight[y]=w;
    return true;
  }
  Weight diff(int x,int y){return weight(y)-weight(x);}
};

int main(){
  int n,q;
  cin>>n>>q;
  PotentializedUnionFind<int> uf(n);
  rep(i,q){
    int t;
    cin>>t;
    if(t){
      int x,y;
      cin>>x>>y;
      if(uf.same(x,y)){
        cout<<uf.diff(x,y)<<endl;
      }else{
        cout<<"?"<<endl;
      }
    }else{
      int x,y,z;
      cin>>x>>y>>z;
      uf.unite(x,y,z);
    }
  }
 return 0;
}



Measured memory_bytes: 4424
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++)
      a[i] = sc.nextInt();
    sc.close();

    long[][] dp = new long[N][N];
    for (int head = N - 1; 0 <= head; head--) {
      for (int tail = 0; tail < N; tail++) {
        if (dp[head][tail] != 0) continue;
        if (head == tail) {
          dp[head][tail] = a[head];
        } else {
          if (tail == 0) {
            dp[head][tail] = a[tail];
          } else if (head == N - 1) {
            dp[head][tail] = a[head];
          } else {
            dp[head][tail] = Math.max(
                a[head] - dp[head + 1][tail],
                a[tail] - dp[head][tail - 1]);
          }
        }
      }
    }

    long ans = dp[0][N - 1];
    System.out.println(ans);
  }
}

Measured memory_bytes: 129916
function isAddedValue( char )
	return Base.ifelse( Base.isequal(char, 'o'), 100, 0 )
end

function abc095_a()

	const val_base = 700

	# STEP.01
	# get the target order
	buffer = Base.readline( Base.STDIN )

	# STEP.02
	# count up the number of the topping
	val_total = val_base

	for itr in buffer
		val_total += Main.isAddedValue( itr )
	end

	# STEP.03
	# output the result
	Base.println( Base.STDOUT, val_total )

	# STEP.TRUE_END
	return Base.nothing

end

#==================================================================================================#

Main.abc095_a()


Measured memory_bytes: 108132
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位



int x[100001], y[100001];
int a[200001];
int bo[100][100];
map<vector<int>, int> ma;

void bin2v(vector<int>& v, int num, int vSize) {
	for (int i = 0; i < vSize; i++) {
		v.push_back(1 & num >> i);
	}
}

bool vSub(int vSize, vector<int>& dst, vector<int>& src) {
	for (int i = 0; i < vSize; i++) {
		dst[i] -= src[i];
		if (dst[i] < 0) return false;
	}
	return true;
}

int grundyNumber(vector<int> v, int vSize) {
	if (ma.find(v) != ma.end()) return ma[v];
	set<int> s;
	int binAll = (1 << vSize) - 1;
	for (int i = 1; i <= binAll; i++) {
		vector<int> vec, dst = v;
		bin2v(vec, i, vSize);
		if (!vSub(vSize, dst, vec)) {
			continue;
		}
		s.insert(grundyNumber(dst, vSize));
	}
	
	
	int res = 0;
	while (s.find(res) != s.end()) res++;
	ma[v] = res;
	return res;
}

signed main() {
	/*
	vector<int> v = { 0,0,0 };
	//vector<int> v = { 0,0 };
	ma[v] = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k<10; k++) {
				v = { i,j, k };
				grundyNumber(v, 3);
			}
		}
	}
	for (auto p : ma) {
		if (p.second != 0) continue;
		cout << "{";
		for (int i : p.first) {
			cout << i << " ";
		}
		cout << "} :" << p.second << "\n";
	}
	*/
	bool flag = false;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int tnp;
		cin >> tnp;
		if (tnp % 2 == 1) flag = true;
	}
	if (flag) cout << "first\n";
	else cout << "second\n";
	
	return 0;
}

Measured memory_bytes: 256