akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

bool pairCompare(const pair<string,ll>& firstElof, const pair<string,ll>& secondElof)
{
    if(firstElof.first != secondElof.first){
        return firstElof.first < secondElof.first;
    }else{
        return firstElof.second >= secondElof.second;
    }
    
}
 

int main(){
    ll n,m;
    bool s[11][11];
    Fill(s,false);
    ll p[11];
    
    std::cin >> n>>m;
    for (int i = 0; i < m; i++) {
        ll tmp;
        std::cin >> tmp;
        for (int j = 0; j < tmp; j++) {
            ll tmp2;
            std::cin >> tmp2;
            tmp2--;
            s[i][tmp2] = true;
        }
        
    }
    for (int i = 0; i < m; i++) {
       std::cin >> p[i];
    }
    ll result = 0;
    for (int i = 0; i < (1<<n); i++) {
        ll count[11];
        Fill(count,0);
        bool ok = true;
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < n; k++) {
                if(s[j][k] && i & (1<<k) ){
                    count[j]++;
                }                
            }
            if(count[j]%2 != p[j]){
                ok = false;
                break;
            }
        }
        if(ok){
            // std::cout << bitset<10>(i) << std::endl;
            result++;
        }
    
    }
    std::cout << result << std::endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,h;cin>>n>>h;
    vl a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    sort(rall(a));
    sort(rall(b));
    int aa = 0,bb = 0;
    ll res = 0;
    while(h>0){
        if(bb == n){
            res+=(h+a[aa]-1)/a[aa];
            h=0;
        }
        else if(b[bb] > a[aa]){
            h-=b[bb++];
            res++;
        }
        else{
            res+=(h+a[aa]-1)/a[aa];
            h=0;
        }
    }
    out(res);
}


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

int main()
{
    int a[5];
    int distance;

    for (int i = 0; i < 5; ++i){
        cin >> a[i];
    }
    cin >> distance;

    if(a[4]-a[0] > distance){
        cout << ":(\n"; 
    }
    else{
        cout << "Yay!"; 
    }
    return 0;
}


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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second

int main()
{
    ios::sync_with_stdio(false);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    string res = "NO";
    for (int i=0; i<n; ++i) {
        ll l = a + i*c - (n-i-1)*d;
        ll r = a + i*d - (n-i-1)*c;
        if (l<=b && b<=r) {
            res = "YES";
            break;
        }
    }

    cout << res << endl;
}}

Measured memory_bytes: 256
K = int(input())
A = list(map(int, input().split()))
A.reverse()
A.append(1)
ansmin = 2
ansmax = 2
for a in A:
  tmin = ((ansmin+a-1)//a)*a
  tmax = (ansmax//a)*a
  if tmin > tmax:
    print('-1')
    exit()
  ansmin = tmin
  ansmax = tmax + a - 1
print(ansmin, ansmax)

Measured memory_bytes: 14224
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,j,i,k;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		f=0;
		g=a;
		h=s;
		if(a<s){
			g=s;
			h=a;
		}
		while(1){
			d=g%h;
			g=d;
			d=h;
			h=g;
			g=d;
			f++;
			if(h==0) break;
		}
		printf("%d %d\n",g,f);
	}
	return 0;
}

Measured memory_bytes: 2728
n=int(input())
v=list(map(int,input().split()))
count=0
A=[[0,i] for i in range(10**5+1)]
Z=[[0,i] for i in range(10**5+1)]
for i in range(n):
  if i%2==0:
    A[v[i]][0]+=1
  else:
    Z[v[i]][0]+=1
A.sort()
Z.sort()
def wfs(x,y):
  if A[x][1]!=Z[y][1]:
    return n-A[x][0]-Z[y][0]
  else:
    return min(wfs(x,y-1),wfs(x-1,y))
print(wfs(-1,-1))

