akhauriyash/Code-Regression huggingface dataset:
// unihernandez22
// https://atcoder.jp/contests/abc153/tasks/abc153_a
// greedy

use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();

    let words: Vec<i64> = s
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let h = words[0];

    s = String::new();
    stdin().read_line(&mut s).unwrap();

    let a: Vec<i64> = s
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut max_attack: i64 = 0;

    for i in a {
        max_attack += i;
    }

    if max_attack >= h {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 6396
import java.util.Scanner;

//M-SOLUTIONS プロコンオープン
//A - Sum of Interior Angles
public class Main {

	/**
	 * @param args
	 */
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		System.out.println((N-2)*180);

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
bool isplaindrome(string s)
{
    ll i = 0, j = s.length() - 1;
    while (j > i)
    {
        if (s[i] != s[j])
        {
            return false;
        }
        i++;
        j--;
    }
    return true;
}
int main()
{
    double n;
    cin >> n;
    cout<<fixed<<setprecision(15)<<pow((double)(n/3),3);

    return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]=sc.nextInt();
		}
		long ans=0;
		for (int i = 0; i < a.length-1; i++) {
			if(a[i]>=a[i+1]){ans=ans+(a[i]-a[i+1]);a[i+1]=a[i];}
		}
		System.out.println(""+ans);
	}
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)
	{
		cout << "bust" << endl;
	}
	else
		cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int n, k, x;

    cin >> n >> k;

    int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> x;

        int a = abs(k-x)*2;
        int b = x*2;
        ans += (a<b) ? a : b;
    }

    cout << ans << endl;

    return 0;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        
        int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = nm[0];
        int M = nm[1];

        var cities = Enumerable.Range(0, M)
            .Select(n => Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray())
            .Select((arr, Num) => new { Num, P = arr[0], Y = arr[1] })
            .ToArray();

        var dict = cities.Take(0).ToDictionary(city => city, city => "");
        dict.Clear();


        foreach(var grp in cities.GroupBy(city => city.P))
        {
            foreach(var itm in grp.OrderBy(city => city.Y).Select((city, idx) => new { city, x = idx + 1 }))
            {
                dict[itm.city] = $"{itm.city.P:000000}{itm.x:000000}";
            }
        }

        foreach(var city in cities)
        {
            Console.WriteLine(dict[city]);
        }

    }
    
}

Measured memory_bytes: 45864
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

q = inp()
L = [0] * q
R = [0] * q
for i in range(q):
    L[i],R[i] = inpl()
    L[i] = (L[i]+1)//2
    R[i] = (R[i]+1)//2
