akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n;
    cin >> n;
    deque<int> v;
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        if(i % 2) v.push_front(a);
        else v.push_back(a);
    }
    if(n % 2){
        for (int i = 0; i < n; ++i) {
            int k = v.back(); v.pop_back();
            if(i) cout << " " << k;
            else cout << k;
        }
    }else {
        for (int i = 0; i < n; ++i) {
            int k = v.front(); v.pop_front();
            if(i) cout << " " << k;
            else cout << k;
        }
    }
    cout << "\n";
    return 0;

}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  
  string s,t;
  
  cin >> s >> t;
  
  int f = 0;
  
  string a[2] = {"",""};
  
  int n = s.size();
  
  for(int i = 0; i < n ; i++)a[i%2] += s[i];
  
  for(int i = 0; i < 2 ; i++){
    
    int cnt = 0;
    
    for(int j = 0 ; j < n ; j++){
	 
	 if(cnt < a[i].size()&&t[j] == a[i][cnt])cnt++;
	 
    }
    
    if(cnt == a[i].size())f = 1;
  }
  
  cout << (f?"Yes":"No") << endl;
  
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,m;
    cin>>n>>m;
    if(abs(n-m)>1)
        cout<<0<<endl;
    else
    {ll ans=1;
        for(int i=1;i<=n;i++)
        {
             ans=(ans*i)%mod;
        }
        for(int i=1;i<=m;i++)
        {
            ans=(ans*i)%mod;
        }
        if(n==m)
            ans=ans*2%mod;
        cout<<ans<<endl;
    }

    
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


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

int main(){
  ll N,K,Q;cin>>N>>K>>Q;
  VL A(Q);
  VL point(N);
  REP(i,Q){
    cin>>A[i];
  }
  REP(i,N)
  {
    point[i]=0;
  }
  REP(i,Q){
    point[A[i]-1]=point[A[i]-1]+1;
  }
  REP(i,N){
    ll tmp;
    tmp=K-Q+point[i];
    if(tmp>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }

  }
return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <list>
#include <climits>

using namespace std;

const int mod = 1e9 + 7;
int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<int>> dp(H, vector<int>(W,0));


    char val[H][W];
    for(int i = 0; i < H; ++i)
        for(int j = 0; j < W; ++j)
            cin >> val[i][j];

    dp[0][0] = 1;
    for(int i = 1; i < W; ++i)
        if(val[0][i] == '.')
            dp[0][i] = dp[0][i - 1];

    for(int i = 1; i < H; ++i)
        if(val[i][0] == '.')
            dp[i][0] = dp[i - 1][0];

    for(int i = 1; i < H; ++i)
        for(int j = 1; j < W; ++j)
        {
            if(val[i][j] == '.')
            {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                if(dp[i][j] >= mod)
                    dp[i][j] -= mod;
            }
        }

    cout << dp[H - 1][W - 1] << "\n";

    return 0;
}


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

#define ll long long
#define rep(i,a,n) for(ll i=a;i<=n;i++)
#define rop(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define pob pop_back
#define pf push_front
#define pis pair<int, string>
#define pof pop_front
#define pii pair<int,int>
#define pll pair<ll, ll>
#define mp make_pair
#define fi first
#define se second
#define endl '\n'

const int dr[]={-1,1,0,0};
const int dc[]={0,0,1,-1};
const int drd[]={-1,-1,1,1};
const int dcd[]={-1,1,-1,1};
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 1e5 + 5;
const double phi= acos(-1);

bool isPrime[1000005];
bool vis[1000005];
void sieve()
{
	rep(i,2,1000003)
	{
		if(vis[i]) continue;
		isPrime[i]=1;
		vis[i]=1;
		for(int j=i;j<=1000003;j+=i)
		{
			vis[j]=1;
		}
	}
}
int n,m,s,t,a,b;
vector <int> lst[MAX];
queue <int> q;
pii dis[MAX];
int vis1, vis2;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	sieve();
	cin>>n>>m>>s>>t;
	rep(i,1,n) dis[i]={INF,INF};
	rep(i,1,m)
	{
		cin>>a>>b;
		lst[a].pb(b);
		lst[b].pb(a);
	}
	q.push(s);
	dis[s]={0,0};
	while(!q.empty())
	{
		int tmp=q.front();
		q.pop();
		int sz=lst[tmp].size();
		rop(i,sz)
		{		
			if(dis[tmp].fi+1 < dis[lst[tmp][i]].se) 
			{
				q.push(lst[tmp][i]);
				dis[lst[tmp][i]].se=dis[tmp].fi+1;	
			}
			else if(dis[tmp].se+1 < dis[lst[tmp][i]].fi) 
			{
				q.push(lst[tmp][i]);
				dis[lst[tmp][i]].fi=dis[tmp].se+1;	
			}
			
		}
	}
	if(dis[t].se!=INF)
	{
		while(isPrime[dis[t].se]==0) dis[t].se+=2;
	}
	if(dis[t].fi==2)
	{
		cout<<2<<endl;
	}
	if(dis[t].fi!=2)
	{
		if(dis[t].se!=INF) cout<<dis[t].se<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}




