akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
string intostr(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}

char Uplowch(char ch){if(ch >= 'A' &&  ch <= 'Z') ch += 32; return ch;}
char Lowupch(char ch){if(ch >= 'a' &&  ch <= 'z') ch -= 32; return ch;}
bool Isalpha(char ch){if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) return true; return false;}
int Strtoint(string str){stringstream ss(str);int x = 0;ss >> x ;return x ;}
string Intostr(int x){stringstream ss; ss << x; string str = ss.str(); return str;}

#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)

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

int dx[] = {0 , 0 , -1 , 1} ; // right , left , forward , backward
int dy[] = {1 , -1 , 0 , 0} ;

//bool check(int x , int y) {
//    if(x <= n && y <= m && x >= 1 && y >= 1)
//        return 1 ;
//    return 0 ;
//}

int main()
{
     //freopen("in.txt","r",stdin);

     ios::sync_with_stdio(0);
	cin.tie(0);

	ll k,a,b;
	cin>>k>>a>>b;
	ll f=0;
	for(ll i =a;i<=b;i++)
    {
        if(i%k==0) f=1;
    }

    if(f) cout<<"OK"<<nn;
    else cout<<"NG"<<nn;




}



Measured memory_bytes: 3660
import java.util.Scanner;
public class Main{
  int a;
  int b;   
  int sa;  
    public void solve(){
        Scanner sc=new Scanner(System.in);
        for(int hi=0; hi<7 ; hi++){
        a = sc.nextInt();
        b = sc.nextInt();
        sa =a-b;
            
        System.out.println(sa);
    }
    }
    public static void main(String[] args){
      Main obj=new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> a(n*3);
    rep(i,3*n) cin >> a[i];
    vector<ll> s(n*2+1, 0);//左i個中から大きいn個の和
    priority_queue<ll, vector<ll>, greater<ll>> left;
    rep(i,n){
        s[i+1] = s[i] + a[i];
        left.push(a[i]);
    }
    for(int i =n; i < 2*n; ++i){
        ll mi = left.top();
        if(a[i] > mi){
            s[i+1] = s[i] - mi + a[i];
            left.pop();
            left.push(a[i]);
        }else s[i+1] = s[i];
    }
    vector<ll> t(2*n+1);//右i個中から小さいn個の和
    priority_queue<ll> right;
    rep(i,n){
        t[i+1] = t[i] + a[n*3 - 1 - i];
        right.push(a[n*3-1 - i]);
    }
    for(int i = n; i < 2*n; ++i){
        ll ma = right.top();
        if(a[n*3-1 - i] < ma){
            t[i+1] = t[i] - ma + a[n*3-1 - i];
            right.pop();
            right.push(a[n*3-1 - i]);
        }else t[i+1] = t[i];
    }
    ll ans = -(1LL << 60);
    for(int i = n; i <= 2*n; ++i){
        ans = max(ans, s[i] - t[n*3 - i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6900
#!/usr/bin/ruby

a, b, h, m = *(ARGF.gets.chomp.split(/\s+/).collect(&:to_i))

theta_a = Math::PI / 6.0 * (h + m / 60.0)
theta_b = Math::PI * 2.0 * m / 60.0

answer = Math.sqrt((b * Math.cos(theta_b) - a * Math.cos(theta_a)) ** 2 + (b * Math.sin(theta_b) - a * Math.sin(theta_a)) ** 2)

puts answer

Measured memory_bytes: 14752
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int N=(int)1e6+6;
vi freq(N);
void solve()
{
fastio
int n;
cin>>n;
int a[n];
cin>>a[0];
int ans=a[0];
int gcd=a[0];
freq[a[0]]++;
for(int i=1;i<n;i++)
{
	cin>>a[i];
	freq[a[i]]++;
	ans=max(ans,a[i]);
	gcd=__gcd(gcd,a[i]);
}
int ans1=-1;
for(int i=ans;i>=1;i--)
{
	int j=i;
	int p=0;
	while(j<=ans)
	{
		if(freq[j]>=2)
		{
				ans1=max(ans1,j);
		}
		else if(freq[j]==1)
		p++;
		j+=i;
		if(p==2)
		{
			ans1=max(ans1,i);
		}
	}
}
if(ans1==1)
cout<<"pairwise coprime";
else
{
	if(gcd==1)
	cout<<"setwise coprime";
	else
	cout<<"not coprime";
}
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 11124
N=int(input())
h=list(map(int,input().split()))
dp = [0]*(N)
dp[1]=abs(h[1]-h[0])

for i in range(2,N):
    if i-2 >= 0:
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
    else:
        dp[i] = dp[i-1]+abs(h[i-1]-h[i])
print(dp[N-1])

Measured memory_bytes: 20520
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;
    return 0;
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int main(){
    string S;
    cin >> S;
    int N = S.size();

    static int64_t dp[4001][4001];
    dp[0][0] = 1;
    int rsum = 0, bsum = 0;

    for(int i=0; i<2*N; i++){
        if(i < N){
            rsum += '2' - S[i];
            bsum += S[i] - '0';
        }
        for(int r=0; r<=rsum; r++){
            int b = i+1 - r;
            if(b < 0 || b > bsum) continue;
            add(dp[i+1][r], dp[i][r]);
            if(r > 0) add(dp[i+1][r], dp[i][r-1]);
        }
    }
    cout << dp[2*N][rsum] << endl;
    return 0;
}

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


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a==b and a!=c){cout << "Yes";}
  else if (a==c and a!=b){cout << "Yes";}
  else if (b==c and a!=b){cout << "Yes";}
  else {cout << "No";}
  
  }


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

int main() {
    string a, b;
    int num, i, flag = 0;
    cin >> a >> b;
    num = stoi(a + b);
    for (i = 1; i * i <= num; i++) {
        if (i * i == num) {
            flag++;
        }
    }
    if (flag > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stdlib.h>
using namespace std;

int main()
{
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	int res2 = 0;

	if (W / 2 == x && H / 2 == y)
	{
		res2 = 1;
	}

	double res1 = W * H / 2;

	cout << res1 << " " << res2 << endl;
}

Measured memory_bytes: 256
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

permutations_N = list(permutations(range(1, N+1)))
a = permutations_N.index(P)
b = permutations_N.index(Q)
print(abs(a-b))


Measured memory_bytes: 13700
#include<bits/stdc++.h>
const int N=5e5+10;
typedef long long ll;
using namespace std;
ll n,a[N],d,b[N],c[N],f[N];
inline ll read(){
	ll f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
inline ll labs(ll x){return x<0?-x:x;}
int main(){
	n=read();d=read();c[0]=d;ll cur=0,lim=0;
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)c[i]=min(c[i-1],labs(c[i-1]-a[i]));
	f[n+1]=1;
	for(int i=n;i;i--)f[i]=f[i+1]<<1<=a[i]?f[i+1]:f[i+1]+a[i];
	int q=read();
	while(q--){
		int x=read();
		puts(c[x-1]>=f[x+1]?"YES":"NO");
	}
}

Measured memory_bytes: 15488
f = lambda x:x%7
p = print

def judge(x):
    if  f(x)== 1:
        p("Thursday")
    elif f(x) == 2:
        p("Friday")
    elif f(x) == 3:
        p("Saturday")
    elif f(x) == 4:
        p("Sunday")
    elif f(x) == 5:
        p("Monday")
    elif f(x) == 6:
        p("Tuesday")
    else:
        p("Wednesday")

days = [31,29,31,30,31,30,31,31,30,31,30,31]
while True:
    month,day = [int(i) for i in input().split()]
    if month == 0:
        break
    elif month == 1:   
        x = day
    else:
        x = sum(days[:month-1]) + day
    judge(x)

Measured memory_bytes: 5596
#include <iostream>

using namespace std;

int main()
{
    long long a, b;
    long long big_n, small_n, mod;
    long long GCD, LCM;

    while (cin >> a >> b)
    {
        if (a > b)
        {
            big_n = a;
            small_n = b;
        }
        else
        {
            big_n = b;
            small_n = a;
        }

        while ((mod = big_n % small_n) != 0)
        {
            big_n = small_n;
            small_n = mod;
        }

        GCD = small_n;
        LCM = (a * b) / GCD;

        cout << GCD << " " << LCM << endl;
    }

    return 0;
}



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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> b(m);
  vector<int> c(m);

  priority_queue<pair<int, int> > v;

  for(int i=0;i<=n-1;i++){
    cin >> a[i];
    v.push(make_pair(a[i],1));
  }

  for(int i=0;i<=m-1;i++){
    cin >> b[i] >> c[i];
    v.push(make_pair(c[i],b[i]));
  }

  unsigned long long ans = 0;

  for(int i=0;i<n;i++){
    auto p = v.top();
    v.pop();
    ans+= p.first;

    if(p.second>1){
      p.second--;
      v.push(p);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define vi vector<int>
#define rs resize
int main()
{  ios::sync_with_stdio(false);
   ll n,t,i,ans,ct;
   cin>>n>>t;
   ll a[n];
   ans=ct=t;
   rep(i,0,n)
   {
     cin>>a[i];
     if(i>0)
     {
        if(a[i]<ct)
          ans+=(t-ct+a[i]);
        else
         ans+=t;
        ct=a[i]+t;
     }
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 1792
n = gets.to_i
x = []
y = []
n.times do
  a,b = gets.split.map(&:to_i)
  x << a
  y << b
end

if n == 2
  puts Math.sqrt((((x[0]-x[1])**2)+((y[0]-y[1])**2)).to_f)
else
  z = 2.to_f/n
  sum = 0

  for i in 0..(n-1)
    for j in (i+1)..(n-1)
      root = Math.sqrt((((x[i]-x[j])**2) + ((y[i]-y[j])**2)).to_f)
      sum += root
    end
  end
  puts sum*z
end


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

void Main() {
    // input
    int N;
    vector<int> nums;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        nums.push_back(num);
    }


    // translate
    int Alice = 0;
    int Bob = 0;
    sort(nums.begin(), nums.end());

    for (int i = 0; i < nums.size(); i++) {
        int num = nums[nums.size() - (i + 1)];
        if (i % 2 == 0) {
            Alice += num;
        } else {
            Bob += num;
        }
    }

    // output
    cout << Alice - Bob << endl;

}

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


Measured memory_bytes: 256
program sample
    implicit none
    
    integer(8) :: a,b,c,i,j,m,n,k,a1,b1,c1,x,y
    

    read(*,*) a,b,c


    if (mod(a,2)==1 .or. mod(b,2)==1 .or. mod(c,2)==1) then
        write(*,*)0
        stop
    end if

    if (a==b .and. b==c)then
        write(*,*)-1
        stop
    end if

    
    x=abs(a-b)
    y=abs(b-c)
    m=0
    do while(mod(x,2)==0 .and. mod(y,2)==0)
        x=x/2
        y=y/2
        m=m+1
    end do
    
    write(*,*)m
    
    stop
end program sample
  



Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
Mod = 10**9+7
A = gets.split.map(&:to_i).sort
B = gets.split.map(&:to_i).sort

if A.uniq.size < A.size || B.uniq.size < B.size
  p 0; exit
end

def powmod(b,r,mod)
  a = 1
  while r > 0
    if r%2 == 1
      a = a * b % mod
    end
    b = b * b % mod
    r /= 2
  end
  a
end

def invmod(f, mod)
  powmod(f, mod-2, mod)
end

def factorial(n, mod)
  fs = [1]
  (1..n).each{ |k| fs << (fs[-1] * k) % mod }
  fs
end
$fs = factorial(N*M+2, Mod)

$is = {}
def inv_factorial(n, mod)
  $is[n] if $is[n]
  $is[n] = invmod($fs[n], mod)
  $is[n]
end


def combination(a,b,mod)
  return 0 if a < b
  $fs[a]*inv_factorial(a-b, Mod)%Mod*inv_factorial(b, Mod)%Mod
end

es = {}
A.each{ |a| 
  es[a] = :row
}
B.each{ |b|
  es[b] = es[b] ? :rowcol : :col
}


n = 0
m = 0
spent = 0
ans = 1
es.keys.sort.each{ |x|
  type = es[x]
  y,z = nil,nil
  case type
  when :row; y = M-m-1; z = y+1
  when :col; y = N-n-1; z = y+1
  else y = z = N+M-n-m-2
  end
  ans = ans * combination(x-1-spent, y, Mod) % Mod * $fs[z] % Mod
  #p [type,x,spent,y,z, x-1-spent, y, combination(x-1-spent, y, Mod), ans]
  case type
  when :row; n += 1
  when :col; m += 1
  else 
    n += 1; m += 1
  end
  spent += y+1
}
p ans

Measured memory_bytes: 11256
#include <iostream>
using namespace std;
int n,a,b,c,d;
string road;
int main(void){
    cin>>n>>a>>b>>c>>d>>road;
    for(int i=a;i<max(c,d)-1;i++){
        if(road[i]=='#'&&road[i+1]=='#'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(c<d){
        cout<<"Yes"<<endl;
        return 0;
    }
    for(int i=b-2;i<min(c,d)-1;i++){
        if(road[i]=='.'&&road[i+1]=='.'&&road[i+2]=='.'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


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

#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define rep(i , j , k) for(int i = j ; i <= k ; i ++)
#define Rep(i , j , k) for(int i = j ; i >= k ; i --)

using namespace std ;
using ll = long long ;
using pii = pair <int , int> ;
using vii = vector <int> ;
auto ot = [&]() { cerr << "ATS TXDY" << '\n' ; int ATS_nantf_txdy = true ; } ;
auto _ios = [&]() { ios :: sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ; } ;
#define int long long
namespace stO_ATS_Orz {
  template < class T > void cmax(T & x , T y) { if(x > y) x = y ; }
  template < class T > void cmin(T & x , T y) { if(x < y) x = y ; }
  template < class T > void abs(T x) { if(x < 0) x = -x ; }
  void main() {
    long long T1,T2,a,b,c,d,e,f;
  	cin>>T1>>T2>>a>>c>>b>>d;
  	if(a*T1+c*T2==b*T1+d*T2){
  		cout<<"infinity";
  		return ;
  	}
  	if(a<b)swap(a,b),swap(c,d);
  	e=a-b;f=c-d;
  	if(e*T1+f*T2>0&&e*T1>0){
  		cout<<0;
  		return ;
  	}
  	if(e*T1+f*T2<0&&e*T1<0){
  		cout<<0;
  		return ;
  	}
  	cout<<2ll*(((a-b)*T1)/(-e*T1-f*T2))+bool(((a-b)*T1)%(1ll*(-e*T1-f*T2)));
  }
}
signed main() {
  _ios() ; ot() ;
  return stO_ATS_Orz :: main() , 0 ;
}

Measured memory_bytes: 256
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


N = int( input())
S_LIST = []
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for i in range(N):
        s = input()
        if s == 'AC':
                C0 += 1
        elif s == 'WA':
                C1 += 1
        elif s == 'TLE':
                C2 += 1
        elif s == 'RE':
                C3 += 1

print("AC x",C0)
print("WA x",C1)
print("TLE x",C2)
print("RE x",C3)

Measured memory_bytes: 9052
n = int(input())
count = 0
tenwari = n%10
baiwari = n%100
ichi = tenwari
jyu = (baiwari-tenwari)//10
hyaku = (n-jyu*10-ichi)//100

if ichi != 7:
  count = count + 1
if jyu != 7:
  count = count + 1
if hyaku != 7:
  count = count + 1
  
if count == 3:
  print('No')
else:
  print('Yes')


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K, R, S, P;
    string T;
    scan(N, K, R, S, P, T);
    vector<vector<ll>> dp(N + 1, vector<ll>(3));
    map<char, int> mp = {{'r', 0}, {'s', 1}, {'p', 2}};
    map<int, int> point{{0, P}, {1, R}, {2, S}};
    rep(i, N) {
        char now = T[i];
        int win  = mp[now];
        rep(j, 3) {
            if (win == j) {
                dp[i][j] = point[j];
            }
        }
        if (0 <= i - K && 0 < dp[i - K][win]) {
            dp[i][win] = 0;
        }
    }
    ll ans = 0;
    rep(i, N) {
        rep(j, 3) { ans += dp[i][j]; }
    }
    print(ans);

    return 0;
}

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

a = []
for i in range(10):
    if i not in d:
        a.append(i)

check = set(a)
for i in range(10**5):
    if i >= n and set(map(int, list(str(i)))) <= set(a):
        print(i)
        exit()


Measured memory_bytes: 3060
def main():
    N,L = map(int,input().split())
    keys = []
    grundy_num=0
    if N==1:
        print("Alice")
        exit()
    for i in range(N):
        s = input()
        #merge node:
        while len(s)>0:
            if s[-1]=='1' and s[:-1]+'0' in keys:
                keys.remove(s[:-1]+'0')
                s = s[:-1]
            elif s[-1]=='0' and s[:-1]+'1' in keys:
                keys.remove(s[:-1]+'1')
                s = s[:-1]
            else:
                if s!="":
                    keys.append(s)
                break
    if len(keys):
        keys = sorted(keys,key=len,reverse=True)
        grundy_list = []
        while len(keys):
            j = keys[0]
            keys.remove(j)
            temp_s = list(reversed(bin(L-len(j)+1)))
            grundy_list.append(1 << temp_s.index('1'))
            if j[:-1]!="":
                keys.append(j[:-1])
            j = j[:-1]
            #merge node
            while len(j)>0:
                if j[-1]=='1' and j[:-1]+'0' in keys:
                    keys.remove(j[:-1]+'0')
                    keys.remove(j)
                    j = j[:-1]
                    if j!="":
                        keys.append(j)
                elif j[-1]=='0' and j[:-1]+'1' in keys:
                    keys.remove(j[:-1]+'1')
                    keys.remove(j)
                    j = j[:-1]
                    if j!="":
                        keys.append(j)
                else:
                    break
            keys = sorted(keys,key=len,reverse=True)
        grundy_num = grundy_list[0]
        for i in range(1,len(grundy_list)):
            grundy_num = grundy_num^grundy_list[i]
    print("Bob" if grundy_num==0 else "Alice")


if __name__=="__main__":
    main()

Measured memory_bytes: 4284
#include<iostream>
#include<stdio.h>
#include<math.h>
#include    <iomanip>
#include    <map>
#include    <set>
#include    <bitset>
using namespace std;
#define FR(i,k,N) for(int i=k;    i<N;i++)
#define REP(i,N) for(int i=0;    i<N;i++)
int a,b;

int main(){
    int sen[10][10001];
    auto maa=0;
    while(cin>>a>>b&&a!=0){
        REP(i, a)REP(j, b) cin>>sen[i][j];
        REP(i, pow(2, a)) {
            bitset<10> senbei(i);
            //cout<<i<<" "<<senbei<<endl;
            bitset<10> ichi(1);
            REP(j, a){
                if ((((senbei >> j) & ichi)==1)){
                    REP(k, b) {sen[j][k]=(sen[j][k]+1)%2;}
                }
            }
            auto sum=0;
            REP(jj, b){
                auto temp=0;
                REP(ii, a){
                    temp+=(sen[ii][jj]+1)%2;
                }
                sum+=max(temp,(a-temp));
            }
            REP(j, a){
                if ((((senbei >> j) & ichi)==1)){
                    REP(k, b) {sen[j][k]=(sen[j][k]+1)%2;}
                }
            }
            maa=(max(maa,sum));
            
            //cout<<i<<" "<<maa<<endl;
        }
        cout<<maa<<endl;
    }
    return 0;
}

Measured memory_bytes: 1592
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k,a,b;
  cin>>a >> b >> c >> k;
  ans+= min(a,k);
  k -= min(a,k);
  k -= min(b,k);

  ans-= min(c,k);
  k -= min(c,k);
  c(ans);
  
 
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstring>
  
using namespace std;
  
#define MAX 10000
#define INF 1e9
typedef pair<int,int> P;
int ans, N;
vector<P> vec[MAX];
int dp[100][100]; 
 
int dist(int x1, int y1, int x2, int y2){
    return abs(x1-x2) + abs(y1-y2);
}
 
int getNum(string &s){
    stringstream ss(s);
    int res;
    ss >> res;
    return res;
}
  
int main(){
    int W, H;
  
    while(cin >> W >> H, (W | H)){
	string in;
	int gx, gy, max = 0;
	for(int i = 0 ; i < MAX ; i++){
	    vec[i].clear();
	}
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < W ; j++){
		cin >> in;
		if(in == ".") continue;
		if(in == "S"){
		    vec[0].push_back(P(i,j));
		}else if(in == "G"){
		    gx = i, gy = j;
		}else{
		    int num = getNum(in);
		    max = std::max(max, num);
		    vec[num].push_back(P(i,j));
		}
	    }
	}
	vec[max+1].push_back(P(gx,gy));
	ans = INF; N = max+2;
	fill(dp[0],dp[H],INF);
	for(int i = 0 ; i < N-1 ; i++){
	    for(int j = 0 ; j < vec[i+1].size() ; j++){
		for(int k = 0 ; k < vec[i].size() ; k++){
		    int bx = vec[i][k].first;
		    int by = vec[i][k].second;
		    int nx = vec[i+1][j].first;
		    int ny = vec[i+1][j].second;
		    if(dp[bx][by] == INF) dp[bx][by] = 0;
		    dp[nx][ny] = min(dp[nx][ny],dp[bx][by] + dist(bx,by,nx,ny));;
		}
	    }
	}
	cout << dp[gx][gy] << endl;
    }
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,ans;
    cin>>A>>B>>C;
    if(C-(A-B)>=0){
        ans=C-(A-B);
    }
    else{
        ans=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

int main()
{
    int a, b, k, cnt = 0;
    cin >> a >> b >> k;
    REPR(i, gcm(a, b))
    {
        if (a % i == 0 && b % i == 0)
        {
            cnt++;
        }
        if (cnt == k)
        {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<map>
using namespace std;

int d[200001],t[200001];
vector<int> vd[200001],vt[200001];

void dfsd(int x,int y){
    d[x]=y;
    for(int i=0;i<vd[x].size();i++){
        if(d[vd[x][i]]==0){
            dfsd(vd[x][i],y);
        }
    }
}

void dfst(int x,int y){
    t[x]=y;
    for(int i=0;i<vt[x].size();i++){
        if(t[vt[x][i]]==0){
            dfst(vt[x][i],y);
        }
    }
}
int main(){
    int n,l,k,p,q,s,r;
    map<long,int> m;
    long x;
    scanf("%d %d %d",&n,&k,&l);
    for(int i=0;i<k;i++){
        scanf("%d %d",&p,&q);
        vd[p].push_back(q);
        vd[q].push_back(p);
    }
    for(int i=0;i<l;i++){
        scanf("%d %d",&r,&s);
        vt[s].push_back(r);
        vt[r].push_back(s);
    }
    for(int i=1;i<=n;i++){
        if(d[i]==0){
            dfsd(i,i);
        }
        if(t[i]==0){
            dfst(i,i);
        }
    }
    for(int i=1;i<=n;i++){
        x=(long)((long)(n+1)*(long)d[i]+(long)t[i]);
        decltype(m)::iterator it = m.find(x);
        if(it!=m.end()){
            m[x]++;
        }
        else{
            m.insert(make_pair(x,1));
        }
    }
    for(int i=1;i<=n;i++){
        printf("%ld ",m[(long)((long)(n+1)*(long)d[i]+(long)t[i])]);
    }
    printf("\n");
}

Measured memory_bytes: 27904
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<numeric>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, M, C, ans = 0; cin >> N >> M >> C;
	vector<int> B(M);
	vector<vector<int>> A(N, vector<int>(M));
	rep(i, M)cin >> B[i];
	rep(i, N)rep(j, M)cin >> A[i][j];
	vector<int> sum(N);
	rep(i, N) {
		rep(j, M) sum[i] += A[i][j] * B[j];
		if (sum[i] + C > 0)++ans;
	}
	cout << ans << endl;
	cin >> N;
}

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

#define STRING(str) #str
#define ll long long

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

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

	int K;
	cin >> K;
	string s = "ACL";
	for (int i=0;i<K;i++) {
		cout << s;
	}
	cout << "\n";
}

Measured memory_bytes: 3684
#include<iostream>
using namespace std;
int getCost(int w){
 int cost = 1150; // ?¬¬?????????
 for (int i = 11; i <= w; i++ ){
 if ( i <= 20 ) cost += 125; // ?¬¬?????????
 else if ( 30 < i ) cost += 160; // ?¬¬?????????
 else cost += 140; // ?¬¬?????????
 }
 return cost;
}
int main(){
 for( int w; cin >> w && w >= 0; ) {
 cout << 4280 - getCost(w) << endl;
 }
 return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,p[50],a[2],ba=0,c,d;
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>p[t];
		if(p[t]!=t+1)
		{
			ba++;
			if(ba==1)
			{
				a[0]=p[t];
				c=t;
			}
			if(ba==2)
			{
				a[1]=p[t];
				d=t;
			}
		}
	} 
	if(ba==0)
	{
		cout<<"YES";
		return 0;
	}
	p[c]=a[1];
	p[d]=a[0];
	//cout<<p[c]<<" "<<p[d]<<" ";
	for(int i=0;i<n;i++)
	{
		//cout<<p[i]<<" "<<i+1<<" ";
		if(p[i]!=i+1)
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
} 

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();

            for (int i = 0; i < S.Length; i++)
            {
                char c = S[i];
                int cn = (int)S[i] - 'A';
                cn += N;
                cn %= 26;

                c = (char)(cn + 'A');
                Console.Write(c);
                
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13140
// D - Redistribution
#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
using vl = vector<ll>;
#define MOD 1000000007
#define MAX 2001// [n+1] 1_origin
#define madd(a,b) (((a)+(b))%MOD)
#define mmul(a,b) (((a)*(b))%MOD)
vl fac{1,1}, inv{0,1}, finv{1,1};

// n 個の配列に、mod p で前処理する
void finv_init(int n){
	for(int i=2; i<=n; ++i){
		fac.push_back(mmul(fac.back(), i));
		inv.push_back(madd(MOD, -mmul(inv[MOD%i], MOD/i)));
		finv.push_back(mmul(finv.back(), inv.back()));
	}
}

// 組み合わせ nCr(mod m)
ll nCr(int n, int r){
	int m = MOD;
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

// 重複組合せ nHr(mod m)
#define nHr(n,r) nCr((n)+(r)-1,(r))

int main(){
	ll S; cin>>S;
	finv_init(S+1);
	ll ans = 0;
	for(int n=1; n<=S; ++n){
		if(S < 3*n) continue;
		ans += nHr(n, S - 3*n);
		ans %= MOD;
	}
	cout<< (ans + MOD) % MOD <<endl;
}


Measured memory_bytes: 3668
i=61,f[],c,m,y;main(s){for(;~s?++f[y*12+*f+"=2>?J13IK<@V&"[1+--s]]:~scanf("%d,%d,%d",f,&y,&s)?s*=4:++i<180?i%12>1?(y=f[i])?y>m?m=y:1:++c:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll P[10], Q[10];

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

  rep( i, N )
    std::cin >> P[i];

  rep( i, N )
    std::cin >> Q[i];

  std::vector<ll> vs( N );
  std::iota( all(vs), 1 );

  ll cnt = 1, a, b;

  do
  {
    if( std::equal( P, P+N, all(vs) ) )
      a = cnt;
    
    if( std::equal( Q, Q+N, all(vs) ) )
      b = cnt;

    ++cnt;
  } while( std::next_permutation( all(vs) ) );

  std::cout << llabs(a-b) << std::endl;

  return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    let n: u32 = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).unwrap();
    let mut v: Vec<u32> = a.trim().split_whitespace()
        .map(|x| x.parse().unwrap()).collect();
    v.sort_by(|a, b| b.cmp(a));

    let mut alice = 0;
    let mut bob = 0;
    let mut tmp = 0;
    for x in v {
        if (tmp % 2 == 0) {
            alice += x;
        }
        if (tmp % 2 == 1) {
            bob += x;
        }
        tmp += 1;
    }
    let ans = alice - bob;
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.io.*;
 
public class Main{
    public static void main(String[]args)throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int[][] matrix = new int[n][m];
        int[] vector = new int[m];
        int[] result = new int[n];
 
        //???????????????¨???????????????
        for(int i=0; i<n; i++){
            String[] str2 = br.readLine().split(" ");
            for(int k=0; k<m; k++){
                matrix[i][k] = Integer.parseInt(str2[k]);
            }
        }
        for(int i=0; i<m; i++){
            vector[i] = Integer.parseInt(br.readLine());
        }
 
        //???????????? x ??????
        for(int i=0; i<n; i++){
            for(int k=0; k<m; k++){
                result[i] += matrix[i][k] * vector[k];
            }
        }
 
        //??????
        for(int i=0; i<n; i++){
            System.out.println(result[i]);
        }
 
    }
}

Measured memory_bytes: 27556
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int x;
	while(~scanf("%d%d", &N, &x)) {
		vector<int> a(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &a[i]);
		vector<int> cost(N, INF);
		ll ans = INFL;
		rer(k, 0, N - 1) {
			rep(i, N)
				amin(cost[i], a[(i + N - k) % N]);
			ll t = accumulate(cost.begin(), cost.end(), 0LL);
			t += (ll)k * x;
			amin(ans, t);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


const string YES = "Yes";
const string NO = "No";

int R[1010][1010];

void solve(long long H, long long W, long long h, long long w, bool rev = false) {
    if (H % h == 0) {
        if (rev) {
            cout << NO << endl;
            return;
        }
        solve(W, H, w, h, true);
        return;
    }

    vector<long long> S(H + 1, -114514);

    S[0] = 0;
    S[H] = 1;
    for (int i = h; i <= H; i += h) {
        assert(S[i] == -114514);
        S[i] = S[i - h] - 1;
    }


    for (int i = H - h; i >= 0; i -= h) {
        assert(S[i] == -114514);
        S[i] = S[i + h] + 1;
    }

    for (int s = 0; s < H; s++) {
        if (S[s] == -114514) {
            S[s] = 0;
            for (int i = s + h; i <= H; i += h) {
                assert(S[i] == -114514);
                S[i] = S[i - h] - 1;
            }
        }
    }
    vector<int> A;
    for (int i = 1; i <= H; i++) A.push_back(S[i] - S[i - 1]);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            R[i][j] = A[i];
        }
    }
    if (rev) swap(H, W);
    cout << YES << endl;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (rev) {
                cout << R[j][i];
            } else {
                cout << R[i][j];
            }
            cout << " ";
        }
        cout << endl;
    }
    cout << endl;


}

int main() {
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    long long h;
    scanf("%lld", &h);
    long long w;
    scanf("%lld", &w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 3328
n,m = map(int,input().split())
students = []
for i in range(n):
    student = list(map(int,input().split()))
    students.append(student)
checkpoints = []
for i in range(m):
    checkpoint = list(map(int,input().split()))
    checkpoints.append(checkpoint)

for student in students:
    for i in range(m):
        if i == 0:
            judge = abs(student[0]-checkpoints[i][0]) + abs(student[1]-checkpoints[i][1])
            place = 0
        manhattan = abs(student[0]-checkpoints[i][0]) + abs(student[1]-checkpoints[i][1])
        if judge > manhattan:
            judge = manhattan
            place = i
    print(place+1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
using namespace std;
const int maxn=1e5+5;
int n,deg[maxn];
vector<int>G[maxn];

int main(){
	ios::sync_with_stdio(false);
	scanf("%d",&n);
	for(int i=0;i<n-1;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
		++deg[x];++deg[y];	
	}
	int mx=0;
	for(int i=0;i<n;++i)
		if(deg[i]>mx)mx=deg[i];
	if(mx<=2){
		return printf("%d\n",1),0;
	}
	queue<int>qu;
	for(int i=0;i<n;i++)
		if(deg[i]==1)qu.push(i);
	
	while(!qu.empty()){
		int u=qu.front();qu.pop();
		for(int i=0;i<G[u].size();++i)
			if(deg[G[u][i]]!=1){
				if(deg[G[u][i]]==2){
					deg[G[u][i]]=1;
					qu.push(G[u][i]);
				}
				break;
			}
	}
	int res=0;
	for(int i=0;i<n;++i)
		if(deg[i]>1){
			int ans=0;
			for(int j=0;j<G[i].size();++j)
				if(deg[G[i][j]]==1)++ans;
			res+=max(0,ans-1);
	}
	printf("%d\n",res);
	return 0;	
}

Measured memory_bytes: 7040
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
bitset<50000>B[50000];
int n, m, T, chk[50100];
struct Edge {
	int a, b;
}Ed[101000];
char res[100100];
int main() {
	int i;
	scanf("%d%d%d", &n, &m, &T);
	if (T == 1) {
		for (i = 0; i < n; i++)B[i][i] = 1;
		for (i = 0; i < m; i++) {
			int a, b;
			scanf("%d%d", &a, &b);
			a--, b--;
			Ed[i] = { a,b };
			B[a] = B[b] = (B[a] | B[b]);
		}
		int root = -1;
		for (i = 0; i < n; i++) {
			if (B[i].count() == n) {
				root = i;
				break;
			}
		}
		if (root == -1) {
			puts("-1");
			return 0;
		}
		chk[root] = 1;
		for (i = m - 1; i >= 0; i--) {
			if (chk[Ed[i].a]) {
				res[i] = '^';
			}
			else if (chk[Ed[i].b]) {
				res[i] = 'v';
			}
			else {
				res[i] = '^';
			}
			int t = chk[Ed[i].a] | chk[Ed[i].b];
			chk[Ed[i].a] = chk[Ed[i].b] = t;
		}
		printf("%s\n", res);
		return 0;
	}

	for (i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--, b--;
		Ed[i] = { a,b };
	}
	if (n == 2) {
		puts("-1");
		return 0;
	}
	int chk = 0;
	int b0, b1, p0, p1, last = -1, tb0, tb1, tp0, tp1;
	for (i = 0; i < m; i++) {
		if (Ed[i].b > 2) {
			res[i] = '^';
			continue;
		}
		int a = Ed[i].a, b = Ed[i].b;
		if (!chk) {
			chk = 1;
			b0 = 7 - (1 << Ed[i].b);
			p0 = 0;
			b1 = 7 - (1 << Ed[i].a);
			p1 = 1;
			last = i;
			continue;
		}
		int bb = (1 << a) + (1 << b);
		if (bb != b0) {
			tb0 = b0;
			tb1 = b0 ^ bb;
			if (!p0)res[last] = '^';
			else res[last] = 'v';
		}
		else {
			tb0 = b1;
			tb1 = b1 ^ bb;
			if (!p1)res[last] = '^';
			else res[last] = 'v';
		}
		if (tb0 < tb1) tp0 = 0, tp1 = 1;
		else tp0 = 1, tp1 = 0;
		b0 = tb0, p0 = tp0;
		b1 = tb1, p1 = tp1;
		last = i;
	}
	if (last != -1) {
		res[last] = '^';
	}
	printf("%s\n", res);
}

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

string s;
deque <char> d1, d2;

bool check() {
	for (int i = 0; i < (int)d1.size(); i++)
		if (d1[i] != d2[i])
			return 0;
	return 1;
}

int main() {
	cin >> s;
	for (char i : s)
		d1.push_back(i);
	cin >> s;
	for (char i : s)
		d2.push_back(i);
	for (int i = 0; i <= (int)d1.size(); i++) {
		int tmp = d1.back();
		d1.pop_back();
		d1.push_front(tmp);
		if (check())
			return cout << "Yes", 0;
	}
	cout << "No";
}

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

int main(void){
	string numl;
	cin>>numl;
	if(numl[0]==numl[1]&&numl[1]==numl[2])
		cout<<"Yes"<<endl;
	else if(numl[1]==numl[2]&&numl[2]==numl[3])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>

int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
ll INF = 10010001010;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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


Measured memory_bytes: 256
from collections import defaultdict

S = list(map(int, input()))
mod = [0] * len(S)
cur = 0
factor = 1
for i, n in list(enumerate(S))[::-1]:
    cur = (cur + n * factor) % 2019
    factor = factor * 10 % 2019
    mod[i] = cur
ans = 0
cnt = defaultdict(int)
for i in range(len(S)):
    ans += cnt[mod[i]]
    cnt[mod[i]] += 1
ans += cnt[0]
print(ans)

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

using namespace std;

int main(int argc, char const *argv[])
{
    string w;
    cin >> w;
    int cnt[26] = {0};
    for (string::iterator itr = w.begin(); itr != w.end(); itr++)
    {
        cnt[(int)*itr - 97]++;
    }
    
    for (int i = 0; i < 26; i++)
    {
        if (cnt[i] % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
        
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    long H,W;
    long ret;
    scanf("%ld %ld",&H,&W);
    // H or Wどちらかが1ならば答えは1
    if (( H == 1 )|| ( W == 1)){
        printf("1\n");
        return 0;
    }
    //積が偶数か奇数かで+1するか判定する
    if((H * W)%2 == 1){
        //奇数
        ret = H*W / 2 + 1;
    }else
    {
        ret = H*W/2;
    }
    printf("%ld\n",ret);
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int N,L;
    cin>>N>>L;

    int sum = 0;
    int minimum = INT_MAX;
    int sign = 0;
    for(int i = 1;i <= N;i++) {
        sum += L+i-1;
        if(abs(L+i-1) < minimum) {
            minimum = abs(L+i-1);
            if(L+i-1 > 0) {
                sign=1;
            } else {
                sign=-1;
            }
        }
    }

    cout<<sum-sign*minimum<<endl;

    return 0;
}





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

int main(){
  string s; cin >> s;
  int m = stoi(s.substr(5,2));

  
  if( m >= 5){ cout << "TBD" << endl;}
  else{ cout <<"Heisei" << endl;
      }
  
  return 0;
}

Measured memory_bytes: 256
from decimal import Decimal

N,K = map(int,input().split())

A= [int(i) for i in input().split()]



a = 10**9+7

ans = 0
Ans = 0

for i in range(0,N-1):

	for j in range(i+1,N):

			if A[i]>A[j]:

					ans+=1

for i in range(0,N):
	for j in range (0,N):

		if A[i]>A[j]:
			Ans+=1

ans =Decimal((ans-Ans))*Decimal(K)+Decimal(Ans)*Decimal(K)*Decimal((K+1))/Decimal(2)


print(Decimal(ans) % Decimal(a))

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define mod 1000000007
#define dbg(a) cout << #a << " = " << a << " ";
int main()
{
    ///freopen("input.txt","r",stdin);
    ///freopen("input15.txt","w",stdout);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll mx=a*c;
    mx = max(mx,max(a*d,max(b*c,b*d)));
    cout<<mx<<endl;
    
}


Measured memory_bytes: 3632
void main()
{
    long n = rdElem;
    long[] x = new long[n], l = new long[n];
    foreach (i; 0 .. n)
    {
        long[] tmp = rdRow;
        x[i] = tmp[0], l[i] = tmp[1];
    }

    zip(x, l).sort!((a, b) => a[0] < b[0]);
    long cnt = n;
    long pos = x[0] + l[0];
    foreach (i; 1 .. n)
    {
        if (pos > x[i] - l[i])
        {
            --cnt;
            pos = min(pos, x[i] + l[i]);
        }
        else
        {
            pos = x[i] + l[i];
        }
    }

    cnt.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4732