Measured memory_bytes: 34044
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <deque>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
#define FOR for(int i=0;i<n;i++)for(int j=0;j<m;j++)
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1);

    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i,N)cin >> H[i];
    sort(H.begin(),H.end(),greater<int>());
    ll ans = 0;
    repX(i,N,K){
        ans += H[i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main() {
  string S,T,U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if(U==S){
      A--;
  }else{
      B--;
  }
  cout << A << endl;
  cout << B << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  string s;cin>>s;
  if(s=="ABC") cout<<"ARC";
  else cout<<"ABC";
  
  
  return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
vector<int>e[N];
int xx, yy;
bool used[N];
bool target[N];
void dfs(int k) {
	used[k] = true;
	f(i, e[k].size()) {
		if (!used[e[k][i]])dfs(e[k][i]);
	}
	return;
}


int main() {
	bool v;
	int n, x, y, m;
	int a[N];
	f(i, N)a[i] = 0;
	scanf("%d %d", &n, &m);
	f(i, m) {
		scanf("%d %d", &x, &y);
		a[x - 1]++;
		a[y - 1]++;
		e[x - 1].push_back(y - 1);
		e[y - 1].push_back(x - 1);
	}
	f(i, n)if (a[i] % 2 != 0) {
		printf("No\n");
		return 0;
	}
	x = -1;
	y = -1;
	f(i, n) {
		if (a[i] >= 6) {
			printf("Yes\n");
			return 0;
		}
		if (a[i] >= 4) {
			if (x < 0)x = i;
			else if (y < 0)y = i;
			else {
				printf("Yes\n");
				return 0;
			}
		}
	}
  if(y<0){
    	printf("No\n");
		return 0;
  }
	xx = x;
	yy = y;
	f(i, n)target[i] = false;
	f(i, 4)target[e[xx][i]] = true;
	f(i, 4) {
		target[e[xx][i]] = false;
		f(j, n)used[j] = false;
		used[xx] = true;
		used[yy] = true;
		dfs(e[xx][i]);
      	used[xx] = false;
		used[yy] = false;
		f(j, n) {
			if (target[j] && used[j]) {
				printf("Yes\n");
				return 0;
			}
		}
		target[e[xx][i]] = true;
	}
  	f(i, 4)target[e[xx][i]] = false;
	f(i, 4)target[e[yy][i]] = true;
	f(i, 4) {
		target[e[yy][i]] = false;
		f(j, n)used[j] = false;
		used[xx] = true;
		used[yy] = true;
		dfs(e[yy][i]);
        used[xx] = false;
		used[yy] = false;
		f(j, n) {
			if (target[j] && used[j]) {
				printf("Yes\n");
				return 0;
			}
		}
		target[e[yy][i]] = true;
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 10240
#include <stdio.h>

int gcd(int num1,int num2){
int gcd;
  while(1){
    gcd=num1%num2;
    if(gcd==0) break;
    num1=num2;
    num2=gcd;
  }
return num2;
}

int main(){
  int num1,num2,gcdnum;
  scanf("%d %d",&num1,&num2);

  gcdnum=gcd(num1,num2);
  printf("%d\n",gcdnum);

  return 0;
}





Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;cin >> s >>t;
  int cnt = 0;
  if(s.at(0) == t.at(0))cnt++;
  if(s.at(1) == t.at(1))cnt++;
  if(s.at(2) == t.at(2))cnt++;
  cout << cnt;
}

Measured memory_bytes: 3552
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int main(){
  int N; cin >> N;
  map<string,int>m;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    m[s]++;
  }
  int MAX=0;
  for(auto itr=m.begin();itr!=m.end();itr++){
    MAX = max(MAX,itr->second);
  }
  for(auto itr=m.begin();itr!=m.end();itr++){
    if(itr->second == MAX){
      cout << (itr->first) << endl;
    }
  }
}


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

int main() {
  long h;
  cin >> h;
  int n = 0;
  while(h > 0) {
    h = h / 2;
    n++;
  }
  long ans = 0;
  for(int i = 0; i < n; i++) {
    ans += (long)pow(2, i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
def main2():
    ketaone = [0]*61
    MOD = 10**9 + 7
    n = int(input())
    A=[int(i) for i in input().split()]

    for i in A:
        for j in range(61):
            if i&(1<<j):
                ketaone[j]+=1
    res = 0

    for i in range(61):
        res = res + (ketaone[i]*(n-ketaone[i])*(2**i))%MOD
        res%=MOD
    print(res)


def main1():
    n = int(input())
    lis = [[] for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            lis[i].append(list(map(int, input().split())))
    res = 0

    for i in range(1<<n):
        f = True
        uso=set()
        syo=set()
        tmp=0
        for j in range(n):
            if(i&(1<<j)):
                tmp+=1
                for k in lis[j]:
                    if (i&(1<<(k[0]-1))) and k[1]==0:
                        f=False
                    if k[1]==1 and not (i&(1<<k[0]-1)):
                        f=False
        if f:
            res = max(res,tmp)
    print(res)


if __name__ == '__main__':
    main2()


Measured memory_bytes: 123056
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {

  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);
    // 1 1 1 2 2 2 7 7 7
    // 721 721 721 771 221 721


    int N = sc.nextInt();
    Long[] team = new Long[N * 3];
    for (int i = 0; i < N; i++) {
      for(int j = 0; j < 3; j++){
        long currNum = sc.nextLong();
        team[(i * 3) + j] = currNum;
      }
    }

    Arrays.sort(team, Collections.reverseOrder());

    long sum = 0;
    for(int i = 0; i < N; i++) {
      sum += team[(i * 2) + 1];
    }

    System.out.println(sum);
  }
}


Measured memory_bytes: 102984
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
int n, a, b;
bool cmp(pair<int, int>& a, pair<int, int>& b)
{
	return a.second < b.second;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		vector<pair<int, int>> v;
		for (int i = 1; i <= n&&cin >> a >> b; ++i)
			v.emplace_back(a, b);
		sort(v.begin(), v.end(), cmp);
		ll sum = 0, cnt = 0;
		for (auto i : v)
		{
			sum += i.first;
			if (sum > i.second)
				break;
			cnt++;
		}
		cout << (cnt == n ? "Yes" : "No") << endl;
	}
}
/*
5
2 4
1 9
1 8
4 9
3 12

3
334 1000
334 1000
334 1000

30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
*/

Measured memory_bytes: 2420
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int n;
  cin >> n;
  map<string, ll> mp;
  ll mx = 0;
  rep(i, n)
  {
    string s;
    cin >> s;
    mp[s] += 1;
    if (mx < mp[s])
    {
      mx = mp[s];
    }
  }
  for (auto x : mp)
  {
    if (mx == x.second)
    {
      cout << x.first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 17664
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    long long g,h=0,maxn=0;
    string s;
    cin>>g;
    cin>>s;
    for(int i=0;i<g;i++)
    {
    	if(s[i]=='I')h++;
    	else h--;
    	if(h>maxn)maxn=h;
	}
	cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));

        String[] inputs = reader.readLine().split(" ");
        int num  = Integer.parseInt(inputs[0]+inputs[1]+inputs[2]);
        if(num %4 ==0) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
}

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

int main() {
  ll a,b;
  cin >> a  >> b;
  
  vector<ll> ay;
  vector<ll> by;
  
  for(ll i = 1; i <= sqrt(a);i++){
    if(a%i == 0){
      ay.push_back(i);
      if(i != a/i){
        ay.push_back(a/i);
      }
    }
  }
  for(ll i = 1; i <= sqrt(b);i++){
    if(b%i == 0){
      by.push_back(i);
      if(i != b/i){
        by.push_back(b/i);
      }
    }
  }
  //cout << ay.size() << " " << by.size() << endl;
  vector<ll> kys;
  for(int i = 0;i<ay.size();i++){
    for(int j = 0;j<by.size();j++){
      
      if(ay[i]==by[j]){
        kys.push_back(ay[i]);
        //cout << ay[i] << " " << by[j]<< endl;
      }
    }  
  }    
  
  int res = 0;
  int flg = 0;
  sort(kys.begin(),kys.end(),greater<ll>());
  for(int i = 0;i<kys.size();i++){
    flg = 0;
    for(int j = i+1;j<kys.size();j++){
      if(__gcd(kys[i],kys[j]) != 1){
        flg = 1;
        break;
      } 
    }
    if(flg == 0){res++;}
  }
  
  
  cout << res;
}

Measured memory_bytes: 3740
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int g[][] = new int[3][3];
		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				g[i][j]=sc.nextInt();
			}
		}
		boolean ok = false;
		for(int i=0; i<=100; i++) {

			int a1=i;
			int b1=g[0][0]-a1;

			int b2=g[0][1]-a1;
			int b3=g[0][2]-a1;
			int a2=g[1][0]-b1;
			int a3=g[2][0]-b1;

			if( g[0][0] == a1+b1 &&
				g[0][1] == a1+b2 &&
				g[0][2] == a1+b3 &&
				g[1][0] == a2+b1 &&
				g[1][1] == a2+b2 &&
				g[1][2] == a2+b3 &&
				g[2][0] == a3+b1 &&
				g[2][1] == a3+b2 &&
				g[2][2] == a3+b3) {
				ok=true;
				break;
			}
		}
		if(ok)System.out.println("Yes");
		else System.out.println("No");
		sc.close();
	}
}