Measured memory_bytes: 11296
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;
int n,m;
long long a[105],b[100005],c[105];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i]>>c[i];
	for(int i=1;i<=n;i++){
		for(int j=m;j>=a[i];j--){
			b[j]=max(b[j-a[i]]+c[i],b[j]);
		}
	}
	cout<<b[m];
	return 0;
}

Measured memory_bytes: 1152
import math

A, B, H, M = map(int, input().split())

wA = math.pi/6
wB = math.pi/30

thetaA = wA*(H+M/60)
thetaB = wB*M

dtheta = abs(thetaA-thetaB)
if dtheta > math.pi:
    dtheta = 2*math.pi - dtheta

c = math.sqrt(A*A + B*B - 2*A*B*math.cos(dtheta))

print(c)

Measured memory_bytes: 9444
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b)
{
    while (b != 0) swap(b, a %= b);
    return a;
}

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x : vect)
        cout << x << " ";
    cout << "\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
//LCM
int lcm(int a, int b)
{
    return a * (b / gcd(a, b));
}

//For sort by second
bool cmp(const pair<int, int> &a)
{
    return a.first < a.second;
}

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower

void add_self(ll &a, ll b)
{
    a += b;
    if(a >= mod)
        a -= mod;

}
vector<vector<ll> > mul(vector<vector<ll> >A, vector<vector<ll> >B)
{
    ll n = A.size();

    vector<vector<ll> >res(n, vector<ll>(n,0));


    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            for(int k = 0; k < n; k++)
            {
                res[i][j] =(res[i][j]+ A[i][k] * B[k][j])%mod;
            }
        }
    }

    return res;
}




vector<vector<ll> > pow(vector<vector<ll> > &mat, ll power)
{
   
    if(power==1)
        return mat;
    vector<vector<ll> >res=pow(mat,power/2);

     if(power&1LL)
        return mul(mul(mat,res),res);

    return mul(res,res);

}

ll solve(vector<vector<ll > >mat,ll k )
{
    vector<vector<ll> >ak=pow(mat,k);

    ll res=0;
    ll n=mat.size();
    for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            add_self(res,ak[i][j]);

    return res;

}


int main()
{
    FASTIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n, k;
    cin >> n >> k;

    vector<vector<ll> >adj(n, vector<ll>(n));

    for(ll i = 0; i < n; i++)
        for(ll j = 0; j < n; j++)
            cin >> adj[i][j];

    cout << solve(adj, k) << "\n";


    return 0;
}

Measured memory_bytes: 3792
n = int(input())
List = list(map(int, input().split()))
standard = [i+1 for i in range(n)]
gap = [List[i] - standard[i] for i in range(n)]

if gap.count(0)== n-2 or gap.count(0) ==n:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{   
    int N,L[10];
    int i,j,tmp,S=0;
  
    scanf("%d",&N);
    
    for(i=0;i<N;i++)
      scanf("%d",&L[i]);
  
    for(i=0;i<N;i++){
      for(j=i+1;j<N;j++){
        if(L[i]>L[j]){
          tmp=L[i];
          L[i]=L[j];
          L[j]=tmp;
        }
      }
    }
  
    for(i=0;i<N-1;i++)
      S+=L[i];
    
    if(S>L[N-1]) printf("Yes\n");
    else printf("No\n");
  
    return 0;
}


Measured memory_bytes: 1636
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		String[] str = N.split("");
		String s1, s2 = "";
		int cnt = 0;
		s1 = str[0];
		for (String a : str) {
			if (!((a.equals(s1) && !a.equals(s2)) || ((!a.equals(s1) && a.equals(s2))))) {
				cnt++;
			}
			if (!a.equals(s1) && s2.equals(""))
				s2 = a;
		}
	if(cnt==1)System.out.println("Yes");
	else System.out.println("No");
	}
}

