akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#define int long long // −9·10^18 to 9·10^18
#define lll __int128_t //−10^38 to 10^38
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define end "\n";

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}

template<typename... T>
void write(T&&... args) {
	((cout << args << " "), ...);
}

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
#define gcd(x,y) return __gcd(x,y);

void fio()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Desktop/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Desktop/CP/output.txt", "w", stdout);
#endif
}

void solve()
{
	string ip;
	set<string> s;
	w(n)
	{
		read(ip);
		s.insert(ip);
	}
	cout << s.size() << end;
}

int32_t main()
{
	fio();
	return solve(), 0;
}


Measured memory_bytes: 19132
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int A = N / 100;
  int B = N % 100;
  if (A <= 12 && A >= 1) {
    if (B <= 12 && B >= 1) {
      cout << "AMBIGUOUS" << endl;
    }
    else cout << "MMYY" << endl;
  }
  else {
    if (B <= 12 && B >= 1) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;
    return 0;
}



Measured memory_bytes: 3608
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
struct data
{
    double x,y;
    data()
    {
        ;
    }
    data(double _x,double _y)
    {
        x = _x;
        y = _y;
    }
};
ll cnt = 1;
double ans = 0.0;
data a[10];
bool flag[10];

double dis(ll p,ll q)
{
    double x,y;
    x = (a[p].x-a[q].x)*(a[p].x-a[q].x);
    y = (a[p].y-a[q].y)*(a[p].y-a[q].y);
    x = sqrt(x+y);
    return x;
}

double table[10][10];

int main()
{
    ll i,n,t,k,j,x=0,y=0,m,cnt2;
    sf(n);
    rep0(i,n)
    {
        cin>>a[i].x>>a[i].y;
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            table[i][j] = dis(i,j);
        }
    }

    for(i=1;i<=n;i++)
    {
        cnt*=i;
    }
    cnt2 = cnt/n;
   // cout<<cnt2<<endl;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
           // cout<<i<<" "<<j<<" "<<table[i][j]<<endl;
            ans+= table[i][j]*(cnt2*1.0);
        }
    }
   // printf("%.6lf\n",ans);
    ans = ans/(cnt*1.0);
    printf("%.9lf\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define maxn 1000006
using namespace std;
int p[maxn], fa[maxn];
int getfa(int x){
	if (fa[x] == x)
		return x;
	return fa[x] = getfa(fa[x]);
}
int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++ i){
		cin >> p[i];
		fa[i] = i;
	}
	for (int i = 1; i <= m; ++ i){
		int x, y;
		cin >> x >> y;
		fa[getfa(p[x])] = getfa(p[y]);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i)
		ans += getfa(i) == getfa(p[i]);
	cout << ans << endl;
}


Measured memory_bytes: 4736
fun main(args: Array<String>) {
    var s = StringBuilder(readLine()!!)
    val words = listOf("dream", "erase", "eraser", "dreamer")
    whileloop@ while(s.isNotEmpty()) {
        for(word in words){
            if(s.endsWith(word)){
                s = s.delete(s.length - word.length, s.length)
                continue@whileloop
            }
        }
        println("NO")
        return
    }
    println("YES")
}

Measured memory_bytes: 39304
n = int(input())
al = []
for i in range(2):
  a = list(map(int, input().split()))
  al.append(a)
cl = []
ac, tc = 0, 0
for i in range(n):
  c = [0] * (n + 1)
  ac += al[0][i]
  for j in range(i, n):
    c[j + 1] = al[1][j]
  tc = ac + sum(c)
  cl.append(tc)
print(max(cl))


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

using ll = long long;

ll solve(int n, ll x) {
    x = std::min(x, (1ll << (n + 2)) - 3);
    if (x == 0) {
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    if (x < (1ll << (n + 1)) - 1) {
        return solve(n - 1, x - 1);
    }
    return (1ll << n) + solve(n - 1, x - (1ll << (n + 1)) + 1);
}

int main() {
    int n;
    ll x;
    scanf("%d%lld", &n, &x);
    printf("%lld\n", solve(n, x));
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let n: usize = buf.trim().parse().unwrap();

    let mut fib = vec![1,1];

    while fib.len() < n + 1 { 
        let f1 = fib[fib.len()-1];
        let f2 = fib[fib.len()-2];
        fib.push(f1+f2);
    }
    println!("{}", fib[n]);
}



Measured memory_bytes: 5028
S = list(input())
T = list(input())

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] !=0 and w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())