Measured memory_bytes: 23252
k, n = map(int,input().split())
a = list(map(int,input().split()))

cost = max(a[0]+k-a[-1],a[-1]-a[-2])
for i in range(1,n-1):
    cost = max(a[i]-a[i-1],a[i+1]-a[i],cost)
print(k-cost)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int n;
struct data{
    int to,nxt,c;
}mp[1000100];
int head[500500],cnt=1;
int cur[500500];
void link(int x,int y,int c)
{
    mp[++cnt].to=y;
    mp[cnt].nxt=head[x];
    mp[cnt].c=c;
    head[x]=cnt;
}
void add(int x,int y,int c){link(x,y,c);link(y,x,0);}
int s,t;
int dis[500500];
queue<int>q;
bool BFS()
{
    for(int i=0;i<=t;++i)dis[i]=0;
    dis[s]=1;q.push(s);
    int u,v;
    while(!q.empty())
    {
        u=q.front();q.pop();
        for(int i=head[u];i;i=mp[i].nxt)
            if(mp[i].c&&!dis[mp[i].to])
            {
                v=mp[i].to;
                q.push(v);
                dis[v]=dis[u]+1;
            }
    }
    return dis[t];
}
int dfs(int x,int f)
{
    if(x==t)return f;
    int rf=0,fl;
    for(int& i=cur[x];i;i=mp[i].nxt)
        if(mp[i].c&&dis[mp[i].to]==dis[x]+1)
        {
            fl=dfs(mp[i].to,min(mp[i].c,f));
            if(fl)
            {
                f-=fl;
                rf+=fl;
                mp[i].c-=fl;
                mp[i^1].c+=fl;
                if(!f)break;
            }
        }
    return rf;
}
int Dinic()
{
    int maxflow=0,flow;
    while(BFS())
    {
        for(int i=1;i<=t;++i)cur[i]=head[i];
        while(flow=dfs(s,inf))maxflow+=flow;
    }
    return maxflow;
}