Measured memory_bytes: 23764
n=int(input())
A=list(map(int,input().split()))
a=0
for i in range(n):
  if A[i]%2==0:
    if A[i]%3==0 or A[i]%5==0:
      continue
    else:
      a=1
      break
if a==0:
  print("APPROVED")
else:
  print("DENIED")
      

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        String s = sc.next();
        int len = s.length();
        int k = sc.nextInt();
        long[][][] dp = new long[len+1][k+1][2];
        dp[0][0][0] = 1;
        for(int i = 1; i <= len; i++){
            int next = s.charAt(i-1) - '0';
            for(int j = 0; j <= k; j++){
                dp[i][j][1] = dp[i-1][j][1];
                if(j > 0){
                    dp[i][j][1] += dp[i-1][j-1][1] * 9;
                }
                if(next == 0){
					dp[i][j][0] = dp[i-1][j][0];
				}else{
					dp[i][j][1] += dp[i-1][j][0];
					if(j > 0) {
						dp[i][j][0] = dp[i-1][j-1][0];
						dp[i][j][1] += dp[i-1][j-1][0] * (next-1);
					}
				}
            }
        }
        System.out.println(dp[len][k][0] + dp[len][k][1]);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21204
#include<iostream>
#include<cctype>

using namespace std;

int main(void){

  string str,jud;
  bool first=true;

    while(cin>>str){
      for(int i=0;i<str.size();i++){
        if(islower(str[i])) str[i]=toupper(str[i]);
        else if(isupper(str[i])) str[i]=tolower(str[i]);
      }
      if(first){
        first=false;
        cout<<str;
      }
      else cout<<" "<<str;


  }
  cout<<endl;
return 0;
}



Measured memory_bytes: 3144
A = int(input())
B = int(input())

if A ==1 and B==2:
    print(3)
elif A==1 and B==3:
    print(2)
elif A==2 and B ==1:
    print(3)
elif A==2 and B==3:
    print(1)
elif A==3 and B==1:
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] NY = readln.chomp.split.to!(int[]);
  int N = NY[0],
      Y = NY[1] / 1000;

  foreach (int i; 0..N+1) {
    foreach (int j; 0..N+1) {
      int k = N - i - j;
      if (k < 0) { continue; }
      int t = i + j*5 + k*10;
      if (t == Y)  {
        writefln("%d %d %d", k, j, i);
        return;
      }
    }
  }

  writeln("-1 -1 -1");
}


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

using namespace std;
using u64 = std::uint_fast64_t;

template <typename T> T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

template <typename T> T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int div2cnt(int x) {
  int res = 0;
  while (x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<u64> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] >>= 1;
  }
  int cnt = div2cnt(A[0]);
  for (int i = 0; i < N; i++) {
    if (cnt != div2cnt(A[i])) {
      cout << 0 << '\n';
      return 0;
    }
  }
  u64 l = 1;
  for (int i = 0; i < N; i++) {
    l = lcm(l, A[i]);
  }
  cout << (M / l + 1) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 1024
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
H,W=H-1,W-1
if not (A[0][0]==A[-1][-1]=="#"):
    print("Impossible")
    exit()

h=0
w=0
while H>h or W>w:
    if H>h and W>w:
        if A[h+1][w]=="#" and  [1 for w_ in range(w+1,W+1) if A[h][w_]=="#"] or A[h][w+1]=="#" and  [1 for h_ in range(h+1,H+1) if A[h_][w]=="#"]:
            print("Impossible")
            exit()
        elif A[h+1][w]=="#":
            h+=1
        elif A[h][w+1]=="#":
            w+=1
        else:
            print("Impossible")
            exit()
    elif H>h and A[h+1][w]=="#":
        h+=1
    elif W>w and A[h][w+1]=="#":
        w+=1
    else:
        print("Impossible")
        exit()

print("Possible")


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

