akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    int p[a+1],q[b+1],r[c+1];
    for(int i = 1;i<=a;i++)
        cin>>p[i];
    for(int i = 1;i<=b;i++)
        cin>>q[i];
    for(int i = 1;i<=c;i++)
        cin>>r[i];
    sort(p+1,p+a+1,greater<int>());
    sort(q+1,q+b+1,greater<int>());
    sort(r+1,r+c+1,greater<int>());
    vector<int> v;
    for(int i = 1;i<=x;i++){
        v.pb(p[i]);
    }
    for(int i = 1;i<=y;i++){
        v.pb(q[i]);
    }
    for(int i = 1;i<=c;i++){
        v.pb(r[i]);
    }
    sort(all(v),greater<int>());
    int ans = 0;
    for(int i = 0;i<(x+y);i++)
        ans+=v[i];
    cout<<ans;
}

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

int main()
{
    string x;
    cin >> x;
    int stack = 0, puyo = 0;
    rep(i, x.length())
    {
        if (x[i] == 'S')
            stack++;
        else if (stack)
        {
            stack--;
            puyo++;
        }
    }
    cout << x.length() - 2 * puyo << endl;
}

Measured memory_bytes: 640
//Atcoder
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        int k = sc.nextInt();

        int ans = (n - 1) / (k - 1);
        if(ans * (k - 1) < n - 1) ans++;

        pw.println(ans);
        pw.close();
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> table(n+1, vector<int>(n+1));
    rep(i, m){
        int l, r;
        cin >> l >> r;
        table[l][r]++;
    }

    rep(i, n){
        rep(j, n){
            table[i+1][j+1] += (table[i+1][j] + table[i][j+1] - table[i][j]);
        }
    }

    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << table[r][r] - table[l-1][r] - table[r][l-1] + table[l-1][l-1] << endl;
    }
}

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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n, k;

    cin >> n >> k;

    vi v(n);

    double suma = 0;

    for(int i = 0; i < n; i++)
    {
        cin >> v[i];

        if(i < k)
        {
            suma += (v[i] + 1) / 2.00;
        }
    }

    double najbolji = suma;
    double trenutna = suma;

    for(int i = k; i < n; i++)
    {
        trenutna += (v[i] + 1) / 2.00;
        trenutna -= (v[i - k] + 1) / 2.00;

        if(trenutna > najbolji)
        {
            najbolji = trenutna;
        }
    }

    cout << fixed << setprecision(12) << najbolji << '\n';

    return 0;
}


Measured memory_bytes: 1024
using System;

namespace AtCoderBeginnerContest174
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = int.Parse(Console.ReadLine());

			if(input >= 30)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}

		}
	}
}