vector<int>bel[100100];
int par[100100];
bool book[100100];
int ed[100100][2],ted;
void solve()
{
    int x,v;
    for(x=2;x<=n;++x)
    {
        for(int i=head[x];i;i=mp[i].nxt)
            if(mp[i].to>n&&mp[i].to<n*2&&!mp[i].c)
                par[mp[i].to-n]=x;
    }
    q.push(1);
    int siz;
    while(!q.empty())
    {
        x=q.front();q.pop();
        siz=bel[x].size();
        for(int i=0;i<siz;++i)
            if(!book[par[bel[x][i]]])
            {
                v=par[bel[x][i]];
                book[v]=1;
                q.push(v);
                ed[bel[x][i]][0]=x;
                ed[bel[x][i]][1]=v;
                ted++;
            }
    }
    if(ted!=n-1)puts("-1"),exit(0);
    for(int i=1;i<n;++i)printf("%d %d\n",ed[i][0],ed[i][1]);
}
int main()
{
    scanf("%d",&n);
    s=n*2;t=s+1;
    int siz,xx;
    for(int i=1;i<n;++i)
    {
        add(i+n,t,1);
        scanf("%d",&siz);
        for(int j=1;j<=siz;++j)
        {
            scanf("%d",&xx);
            bel[xx].push_back(i);
            if(xx!=1) add(xx,i+n,1);
        }
    }
    for(int i=1;i<=n;++i)add(s,i,1);
    int flow=Dinic();
    if(flow!=n-1)
    {
        puts("-1");
        return 0;
    }
    solve();
    return 0;
}