const int inf = 1e9;
const int maxn = 1e5 + 5;
int a[maxn], b[maxn], min_a = inf, min_b = inf;
int n_a, n_b, m, ans = inf;
int main(){
	scanf("%d%d%d",&n_a,&n_b,&m);
	for(int i=1;i<=n_a;i++) scanf("%d",&a[i]), min_a = std::min(min_a, a[i]);
	for(int i=1;i<=n_b;i++) scanf("%d",&b[i]), min_b = std::min(min_b, b[i]);
	ans = std::min(ans, min_a + min_b);
	for(int i=1;i<=m;i++){
		int x, y, z;
		scanf("%d%d%d",&x,&y,&z);
		ans = std::min(ans, a[x] + b[y] - z);
	}
	printf("%d\n", ans);
	return 0;
}

	

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main(){

    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    vector<vector<ll>> dp(2, vector<ll>(s.size()+1, 0));

    dp[1][0] = 3;
    for(int i = 1; i < s.size()+1; i++)
        dp[1][i] = ( dp[1][i-1]*3 )%MOD;

    if( s[0] == '0' )
        dp[0][0] = 1;
    else
        dp[0][0] = 3;

    for(int i = 1; i < s.size(); i++)
        if( s[i] == '0' )
            dp[0][i] = dp[0][i-1];
        else
            dp[0][i] = (dp[0][i-1]*2 + dp[1][i-1])%MOD;


    cout << dp[0][s.size()-1]%MOD << endl;
    return 0;
}

Measured memory_bytes: 2816
from itertools import permutations

N,M=map(int,input().split())
L=[]
for i in range(N-1):
    L.append(1+i)
A=[]
a=[]
for i in range(N):
    for j in range(N):
        a.append(10)
    A.append(a)
    a=[]
    
#print(A)

for i in range(M):
    a,b=map(int,input().split())
    A[a-1][b-1]=1
    A[b-1][a-1]=1

#print(A)
cnt=0
for i in permutations(L,len(L)):
    S=0
    for j in range(len(i)-1):
        if A[i[j]][i[j+1]]==10:
            break
        else:
            S+=1
    if S==len(L)-1:
        if A[0][i[0]]==1:
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
   int n;
   cin >> n;
   string s,t;
   cin >> s >> t;
   string ans = "";
   rep(i,n){
      ans += s[i];
      ans += t[i];
   }
   cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define fs first
#define ss second
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){

   int n;
   cin >> n;
   
   vector<pair<double, pair<double,double> > > deg;
   
   rep(i,0,n){
	  
	  double x,y;
	  cin >> x >> y;
	  deg.push_back(mp(atan2(y,x),mp(x,y))); 
	   
   }
	 sort(deg.begin(),deg.end());
	 
	long double ans = 0;
	
	rep(i,0,n){
		long double x = 0.0000;
		long double y = 0.0000;
		
		rep(j,0,n){
		 
		 x+= deg[(i+j)%n].ss.fs;
		 y+= deg[(i+j)%n].ss.ss;
		 amax(ans,sqrt(x*x + y*y));
		 
	}
	
	}
	 
	 cout << setprecision(30) << ans <<endl;
	     
	   
   } 





Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

vector<int> g[200010];
int d[200010];

void dfs(int v,int depth){
    if(depth>2 || d[v]>0)return;
    d[v] = depth;
    for(int u : g[v]){
        dfs(u,depth+1);
    }
}

int main(void){
    int n,m;
    cin>>n>>m;

    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,0);
    cout<<(d[n-1]==2 ? "POSSIBLE" : "IMPOSSIBLE")<<endl;
    return 0;
}


Measured memory_bytes: 12784
#include <stdio.h>

int main(void) {
  int H, W;
  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0) break;
    int i, j;
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	int N, D;
	cin >> N >> D;
	int ans = N/(2*D+1);
	if(ans*(2*D+1)<N) ans++;
	
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N;cin>>N;
    int a=0,b=0,c=0,d=0;
    REP(i,N){
        char s;cin>>s;
        if(s=='G')a=1;
        if(s=='P')b=1;
        if(s=='W')c=1;
        if(s=='Y')d=1;
    }
    if(a==1&&b==1&&c==1&&d==1)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

num = '0123456789'
cnt = 0
for i in num:
    for j in num:
        for k in num:
            if i in s:
                idx1 = s.find(i)
                if j in s[idx1 +1 :]:
                    idx2 = s.find(j, idx1 + 1)
                    if k in s[idx2 + 1:]:
                        idx3 = s.find(k, idx2 + 1)
                        cnt += 1
print(cnt)