# print(L,R)
cnt = [0] * ((10**5+10)//2)
for i in range(1,(10**5+5)//2):
    if is_prime(i) and is_prime(i+i-1):
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]
for i in range(q):
    print(cnt[R[i]] - cnt[L[i]-1])

Measured memory_bytes: 51416
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
#define gcd(a,b) __gcd(a,b)
#define sqre(x) (x)*(x)
#define mem(x,y) memset(x,t,sizeof(x))
const int MaxN = 1005;
const int inf = 1e8;
const double PI = acos(-1);

LL wt[200005];

int main()
{
	LL ans = 0;
	int n , t ; scanf("%d%d",&n,&t);
	wt[1] = 0;
	for(int i = 1 ; i <= n ; i++)scanf("%lld",&wt[i]);
	for(int i = 2 ; i <= n ; i++)
	{
		ans += min((LL)t, wt[i] - wt[i - 1]);
	}
	ans += t;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
#define lli long long int
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std; 

int main() 
{ 
    fast();
    lli n,m;
    cin>>n>>m;
    if(m==2)
    {
        cout<<(n*(n-1)/2)+1<<endl;
    }
    else if(m<2)
    {
        cout<<(n*(n-1)/2)<<endl;
    }
    else
    {
        cout<<(n*(n-1)/2)+(m*(m-1)/2)<<endl;
    }
    return 0; 
} 

Measured memory_bytes: 256
def f(x):
    return (x + 1) * x // 2


def main():
    s = input()

    li = []
    prev = 0
    top = 0
    for i in range(len(s) - 1):
        cs = s[i:i+2]
        if cs == "<>":
            top = i + 1
        elif cs == "><":
            li.append((prev, top, i+1))
            prev = i + 1

    li.append((prev, top, len(s)))

    ans = 0
    for l, t, r in li:
        if l < t < r:
            ld = t - l
            rd = r - t
            mx = max(ld, rd)
            mn = min(ld, rd)
            sm = f(mx) + f(mn - 1)
            ans += sm

        else:
            sm = f(r - l)
            ans += sm

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25992
def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    P = []
    Y = []
    for i in range(M):
        buf = input()
        buflist = buf.split()
        P.append(int(buflist[0]))
        Y.append(int(buflist[1]))
    citylist = []
    for i in range(len(P)):
        citylist.append([i,P[i],Y[i]])
    citylist = list(sorted(citylist, key=lambda x:x[2]))
    citycount = []
    for i in range(100000):
        citycount.append(1)
    for i in range(len(citylist)):
        citylist[i].append(citycount[citylist[i][1]-1])
        citycount[citylist[i][1]-1] += 1
    citylist = list(sorted(citylist, key=lambda x:x[0]))
    for i in range(len(citylist)):
        print("{:06}".format(citylist[i][1])+"{:06}".format(citylist[i][3]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 34604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
using ll = long long;

int const nmax = 100;
char v[5 + nmax][5 + nmax];
int dp[1 + nmax][1 + nmax];

int main()
{
  int n, m;
  cin >> n >> m;
  for(int i = 1;i <= n; i++)
    for(int j = 1;j <= m; j++)
      cin >> v[i][j];
  for(int i = 1;i <= n; i++)
    for(int j = 1;j <= m; j++) {
      if(i == 1 && j == 1){
        dp[i][j] = (v[i][j] == '#');
      } else {
        dp[i][j] = nmax + nmax;
        if(1 < i)
          dp[i][j] = min(dp[i][j], dp[i - 1][j] + ((v[i][j] == '#') & (v[i - 1][j] == '.')));
        if(1 < j)
          dp[i][j] = min(dp[i][j], dp[i][j - 1] + ((v[i][j] == '#') & (v[i][j - 1] == '.')));
      }
    }
  cout << dp[n][m];
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int dijkstra( vector< vector< PII > > G, int s, int t )
{
	priority_queue< PII, vector< PII >, greater< PII > > que;
	que.push( MP( 0, s ) );

	VI dist( G.size(), INT_MAX );

	while ( !que.empty() )
	{
		auto cur = que.top();
		que.pop();

		if ( dist[ cur.snd ] <= cur.fst )
		{
			continue;
		}

		dist[ cur.snd ] = cur.fst;

		EACH( e, G[ cur.snd ] )
		{
			que.push( MP( cur.fst + e.snd, e.fst ) );
		}
	}

	return dist[t] == INT_MAX ? -1 : dist[t];
}

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

	while ( true )
	{
		int n, k;
		cin >> n >> k;

		if ( !( n | k ) )
		{
			break;
		}

		vector< vector< PII > > G( n );

		REP( i, 0, k )
		{
			int q, a, b;
			cin >> q >> a >> b;

			a--;
			b--;

			switch ( q )
			{
				case 0:
					cout << dijkstra( G, a, b ) << endl;

					break;
				case 1:
					int c;
					cin >> c;
					
					G[a].PB( MP( b, c ) );
					G[b].PB( MP( a, c ) );
					
					break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1284
local n, m = io.read("*n", "*n")
local color = {}
local edge = {}
for i = 1, n do
  color[i] = 0
  edge[i] = {}
end
local tasks = {}
do
  local a, b = io.read("*n", "*n")
  color[a] = 1
  color[b] = 2
  tasks[1] = a
  tasks[2] = b
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end
for i = 2, m do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end
local allsame = false
for itask = 1, n do
  local src = tasks[itask]
  for j = 1, #edge[src] do
    local dst = edge[src][j]
    if color[dst] == 0 then
      color[dst] = 3 - color[src]
      table.insert(tasks, dst)
    elseif color[dst] == color[src] then
      allsame = true
      break
    end
  end
  if allsame then break end
end
if allsame then
  print(n * (n - 1) // 2 - m)
else
  local cnt1, cnt2 = 0, 0
  for i = 1, n do
    if color[i] == 1 then
      cnt1 = cnt1 + 1
    else
      cnt2 = cnt2 + 1
    end
  end
  print(cnt1 * cnt2 - m)
end


Measured memory_bytes: 17912
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		
		int a = P + Q;
		int b = P + R; 
		int c = Q + R;
		
		int x = Math.min(a, b);
		int ans = Math.min(x, c);
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){
  int n,i,x,y,c=0,t;
  //char s[10];
  int l[100];
    
  /*fgets(s,sizeof(s),stdin);
  a[0] = strtok(s, " ");
  
  for(i=1;i<10;i++){
    //printf("a\n");
    a[i] = strtok(NULL, " ");
    }*/
  scanf("%d %d",&x,&y);
  t = x;
  
  for(c=0;c<=x;c++){
    //printf("%s",a[i]);
    if( 2*c + 4*t == y ){
      printf("Yes\n");
      return 0;
    }
    t--;
  }
  printf("No\n");
  return 0;
}

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

using ll = long long;

int main() {
  int N, M;
  scanf("%d%d", &N, &M);

  vector<pair<ll, ll>> AB(N, make_pair(0, 0));
  for (int i = 0; i < N; i++) {
    ll A, B;
    scanf("%lld%lld", &A, &B);
    AB.at(i) = make_pair(A, B);
  }

  sort(AB.begin(), AB.end());

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (M <= 0) break;

    if (AB.at(i).second < M) {
      ans += AB.at(i).first * AB.at(i).second;
      M -= AB.at(i).second;
    } else {
      ans += AB.at(i).first * M;
      M -= M;
    }
  }

  printf("%lld", ans);
  return 0;
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cout << #x << "= " << x<< endl;
// template starts
typedef long long int ll;

// template ends here

string a = "pairwise coprime";
string b = "setwise coprime";
string c = "not coprime";

void solve(){
	// code starts from here
	srand(time(0));
	int N;
	cin >> N;
	vector<ll> vec(N);
	input(vec,N);
	
	random_shuffle(all(vec));
	//sort(all(vec));
	
	//ll limit = 1e7;
	unordered_set<ll> s;
	
	//print(vec,0,N-1);
	bool t = true;
	for(int i = 0; i < N; i++){
		if(!t) break;
		
		for(ll j = 1; j*j <= vec[i]; j++){
			if(vec[i]%j == 0){
				ll f1 = vec[i]/j;
				ll f2 = j;
				
				//debug(f1);
				//debug(f2);
				if(f1 != 1 && s.find(f1) != s.end()){
					t = false;
					break;
				}
				if(f2 != 1 && s.find(f2) != s.end()){
					t = false;
					break;
				}
				
				s.insert(f1);
				if(f2 != 1)s.insert(f2);
			}
		}
	}
	
	//debug(t);
	if(!t){
		ll g = vec[0];
		for(int i = 1; i < N; i++){
			g = __gcd(g,vec[i]);
		}
		if(g == 1) cout << b << endl;
		else cout << c << endl;
	}
	else cout << a << endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 11100
import sys

n,k=map(int,input().split())
a=list(map(int,input().split()))

for i in range(n):
    a[i]-=1
#print(a)

if k<=n:
    b=0
    for i in range(k):
        b=a[b]
    print(b+1)
    sys.exit()
    
b=0
c=[-1]*n
c[0]=0
for i in range(n):
#   print(b,a[b])
   b=a[b]
   if c[b]>=0:
#       print("i:",i)
       break
   else:
       c[b]=i+1

ki=c[b]+1
kc=(i+1)-c[b]
k2=(k-ki)%kc+ki
#print("ki:",ki,"kc:",kc,"k2:",k2)
b=0
for i in range(k2):
    b=a[b]
print(b+1)


Measured memory_bytes: 32404
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>

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

using namespace std;

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

int main() {
	vi a;
	int i, j, k, n, l, m;
	int sum;
	float s;

	cin >> n;

	sum = 0;
	rep(i, n) {
		cin >> j;
		sum += j;
		a.push_back(j);
	}
	k = (int)(sum / n);
	if ((float)k != (float)sum / n) {
		if (k > 0)
			k = (int)((float)sum / n + 0.5);
		else
			k = (int)((float)sum / n - 0.5);
	}
	sum = 0;
	rep(i, n) {
		sum += pow(k - a[i], 2);
	}

	cout << sum;

	return 0;
}


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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    string s;
    cin>>s;
    for(int i=s.size()-1;i>=0;i--){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    set<string> res;
    queue<string> que;
    que.push("a");
    while(!que.empty()) {
        string s = que.front();
        que.pop();
        if(s.size() == N) {
            res.insert(s);
            continue;
        }
        int n = 0;
        rep(i, s.size()) { n = max(n, s[i] - 'a' + 1); }
        for(int i = 0; i <= n; i++)
            que.push(s + (char)('a' + i));
    }
    for(auto s : res) {
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>

using namespace std;


int main(){
  stack<int> train;
  int tmp;
  while(cin >> tmp){
    if(tmp!=0){
      train.push(tmp);
    }else{
      cout << train.top() << endl;
      train.pop();
    }
  }
    
  

  
  return 0;
}

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

using namespace std;

const int mx = 2e5+5;
vector<int> v[mx];
int val[mx]={0};
int par[mx]={-2};

void dfs(int node,int par)
{	
	if(par!=-1)
		val[node]+=val[par];

	for(int i: v[node])
	{
		if(i==par)
			continue;
		dfs(i,node);
	}
}

int main()
{
	int n,q;
	cin>>n>>q;

	int limit = n-1;

	int x,y;
	while(limit--)
	{
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	//parentfind(1,-1);
	while(q--)
	{
		int p,inc;
		cin>>p>>inc;
		val[p]+=inc;
	}
	dfs(1,-1);
	for(int i=1;i<=n;i++)
		cout<<val[i]<<" ";

	cout<<'\n';
	return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    int ans;
    if(S=="RRR") ans=3;
    else if(S=="RRS"||S=="SRR") ans=2;
    else if(S=="SSS") ans=0;
    else ans=1;
    cout << ans << endl;
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 52;
int n, m, q;
int a[N], b[N], c[N], d[N];
vector<int> v;

int rek(int last = 1, int depth = 0) {
  int ret = 0;
  if (depth == n) {
    for (int i = 0; i < q; ++i) {
      if (v[b[i]]-v[a[i]] == c[i])
	ret += d[i];
    }
    return ret;
  }
  for (int i = last; i <= m; ++i) {
    v.push_back(i);
    ret = max(ret, rek(i, depth+1));
    v.pop_back();
  }
  return ret;
}

void solve() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%d%d", a+i, b+i, c+i, d+i);
    --a[i]; --b[i];
  }
  printf("%d", rek());
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int H,W,N;
int X[200010],Y[200010],inf = 1e9;
vector<vector<int>> v(200010);

int main(){
	cin >> H >> W >> N;
	for(int i=1;i<=N;i++){
		cin >> X[i] >> Y[i];
		v[Y[i]].push_back(X[i]);
	}
	for(int i=1;i<=W;i++){
		v[i].push_back(H+1); v[i].push_back(1);
		sort(v[i].begin(),v[i].end());
	}
	int ans = inf,y[W+2] = {};
	y[1] = 1;
	for(int i=1;i<=W;i++){
		for(int j=0;j<v[i].size()-1;j++){
			if(v[i][j]<=y[i] && y[i]<v[i][j+1]){
				ans =  min(ans,v[i][j+1]-1);
				break;
			}
		}
		if(i==W) continue;
		y[i+1] = H;//こういう初期化をしないと大変なことになる
		for(int j=1;j<v[i+1].size();j++){
			if(y[i]+1<v[i+1][j]){
				y[i+1] = y[i]+1;
				break;
			}else y[i] = max(v[i+1][j],y[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	double a, b, x;
	cin >> a >> b >> x;
	cout << fixed << setprecision(9);
	double y = 2 * x / (a * a) - b;
	if (y <= 0)
	{
		y = (2 * x) / (a * b);
		double r = b / y;
		double result = atan(r);
		cout << result * 180 / pi << en;
		return 0;
	}
	b = b - y;
	//cout << b << en;
	double r = b / a;
	double result = atan(r);
	cout << result * 180 / pi << en;


	return 0;
}



Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] d = new int[10];
    for(int i = 0; i < k; i++) {
      int dd = sc.nextInt();
      d[dd] = 1;
    }
    int ans = 0;
    for(int i = n; i < 100000; i++) {
      String str = String.valueOf(i);
      int p = 0;
      for(int j = 0; j < str.length(); j++) {
        int d1 = Integer.parseInt(String.valueOf(str.charAt(j)));
        if(d[d1] == 1) p++;
      }
      if(p == 0) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 53428
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, x: "List[int]", y: "List[int]"):
    if N == 1:
        print(1)
        return
    x, y = zip(*sorted(list(zip(x, y))))
    p_cand = [x[j]-x[i] for i in range(N) for j in range(i+1, N)]
    q_cand = [y[j]-y[i] for i in range(N) for j in range(i+1, N)]

    minimum = INF
    for p, q in set(zip(p_cand, q_cand)):
        # print("(p, q) = ({}, {})".format(p, q))
        xy = list(zip(x, y))
        cost = 0
        while len(xy) > 0:
            xx, yy = xy.pop()
            cost += 1
            # print(xx, yy, xy, xx-p, yy-q)
            while (xx-p, yy-q) in xy:
                xy.remove((xx-p, yy-q))
                xx -= p
                yy -= q
        if minimum > cost:
            minimum = cost
    print(minimum)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, M, K, i, j, a;
  cin >> N >> M >> K;
  a = 0;
  if(K == 0 || K == N*M)
  {
    a = 1;
  }
  for (i = 1; i < N + 1; ++i)
  {
    for (j = 1; j < M + 1; ++j)
    {
      if (i * M + j * N - i * j * 2 == K)
      {
        a = 1;
      }
    }
  }

  if (a == 1)
  {
    cout << "Yes" << endl;
  }
  else if(a == 0)
  {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {

    ll L, R;
    cin >> L >> R;

    if(R - L >= 2019){
        cout << 0 << endl;
        return 0;
    }

    ll ans = LLONG_MAX;
    REP(i, L, R){
        REP(j, i+1, R+1){
            ll tmp = (i * j) % 2019;
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define N 300005

using namespace std;

string s;
int n,sig[N];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(n);
	cin>>s;
}
 
int main(){
	init();
	sig[0]=0;
	for(int i=0;i<s.size();i++)
	sig[i+1]=sig[i]+(s[i]=='E');
	int Min=n;
	for(int i=1;i<=n;i++)
	if(Min>i-1-sig[i-1]+sig[n]-sig[i])
	Min=i-1-sig[i-1]+sig[n]-sig[i];
	cout<<Min<<endl;
	return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  string s;
  cin >> n >> s;
  string ans="";
  for(int i=0; i<n;){
    char tmp=s[i];
    ans+=tmp;
    while(s[i]==tmp) i++;
    //cout << i << endl;
  }
  cout << sz(ans) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#define MAX 100
#define inf 1000000000
#define WHITE 0
#define BLACK 1
#define GRAY 2

int n,A[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=inf;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=inf;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK && A[u][v]!=inf){
	if(d[v]> d[u]+A[u][v]){
	  d[v]=d[u]+A[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    printf("%d",i);
    if(d[i]==inf) printf(" -1\n");
    else printf(" %d\n",d[i]);
  }
}

int main(){
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=inf;
    }
  }

  int k,c,u,v;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][v]=c;
    }
  }

  dijkstra();

  return 0;
}

  
  
    
 



Measured memory_bytes: 2052
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    
    long long int x,k,d,p;
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d >= k) cout << abs(x - (k*d)) << endl;
    else{ 
          p = x%d;
          k = k - (x/d);
          if(k%2 == 0) cout << p << endl;
          else{
              cout << min(abs(p-d),abs(p+d)) << endl;
          }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;


int main() {
	int N, K; cin >> N >> K;
	string S; cin >> S; 
	int ans = 0;
	vector<int> a,b;
	for (int i = 0; i < N; i++) {
		if (S[i] == '1') {
			a.push_back(i);
			while (S[i] == '1') {
				i++;
			}
			i--;
			b.push_back(i);
		}
	}
	if (a.size()<K) {
		cout << N << endl; return 0;
	}
	for (int i = 0; i < a.size()-K; i++) {
		ans = max(ans, b[i + K] - a[i]+1);
	}
	ans = max(ans, b[K - 1]+1);
	ans = max(ans, N-a[a.size()-K]);
	cout << ans << endl;
}




Measured memory_bytes: 1020
#include<bits/stdc++.h>
    using namespace std;
  #define int long long int
    #define endl "\n"
    #define MOD 1000000007
    #define mod 1000000007
    #define M 1000000007
    
    #define pb push_back
    #define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
  //  #define mp make_pair
  #define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
  #define mx 400005
  #define fiint(a,b) memset(a,b,sizeof(a))  
  #define bitcount __builtin_popcount
  #define fori(i,a,b) for(int i=a;i<b;i++)
  #define ford(i,a,b) for(int i=a;i>=b;i--)
  #define debug(x) cout<<x<<endl;
  #define cases(t) int t; cin>>t; while(t--)
  #define inf1 INT_MAX
  #define all(a) a.begin(),a.end()
  #define vec vector<int>
  #define pii pair<int,int>
  #define plii pair<int,int>
  #define pint pair<int,int>
  #define ff first
  #define ss second
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define sz(x) (int)x.size()
#define PI                    3.14159265359

bool prime[10000001];

void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}



signed  main() 
{ 
	int n,k;cin>>n;
	vec v(n+1);
	fori(i,1,n+1) cin>>v[i];
	int dp[n+2][n+2];
	fori(i,0,n+2)
		fori(j,0,n+2)
			dp[i][j]=0;
	int x=0,y=0;
	int turn = 0;
	

	ford(l,n,1)
		fori(r,l,n+1)
			if(l==r)
				dp[l][r] = v[l];
			else
			dp[l][r] = max ( v[r] - dp[l][r-1]  ,v[l] -  dp[l+1][r]  );   
		
		cout<<dp[1][n]<<endl;



}

 


Measured memory_bytes: 70656
class UnionFind:
  def __init__(self, N):
    self.N = N
    self.parent = [-1] * N

  def root(self, i):
    if self.parent[i] < 0:
      return i
    r = self.root(self.parent[i])
    self.parent[i] = r
    return r

  def unite(self, i, j):
    i = self.root(i)
    j = self.root(j)
    if i == j:
      return
    if i > j:
      i, j = j, i
    self.parent[i] += self.parent[j]
    self.parent[j] = i

  def same(self, i, j):
    return self.root(i) == self.root(j)

  def size(self, i):
    return -self.parent[self.root(i)]

  def roots(self):
    return [self.root(i) for i in range(self.N)]

  def groupcount(self):
    return len(set(self.roots()))

N, M = map(int,input().split())
forest = UnionFind(N)

edges = []
for _ in range(M):
  edges.append([int(e) - 1 for e in input().split()])

inconvenience =N*(N-1)//2
score=[]
for a, b in edges[::-1]:
  score.append(inconvenience)
  if not forest.same(a,b):
    inconvenience -= forest.size(a) * forest.size(b)
  forest.unite(a, b)

for s in score[::-1]:
  print(s)

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,C;
  cin>>N>>C;
  VV(ll,d,C,C,0);
  VV(ll,c,N,N,0);
  rep(i,C)rep(j,C)cin>>d[i][j];
  rep(i,N)rep(j,N)cin>>c[i][j];

  VL a[3];
  rep(i,N)rep(j,N)a[(i+j)%3].pb(c[i][j]-1);
  
  VP res[3];
  rep(i,3){
    rep(j,C){
      int calc=0;
      for(auto e:a[i]){
        calc+=d[e][j];
      }
      res[i].pb({calc,j});
    }
  }

  int ans=1e12;
  for(auto x:res[0])
    for(auto y:res[1])
      for(auto z:res[2])
        if(x.se!=y.se && y.se!=z.se && z.se!=x.se)
          chmin(ans,x.fi+y.fi+z.fi);

  out(ans);          
  
  
  return 0;
}



Measured memory_bytes: 4400
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long grid[600000] = {};
vector<long long> finding_X[2000000];
long long zero[600000] = {};
long long cnt_zero(long long l, long long r) {
	long long ans = zero[r];
	if (l != 0) {
		ans -= zero[l - 1];
	}
	return ans;
}
pair<long long,long long> calc(long long X) {
	pair<long long, long long> ans = make_pair(1, 0);
	if (finding_X[X].size() != 0) {
		ans.second = 1;
	}
	for (int i = 1; i < finding_X[X].size(); ++i) {
		long long zero_move = cnt_zero(finding_X[X][i - 1], finding_X[X][i]);
		ans.first += zero_move * ans.second;
		ans.first %= MAX_MOD;
		ans.second += ans.first;
		ans.second %= MAX_MOD;
	}
	return ans;
}
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	REP(i, n) {
		cin >> grid[i + 1];
		grid[i + 1] ^= grid[i];
	}
	for (int i = 1; i <= n; ++i) {
		zero[i] = zero[i - 1];
		if (grid[i] == 0) {
			zero[i]++;
		}
		else {
			finding_X[grid[i]].push_back(i);
		}
	}
	if (grid[n] != 0) {
		cout << calc(grid[n]).first << endl;
		return 0;
	}
	long long ans = 1;
	for (int i = 0; i < zero[n]-1; ++i) {
		ans *= 2;
		ans %= MAX_MOD;
	}
	for (int i = 1; i < (1 << 20); ++i) {
		ans += calc(i).second;
		ans %= MAX_MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 64768
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 1000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

string ans = "Yes";

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

	ll N;
	cin >> N;

	map<char,int> ansstr;
	map<char,int> chcnt;
	string s;
	cin >> s;
	rep(i,s.size()){
		ansstr[s[i]]++;
	}

	rep(i,N-1){
		chcnt.clear();
		cin >> s;
		rep(j,s.size()){
			chcnt[s[j]]++;
		}
		for(auto& p:ansstr){
			if(chcnt.count(p.first)){
				p.second = min(p.second,chcnt[p.first]);
			}
			else{
				ansstr.erase(p.first);
			}
		}
	}

	for(auto p:ansstr){
		rep(i,p.second){
			cout << p.first;
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

prime_A = set()
prime_B = set()

curr = 2
while A > 1:
  if A%curr == 0:
    prime_A.add(curr)
    A = A//curr
  elif curr*curr >=A:
    prime_A.add(A)
    A = 1
  else:
    curr+=1
    
curr = 2
while B > 1:
  if B%curr == 0:
    prime_B.add(curr)
    B = B//curr
  elif curr*curr >=B:
    prime_B.add(B)
    B /= B
  else:
    curr+=1
print(len(prime_A& prime_B)+1)

Measured memory_bytes: 3064
using System;


namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true) {
            String[] s = Console.ReadLine().Split(' ');
            int H = int.Parse(s[0]);
            int W = int.Parse(s[1]);

            if (H == 0 && W == 0) break;
                int i = 0;
                while (true)
                {
                    if (i == H) break;
                    for (int x = 0; x < W; x++)
                    {
                        Console.Write("#");
                    
                    }
                    Console.WriteLine();

                    i++;
                }
                Console.WriteLine();


            }

        }
    }
}

Measured memory_bytes: 9024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9
int com_desc_str(const void* a,const void* b){
   char *x=(char*)a,*y=(char*)b;
   return strcmp(y,x);
} 
int com_dic_str(const void* a,const void* b){
   char *x=(char*)a,*y=(char*)b;
   return strcmp(x,y);
} 
int main(){
   char s[101],t[101];scanf("%s %s",s,t);
   qsort(t,strlen(t),sizeof(char),com_desc_str);
   qsort(s,strlen(s),sizeof(char),com_dic_str);
   //printf("%s %s\n",s,t);
   if(strcmp(s,t)<0)printf("Yes");
   else printf("No");
   /*for(int i = 0;i < MAX(strlen(s),strlen(t));i++){
      if(s[i]<t[i]){
         printf("Yes");
         return 0;
      }else if(s[i]>t[i]){
         printf("No");
         return 0;
      }
      if(i >= strlen(s)&&strlen(s)<strlen(t)){
         printf("Yes");
         return 0;
      }
   }*/
}

Measured memory_bytes: 128
# 23:20
n, m = map(int, input().split())
S = [list(map(int, input().split()))[1:] for i in range(m)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    for s, p in zip(S, P):
        c = 0
        for t in s:
            if (i >> t-1) & 1:
                c += 1
        if c % 2 != p:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}
long long fact(long long n)
{
    if(n==1)
        return 1;
    return n * fact(n-1);
}
pair<int ,char>p;
pair<int ,char>p1;
pair<int ,char>p2;
int main(){
    int a=d(),b=d();
    if(a==b){
    printf("Draw\n");
    return 0;
    }
    if((a>b && b!=1) || (a<b && a==1)){
    printf("Alice\n");
    return 0;
    }
    if((b>a && a!=1)||(b<a && b==1)){
     printf("Bob\n");
     return 0;
    }



}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <set>
#include <unordered_map>
using namespace std;

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

const int INF = 1e9;
const int MAX_V = 1e6+1;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

int N, M, X;
int v[101];
int main() {
  cin >> N >> M >> X;
  fill(v, v + M, false);
  int a;
  rep(i, M) {
    cin >> a;
    v[a] = true;
  }
  int t, u = 0;
  for(int i=X; i>0; i--) {
    if(v[i-1]) t++;
  }
  for(int i=X; i<N; i++) {
    if(v[i+1]) u++;
  }
  int ans = min(t, u);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g;

vector<int> color;
P dfs(int v, int c){
  P res = {0, 0};
  color[v] = c;
  if(c == 1)++res.first; 
  else ++res.second; 
  for(auto nv : g[v]){
    if(color[nv] == c)return {-1, -1};
    if(color[nv] == 0){
      P tmp = dfs(nv, -c);
      if(tmp.first < 0)return {-1, -1};
      res.first += tmp.first;
      res.second += tmp.second;
    }
  }
  return res;
}

int dp[100100];
map<int, int> mp;

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

  color.assign(n, 0);
  int v = 0;
  for(int i = 0; i < n; ++i){
    if(color[i] != 0)continue;
    P p = dfs(i, 1);
    int a = min(p.first, p.second);
    int b = max(p.first, p.second);
    if(a < 0){
      cout << -1 << endl;
      return 0;
    }
    ++mp[b - a];
    v += a;
  }

  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  for(auto p : mp){
    int plus = p.first;
    int num = p.second;
    for(int i = 0; i <= n; ++i){
      if(dp[i] >= 0)dp[i] = num;
      else if(i < plus || dp[i - plus] <= 0)dp[i] = -1;
      else dp[i] = dp[i - plus] - 1;
    }
  }

  ll ans = 0;
  for(int i = 0; i <= n; ++i){
    if(dp[i] >= 0)ans = max(ans, ll(v + i) * (n - v - i));
  }
  cout << ans - m << endl;
  return 0;
}



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

int main(){
    int a,b; cin >> a >> b;
    if (a*b%2==0) cout << "Even";
    else cout << "Odd";
}

Measured memory_bytes: 256
f=->a,b{a.size.times.map{|i|a[b[i]]}}
n,*z=`dd`.split.map &:to_i
t=[*0...n]
e=[*0...n]
a=z.shift(n)<<0
(n-1).downto(1){|i|a[i]-=a[i-1]}
m,k=z.shift 2
z.map{|x|t[x-2],t[x-1]=t[x-1],t[x-2]}
(e=f[e,t]if k%2>0;t=f[t,t];k/=2)while k>0
k=a[0]
n.times{|i|p k;k+=a[e[i]+1]}

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

using namespace std;

bool compare_by_b(pair<unsigned int, unsigned int> a, pair<unsigned int, unsigned int> b)
{
	if (a.second != b.second)
	{
		return a.second < b.second;
	}
	else
	{
		return a.first > b.first;
	}
}

int main(void)
{
	int n;
	cin >> n;
	vector<pair<unsigned int, unsigned int>> task;
	for (int i = 0; i < n; ++i)
	{
		unsigned int bufa, bufb;
		pair<unsigned int, unsigned int> p;
		cin >> bufa >> bufb;
		p = make_pair(bufa, bufb);
		task.push_back(p);
	}
	sort(task.begin(), task.end(), compare_by_b);
	unsigned int sumtime = 0;
	bool flag = true;
	for (int i = 0; i < task.size(); ++i)
	{
		sumtime += task[i].first;
		if (sumtime > task[i].second)
		{
			flag = false;
			break;
		}
	}
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long double pi = 3.14159265;
const long long mod =1e9+7;


int main(){
    int M;
    cin >> M;
    
        cout << 48-M << endl;    

    return 0;
}
 

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


int main()
{
  string a,b;
  cin>>a>>b;
  
  int n=a.size();
  int s=b.size();
  int dp[3100][3100] = {0};
  
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<s;j++)
    {
      if(a[i]==b[j])
      {
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
      }
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
    }
  }
  
  string ans="";
  while(n>0&&s>0)
  {
    if(dp[n][s]==dp[n-1][s])
      n--;
    else if(dp[n][s]==dp[n][s-1])
      s--;
    else
    {
      ans+=a[n-1];
      n--;
      s--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
}

Measured memory_bytes: 37760
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    LL n;
    LL k;
    LL ans=0;
    cin >> n >> k;
    LL tmp;
    LL res;
    for(LL i=k+1; i<=n; i++){
        tmp=n/i;
        res=n%i;
        if(k==0){
            ans+=n;
        }else{
            if(res>=k){
                ans+=res-(k-1);
            }
            if(tmp>=1){
                ans+=tmp*(i-1-(k-1));
            }
        }
        //cout << ans << endl;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k;
  int count,i=0,x=0,y[105]={};
  cin>>a>>b>>k;
  count=a;
  if(a>b) count=b;
  for(int i=1;i<=count;i++){
    if(a%i==0 && b%i==0){
      y[x]=i;
      x++;
    }
  }
  sort(y,y+x,greater<int>());
  cout<<y[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

list=[input() for i in range(N)]

C0 = 0
C1 = 0
C2 = 0
C3 = 0

for j in list:
  if j == 'AC':
    C0 = C0 + 1
  elif j == 'WA':
    C1 = C1 + 1
  elif j == 'TLE':
    C2 = C2 + 1
  elif j == 'RE':
    C3 = C3 + 1
    
print('AC x %d' % C0)
print('WA x %d' % C1)
print('TLE x %d' % C2)
print('RE x %d' % C3)

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

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

	if(a >= b && b >= c){
		cout << c << " " << b << " " << a << endl;
	}
	else if(a >= b && b <= c && a <= c){
		cout << b << " " << a << " " << c << endl;
	}
	else if(a >= b && b <= c && a >= c){
		cout << b << " " << c << " " << a << endl;
	}
	else if(a <= b && b >= c && a <= c){
		cout << a << " " << c << " " << b << endl;
	}
	else if(a <= b && b >= c && a >= c){
		cout << c << " " << a << " " << b << endl;
	}
	else{
		cout << a << " " << b << " " << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
<?php
  $stdin = trim(fgets(STDIN));
  $ary = explode(" ", $stdin);
  $area = (intval($ary[0]) * intval($ary[1]));
  $side = (intval($ary[0]) * 2) + (intval($ary[1]) * 2);
  print ($area . " " . $side);
?>

Measured memory_bytes: 6556
import math
n, k = [int(v) for v in input().split()]

#1-N => iが出たとする
#i * 2^(ai-1) < k <= i * 2^(ai) となる aiを求める
#ai = math.ceil(math.log(k/i, 2)) 
#勝率は(1/2)^ai
#勝率を求めるには i について平均をとればよい
pi = []
for i in range(1,n+1):
  if i < k:
    ai = math.ceil(math.log(k/i, 2))
    pi.append( ((1/2)**ai) / n )
  else:
    pi.append( 1 / n )
    
print(sum(pi))


Measured memory_bytes: 6296
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if((a%3 == 0) || ((b%3) ==0) || ((a+b)%3 == 0)){
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620