Measured memory_bytes: 28416
#include<stdio.h>
 
main()
{
    char s[101],p[101];
 
     
    scanf("%s",s);
    scanf(" %s",p);
     
    short pcount=0;
    short scount=0;
     
    while(p[pcount]!='\0'){
        pcount++;
    }
     
    while(s[scount]!='\0'){
        scount++;
    }
     
    short i,j;
    short judge = 0;
     
    for(i=0;i<101;i++){
        if(s[i]==p[0]){
            for(j=0;j<pcount;j++){
                if(s[(i+j)%scount] != p[j]){
                    break;
                }
                if(j == pcount-1){
                    judge=1;
                }
            }
        }
         
        if(judge == 1){
            break;
        }
    }
     
    judge ? printf("Yes\n") : printf("No\n");
     
    return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

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

	if (a == b)cout << c << endl;
	else if (b == c)cout << a << endl;
	else cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ld t, x;
    cin>>t>>x;
    cout<<setprecision(10)<<fixed<<t/x;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reps(i, n) for (int i = 1; i <= (int)n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define pb push_back

const int INF = 1e9;

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k << endl;
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓

            var nq = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var n = nq[0];
            var q = nq[1];

            var parent = new int[n];

            for (int i = 0; i < n-1; i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                var a = ab[0] - 1;
                var b = ab[1] - 1;

                parent[b] = a;
            }

            var xs = new int[n];

            for (int i = 0; i < q; i++)
            {
                var px = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                var p = px[0] - 1;
                var x = px[1];

                xs[p] += x;
            }


            var rs = new int?[n];
            rs[0] = xs[0];

            Console.Write(rs[0]);
            Console.Write(' ');

            for (int i = 1; i < n; i++)
            {
                var v = xs[i];

                var newi = parent[i];
                var p = rs[newi];
                if (p.HasValue)
                {
                    v += p.Value;
                    rs[i] = v;
                    Console.Write(v);
                    Console.Write(' ');
                    continue;
                }

                while (!p.HasValue)
                {
                    v += xs[newi];
                    newi = parent[newi];

                    p = rs[newi];
                }

                v += p.Value;
                rs[newi] = v;

                Console.Write(v);
                Console.Write(' ');
            }


			//↑
        }
	}
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    ll k; cin >> k;
    ll n = s.size();
    ll mi = min(n,k);
    rep(i,mi){
        if(s[i] != '1'){
            out(s[i]);
            return 0;
        }
    }
    out(1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long int 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
 
int32_t main()
{
    c_p_c();
    int n; cin>>n;
    int arr[n];
    from(i,n)cin>>arr[i];
    int b[n];
    map<int,int>freq;
    from(i,n){
        b[i]=i+1+arr[i];
        freq[b[i]]++;
    }
    int c[n];
    int ans = 0;
    from(i,n){
        c[i]=i+1-arr[i];
        int temp = freq[c[i]];
        ans+=temp;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 30960
#include <bits/stdc++.h>
// #include<iostream>
// #include<vector>
// #include<cmath>
// #include<iomanip>
using namespace std;

const double PI= acos(-1.0);

int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
   // freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    char ipt; cin >> ipt;
    if(ipt - 'A' < 26 && ipt-'A' >=0){
        cout << 'A';
    }
    else{
        cout << 'a';
    }
    return 0;
}

Measured memory_bytes: 3516
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double r = sc.nextDouble();
    double pi = Math.PI;
    double area = pi*r*r;
    double length = 2*pi*r;
    System.out.printf("%f %f", area, length);
    sc.close();
  }
}