Measured memory_bytes: 9216
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k = (n-i-j)
        if 10000*i + 5000*j + 1000*k == y:
            print(i,j,k)
            exit()
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int ans=k;
    rep(i,n-1) ans*=(k-1);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: chars
    }

    if s[1] == 'R' {
        println!("ABC");
    } else {
        println!("ARC");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2240
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
   ll K,T;
   cin>>K>>T;
   vector<ll> c(T,0);
   for(ll i=0;i<T;i++){
     cin>>c[i];
   }

  ll M = *max_element(ALL(c));


  ll dd = K-2*M;
  if(dd>=0){
dd =0;
  }
  else{
    dd = abs((K-2*M))-1;
  if(dd<=0){
dd =0;
  }

  }
  

  cout<<dd<<endl;





}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();

            int max = 1;
            for (int i = 2; i * i <= n; i++) {
                int cn = i * i;
                while (cn <= n) {
                    if (cn > max)
                        max = cn;
                    cn *= i;
                }
            }

            out.println(max);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll sum = 0;
	for (int i = 0; i < 1000; i++) {
		int t = i % 10;
		int cache = i;
		int c = 0;
		for (int j = n - 1; j >= 0; j--) {
			if (s[j] - '0' == t) {
				c++;
				cache /= 10;
				t = cache % 10;
				if (c == 3) {
					sum++;
					break;
				}
			}
			if (c == 3) {
				break;
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3668
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

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

  if(s=="Sunny") cout << "Cloudy" << endl;
  if(s=="Cloudy") cout << "Rainy" << endl;
  if(s=="Rainy") cout << "Sunny" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  while(true){
    int b=0;
    for(int i=0;i<n;i++){
      if(a[i]%2==1){
        goto endloop;
      }else{
        if(a[i]==0)
          b++;
        a[i]/=2;
        
      }
    }
    if(b==n)
      break;
    c++;
  }
  endloop:
  cout<<c;
}

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

int main()
{
	int N;
	int d[99], i,j;
	int cnt;
	int result;

	cnt = 1;
	result = 0;

	cin >> N;

	for (i = 0; i < N; i++) {
		cin >> d[i];
	}

	for (i = 0; i < N; i++) {
		if(0<i<N){
			for (j = cnt; j < N; j++) {
				result = d[i] * d[j] + result;
			}
			cnt++ ;
		}

	}

	cout << result;

#if 0
	for (i = 0; i < N; i++) {

		cout << d[i];
	
	}
#endif

	return 0;
}


Measured memory_bytes: 256
// AOJ1053 Accelerated Railgun

#include <iostream>
#include <complex>

using namespace std;

typedef complex<double> P;

double dot(P a, P b){ return real(conj(a)*b); }
double cross(P a, P b){ return imag(conj(a)*b); }

int main(){
	double d;
	while(cin >> d){
		if(d == 0.0) break;
		double px, py, vx, vy;
		cin >> px >> py >> vx >> vy;
		P p = P(px, py), v = P(vx, vy);
		if(abs(cross(p,v)) < 1e-8){
			double L = 0.0;
			if(dot(p,v) > 0) L = 2.0 - abs(p);
			else             L = abs(p);
			if(L < d-1e-8){
				printf("%.8lf\n", L);
				continue;
			}
		}
		puts("impossible");
	}
}

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

int h;
int w;

char buf[102];
vector<string> v;
int main(){
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++){
		scanf("%s", buf);
		v.push_back(buf);
		v.push_back(buf);
	}
	for (int i = 0; i < v.size(); i++){
		printf("%s\n", v[i].c_str());
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int A[3];
    for(int i=0;i<3;i++){
        cin>>A[i];
    }
    cout<<max({A[0],A[1],A[2]})-min({A[0],A[1],A[2]})<<endl;
}

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

char getch()
{
    static char buf[1<<14],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<14,stdin),p1==p2)?EOF:*p1++;
}

void read(int &x)
{
    x=0;
    char c=getch();
    while(c<'0'||c>'9') c=getch();
    while(c>='0'&&c<='9')
    {
        x=(x<<1)+(x<<3)+(c-'0');
        c=getch();
    }
}

int n,sum,m,p,x;
int a[101];

int main()
{
	read(n);
	for(int i=1;i<=n;++i)
	{
		read(a[i]);
		sum+=a[i];
	}
	read(m);
	while(m--)
	{
		read(p);read(x);
		printf("%d\n",sum-a[p]+x);
	}
	return 0;
}

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

using namespace std;