Measured memory_bytes: 70476
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};
const double EPS = 1e-8;
int h,w;
string g[100];

void dfs(int y, int x, vector<pii> &b){
  for(int i=0;i<(int)b.size();i++){
    if(b[i] == pii(y,x))return;
  }
  b.push_back(pii(y,x));

  for(int i=0;i<4;i++){
    int ny = y+dy[i], nx = x+dx[i];
    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
    if(g[ny][nx] == g[y][x])dfs(ny,nx,b);
  }
}

bool rec(int y, int x, int &mid, int &num){
  vector<pii> b;
  dfs(y,x,b);

  num = b.size(); mid = 0;
  int l = 1000, r = -1000;

  for(int i=0;i<(int)b.size();i++){
    int by = b[i].first+1, bx = b[i].second;
    if(by==h || (g[by][bx] != g[y][x] && g[by][bx] != '.')){
      l = min(l, bx); r = max(r, bx+1);
    }
    mid += bx;

    by = b[i].first-1;

    if(by>=0 && (g[by][bx] != g[y][x] && g[by][bx] != '.')){
      int tmpnum = 0, tmpmid = 0;
      if(!rec(by,bx,tmpmid,tmpnum))return false;

      num += tmpnum;
      mid += tmpmid;
    }
  }

  for(int i=0;i<(int)b.size();i++)g[b[i].first][b[i].second] = '.';
  return (l*num < mid + num/2 && mid + num/2 < r*num);
}