Measured memory_bytes: 28244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            double[] l = new double[10];
            for (int i = 0; i < 10; i++) {
                l[i] = sc.nextDouble();
            }
            int[] count = new int[3];
            for (int i = 0; i < 4; i += 2) {
                for (int j = 0; j < 6; j += 2) {
                    if (ex(l[6 + i], l[7 + i], l[j], l[j + 1], l[(j + 2) % 6], l[(j + 3) % 6]) > 0) {
                        count[i / 2]++;
                    }
                }
                if (count[i / 2] % 3 == 0) {
                    count[2]++;
                }
            }
            System.out.println(count[2] == 1 ? "OK" : "NG");
        }
    }

    static double ex(double... l) {
        return (l[2] - l[0]) * (l[5] - l[1]) - (l[4] - l[0]) * (l[3] - l[1]);
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	double R1, R2;
	cin >> R1 >> R2;
	cout << fixed << setprecision(10) << 1.0 / (1.0 / R1 + 1.0 / R2) << endl;
	return (0);
}


Measured memory_bytes: 256
S = input()
ANS = {0:'NA', 1:'YYMM', 2:'MMYY', 3:'AMBIGUOUS'}
ans = 0
if '00' <= S[:2] <= '99' and '01' <= S[2:] <= '12':
    ans += 1
if '00' <= S[2:] <= '99' and '01' <= S[:2] <= '12':
    ans += 2
print(ANS[ans])


Measured memory_bytes: 9012
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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

const double PI=3.14159265358979323846;

int main(){
  double a,b,h,m,x1,y1,x2,y2,c,d,ans;
  cin>>a>>b>>h>>m;
  
  c=(60*h+m)/360*PI;
  d=m*PI/30;
  
  x1=a*cos(c);
  y1=a*sin(c);
  x2=b*cos(d);
  y2=b*sin(d);
  
  ans=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  cout << fixed << setprecision(15) << ans <<endl;
  
  return 0;
}

Measured memory_bytes: 4132
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	int mn = min(n, (ll)m);
	vector<pair<int,int>> P; // (x,pre_sum)
	ll sum_p = 0; // sum of pre + cycle
	vector<int> X(m, -1); // for cycle check & pre_len
	rp(i, 0, mn){
		if(X[x] > -1){
			int cyc_len = P.size() - X[x];
			ll remain = P[X[x]].second;
			ll cyc = (sum_p - remain) * ((n - X[x]) / cyc_len);
			remain +=P[X[x] + (n - X[x]) % cyc_len].second - P[X[x]].second;
			cout<< cyc + remain <<endl;
			return 0;
		}
		P.emplace_back(x, sum_p);
		sum_p += x;
		X[x] = i;
		x = (ll)x*x % m;
	}
	cout<< sum_p <<endl;
}


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