const int N = 1e5 + 2;

int n, w, a[N], b[N];
long long dp[N];

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

    for(int i = 1; i < N; i ++){
        dp[i] = 1e18;
    }

    for(int i = 1; i <= n; i ++){
        cin >> a[i] >> b[i];
        for(int j = N - 1; j >= b[i]; j --){
            dp[j] = min(dp[j - b[i]] + a[i], dp[j]);
        }
    }

    for(int i = N - 1; i >= 0; i --){
        if(dp[i] <= w){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
n = int(input())
me = [0,0]
arr = []
tmp = 0
flg = True
for i in range(n):
    arr += [list(map(int,input().split()))]

for t in arr:
    for _ in range(t[0]-tmp):
        if me[0] < t[1]:
            me[0] += 1
        elif me[0] > t[1]:
            me[0] -= 1
        elif me[1] < t[2]:
            me[1] += 1
        elif me[1] > t[2]:
            me[1] -= 1
        else:
            me[0] += 1
        tmp = t[0]
    if me != t[1:]:
        flg = False
        break
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,H,W;cin>>N>>W>>H;
        if(N+H+W==0) break;
        vector<pair<int,int>> A(N+1),B(N+1);
        A[0]={0,0};
        B[0]={H,W};
        
        for(int i=0;i<N;i++){
            int p,s;cin>>p>>s;
            p--;
            int m=(B[p].second-A[p].second),n=(B[p].first-A[p].first);
            s%=2*(m+n);
            if(s<=m||(m+n<=s&&s<=m+n+m)){
                if(s>=m+n) s=m+n+m-s;
                B[i+1]=B[p];
                A[i+1]={A[p].first,A[p].second+s};
                B[p].second=A[p].second+s;
                
                if(B[p].second-A[p].second>B[i+1].second-A[i+1].second){
                    swap(A[p],A[i+1]);
                    swap(B[p],B[i+1]);
                }
            }else{
                if(s>=m+n+m) s=m+n+m+n-s;
                else if(s>=m) s-=m;
                
                B[i+1]=B[p];
                A[i+1]={A[p].first+s,A[p].second};
                B[p].first=A[p].first+s;
                
                if(B[p].first-A[p].first>B[i+1].first-A[i+1].first){
                    swap(A[p],A[i+1]);
                    swap(B[p],B[i+1]);
                }
            }
            
            for(int j=p+1;j<i+1;j++){
                swap(A[j-1],A[j]);
                swap(B[j-1],B[j]);
            }
        }
        
        vector<int> ans(N+1);
        
        for(int i=0;i<N+1;i++){
            ans[i]=(B[i].first-A[i].first)*(B[i].second-A[i].second);
        }
        
        sort(all(ans));
        
        for(int i=0;i<ans.size();i++){
            if(i) cout<<" ";
            cout<<ans[i];
        }
        cout<<endl;
    }
}







Measured memory_bytes: 3136
import sys
from bisect import bisect_right as bi_r, bisect_left as bi_l
inf = float('inf')

n, *a = map(int, sys.stdin.read().split())

def main():
  res = [inf] * n
  for x in a[::-1]:
    res[bi_r(res, x)] = x
  print(bi_l(res, inf))

if __name__ == '__main__':
  main()