int main(){
  while(cin >> w >> h, h){
    for(int i=0;i<h;i++)cin >> g[i];

    for(int i=0;i<w;i++){
      int num = 0, mid = 0;
      if(g[h-1][i]!='.'){
	cout << (rec(h-1,i,mid,num)?"STABLE":"UNSTABLE") << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int h1, w1, h2, w2, k;
	cin >> h1 >> w1 >> h2 >> w2 >> k;
	
	int x = (h2 - h1) * 60 + w2 - w1 - k;
	cout << x << endl;
	
	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int x = 1; x <= n; ++x) {
    if (x * 108 / 100 == n) {
      cout << x << '\n';
      return 0;
    }
  }
  cout << ":(\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll x,y;cin>>x>>y;
    ll ans=1;
    while(x*2<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string s;
    int n,i;
    cin >> n>> s;
    int k=0;
    for(int i=0;i<s.length();i++){
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            k++;
        }
    }
    cout << k;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

int S[1000], top;

void push(int a) {
    S[++top] = a;
}

int pop() {
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    top = 0;
    char s[100];
    while (scanf("%s", s) != EOF) {
        if(s[0] == '+') {
            a = pop();
            b = pop();
            push(a+b);
        } else if(s[0] == '-') {
            a = pop();
            b = pop();
            push(b-a);
        } else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else {
           push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}



Measured memory_bytes: 2728
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 500002;

int n, Q;
string s;
set<int> pos[26];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n;
    cin >> s;
    cin >> Q;

    for (int i = 0; i < n; ++i) {
        pos[s[i]-'a'].insert(i);
    }

    for (int i = 0; i < Q; ++i) {
        int op = 0;
        cin >> op;
        if (op == 1) {
            int idx;
            string c;
            cin >> idx >> c;

            --idx;
            if (c[0] != s[idx]) {
                pos[s[idx]-'a'].erase(idx);
                pos[c[0]-'a'].insert(idx);
                s[idx] = c[0];
            }
        } else {
            int l, r;
            cin >> l >> r;
            --l;
            --r;

            int cnt = 0;
            for (int j = 0; j < 26; ++j) {
                set<int>::iterator it = pos[j].lower_bound(l);
                if (it != pos[j].end() && *it <= r)
                    ++cnt;
            }
            cout << cnt << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 24220
import java.util.*;
public class Main{
      static Scanner sc=new Scanner(System.in);
      public static void main(String[] args) {
            int x=sc.nextInt();
            if(x%4==0||x%7==0){
                  System.out.println("Yes");
                  return;
            }
            else{
                  for(int i=4; i<=x; i+=4){
                        for(int j=i+7; j<=x; j+=7){
                              
                              if(j==x){
                                    System.out.println("Yes");
                                    return; 
                              }
                        }
                  }
            }
            System.out.println("No");
      }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public class Person
	{
		public long[] Says {get;set;}
		public Person(long k )
		{
			Says = new long[k];
		}
	}
	public static void Main(string[] args)
	{
		int n = (int)Console.ReadLine().ToLong();
		Person[] people = new Person[n];
		
		for(long i = 0; i < n; i++)
		{
			var a = Console.ReadLine().ToLong();
			people[i] = new Person(n);
			
			for(long j = 0; j < a; j++)
			{
				var p = Input().ToInt();
				people[i].Says[p[0]-1] = p[1]+1;
			}
		}
		long max = 0;
		for(long bit = 0; bit < (1 << n); bit++)
		{
			bool mujun = false;
			long cnt = 0;
			for(int i = 0; i < n; i++)
			{
				long h = ((bit >> i) & 1);
				if(h == 1)
					cnt++;
				//Console.Write(h);
				var says = people[i].Says;
				
				for(int k = 0; k < says.Length; k++)
				{
					if(k == i || says[k] == 0)
						continue;
					int q = -1;
					if((h == 1 && says[k] == 2))// || (h == 0 && says[k] == 1))
					{
						q = 1;	//syouzikimono
					}
					if((h == 1 && says[k] == 1))// || (h == 0 && says[k] == 2))
					{
						q = 0;	//tigau
						//Console.WriteLine("SET>>{3},{2};{0}={1}", k, says[k], bit, h);
					}
					//Console.WriteLine("{0}={1}",q, ((bit >> k) & 1));
					if(q == -1)
						continue;
					if(((bit >> k) & 1) == q)
					{
					}
					else
					{
						mujun = true;
						break;
					}
				}
				if(mujun)	break;
			
			}
			if(!mujun)
			{
				max = Math.Max(max, cnt);
			}
		}
		Console.WriteLine(Math.Min(n, max));
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static long Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11220
import java.util.*;

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

        int num = Integer.parseInt(line[0]);
        int yen = Integer.parseInt(line[1]);

        for(int ichiman = 0; ichiman <= num;ichiman++){
            for(int gosen = 0;ichiman + gosen <= num;gosen++){
                int sen = num - ichiman - gosen;
                if(yen == 10000*ichiman+ gosen*5000 + 1000*sen){
                    System.out.println(ichiman + " " + gosen + " " + sen);
                    return;
                }
            }
        }

        System.out.println("-1" + " " + "-1" + " " + "-1");
        return;
    }
}

Measured memory_bytes: 21844
#include<vector>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n;){
		vector< pair<int,int> > a(m);
		for(int i=0;i<m;i++)	a[i].second=i+1;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				int t;	cin>>t;
				a[j].first-=t;
			}
		}
		sort(a.begin(),a.end());
		for(int i=0;i<m;i++)	cout<<(i?" ":"")<<a[i].second;
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 908
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;

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

  int N;
  cin >> N;

  int min = 1000000001, max = -1;
  int buf;
  for (int i = 0; i < N; ++i) {
    cin >> buf;
    if (buf < min) min = buf;
    if (buf > max) max = buf;
  }

  cout << max - min << endl; 
  
  return 0;
}

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

void swap (int *x, int *y);
int partition (int array[], int left, int right);
void quick_sort (int array[], int left, int right);

int main(void){
  int i,j,k;
  int N;
  scanf("%d",&N);
  int L[N];
  int ans=0;
  for(i=0;i<N;i++){
    scanf("%d",&L[i]);
  }

  quick_sort(L, 0, N-1);

  for(i=N-1;i>=2;i--){
    for(j=i-1;j>=1;j--){
      for(k=j-1;k>=0;k--){
        if(L[i]<L[j]+L[k]){
          ans++;
        }else{
          break;
        }
      }
    }
  }

  // for(i=0;i<N;i++){
  //   printf("L[%d]=%d\n",i,L[i]);
  // }
  
  printf("%d\n",ans);

  return 0;
}


/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int>P(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
    }
    vector<int>idx(N+1);
    for (int i = 0; i < N; ++i) {
        idx[P[i]] = i;
    }
    int cur = 1;
    int ans = 0;
    for (int i = 1; i < N; ++i) {
        if (idx[i] < idx[i+1]) {
            cur++;
        } else {
            ans = max(ans, cur);
            cur = 1;
        }
    }
    ans = max(ans, cur);
    ans = N - ans;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int ttom(T a)
{
	int p=0;
	p+=a.fi.fi*3600;
	p+=a.fi.sec*60;
	p+=a.sec;
	return p;
}
T mtot(int a)
{
	T p;
	p.fi.fi=a/3600;
	a%=3600;
	p.fi.sec=a/60;
	a%=60;
	p.sec=a;
	return p;
}
int main()
{
	for(int i=0;i<3;i++)
	{
		T a,b;
		cin >> a.fi.fi >> a.fi.sec >> a.sec;
		cin >> b.fi.fi >> b.fi.sec >> b.sec;
		T ans=mtot(ttom(b)-ttom(a));
		cout << ans.fi.fi << ' ' << ans.fi.sec << ' ' << ans.sec << endl;
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  for (int loop = 0; loop < 50; loop++) {
    for (int i = 1; i < N; i++) {
      if (A[i] % A[0] > 0) A[i] = A[i] % A[0];
    }
    sort(A.begin(), A.end());
  }
  cout << A[0] << endl;
}

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

int main(){
 int n,i = 1,f = 0;

 cin >> n;

 while(++i <= n){
  int x = i;

  if(x % 3 == 0){
   cout << " " << i;
  } else {
   do{
    if(x % 10 == 3){
     cout << " " << i;
     f = 1;
     break;
    }
    x /= 10;
   }while(x);
  }
 }

 cout << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>


#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
using namespace std;

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

int  dp[10000];

int main()
{
	REP(i, 10){
		REP(j, 10){
			REP(k, 10){
				REP(l, 10){
					dp[i * 1000 + j * 100 + k * 10 + l] = i + j + k + l;
				}
			}
		}
	}
	int n;
	while (cin >> n){
		cout << count_if(dp, dp + 10000, [n](int o){return o == n; }) << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
using System;

class Program
    {
        static void Main(string[] args)
        {
            var number = int.Parse(Console.ReadLine());
            var result = GetFizzBuzzSequence(number);

            Console.WriteLine(result);
        }

        private static long GetFizzBuzzSequence(int number)
        {
            long result = 0L;
            for(int i = 1; i <= number; i++)
            {
                result += GetFizzBuzzNumber(i);
            }

            return result;
        }

        private static long GetFizzBuzzNumber(int i)
        {
            if (i % 3 == 0 || i % 5 == 0)
            {
                return 0;
            }

            return i;
        }
    }

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////


ll N, M, N2;
#define MOD M
ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll i, j, k, ans;
ll dp[5050][10101],mk[5050];

int main(){
    scanf("%lld%lld", &N, &M);
    
    fornum(i,0,(N+1)/2){
        mk[i + 1] = i + 1;
        mk[N - i] = i + 1;
    }

    dp[1][0] = 1;
    fornum(i,1,N){
        fornum (j,0,N+1)
        {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;
            dp[i + 1][j + mk[i]] += dp[i + 1][j];
            //printf("%lld ", dp[i + 1][j]);
        }
        //printf("\n");
    }
    fornum(i,0,N){
        ans = (ans + dp[N][i] * (N - i)) % MOD;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 394624
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a*b, c) <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[2][111];
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  int bc=0,cc=0;
  int b[111]={},c[111]={};
  for(int i=0;i<n;i++){
    bc+=a[0][i];
    cc+=a[1][n-1-i];
    b[i]=bc;
    c[i]=cc;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(b[i]+c[n-1-i],ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)

count = as.count{|a| a < 0}
sum = as.reduce(0){|a,e| a += e.abs}
ans = if count.odd?
  sum - as.map{|a| a.abs}.min * 2
else
  sum
end

puts ans


Measured memory_bytes: 9348
#include<stdio.h>

int main(void) {
	int n, a[100][100] = {0}, kyori[100] = {0}, homon1[100] = {0}, homon2[100] = {0}, kyo, u, k, v, i, j, m;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &u);
		scanf("%d", &k);
		for (j = 0; j < k; j++)
		{
			scanf("%d", &v);
			a[u - 1][v - 1] = 1;
		}
	}
	
	kyori[0] = 0;
	kyo = 0;
	homon1[0] = 1;
	for (m = 0; m < n; m++)
	{
		for (i = 0; i < n; i++)
		{
			if (homon1[i] == 1 && homon2[i] == 0 && kyori[i] == kyo)
			{
				for (j = 0; j < n; j++)
				{
					if (a[i][j] == 1 && homon1[j] == 0)
					{
						kyori[j] = kyori[i] + 1;
						homon1[j] = 1;
					}
				}
				homon2[i] = 1;
			}
		}
		kyo++;
	}
	
	for (i = 0; i < n; i++)
	{
		if (i != 0 && kyori[i] == 0) kyori[i] = -1;
		printf("%d %d\n", i + 1, kyori[i]);
	}
	
	return 0;
}

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

namespace AtCoder.DP
{
    class EDPC_C
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            var dp = new int[n, 3];
            var abc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            dp[0, 0] = abc[0];
            dp[0, 1] = abc[1];
            dp[0, 2] = abc[2];

            for (int i = 1; i < n; i++)
            {
                abc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                dp[i, 0] = Math.Max(dp[i-1, 1], dp[i-1, 2]) + abc[0];
                dp[i, 1] = Math.Max(dp[i-1, 0], dp[i-1, 2]) + abc[1];
                dp[i, 2] = Math.Max(dp[i-1, 0], dp[i-1, 1]) + abc[2];
            }

            Console.WriteLine(Math.Max(Math.Max(dp[n-1, 0], dp[n-1, 1]), dp[n-1, 2]));
        }
    }
}


Measured memory_bytes: 18356
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,a[52][52];
char map[52][52];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	scanf("%s",map[i]+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(map[i][j]!='#')
			{
				if(map[i+1][j]=='#')
				a[i][j]++;
				if(map[i-1][j]=='#')
				a[i][j]++;
				if(map[i][j+1]=='#')
				a[i][j]++;
				if(map[i][j-1]=='#')
				a[i][j]++;
				if(map[i+1][j+1]=='#')
				a[i][j]++;
				if(map[i+1][j-1]=='#')
				a[i][j]++;
				if(map[i-1][j+1]=='#')
				a[i][j]++;
				if(map[i-1][j-1]=='#')
				a[i][j]++;
				printf("%d",a[i][j]);
			}
			else
			printf("%c",map[i][j]);
		}
		printf("\n");
	}	
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main(){
    int N;
    cin>>N;
    double x;
    string u;
    double sum=0;
    for(int i=0;i<N;i++){
        cin>>x>>u;
        if(u=="BTC"){
            x*=380000;
        }
        sum+=x;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define MP make_pair
typedef pair<int, int> PII;
const int maxn = 55;

struct Point {
	int x, y;
	Point() {}
	void read() { scanf("%d%d", &x, &y); }
};

int dist(const Point& A, const Point& B) {
	return abs(A.x - B.x) + abs(A.y - B.y);
}

int n, m;

Point stu[maxn], check[maxn];

int main() {
	scanf("%d%d", &n, &m);
	REP(i, 0, n) stu[i].read();
	REP(i, 0, m) check[i].read();

	REP(i, 0, n) {
		PII ans(dist(stu[i], check[0]), 1);
		REP(j, 1, m) ans = min(ans, MP(dist(stu[i], check[j]), j + 1));
		printf("%d\n", ans.second);
	}

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

struct node {
  int id;
  int weight;
  struct node *next;
};
struct node **list;
int *key, *prev, *visit, *heap, *heap_index, heapsize;

void Insert(int, int, int);
void downheap(int);
void upheap(int);
void PQ_init(int);
void PrimPQ(int, int);
int main(void)
{
  int i, j, n, w, cost = 0;
  scanf("%d", &n);
  list = (struct node**)malloc(sizeof (struct node*) * n);
  key = (int*)malloc(sizeof (int) * n);
  prev = (int*)malloc(sizeof (int) * n);
  visit = (int*)malloc(sizeof (int) * n);
  for (i = 0; i < n; i++) list[i] = NULL;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf(" %d", &w);
      if (w != -1) {
        Insert(i, j, w);
      }
    }
  }
  PrimPQ(0, n);
  for (i = 0; i < n; i++) {
    cost += key[i];
    free(list[i]);
  }
  printf("%d\n", cost);
  free(list);
  free(key);
  free(prev);
  free(visit);
  free(heap);
  free(heap_index);
}
void Insert(int a, int b, int weight)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->weight = weight;
  p->id = b;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->weight = weight;
  p->id = a;
  p->next = list[b];
  list[b] = p;
}
void downheap(int k)
{
  int j, v = heap[k];
  while (k < heapsize / 2) {
    j = 2 * k + 1;
    if (j < heapsize - 1 && key[heap[j]] > key[heap[j+1]]) j++;
    if (key[v] <= key[heap[j]]) break;
    heap[k] = heap[j];
    heap_index[heap[j]] = k;
    k = j;
  }
  heap[k] = v;
  heap_index[v] = k;
}
void upheap(int j)
{
  int k, v = heap[j];
  while (j > 0) {
    k = (j + 1) / 2 - 1;
    if (key[v] >= key[heap[k]]) break;
    heap[j] = heap[k];
    heap_index[heap[k]] = j;
    j = k;
  }
  heap[j] = v;
  heap_index[v] = j;
}
void PQ_init(int size)
{
  int i;
  heapsize = size;
  heap = (int*)malloc(sizeof(int) * size);
  heap_index = (int*)malloc(sizeof(int) * size);
  for (i = 0; i < size; i++) {
    heap[i] = heap_index[i] = i;
  }
  for (i = size / 2 - 1; i >= 0; i--) {
    downheap(i);
  }
}
void PrimPQ(int p, int size)
{
  int i;
  for (i = 0; i < size; i++) {
    key[i] = INT_MAX;
    prev[i] = -1;
    visit[i] = 0;
  }
  key[p] = 0;
  PQ_init(size);
  while (heapsize > 0) {
    struct node *n;
    int u = heap[0];
    visit[u] = 1;
    heap[0] = heap[heapsize - 1];
    heap_index[heap[heapsize - 1]] = 0;
    heapsize--;
    downheap(0);
    for (n = list[u]; n != NULL; n = n->next) {
      int v = n->id, w = n->weight;
      if (visit[v] == 0 && w < key[v]) {
        key[v] = w;
        prev[v] = w;
        upheap(heap_index[v]);
      }
    }
  }
}


Measured memory_bytes: 2208
import sys
input = sys.stdin.readline

H,W = map(int,input().split())
#差分だけで良い，これを*1 or -1していく
diff = [list(map(int, input().split())) for _ in range(H)]

for i in range(H):
    B = list(map(int,input().split()))
    for j in range(W):
        diff[i][j] = abs(diff[i][j] - B[j])
        
 # i,jマスにおいて，偏りがkになれるかどうかでDP
#dp[i][j]にはkという数字にたどり着けるかどうかを示す2進数を入れる

dp = [[False]*W for _ in range(H)]
ofs = 80*(H+W)


dp[0][0]=(1<<(ofs+diff[0][0]) | 1>>(ofs-diff[0][0]))
 
for i in range(H):
    for j in range(W):
        if i>0:
            dp[i][j]|=(dp[i-1][j]<<diff[i][j] | dp[i-1][j]>>diff[i][j])
        if j>0:
            dp[i][j]|=(dp[i][j-1]<<diff[i][j] | dp[i][j-1]>>diff[i][j])


#0のところから見て，最初に1が出てきたところが答え
for k in range(ofs):
    if (dp[-1][-1]>>(k+ofs)&1):
        print(k)
        break

Measured memory_bytes: 58076
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int INF = 1e8;

//i番目のビットを返す
bool getBit(int num, int i){
	return ((num & (1 << i)) != 0);
}

//i番目を1にする
int setBit(int num, int i){
	return num | (1 << i);
}

//i番目を0にする
int clearBit(int num, int i){
	int mask = ~(1 << i);
	return num & mask;
}

//i番目をvで置き換える
int updateBit(int num, int i, int v){
	int mask = ~(1 << i);
	return (num & mask) | (v << i);
}

int main(){
	int n, m;
	while(cin >> n >> m,n||m){
		vector<int> S(n), d(m);
		cin >> S >> d;

		sort(all(d));

		vector<int> sum(1 << n, 0);
		rep(s,1 << n){
			rep(i,n){
				if(getBit(s, i)) sum[s] += S[i];
			}
		}

		vector<vector<int>> dp(m + 1, vector<int>(1 << n, INF));
		dp[0][0] = 0;
		//rep(i, 1 << n) dp[0][i] = 0;
		rep(i,m){
			rep(s, 1 << n){
				dp[i + 1][s] = min(dp[i + 1][s], dp[i][s] + abs(d[i] - sum[s]));

				rep(j,n){
					int b = setBit(s, j);
					dp[i + 1][b] = min(dp[i + 1][b], dp[i][s] + abs(d[i] - sum[b]));
					dp[i][b] = min(dp[i][b], dp[i][s]);
				}
			}
		}
		//rep(j,m){
		//	cout << dp[2][j] << endl;
		//	cout << dp[6][j] << endl;
		//}

		cout << *min_element(all(dp[m])) << endl;
	}
}



Measured memory_bytes: 16528
n, m, l = map(int, input().split())
A, B = [], []
for _ in range(n):
    A.append(list(map(int, input().split())))
for _ in range(m):
    B.append(list(map(int, input().split())))

C = []
B_T = list(zip(*B))
for a_row in A:
    C.append([sum(a * b for a, b, in zip(a_row, b_column)) for b_column in B_T])
for row in C:
    print(' '.join(map(str, row)))

Measured memory_bytes: 7764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int N;
  scanf("%d", &N);
  printf("%d\n", (N+1)/ 2);
  return 0;
}


Measured memory_bytes: 128
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];
		int first = 0;
		int second  = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if(first < a[i]) {
				second = first;
				first = a[i];
			}
			else if(second < a[i]) {
				second = a[i];
			}
		}
		for(int i =0 ;i < n; i++) {
			if(a[i] == first) {
				System.out.println(second);
			}
			else {
				System.out.println(first);
			}
		}
	}
}