int main() {
  string S;
  cin >> S;
  S += 'R';

  int len_R = 1, len_L = 0;
  
  char c, d;

  for(int i = 0; i < S.size() - 1; i++) {
    c = S.at(i);
    d = S.at(i + 1);
    
//  cout << "c = " << c << ", d = " << d << endl;
    
    if (c == 'R' && d == 'R') {
      len_R++;
    } else if (c == 'R' && d == 'L') {
      len_L = 1;
    } else if (c == 'L' && d == 'L') {
      len_L++;
    } else if (c == 'L' && d == 'R') {
      int n = len_R + len_L;
      
      for (int j = 1; j <= len_R - 1; j++) {
        cout << 0 << " ";
      }
      
      if (n % 2 == 0) {
        cout << n / 2 << " " << n / 2 << " ";
      } else {
        cout << n / 2 + len_R % 2 << " " << n / 2 + len_L % 2 << " ";
      } 
      
      for (int j = 1; j <= len_L - 1; j++) {
        cout << 0 << " ";
      }

      len_R = 1;
      len_L = 0;
    }
    
//  cout << "len_R = " << len_R << ", len_L = " << len_L << endl;
  }
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author P.Alizadeh
 */

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

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll,ll>     pll;

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define trace(x)        cerr << #x << " = " << x << endl;
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 2e5 + 10,
        INF  = 8e18,
        MOD  = 1e9 + 7;
//const ld PI   = acos(-1);

ll n, m, h[MAXN], dp[MAXN];

int main()
{
    fastio;
    //ld_io;

    cin >> n >> m;
    for (ll i = 0; i < n; i++) {
        cin >> h[i+1];
    }

    dp[1] = 0;
    for (ll i = 2; i <= n; i++) {
        dp[i] = INF;
        for (ll j = 1; j <= m && (i - j) > 0; j++) {
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n] << endl;

    return 0;
}



Measured memory_bytes: 1792
n = int(input())
a = list(int(i) for i in input().split())
aodd = []
aeven = []
for i in range(n):
 if i%2 == 1: aodd.append(a[i])
 else: aeven.append(a[i])
ans = []
if n%2 == 0:
  aeven.reverse()
  ans = aeven + aodd
else:
  aodd.reverse()
  ans = aodd+ aeven
ans.reverse()
  
print(*ans)

Measured memory_bytes: 26020
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> num(100100, 0);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        num[a] += b;
    }
    int ans;
    ll tot = 0;
    rep(i, num.size()) {
        tot += num[i];
        if(tot >= k) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

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

  vector<ll> w(N), v(N);

  rep(i, N) {
    cin >> w[i] >> v[i];
  }

  vector< vector<ll> > dp(N+1, vector<ll>(W+1, 0));

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= W; ++j) {
      if (j - w[i - 1] >= 0) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
      } else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  cout << dp[N][W] << endl;
}


Measured memory_bytes: 80256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[][] c = new int[4][4];

        for (int i = 1; i <= 3; i++) {
            for (int j = 1; j <= 3; j++) {
                c[i][j] = sc.nextInt();
            }
        }

        if (c[2][1] - c[1][1] == c[2][2] - c[1][2] &&
                c[2][1] - c[1][1] == c[2][3] - c[1][3] &&
                c[3][1] - c[1][1] == c[3][2] - c[1][2] &&
                c[3][1] - c[1][1] == c[3][3] - c[1][3]) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }
}

Measured memory_bytes: 23764
R=[0]
L=list()
N=int(input())
for i in range(N):
  k=int(input())
  L.append(k)
  if k==0:
    R.append(len(L))
S=sum(L)
R.append(N)
for i in range(len(R)-1):
  if sum(L[R[i]:R[i+1]])%2==1:
    S=S-1
print(S//2)

Measured memory_bytes: 85968
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int ans = 0;
        for(int i=0; i<n; i++){
            char ac = a.charAt(i);
            char bc = b.charAt(i);
            char cc = c.charAt(i);
            if(ac == bc && bc == cc){
                //
            }else if(ac == bc || bc == cc || cc == ac){
                ans ++;
            }else{
                ans += 2;
            }
        }
        System.out.println(ans);
    }
}

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

#define forw(m,i,n) for(i=m; i<n; i++)
#define done return 0
#define in(x) cin >> x
#define out(x) cout << x << endl
#define pb(x) push_back(x)
#define w(x) while(x--)
#define maxx 1000000000

using namespace std;

typedef long long ll;

map<string,string> inp;

int main() {
    //freopen("output.txt","w",stdout);
    //freopen("input.txt","r",stdin);
    int m,n,i;
    in(n),in(m);
    string ss[n];
    for(i=0;i<n; i++) {
        cin>>ss[i];
    }
    sort(ss,ss+n);
    for(i=0;i<n;i++) {
        cout << ss[i];
    }
    cout << endl;
    done;
}

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

#define int long long
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;

string s;
int n;
char endc;
vector<int> p[26];
int pre[300010];