Measured memory_bytes: 14092
/*
 ============================================================================
 Name        : AOJ.c
 Author      :
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>

int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%d %d\n",a*b,(a+b)*2);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,k;
    cin >> n>> k;
    bool checked[n];
    set<ll> neighbor[n];
    queue<ll> que;
    rep(i,n-1){
        ll tmpa,tmpb;
        cin >> tmpa >> tmpb;
        tmpa--;
        tmpb--;
        neighbor[tmpa].insert(tmpb);
        neighbor[tmpb].insert(tmpa);
    }
    for(auto x:neighbor[0]){
        que.push(x);
        checked[x]=true;
        neighbor[x].erase(0);
    }
    ll res=0;
    res+=k;
    rep(i,que.size()){
        res *= k-1-i;
        res %= MOD;
    }
    // checked[0]=true;
    while(!que.empty()){
        ll cur=que.front();
        que.pop();
        DEBUG{
            cout << "cur "<<cur << endl;
        }
        rep(i,neighbor[cur].size()){
            res *= k-2-i;
            res %=MOD;
        }
        for(auto x:neighbor[cur]){
            // if(!checked[x]){
                que.push(x);
                neighbor[x].erase(cur);
                // checked[x]=true;
            // }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 15104
N = int(input())
A = list(map(int, input().split()))
H = [0] * 3
P = 1
for i in A:
	if H.count(i) == 0:
		P = 0
		break
	P *= H.count(i)
	P %= 1000000007
	H[H.index(i)] += 1
print(P)

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

int main() {

    int a,b,x;
    cin>>a>>b>>x;

    if(x==a){
        cout<<"YES"<<endl;
    }
    else if(x>a && x<=a+b){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, k, ans = 1; cin >> n >> k;
  vector<int> v(n);
  rep(i, n)cin >> v[i];
  int i = k;
  while(n > i){
    ans++;
    i += k-1;
  }  
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vd vector<double>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
typedef pair<int,Pi> Pii;
typedef pair<ll,int> Pl;
typedef pair<int,Pl> Pil;
const int inf=1000000000;
const ll inf2=1000000000000000;
const int np=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<string> word;
vector<string> rword;

int rev(int high,int low,string str1){
	if(high-low<2)return low;
	int mid=(high+low)/2;
	if(word[mid]>=str1){
		return rev(mid,low,str1);
	}else{
		return rev(high,mid,str1);
	}
}
int revR(int high,int low,string str1){
	if(high-low<2)return low;
	int mid=(high+low)/2;
	if(rword[mid]>=str1){
		return revR(mid,low,str1);
	}else{
		return revR(high,mid,str1);
	}
}


int main() {

	string al="abcdefghijklmnopqrstuvwxyz{";
	int n,m;
	cin>>n>>m;

	rep(i,n){
		string str;
		cin>>str;
		word.push_back(str);
		if(str.size()>1)reverse(str.begin(),str.end());
		rword.push_back(str);
	}
	sort(word.begin(),word.end());
	sort(rword.begin(),rword.end());


	rep(i,m){
		string str;
		int total=0;
		cin>>str;
		int num=str.length();
		bool flg=true;
		if(str[0]=='*'){
			reverse(str.begin(),str.end());
			rep(j,num){
				if(flg&&(str[j]=='?')){
					rep(k,26){
						str[j]=al[k];
						str.pop_back();
						int it1=revR(n,-1,str);
						str=str+'{';
						int it2=revR(n,-1,str);
						total+=it2-it1;
					}
					flg=false;
				}
			}
			if(flg){
				str.pop_back();
				int it1=revR(n,-1,str);
				str=str+'{';
				int it2=revR(n,-1,str);
				total+=it2-it1;
//				cout<<it2<<" "<<it1<<endl;
			}
		}else{
			rep(j,num){
				if(str[j]=='?'){
					if(str[num-1]!='*'){
						rep(k,26){
							str[j]=al[k];
							int it1=rev(n,-1,str);
							if(it1<n-1&&word[it1+1]==str)total++;
						}
					}else{
						rep(k,26){
							str[j]=al[k];
							str.pop_back();
							int it1=rev(n,-1,str);
							str=str+'{';
							int it2=rev(n,-1,str);
							total+=it2-it1;
//							cout<<total<<endl;
						}
					}
					flg=false;
				}
			}
			if(flg){
//				cout<<str<<endl;

				if(str[num-1]!='*'){
					int it1=rev(n,-1,str);
					if(it1<n-1&&word[it1+1]==str)total++;
				}else{
					str.pop_back();
					int it1=rev(n,-1,str);
					str=str+'{';
					int it2=rev(n,-1,str);
					total+=it2-it1;
				}
			}
		}
		cout<<total<<endl;
	}
	return 0;
}



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

const int MAXN = 1e5+5;

int n, s[MAXN];
vector<int> g[MAXN];

int dfs(int v, int f = -1) {
	for (int u : g[v])
		if (u != f)
			s[v] ^= (1 + dfs(u, v));
	return s[v];
}

int main() {
	cin >> n;
	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	if (dfs(0) == 0) {
		cout << "Bob\n";
	} else
		cout << "Alice\n";
}

Measured memory_bytes: 10752
# |a - k| = |b - k|
# a2 - 2ak + k2 = b2 - 2bk + k2
# a2 - 2ak = b2 - 2bk
# 2ak - 2bk = a2 - b2
# 2k(a - b) = a2 - b2
# k = (a2 - b2) / 2(a - b)
# k = (a + b) / 2

a, b = readline.strip.split.map(&:to_i)
if (a + b) % 2 == 0
  puts (a + b) / 2
else
  puts 'IMPOSSIBLE'
end


Measured memory_bytes: 1788
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

#define pb push_back
#define scd second
#define fst first

using namespace std;

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

int main(){
	vector<int> v(26,0);
	string str;
	cin>>str;
	for(int i=0; i<str.length(); i++){
		v[str[i]-'a']++;
	}
	string tstr="None";
	for(int i=0; i<26; i++){
		if(v[i]==0){
			tstr="";
			tstr+=(char)(i+'a');
			break;
		}
	}
	cout<<tstr<<endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int N, T,ans=10000;
	int C[10000], t[10000];
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> C[i] >> t[i];
		if (t[i] <= T && C[i] < ans) {
			ans = C[i];
		}
	}
	if (ans != 10000) {
		cout << ans << endl;
	}
	else {
		cout << "TLE" << endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char s[5];
int main(){
	scanf("%s",s+1);
	for(int i=1;i<=3;i++){
		if(s[i]=='1') s[i]='9';
		else if(s[i]=='9') s[i]='1';
		printf("%c",s[i]);
	}puts("");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin>>str;
	int l=0;
	int cnt=0;
	for(int i=0;i<str.length();i++)
	{
		char c=str[i];
		if(c=='A'||c=='C'||c=='G'||c=='T')
		{
			l=max(l,++cnt);
		}
		else
		{
			cnt=0;
		}
	} 
	cout<<l;
	return 0;
 } 

Measured memory_bytes: 256
package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)

	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%s\n", &s[i])
	}

	lastA := 0
	firstB := 0
	lastAAndFirstB := 0
	count := 0
	for i, _ := range s {
		count += strings.Count(s[i], "AB")
		if strings.HasSuffix(s[i], "A") && strings.HasPrefix(s[i], "B") {
			lastAAndFirstB++
			continue
		}
		if strings.HasSuffix(s[i], "A") {
			lastA++
			continue
		}
		if strings.HasPrefix(s[i], "B") {
			firstB++
			continue
		}
	}

	if lastA == 0 && firstB == 0 {
		if lastAAndFirstB == 0 {
			fmt.Fprintln(w, count)
			return
		}
		count += lastAAndFirstB - 1
		fmt.Fprintln(w, count)
		return
	}
	if lastA > 0 && firstB > 0 {
		lastA--
		firstB--

		count += lastAAndFirstB + 1
		if lastA < firstB {
			count += lastA
		} else {
			count += firstB
		}

		fmt.Fprintln(w, count)
		return
	}
	count += lastAAndFirstB
	fmt.Fprintln(w, count)
	return
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
    int n,m,q,x,y;
    cin>>n>>m>>q;
    int A[n][n],B[n][n];
    for(int i=0;i<n;i++){
         for(int j=0;j<n;j++){
            A[i][j]=0;
         }
    }
    for(int i=0;i<m;i++){
            cin>>x>>y;
            x=x-1;
            y=y-1;
            A[x][y]++;

    }
    B[0][0]=A[0][0];
    for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i!=0 && j!=0){B[i][j]=B[i-1][j]+B[i][j-1]-B[i-1][j-1]+A[i][j];
                }else if(i==0 && j!=0){
                    B[i][j]=B[i][j-1]+A[i][j];
                }else if(i!=0 && j==0) {B[i][j]=B[i-1][j]+A[i][j];}
            }

    }
    for(int i=0;i<q;i++){
        cin>>x>>y;
        x=x-1;
        y=y-1;
        if(x!=0){
        cout<<B[n-1][y]-B[x-1][y]<<endl;
        }else{cout<<B[n-1][y]<<endl;}

    }


}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int p[100010];
int n,m;
int ans;
int fifa(int x)
{
	int t=x;
	while(p[t]!=t)
	{
		t=p[t];
	}
	while(p[x]!=t)
	{
		int tmp=p[x];
		p[x]=t;
		x=tmp;
	}
	return t;
}
void join(int x,int y)
{
	int px=fifa(x);
	int py=fifa(y);
	if(px!=py)
	{
		p[px]=py;
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		p[i]=i;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin>>x>>y;
		join(x,y);
	}
	for(int i=1;i<=n;i++)
	{
		if(fifa(i)==i)
		{
			ans++;
		}
	}
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 4012