Measured memory_bytes: 27520
// 2019/06/14
// AtCoder Beginner Contest 097 - A 
 
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
    // Input
    int a;
    int b;
    int c;
    int d;
    string ans;
  
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
  
    // Calc
    if((abs(a - b) <= d && abs(c - b) <= d) || abs(c - a) <= d){
        ans = "Yes";
    } else {
        ans = "No";
    }
 
    // Output
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100005],b[100005];
int main()
{
	cin>>a;
	for(int i=0;i<strlen(a);i++){
		b[i]=a[strlen(a)-i-1];
		if(b[i]=='b')
		b[i]='d';
		else if(b[i]=='d')
		b[i]='b';
		else if(b[i]=='p')
		b[i]='q';
		else if(b[i]=='q')
		b[i]='p';
		if(b[i]!=a[i]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
#include<iostream>  
#include<cstdio>  
using namespace std;  
long long ans=0, b=0; 
int a[1000005];  
int main()  
{  
    int n, x;  
    scanf("%d%d", &n, &x);  
    for(int i = 1; i <= n; i++) 
	scanf("%d", &a[i]);   
    for(int i = 1; i <= n; i++)  
    {  
        if(b + a[i] <= x)
		b = a[i];  
        else 
		{
		 ans += b + a[i] - x;
		 b = a[i] - (b + a[i] - x);
	    }
    }  
    printf("%lld\n", ans);  
    return 0;  
}  


Measured memory_bytes: 640
#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;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,K;

void solve(int node_num) {
    vector<pair<int,int>> ans;

    for(int i = 2;i <= N;i++) {
        ans.push_back({1,i});
    }

    for(int l = 2;l < N;l++) {
        for(int r = l+1;r <= N;r++) {
            if(node_num == 0)
                break;
            ans.push_back({l,r});
            node_num--;
            
        }
        if(node_num==0)
            break;
    }

    cout<<ans.size()<<endl;
    for(auto u:ans) {
        cout<<u.first<<" "<<u.second<<endl;
    }

    return;
}

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

    if(K > ((N-1)*(N-2))/2) {
        cout<<-1<<endl;

        return 0;
    }

    int node = ((N-1)*(N-2))/2 - K;
    solve(node);

    return 0;
}



Measured memory_bytes: 384
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

int w, a, b;

int main() {
  cin >> w >> a >> b;

  solve();

  return 0;
}

void solve() {

  if((b>=a&&b<=a+w) || (b+w>=a&&b+w<=a+w)) {
    cout << 0 << endl;
  }else if(a+w<b) {
    cout << b-(a+w) << endl;
  }else {
    cout << a-(b+w) << endl;
  }
}


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

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<char> Alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
vector<char> alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main()
{
  cout << fixed << setprecision(10);
  double D,T,S;
  cin >> D >> T >> S;
  if(S*T>=D)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


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

const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


  
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

long long N;
int main(){
    cin>>N;
    mint m=1LL,m_=1LL,m__=1LL;
    for(int i=0;i<N;i++)m*=10LL;
    for(int i=0;i<N;i++)m_*=9LL;
    for(int i=0;i<N;i++)m__*=8LL;
    cout<<m-m_-m_+m__<<endl;
    return 0;
}

Measured memory_bytes: 3572
#!/usr/bin/env python3

"""Determines whether an input integer is prime, by trial division.

Verification: [ALDS1_1_C](https://onlinejudge.u-aizu.ac.jp/status/users/hamukichi/submissions/1/ALDS1_1_C/judge/4573080/Python3)
"""


def is_prime_trial_division(n):
    """Determing whether the given integer `n` is prime by trial division.

    """

    assert n > 0
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True


def count_primes(ms):
    return sum(is_prime_trial_division(m) for m in ms)


def main():
    n = int(input())
    ms = [int(input()) for _ in range(n)]
    print(count_primes(ms))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int n;
  cin >> n;
  int a[n];
  int b[n];
  r(i,n){
    cin >> a[i];
    b[i]=a[i];
  }

  sort(b, b+n);
  r(i,n){
    if(a[i]<=b[n/2-1])cout << b[n/2] << endl;
    else cout << b[n/2-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>

using namespace std; 

typedef unsigned long long ull;

bool tri(ull x, ull y, ull z, ull d, ull e, ull f){

	ull b[6] = {x,y,z,d,e,f};
	ull p[6];

	p[0]=b[0]; p[1]=b[1]; p[2]=b[2]; p[3]=b[3]; p[4]=b[4]; p[5]=b[5];
	if((((p[0]+p[1])>p[2])&&((p[2]+p[0])>p[1])&&((p[1]+p[2])>p[0]))&& (((p[3]+p[4])>p[5])&&((p[4]+p[5])>p[3])&&((p[3]+p[5])>p[4] )) ){return true;}

	if((((p[0]+p[1])>p[3])&&((p[3]+p[0])>p[1])&&((p[1]+p[3])>p[0]))&& (((p[2]+p[4])>p[5])&&((p[4]+p[5])>p[2])&&((p[2]+p[5])>p[4] )) ){return true;}

	if((((p[0]+p[1])>p[4])&&((p[4]+p[0])>p[1])&&((p[1]+p[4])>p[0]))&& (((p[3]+p[2])>p[5])&&((p[2]+p[5])>p[3])&&((p[3]+p[5])>p[2] )) ){return true;}

	if((((p[0]+p[1])>p[5])&&((p[5]+p[0])>p[1])&&((p[1]+p[5])>p[0]))&& (((p[3]+p[4])>p[2])&&((p[4]+p[2])>p[3])&&((p[3]+p[2])>p[4] )) ){return true;}

	if((((p[0]+p[3])>p[2])&&((p[2]+p[0])>p[3])&&((p[3]+p[2])>p[0]))&& (((p[1]+p[4])>p[5])&&((p[4]+p[5])>p[1])&&((p[1]+p[5])>p[4] )) ){return true;}

	if((((p[0]+p[4])>p[2])&&((p[2]+p[0])>p[4])&&((p[4]+p[2])>p[0]))&& (((p[3]+p[1])>p[5])&&((p[1]+p[5])>p[3])&&((p[3]+p[5])>p[1] )) ){return true;}

	if((((p[0]+p[5])>p[2])&&((p[2]+p[0])>p[5])&&((p[5]+p[2])>p[0]))&& (((p[3]+p[4])>p[1])&&((p[4]+p[1])>p[3])&&((p[3]+p[1])>p[4] )) ){return true;}

	if((((p[0]+p[3])>p[4])&&((p[4]+p[0])>p[3])&&((p[3]+p[4])>p[0]))&& (((p[1]+p[2])>p[5])&&((p[1]+p[5])>p[2])&&((p[2]+p[5])>p[1] )) ){return true;}

	if((((p[0]+p[3])>p[5])&&((p[5]+p[0])>p[3])&&((p[3]+p[5])>p[0]))&& (((p[1]+p[2])>p[4])&&((p[1]+p[4])>p[2])&&((p[2]+p[4])>p[1] )) ){return true;}

	if((((p[0]+p[4])>p[5])&&((p[5]+p[0])>p[4])&&((p[4]+p[5])>p[0]))&& (((p[1]+p[2])>p[3])&&((p[1]+p[3])>p[2])&&((p[2]+p[3])>p[1] )) ){return true;}

	return false;
}

int main()
{
	int N;

	cin >> N;
	ull* bar = new ull[N];

	bool count = false;
	ull ans=0;

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

	sort(bar, bar+N, greater<ull>());

	for(int i=0; i<N-5; i++){
		for(int j=i+3; j<N-2; j++){
			if( tri(bar[i],bar[i+1],bar[i+2],bar[j],bar[j+1],bar[j+2]) ){
				ans = ans + bar[i]+bar[i+1]+bar[i+2]+ bar[j]+bar[j+1]+bar[j+2];
				cout << ans << endl;
				delete[] bar;
				return 0;
			}
		}
	}

	delete[] bar;	
	cout << "0" << endl;

	return 0;
}

Measured memory_bytes: 1800
#include <iostream>

int main() {
	using namespace std;

	for (;;) {
		int a, b;
		cin >> a >> b;
		if (cin.eof()) { break; }

		int sum = a + b;
		int num = 0;
		for (; sum != 0; ++num) {
			sum /= 10;
		}

		cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N,M=map(int,input().split())
A=list(map(int,input().split()))

if N % 2 == 0:
  if 1 in A:
    print(int('1'*(N//2)))
    exit()

need =(2,5,5,4,5,6,3,7,6)

if 2 in A and 3 in A:
  del A[A.index(2)]
if 3 in A and 5 in A:
  del A[A.index(3)]
if 6 in A and 9 in A:
  del A[A.index(6)]
if 1 in A and 4 in A:
  del A[A.index(4)]
if 6 in A and 7 in A:
  del A[A.index(6)] 
if 7 in A and 9 in A:
  del A[A.index(9)] 
if 1 in A and 6 in A:
  del A[A.index(6)] 
if 1 in A and 9 in A:
  del A[A.index(9)] 
  
A = tuple(A)
M = len(A)

dp = [[0]*(N+1) for _ in range(M)]
dpmax = [0]*(N+1)

def take_max():
  return max(A[i]*(10**len(str(tmp2)) + tmp2,tmp2*10+A[i]))

for j in range(2,N+1):
  tmpmax = 0
  for i in range(M):
    tmp = need[A[i]-1]
    if j == tmp:
      dp[i][j] = A[i]
    elif j > tmp:
      if dpmax[j-tmp] != 0:
        tmp2 = dpmax[j-tmp]
        dp[i][j] = take_max()
    if tmpmax < dp[i][j]:
      tmpmax = dp[i][j]
  dpmax[j] = tmpmax
  
print(dpmax[-1])

Measured memory_bytes: 93504
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int x, ll int y){
	ll int jhogeo = 1;
	rep(jinto,0,y) jhogeo=jhogeo*x;
	return jhogeo;
}


int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b) cout<<"YES";
  else cout<<"NO";
      
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

bool check(const string& S)
{
  if (S[0] != 'A') return false;
  int upper = 0;
  bool C = false;
  for (size_t i = 0; i < S.size(); ++i) {
    char c = S[i];
    if (c >= 'A' and c <= 'Z') ++upper;
    if (c == 'C' and i >= 2 and i <= S.size() - 2) C = true;
  }
  if (upper != 2 or !C) return false;
  return true;
}

int main()
{
  string S;
  cin >> S;
  cout << (check(S) ? "AC" : "WA") << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
  
def solve(i,m):
  if m == 0:
    return True
  if i >= n or m - sum(A) > 0:
    return False
  res = solve(i+1,m) or solve(i+1, m-A[i])
  return res

for j in range(q):
   if solve(0,M[j]):
      print "yes"
   else:
      print "no"
 

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

using std::ios_base;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::fixed;

using std::vector;
using std::string;
using std::stack;
using std::queue;
using std::deque;
using std::map;
using std::set;
using std::unordered_map;
using std::unordered_set;

using std::tuple;
using std::make_tuple;
using std::pair;
using std::make_pair;

using std::sort;
using std::reverse;
using std::nth_element;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int MAXN = 100000;
const int INF = 1e9;
const int MOD = 1e9+7;
const int64_t L_INF = 4e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << std::min(a, b) + std::min(c, d) << '\n';

    #ifdef LOCAL
        cerr << "\n== " << 1.0 * clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        int count = 0;
        for(int x = 0; x <= n[0]; x++)
        {
            for(int y = 0; y <= n[0]; y++)
            {
                int z = n[1] - x - y;
                if(0 <= z && z <= n[0])
                    count++;
            }
        }
        WriteLine(count);
        ReadLine();
    }
}



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

using namespace std;
const int maxn = 200005;
int n, ans;
char c[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> c[i];
    int i = 1, r = n;
    for (; i <= n; i++) {
        while (c[r] == 'W' && r > i) r--;
        if (c[i] == 'W' && i < r && c[r] == 'R') {
            swap(c[i], c[r]);
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include<string.h>
#include<vector>
using namespace std;

#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

int main(void) {
	int n, p[50], i, j, temp, count = 0;  
	cin >> n;
	rpt(i, n) {
		cin >> p[i];
	}

	rpt(i, n) {
		if (i + 1 != p[i]) {
			count++;
		}
	}
	if (count == 0 | count == 2) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::map<std::pair<int64_t, int64_t>, int64_t> list;
  std::set<std::pair<int64_t, int64_t>> dif;

  for (int64_t i = 0; i < n; i++) {
    int64_t a, b;
    std::cin >> a >> b;
    list.insert(std::make_pair(std::make_pair(a, b), 0));
  }

  for (auto itr = list.cbegin(); itr != list.cend(); itr++) {
    for (auto j = list.cbegin(); j != list.cend(); j++) {
      if (itr != j) {
        const auto &a = itr->first;
        const auto &b = j->first;
        dif.insert(std::make_pair(a.first - b.first, a.second - b.second));
      }
    }
  }

  int64_t cost = n;

  for (const auto &v : dif) {
    int64_t t = 0;
    for (const auto &i : list) {
      const auto &a = i.first;
      if (list.find(std::make_pair(a.first - v.first, a.second - v.second)) ==
          list.cend()) {
        t++;
      }
    }
    cost = std::min(cost, t);
  }

  std::cout << cost << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int s;
   cin>>s;
   map<int,int>A;
   int f=s;
   int cnt=1;
   A[s]=1;
   rep(i,1000000){
       if(f%2==1){
           f=3*f+1;
       }
       else{
           f/=2;
       }
       cnt++;
       A[f]++;
       if(A[f]==2){
           break;
       }
   }
   cout<<cnt<<endl;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



template <typename T>
class dijkstra
{
private:
    using P = pair<T, T>;
    struct edge{
        T to, cost;
    };
    long long vertex;   // 頂点数
    vector<vector<edge>> list;  //隣接リスト
    vector<T> distance;    // 距離
public:
    dijkstra(long long n);  // nは頂点の数
    void add_edge(T v1, T v2, T cost);    // 頂点v1から頂点v2に辺を張る
    void run(long long s);        // sは開始地点。
    T get_distance(long long v);    // 頂点vへの距離を返す
};

template <typename T>
dijkstra<T>::dijkstra(long long n){
    vertex = n;
    list.resize(n);
}

template <typename T>
void dijkstra<T>::add_edge(T v1, T v2, T cost){
    list[v1].push_back({ v2, cost });
}

template <typename T>
void dijkstra<T>::run(long long s){
    priority_queue<P, vector<P>, greater<P>> que;
    distance = vector<T>(vertex, 1e16);
    distance[s] = 0;    // 開始点の距離は0
    que.push(P(0, s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        T v = p.second;
        if(distance[v] < p.first) continue;
        for(auto e : list[v]){
            if(distance[e.to] > distance[v] + e.cost){
                distance[e.to] = distance[v] + e.cost;
                que.push(P(distance[e.to], e.to));
            }
        }
    }
}

template <typename T>
T dijkstra<T>::get_distance(long long v){
    return distance[v];
}



int main() {
    ll sx, sy, gx, gy, n;
    cin >> sx >> sy >> gx >> gy >> n;
    
    vector<ll> x(n), y(n), z(n);
    REP(i, n){
        cin >> x[i] >> y[i] >> z[i];
    }
    
    dijkstra<double> dik(n + 2);
    
    dik.add_edge(0, n + 1, sqrt(pow(gx - sx, 2) + pow(gy - sy, 2)));
    REP(i, n){
        dik.add_edge(0, i + 1, max(sqrt(pow(x[i] - sx, 2) + pow(y[i] - sy, 2)) - z[i], 0.0));
        dik.add_edge(i + 1, 0, max(sqrt(pow(x[i] - sx, 2) + pow(y[i] - sy, 2)) - z[i], 0.0));
        dik.add_edge(n + 1, i + 1, max(sqrt(pow(x[i] - gx, 2) + pow(y[i] - gy, 2)) - z[i], 0.0));
        dik.add_edge(i + 1, n + 1, max(sqrt(pow(x[i] - gx, 2) + pow(y[i] - gy, 2)) - z[i], 0.0));
    }
    REP(i, n - 1){
        for(int j = i + 1; j < n; j++){
            dik.add_edge(i + 1, j + 1, max(sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2)) - z[i] - z[j], 0.0));
            dik.add_edge(j + 1, i + 1, max(sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2)) - z[i] - z[j], 0.0));
        }
    }
    
    dik.run(0);
    
    printf("%.10lf\n", dik.get_distance(n + 1));
}


Measured memory_bytes: 22384
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, M = read_ints()
# グラフ構造が与えられたとき
from collections import defaultdict
light = []
for i in range(M):
    S = read_ints()
    light.append([s-1 for s in S[1:]])
P = read_ints()

# print(light)
n = N

ans = 0  # すべての電球がつくパターン
for i in range(1 << n):
    # スイッチの付き方のパターンを2進数で全探索
    for l_idx, l in enumerate(light):
        # 個々のlightについて探索
        ltmp = 0  # ついているスイッチの数
        for j in l:
            if (i >> j) % 2:
                # もしビットが1だったらswitch on
                ltmp += 1
        if ltmp % 2 != P[l_idx]:
            # 電球がつかなかった
            break
    else:
        ans += 1


print(ans)


Measured memory_bytes: 3424
#include <iostream>
#include <string>
#include <regex>

using namespace std;

bool isTypeOfKeyence(string);

int main(){
    string s;
    cin >> s;
    if(isTypeOfKeyence(s)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

bool isTypeOfKeyence(string s){
    regex re1(".*keyence");
    regex re2("k.*eyence");
    regex re3("ke.*yence");
    regex re4("key.*ence");
    regex re5("keye.*nce");
    regex re6("keyen.*ce");
    regex re7("keyenc.*e");
    regex re8("keyence.*");

    if(regex_match(s, re1)) return true;
    if(regex_match(s, re2)) return true;
    if(regex_match(s, re3)) return true;
    if(regex_match(s, re4)) return true;
    if(regex_match(s, re5)) return true;
    if(regex_match(s, re6)) return true;
    if(regex_match(s, re7)) return true;
    if(regex_match(s, re8)) return true;
    return false;
}

Measured memory_bytes: 888
N=gets.to_i
s1 = gets.chomp
s2 = gets.chomp

a = s1.chars.uniq

if N==1 then
  puts 3
  exit
elsif N==2 then
  puts 6
  exit
end

count = []
ison = true
tor = 6

count << s1.count(a[0])
count << s1.count(a[1])
ison = false if count[1]>1

if count[0]*count[1] == 4 then
  tor = 18
end

(a.size-2).times{|i|
  count << s1.count(a[i+2])
  noon = count[i+2]==1
  if ison == noon then
    if ison then
      tor = tor*2%1000000007
    else
      tor = tor*3%1000000007
    end
  else
    if ison then
      tor = tor*2%1000000007
    else
      tor = tor*1%1000000007
    end
  end
  ison = noon
}

puts tor

Measured memory_bytes: 1788
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<bitset>
#include<stack>
#include<cctype>
#define sc(x) scanf("%d",&x);
#define pr(x) cout<<#x<<": "<<x<<" ";
#define prln(x) cout<<#x<<": "<<x<<endl;
#define bug() cout<<"bug: "<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps = 1e-4;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e3+7;
const int maxm = 1e6+7;
const double pi = acos(-1.0);

ll gcd(ll a,ll b){
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main(){
	int n; cin>>n; ll a[maxn];
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	ll ans=1;
	for(int i=1; i<=n; i++){
		ll gg = gcd(a[i],ans);
		ans = ans/gg*a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int x = 700;
	for (int i = 0 ; i < 3 ; i++) {
		if (s[i] == 'o') x += 100;
	} 
	cout << x;
}
/*
*/

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int a,i,j,h;
  cin>>a;
  i=a/3600;
  j=(a-i*60*60)/60;
  h=(a-j*60-i*3600);
  cout<<i<<":"<<j<<":"<<h<<'\n';
  return 0;
}



Measured memory_bytes: 3112
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	x,n = readline() |> split |> parseMap
	if n==0
		println(x)
	else
	p = readline() |> split |> parseMap
	s = Set{Int}(p)
	f = 0
	l = 0
	while f==0
		if !(x-l in s)
			f = 1
			println(x-l)
			break
		end
		if !(x+l in s)
			f = 1
			println(x+l)
			break
		end
		l+=1
	end
end
end

main()

Measured memory_bytes: 163716
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long total = 1;
		long A = sc.nextInt();
		long B = sc.nextInt();
		//A>B←条件　?がifの役割 A:B 左がtrue,右がfalse
		long c = A>B? A:B;
		List<Long> list = new ArrayList<Long>();
		boolean bool = true;
		//boolにfalseが入るまで繰り返す。
		while(bool) {

			for(long i = c; i <= c ;i--  ) {
				if(A%i == 0 && B%i ==0) {
					list.add(i);
					A = A / i;
					B = B / i;
					break;
				}
				if(i <= 2) {
					bool = false;
					break;

				}
			}

		}
		list.add(A);
		list.add(B);
		for(int i = 0; i < list.size(); i++) {
			total = total * list.get(i);
		}
		System.out.println(total);
	}

}

Measured memory_bytes: 21972
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

std::string substrBack(std::string str, size_t pos, size_t len) {
	const size_t strLen = str.length();

	return str.substr(strLen - pos, len);
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> sl(m);
	vector<int> pl(m);
	rep(i, m) {
		int k;
		cin >> k;
		rep(j, k) {
			int s;
			cin >> s;
			sl[i].push_back(s);
		}
	}
	rep(i, m) {
		int p;
		cin >> p;
		pl[i] = p;
	}
	int ans = 0;
	int c = pow(2, n);
	rep(i, c) {
		bool isOK = true;
		rep(k, m) {
			int count = 0;
			int p = pl[k];
			rep(j, n) {
				if ((i >> j) & 1) {
					rep(l, sl[k].size()) {
						if (j == (sl[k][l] - 1)) {
							count++;
						}
					}
				}
			}
			if (count % 2 != p) {
				isOK = false;
			}
		}
		if (isOK) ++ans;
	}
	cout << ans << endl;
	system("pause");
}




Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 998244353
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
int main()
{
       ios::sync_with_stdio(0) ;
       cin.tie(0); 
        long  double l;
       cin>>l;
       long double ans=1;
       ans=l*l*l;
       ans/=27;
       cout<<fixed<<setprecision(9)<<ans<<endl;
  return 0 ;
}
//make all values ll



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,sum=0;
  cin>>N;
  vector<int> t(N);
  for(int i=0;i<N;i++){
       cin>>t.at(i);
  }
  cin>>M;
  vector<int> p(M);
  vector<int> x(M);
  for(int i=0;i<M;i++)
    cin>>p.at(i)>>x.at(i);
  for(int i=0;i<N;i++)
    sum+=t.at(i);
  for(int i=0;i<M;i++){
    cout<<sum-t.at(p.at(i)-1)+x.at(i)<<endl;
  }
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  rep(i,0,n){
    if(i==n-1||s[i]!=s[i+1])res++;
    else{

    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int add(int a[], int b[]);

int main(){
	const int smax = 81;
	int n;
	int a[smax + 1];
	int b[smax + 1];
	int sum[smax + 1];
	string s1, s2;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s1 >> s2;
		if(s1.size() >= smax || s2.size() >= smax){
			cout << "overflow" << endl;
		} else {
			int i = 1;
			for(int i = 1; i <= smax; i++){
				a[i] = 0; b[i] = 0; sum[i] = 0;
			}
			for(string::const_reverse_iterator iter = s1.rbegin();
				iter != s1.rend(); iter++)
			{
				a[i++] = ((int)(*iter) - 48);
			}
			i = 1;
			for(string::const_reverse_iterator iter = s2.rbegin();
				iter != s2.rend(); iter++)
			{
				b[i++] = ((int)(*iter) - 48);
			}
			int c = 0;
			for(int j = 1; j < smax; j++){
				sum[j] = (a[j] + b[j] + c) % 10;
				c = (a[j] + b[j] + c) / 10;
			}
			if(c){
				cout << "overflow" << endl;
			} else {
				int sum_sz = max(s1.size(), s2.size());
				if(sum[sum_sz + 1]) cout << 1;
				for(int k = sum_sz; k >= 1; k--)
					cout << sum[k];
				cout << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =1000005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main()
{
	fio;
	ll n,w;cin>>n>>w;
	vl weight(n),value(n);
	f(n){cin>>weight[i]>>value[i];}
	ll sum_value=0;
	f(n)sum_value+=value[i];
	vl dp(sum_value+1,linf);
	dp[0]=0;
	for(ll i=0;i<n;i++)
	{
		for(ll value_ream=sum_value-value[i];value_ream>=0;value_ream--)
		{
			dp[value_ream+value[i]]=min(dp[value_ream]+weight[i],dp[value_ream+value[i]]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=sum_value;i++)
	{
		if(dp[i]<=w)ans=max(ans,i);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) {//最大公約数
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp; 
    }
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {//最小公倍数
    return a * b / gcd(a, b);
}

int main() {
    ll n; cin >> n;
    ll now=0,num=1,ans=0;
    while(now<n){
        if(num%3==0 || num%5==0){
        }else if(num%3==0){
        }else if(num%5==0){
        }else{
            ans += num;
            //cout << num << endl;
        }
        num++;
        now++;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3576
a,b=map(int,input().split())
if a==1:
    if b==1:
        print('Draw')
    else:
        print('Alice')
else:
    if b==1:
        print('Bob')
    else:
        if a>b:
            print('Alice')
        elif a==b:
            print('Draw')
        else:
            print('Bob')

Measured memory_bytes: 3060
[N,M] = list(map(int,input().split()))
cnt = [0]*M
for i in range(N):
  A = list(map(int,input().split()))
  for a in A[1:]:
    cnt[a-1] += 1
ans = 0
for i in range(M):
  if cnt[i] == N:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define N 100004
int S[N];
int memo[N];
int n,k;
int dp(int pos) {
    if(pos == n-1) {
        return 0;
    }
    if(memo[pos]!=-1) return memo[pos];
    int s = 1e9;
    for(int i = 1; i <= k; i++) {
        if(pos + i < n) {
            s = min(s, abs(S[pos] - S[pos+i]) + dp(pos+i));
        }
    }
    return memo[pos] = s;
}
int main(){
    scanf("%d %d",&n, &k);
    for(int i = 0; i < n; i++) {
        scanf("%d",S + i);
        memo[i] = -1;
    }
    printf("%d\n", dp(0));
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
ll last0(ll n){
  ll ans=n/10;
  return ans;
}
ll last5(ll n){
  ll ans=0;
  ll buf=n;
  while(buf>0){
    buf/=5;
    ans+=buf;
    ans-=buf/2;
  }
  return ans;
}
ll solve(ll n){
  ll buf=n;
  ll keta=0;
  ll ans=0;
  ans+=last0(buf);
  buf/=10;
  while(buf>0){
    ans+=last0(buf);
    ans+=last5(buf);
    buf/=10;
  }
  return ans;
}
int main(){
  ll n;cin>>n;
  ll ans=0;
  if(n%2==1){
    ans=0;
  }
  else{
    ans=solve(n);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<char>> s(55, vector<char>(55));
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> s[i][j];
        }
    }
    vector<vector<int>> s2(55, vector<int>(55));
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (s[i][j] == '#') {
                s2[i][j] = -10;
                ++s2[i-1][j-1];
                ++s2[i-1][j];
                ++s2[i-1][j+1];
                ++s2[i][j-1];
                ++s2[i][j+1];
                ++s2[i+1][j-1];
                ++s2[i+1][j];
                ++s2[i+1][j+1];
            }
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (s2[i][j] < 0) cout << '#';
            else cout << s2[i][j];
        }
        cout << '\n';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 10001
#define M 501
using namespace std;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef long long ll;
string A,B,C;

ll calc(ll idx1,ll sameA,ll sameB){
  static int mem[N][2][2],used[N][2][2]={};
  if(idx1 == (int)A.size()) return 1;
  if(used[idx1][sameA][sameB]++) return mem[idx1][sameA][sameB];
  ll res = 0;
  for(ll i='0';i<='9';i++){
    if(sameA && i < A[idx1]) continue;
    if(sameB && i > B[idx1]) continue;
    ll nidx1 = idx1+1;
    ll nA = sameA & (i == A[idx1]);
    ll nB = sameB & (i == B[idx1]);      
    res = (res + calc(nidx1,nA,nB))%mod;
  }
  return mem[idx1][sameA][sameB] = res;
}

typedef pair<int,int> P;
typedef pair<P,P> PP;
map<PP,int> mem[N];
ll dfs(ll idx1,ll idx2,ll sameA,ll sameB,ll ok){
  PP p = PP(P(idx2,sameA),P(sameB,ok));
  if(idx1 == (int)A.size()) return 0;
  if(mem[idx1].count(p)) return mem[idx1][p];

  ll res = 0;
  for(ll i='0';i<='9';i++){
    if(sameA && i < A[idx1]) continue;
    if(sameB && i > B[idx1]) continue;
    if(idx2 && C[idx2] != i) continue;
    ll nidx1 = idx1+1;
    ll nidx2 = C[idx2] == i? idx2+1:0;
    ll nA = sameA & (i == A[idx1]);
    ll nB = sameB & (i == B[idx1]);      
    ll nok = ok | (i != '0');
    if(nidx2 == (int)C.size()) res = (res + nok*calc(nidx1,nA,nB)) % mod;
    else res = (res + dfs(nidx1,nidx2,nA,nB,nok))%mod;
    if(nidx2 == 1) res = (res + dfs(nidx1,0,nA,nB,nok))%mod;
  }
  if(idx2 <= 1) mem[idx1][p] = res % mod;
  return res % mod;
}

signed main(){
  cin>>A>>B>>C;
  A = string(B.size()-A.size(),'0') + A;
  cout<<(dfs(0,0,1,1,0) + (A == string(A.size(),'0') && C == "0"))%mod<<endl;
  return 0;
}

Measured memory_bytes: 7980
//https://atcoder.jp/contests/abc098/tasks/arc098_b
//xor x^x で打ち消せる
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    ll left=0;
    ll right=0;
    ll sum=0;
    ll xo=0;
    ll ans=0;
#if 0
    while(right<N){
        //右を動かす
        while(right<N) {
            auto a=an.at(right);
            auto n_sum = sum + a;
            auto n_xo = xo ^ a;
            if (n_sum == n_xo) {
                sum = n_sum;
                xo = n_xo;
                ++ans;
                ++right;
            } else {
                break;
            }
        }
        //左を動かす
        do {
			auto dv = an.at(left);
			sum -= dv;
			xo ^= dv;
			++left;
		    ans += (right - left);
		} while(sum == xo && right-left>0);
	}
#else
    while(right<N){
        if (right>=N) break;
        auto a=an.at(right);
        auto n_sum = sum + a;
        auto n_xo = xo ^ a;
        if (n_sum == n_xo) {
            sum = n_sum;
            xo = n_xo;
            ++ans;
            ++right;
        } else {
            do {
                auto dv=an.at(left);
                sum -= dv;
                xo ^= dv;
                ++left;
            } while(sum != xo);
            ans += (right-left);
        }
    }
    while(right - left > 0) {
		auto dv = an.at(left);
		sum -= dv;
		xo ^= dv;
		++left;
        if (sum == xo) {
	        ans += (right - left);
        }else{
            break;
        }
	}
#endif
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n=1000, a, b;    cin >> a >> b;
    int tmp=b, dig=0;
    while(0<tmp){
        dig += 1;
        tmp /= 10;
    }
    int obj = b + a*pow(10, dig);
    string ans="No";
    for(int i=2; i<=n; i++){
        if(i*i != obj) continue;
        ans = "Yes";
        break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A1 = np.array(list(map(int, input().split())))
A2 = np.array(list(map(int, input().split())))

A1_ = np.cumsum(A1)
A2_ = np.cumsum(A2[::-1])[::-1]

print((A1_ + A2_).max())


Measured memory_bytes: 12508
#include <cstdio>  
#include <algorithm>
using namespace std;  
int main() { 	
	int a,b,c;
	int d;
	scanf("%d %d %d", &a,&b,&c);
	
	if(a*c<=b){
		printf("%d", c);
	}
	if(a*c>b){
		if(a>b){
			printf("0");
		}
		else{
			printf("%d", b/a);
		}
	}

	
	
}






Measured memory_bytes: 128
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
L K(L f){p=X[f];n=X[b];return p-n?M(O[E[p]<E[n]?p=n,a=b,b=f,a:f])-M(O[p])+G(p)+K(P[p]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(b=p=0);p<n;p++)if(!p|H[P[a=p]]-p)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=p;
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Measured memory_bytes: 33476
#include <cstdio>

const long long mod=1000000007ll;

int main()
{
  static long long P[401][401];
  for(int i=0;i<=400;i++){
    P[i][0]=1;
    for(int j=1;j<=400;j++){
      P[i][j]=P[i][j-1]*i%mod;
    }
  }
  int N,C;
  scanf("%d%d",&N,&C);
  int A[400],B[400];
  for(int i=0;i<N;i++){
    scanf("%d",A+i);
  }
  for(int i=0;i<N;i++){
    scanf("%d",B+i);
  }
  static long long S[401][401];
  for(int i=0;i<N;i++){
    for(int j=0;j<=C;j++){
      S[i][j]=0ll;
      for(int k=A[i];k<=B[i];k++){
	S[i][j]+=P[k][j];
	S[i][j]%=mod;
      }
    }
  }
  static long long dp[401][401];
  for(int j=0;j<=C;j++){
    dp[0][j]=S[0][j];
  }
  for(int i=0;i<N-1;i++){
    for(int j=0;j<=C;j++){
      dp[i+1][j]=0ll;
      for(int k=0;k<=j;k++){
	dp[i+1][j]+=dp[i][j-k]*S[i+1][k]%mod;
	dp[i+1][j]%=mod;
      }
    }
  }
  printf("%lld\n",dp[N-1][C]);
  return 0;
}


Measured memory_bytes: 3968