int dij() {
  bool used[n+10] = {0};
  queue<Pip> Q;
  for ( int i = 0; i < 26; i++ ) {
    if ( p[i].size() == 0 ) continue;
    Q.push(Pip(1, Pii(i*i, p[i][0])));    
    used[p[i][0]] = true;
  }

  while ( !Q.empty() ) {
    Pip q = Q.front(); Q.pop();
    int c = q.first, v = q.second.second;
    int u = q.second.first;

    //cout << v << endl;

    if ( v == n+1 ) {
      return c;
    }

    /*if ( v == 126 ) {
      cout << "ac";
    }
    if ( v == 85 ) {
      cout << "ba" << endl;
      }*/
    for ( int i = 0; i < 26; i++ ) {
      auto it = upper_bound(p[i].begin(), p[i].end(), v);
      if ( it == p[i].end() ) {
	if ( used[n+1] ) continue;
	used[n+1] = true;
	endc = 'a'+i;
	pre[n+1] = v;
	Q.push(Pip(c+1, Pii(i, n+1)));
      } else {
	if ( used[*it] ) continue;
	used[*it] = true;
	pre[*it] = v;
	Q.push(Pip(c+1, Pii(i, (int)(*it))));	
      }
    }
  }
}

signed main() {
  cin >> s;
  n = s.size();
  for ( int i = 0; i < n; i++ ) {
    p[s[i]-'a'].push_back(i);
    //if ( s[i] == 'c' ) cout << i << " ";
  }
  //cout << endl;
  

  for ( int i = 0; i < 26; i++ ) {
    if ( p[i].size() == 0 ) {
      cout << (char)('a'+i) << endl;
      return 0;
    }
  }

  for ( int i = 0; i < 300001; i++ ) pre[i] = -1;

  int cost = dij();
  //cout << cost << endl;

  int now = n+1;
  string ans = "";
  while ( pre[now] != -1 ) {
    ans.push_back(s[pre[now]]);
    //cout << s[pre[now]] << " " << pre[now] << endl;
    now = pre[now];
  }

  for ( int i = ans.size()-1; i >= 0; i-- ) cout << ans[i];  
  cout << endc << endl;
  
  return 0;
}


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

int main() {
	long long int n;
	cin>>n;
	vector<long long int>a(n);
	for(long long int i = 0 ; i < n ; i++) cin>>a[i];
    long long int dp[n][n];
    for(int i = 0 ; i < n ; i++){
        for(long long int j = 0 ; j < n ; j++){
            dp[i][j] = 0;
        }
    }
    for(long long int i = 0 ; i < n ; i++){
        dp[i][i] = a[i];
    }
    for (long long int size = 1 ; size < n ; size++){
        long long int i = 0;
        long long int j = i+size;
        while(j < n){
            dp[i][j] = max(a[i] - dp[i+1][j],a[j] - dp[i][j-1]);
            i++;j++;
        }
    }
    cout<<dp[0][n-1]<<endl;
	return 0;
}


Measured memory_bytes: 70528
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
    while(x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x) {
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) {
    Node *y; //object to delete
    Node *x; //child of y
    
    //decide which node is deleted
    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);
    
    //define x which is a child of y
    if(y->left != NIL) {
        x = y->left;
    }else {
        x = y->right;
    }
    
    if(x != NIL) {
        x->parent = y->parent;
    }
    
    if(y->parent == NIL) {
        root = x;
    }else {
        if(y == y->parent->left) {
            y->parent->left = x;
        }else {
            y->parent->right = x;
        }
    }
    
    if(y != z) {
        z->key = y->key;
    }
    
    free(y);
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        }else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    }else {
        if(z->key < y->key) {
            y->left = z;
        }else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++) {
        cin >> com;
        if(com[0] == 'f') {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }else if(com == "delete") {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }
    
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 700;
    if (s[0] == 'o') counter += 100;
    if (s[1] == 'o') counter += 100;
    if (s[2] == 'o') counter += 100;
    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

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

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

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int x,y,z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256