Measured memory_bytes: 102280
#include <iostream>
#include<string>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define pb push_back
#define fo(i,s,e) for(i=s;i<e;i++)
//               When something is important enough, you do it even if the odds are not in your favor.
bool solve(string s){
	int l=0,r=s.length()-1;
	while(l<=r){
		if(s[l]!=s[r]) return 0;
		l++;r--;
	}
	return 1;
}
int main(){   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    string s,s1;cin>>s;
    if(!solve(s)) {cout<<"No";return 0;}
    int i;
    fo(i,0,s.length()/2) s1.pb(s[i]);
    if(!solve(s1)) {cout<<"No";return 0;}
    s1.clear();
    fo(i,s.length()/2+1,s.length()) s1.pb(s[i]);
    if(!solve(s1)) {cout<<"No";return 0;}
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations 
n,k=map(int,input().split())
m = (n-1)*(n-2)//2
if k>m:
    print(-1)
else:
    es = []
    for i in range(2,n+1):
        es.append((1,i))
        
    idx = 0
    for i,j in combinations(range(2,n+1),2):
        if idx == m-k:
            break
        es.append((i,j))
        idx +=1
    print(len(es))
    for i,j in es:
        print(i,j)

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

int main(){
  char k;
  cin >> k;
  if(k == 'A'){
    cout << 'T' << endl;
  }
  if(k == 'T'){
    cout << 'A' << endl;
  }
  if(k == 'C'){
    cout << 'G' << endl;
  }
  if(k == 'G'){
    cout << 'C' << endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    
    vector<pair<long long, long long>> S(N);
    rep(i, N) S[i] = {A[i] + B[i], A[i]};
    sort(S.rbegin(), S.rend());
    long long Ta = 0, Ao = 0;
    rep(i, N) {
        if (i % 2) {
            Ao += S[i].first - S[i].second;
        } else {
            Ta += S[i].second;
        }
    }
    cout << Ta - Ao << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,p;

int main(){
	cin>>n>>p;
	ll res=0,tmp=1,m=0;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		if(A%2==1) m++;
		else tmp*=2;
	}
	vvl C(m+1,vl(m+1));
	C[0][0]=1;
	for(int i=1;i<=m;i++) for(int j=0;j<=i;j++) C[i][j]=C[i-1][j]+(j?C[i-1][j-1]:0);
	for(int i=p;i<=m;i+=2) res+=C[m][i];
	cout<<res*tmp<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

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


Measured memory_bytes: 512
N,M=map(int,input().split())
list=[0 for i in range(5*10**5+1)]
mod=10**9+7
list[0]=1
for i in range(len(list)-1):
  list[i+1]=list[i]*(i+1)%mod
def c(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)*pow(list[n],mod-2,mod)
  return a
def p(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)
  return a
ans=pow(p(M,N),2)
g=pow(list[M-N],mod-2,mod)
g2=pow(g,2,mod)
nn=list[N]
mm=list[M]
nmg=nn*mm*g2%mod
for i in range(1,N+1):
  ans+=nmg*pow(list[N-i],mod-2,mod)*pow(list[i],mod-2,mod)*list[M-i]*(-1)**i
  ans%=mod
print(ans)


Measured memory_bytes: 103764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)

int main()
{
    //B
    int N;
    cin >> N;
    vector<int> A(N);
    bool flag = true;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N)
    {
        if (A[i] % 2 == 0)
        {
            if (A[i] % 3 != 0 && A[i] % 5 != 0)
            {
                flag = false;
                break;
            }
        }
    }
    if (flag)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
}

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

void solve(){
  int n, k; cin >> n >> k;
  if(n % k == 0) cout << 0 << endl;
  else cout << 1 << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    long long H, W;
    scanf("%lld %lld", &H, &W);
    if(H == 1 || W == 1) printf("1\n");
    else printf("%lld\n", (H >> 1) * W  + (H & 1) * ((W + 1) >> 1));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rrep(i,n) for (int i = 1; i <= (n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int main() {
  int n; cin >> n;
  std::vector<vector<int>> v(n, std::vector<int>(n));
  rep(i,n) rep(j,n) v.at(i).at(j) = -1;
  rep(i,n) {
    int m; cin >> m;
    rep(j,m) {
      int x,y; cin >> x >> y;
      x--;
      // i番目の人がxに対してyという証言をした
      v[i][x] = y;
    }
  }
  int ans = 0;
  rep(bit,1<<n) {
    std::vector<int> d(n);
    rep(i,n) {
      if (bit>>i&1) d[i] = 1;
    }
    bool ok = true;
    rep(i,n) {
      if (d[i]) {
        rep(j,n) {
          if (v[i][j] == -1) continue;
          if (v[i][j] != d[j]) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(bit));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    a = get_int()
    b = get_int()
    c = get_int()
    d = get_int()
    e = get_int()
    da, ma = divmod(a, 10)
    db, mb = divmod(b, 10)
    dc, mc = divmod(c, 10)
    dd, md = divmod(d, 10)
    de, me = divmod(e, 10)
    ta = (a + 9) // 10
    tb = (b + 9) // 10
    tc = (c + 9) // 10
    td = (d + 9) // 10
    te = (e + 9) // 10
    mm = min(list(filter(lambda m: m != 0, [ma, mb, mc, md, me])) + [inf])
    if mm == ma:
        print(10 * (tb + tc + td + te) + a)
    elif mm == mb:
        print(10 * (ta + tc + td + te) + b)
    elif mm == mc:
        print(10 * (ta + tb + td + te) + c)
    elif mm == md:
        print(10 * (ta + tb + tc + te) + d)
    elif mm == me:
        print(10 * (ta + tb + tc + td) + e)
    else:
        print(a + b + c + d + e)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


vlint base_3(int k){
    vlint ret; while (k > 0){ ret.pb(k % 3); k /= 3;} reverse(all(ret)); return ret;
}

int main(){
    STR(n);
    lint ret = 0;
    rep(i, Size(n)){
        ret += (int)(n[i] - '0');
        ret %= 9;
    }
    print(Yes[ret == 0]);
}


Measured memory_bytes: 3752