akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_6_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] lineA = ReadIntAr();
            int m = ReadInt();
            int[] lineB = ReadIntAr();

            int aIdx = 0; int bIdx = 0;
            while (true)
            {
                if (lineA[aIdx] == lineB[bIdx]) bIdx++;
                aIdx++;
                if (bIdx == m || aIdx == n) { Console.WriteLine(bIdx == m ? 1 : 0); return; }
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 51172
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<long long> dp(n+1);
  dp[0]=2;
  dp[1]=1;
  for(int i=2;i<n+1;i++) {
    dp[i] = dp[i-1]+dp[i-2];
  }
  cout<<dp[n];
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<math.h>

#define pi 3.14159265359793

int main()
{
  int n1, n2, an;
  double l, h, a;

  scanf("%d%d%d", &n1, &n2, &an);

  a = sin(an*pi/180)*n1*n2/2;
  l = n1+n2 + sqrt(n1*n1 + n2*n2 - 2*n1*n2 *cos(an*pi/180.0));
  h = a/n1*2;

  printf("%lf %lf %lf\n", a, l, h);
}



Measured memory_bytes: 2080
//https://atcoder.jp/contests/abc158/tasks/abc158_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    string S; cin>>S;
    ll Q; cin>>Q;
    struct info{
        ll type=0;
        ll fb=0;
        char c=0;
    };
    vector<info> ql(Q);
    for(auto&&q:ql){
        cin>>q.type;
        if(q.type==2) {
            cin>>q.fb>>q.c;
        }
    }

    bool sw_flag=false;
    for(ll i=Q-1;i>=0;--i){
        auto&& q=ql.at(i);
        if(q.type==1){
            sw_flag=!sw_flag; //反転
        }else{
            if(sw_flag){
                if(q.fb==1){
                    q.fb=2;
                } else{
                    q.fb=1;
                }
            }
        }
    }

    if(sw_flag) reverse(S.begin(),S.end());
    deque<char> lst;
    for(auto& c:S){
        lst.push_back(c);
    }
    dump(lst);

    REP(i,Q){
        auto& q=ql.at(i);
        if(q.type==1){
        }else {
            ll t2=q.fb;
            char c=q.c;
            if(t2==1){
                lst.push_front(c);
            }else{
                lst.push_back(c);
            }
        }
    }

    for(auto& c:lst){
        cout<<c;
    }
    cout<<endl;
    return 0;
}

int main_() {
    string S; cin>>S;

    deque<char> lst;
    for(auto& c:S){
        lst.push_back(c);
    }
    dump(lst);

    ll Q; cin>>Q;    
    REP(i,Q){
        ll t; cin>>t;
        if(t==1){
            //swap(lst.back(),*lst.begin());
            std::reverse(lst.begin(),lst.end());
        }else if(t==2){
            ll t2; cin>>t2;
            char c; cin>>c;
            if(t2==1){
                lst.push_front(c);
            }else{
                lst.push_back(c);
            }
        }
    }

    for(auto& c:lst){
        cout<<c;
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 5712
package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		A, B, K int
	)
	fmt.Scan(&A, &B, &K)
	if B-A+1 <= 2*K {
		for i := A; i <= B; i++ {
			fmt.Println(i)
		}
		return
	}
	for i := A; i < A+K; i++ {
		fmt.Println(i)
	}
	for i := B - K + 1; i <= B; i++ {
		fmt.Println(i)
	}
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }


Measured memory_bytes: 512
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]

ls=[chr(i) for i in range(ord("a"),ord("z")+1)]
li=[9999 for _ in range(ord("a"),ord("z")+1)]

c=[]
for x in s:
   c.append(Counter(x))

for x in c:
    for i,y in enumerate(ls):
        li[i]=min(x[y],li[i])

res=""
for i,x in enumerate(li):
    res+=ls[i]*x
print(res)

Measured memory_bytes: 9456
//JOI2015 Swapping Bibs
//20181209
//F_Naru
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int* A=new int[N];
  for(int i=1; i<=N; i++){
    cin >> A[i];
  }

  //計算
  for(int k=1; k<=M; k++){//バトン
    for(int i=1; i<N; i++){//生徒
      if(A[i]%k > A[i+1]%k){//ゼッケンを交換するとき
        int temp;
        temp=A[i];
        A[i]=A[i+1];
        A[i+1]=temp;
      }
    }

  }
  for(int i=1; i<=N; i++){
    cout <<  A[i] << endl;
  }
}




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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
ll N, M, nums[MAXN];


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    for(int i=0; i<N; i++)
    {
        cin >> nums[i];
    }
    ll num2, prev;
    for(int i=0; i<N; i++)
    {
        num2 = 0;
        ll y = nums[i];
        while(y > 0 && y == (y/2)*2)
        {
            num2++;
            y/=2;
        }
        if(i && num2 != prev)
        {
            cout << 0;
            return 0;
        }
        prev = num2;
    }
    sort(nums, nums+N);
    ll lcm = 1;
    for(int i=0; i<N; i++)
    {
        nums[i]/=2;
        lcm = lcm*nums[i]/(__gcd(lcm, nums[i]));
        if(lcm > M)
        {
            cout << 0;
            return 0;
        }
    }
    cout << (M+lcm)/(2*lcm);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 1e5 + 10;

vector<int> g[MAX_N];
int dist[MAX_N], par[MAX_N];
int cnt = 1;

void bfs(int s) {
    queue<int> q;
    q.push(s);
    while(!q.empty()) {
        int curr = q.front(); q.pop();
        for(auto it : g[curr]) {
            if(par[it] == -1) {
                par[it] = curr;
                q.push(it);
                cnt ++;
            }
        }
    }
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i ++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    fill_n(dist, MAX_N, mod);
    fill_n(par, MAX_N, -1);
    bfs(1);
    if(cnt < n) {
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    for(int i = 2; i <= n; i ++) {
        cout << par[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 10904
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    double h, a; cin >> h >> a;
    cout << ceil(h/a) << endl;
    return 0;
}


Measured memory_bytes: 3732
#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];
  }
  int j=0;
  bool check = false;
  for(int i=0;i<N;i++){
    if(a[i] == j+1){
      j++;
      check = true;
    }
  }
  if(!check) cout << -1 << endl;
  else cout << N - j << endl;
}
  

Measured memory_bytes: 1152
#!/usr/local/bin/python3
#coding:utf-8
#import numpy as np


def main():

   in0 = input()

   IN = in0.split(' ')

   N = int(IN[0])
   A = int(IN[1])
   B = int(IN[2])

   train = N*A
   taxi = B

   if(train<taxi):
      print ("%s" % (train))
   else:
      print ("%s" % (taxi))
      



if __name__ == "__main__":
   main()

Measured memory_bytes: 3064
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

string toUpper(string s){
 string t = s;
 for(int i = 0; i < s.size(); i++){
  t[i] = toupper(s[i]);
 }

 return t;
}

int main(){
 int count = 0;
  string w, str;

  cin >> w >> str;
  w = toUpper(w);
  str = toUpper(str);

  while (1){
   if (str == w)
    count++;

   cin >> str;
   if(str == "END_OF_TEXT") break;
   str = toUpper(str);
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int, int> Edge;



int main() {
	long long int a, b, c,k;
	cin >> a >> b >> c>>k;
	if (k % 2 == 0) {
		if (abs(a - b) > 1000000000000000000) {
			cout << "Unfair" << endl;
		}
		else {
			cout << a - b << endl;
		}
	}
	else {
		if (abs(a - b) > 1000000000000000000) {
			cout << "Unfair" << endl;
		}
		else {
			cout << b-a << endl;
		}
	}
}


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

using namespace std;

int main() {
	string s;

	cin >> s;

	int n = s.length();
	int m = 0;

	for (int i = 0; i < n; i++) {
		m = m + (s[i] - '0');
		m = m % 9;
	}

	if (!m) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3748
import java.util.*;

public class Main {

    public static ArrayList<Integer> erathosthenes(int x) {
        int[] nums = new int[x];
        int[] flag = new int[x];
        for (int i=2;i<x;i++) {
            nums[i]=i;
        }
        for (int i=2;i<Math.sqrt(x);i++) {
            if (flag[i]==1) {
                continue;
            }
            for (int j=2;j*i<x;j++) {
                flag[j*i]=1;
            }
        }
        ArrayList<Integer> ans = new ArrayList<Integer>();
        for (int i=2;i<x;i++) {
            if (flag[i]==0) {
                ans.add(nums[i]);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        ArrayList<Integer> list = erathosthenes(200000);
        for (Integer x : list) {
            if (x>=X) {
                System.out.println(x);
                break;
            }
        }
    }
}

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

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

			call(input);
		}

		private static void call(int input)
		{
			int i = 1;

		while (i <= input)
			{
				int x = i;
				if (x % 3 == 0)
				{
					Console.Write(" " + i);
				}
				else
				{
					while (x != 0)
					{
						if (x % 10 == 3)
						{
							Console.Write(" " + i);
							break;
						}
						x /= 10;
					}
				}
				++i;
			}

			Console.WriteLine();
		}
	}
}

Measured memory_bytes: 5812
#include<iostream>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int d=b/a;
    if(d>c){
    	cout<<c<<endl;
	}
	else{
		cout<<d<<endl;
	}
    return 0;
}



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

int main(){
	long long n, a, b, now, ans = 0;
	cin >> n >> a >> b >> now;
	n--;
	while(n--){
		int x;
		cin >> x;
		ans += min(a * (x - now), b);
		now = x;
	}
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;

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

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

    cout << str.substr(0,5) << " " << str.substr(6,7) << " " <<str.substr(14,5) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int cnt[10001] = { 0 };
	int len;
	cin >> len;
	//important point: using len+1 rather than len
	int* arr = new int[len+1];
	int* narr = new int[len+1];
	int max = -1;
	for (int i = 1; i < len + 1; i++) {
		cin >> arr[i];
		if (arr[i] > max)
			max = arr[i];
		narr[i] = 0;-
		cnt[arr[i]]++;
	}
	for (int i = 1; i <= max; i++) 
		cnt[i] += cnt[i - 1];
	for (int i = len; i >= 1; i--) {
		narr[cnt[arr[i]]] = arr[i];
		cnt[arr[i]]--;
	}
	for (int i = 1; i <= len; i++)
		if (i!=1)
			cout << " " << narr[i];
		else
			cout << narr[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 18752
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
int a[200];

int main() {
  //
  cin >> N;
  int ans = 0;
  repe(i, 1, N) {
    cin >> a[i];
    if (i % 2 == 1 && a[i] % 2 == 1) {
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int N, K;
	string S;
	
	cin >> N >> K;
	cin >> S;

	bool flag_le_hand = (S[0] == '1');

	vector<int> hand(N, 0);
	vector<int> stand(N, 0);
	int h_idx = 0;
	int s_idx = 0;

	char p = S[0];
	int num_sw = 0;

	for (int i = 0; i < N; i++) {
		if (p != S[i]) {
			num_sw++;
		}

		if (S[i] == '1') {
			h_idx = num_sw / 2;
			hand[h_idx]++;
		}
		else {
			s_idx = num_sw / 2;
			stand[s_idx]++;
		}

		p = S[i];

	}

	if (s_idx <= K - 1) {
		cout << N;
	}
	else {
		int num_cont = 0;
		int max_num_cont;
		REP(i, K) {
			num_cont += hand[i] + stand[i];
		}
		if (flag_le_hand) {
			num_cont += hand[K];
		}
		max_num_cont = num_cont;
		REP(i, s_idx - K + 1) {
			if (flag_le_hand) {
				num_cont -= hand[i] + stand[i];
				num_cont += hand[i + K + 1] + stand[i + K];
			}
			else {
				if (i == 0) {
					num_cont -= stand[0];
				}
				else {
					num_cont -= hand[i - 1] + stand[i];
				}
				num_cont += hand[i + K] + stand[i + K];
			}
			if (max_num_cont < num_cont) {
				max_num_cont = num_cont;
			}			
		}
		cout << max_num_cont << endl;
	}
	return 0;

}


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

using namespace std;

bool xok[4005][8005];
bool yok[4005][8005];
vector<int> xdir;
vector<int> ydir;

bool solve(int target,vector<int> nums, bool cache[][8005]){
    cache[0][0]=true;
    for(int i=0;i<nums.size();i++){
        int n=nums[i];
        for(int j=0;j<8005;j++){
            if(!cache[i][j]) continue;
            cache[i+1][abs(j+n)]=true;
            cache[i+1][abs(j-n)]=true;
        }
    }
    return cache[nums.size()][abs(target)];
}


int main(void){
    string s;
    cin >> s;
    int x,y;
    cin >> x >> y;
    bool initflag=true,yflag=false;

    for(char c : s){
        if(c=='F'){
            if(initflag){
                x--;
            }else if(yflag){
                (ydir.back())++;
            }else{
                (xdir.back())++;
            }
        }else{
            yflag=!yflag;
            if(yflag){
                if(ydir.size()==0 || ydir.back()!=0){
                    ydir.push_back(0);
                }
            }else{
                if(xdir.size()==0 || xdir.back()!=0){
                    xdir.push_back(0);
                }
            }
            initflag=false;
        }
    }
    if(solve(x,xdir,xok) && solve(y,ydir,yok)){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int mul = n * a;
    if(mul <= b)
        cout << mul << endl;
    else
        cout << b << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  int A,B,M;
  cin >> A >> B >> M;
  vt<int> a(A), b(B), x(M),y(M),c(M);

  rep(i,A)
    cin >> a[i];
  rep(i,B)
    cin >> b[i];
  rep(i,M)
    cin >> x[i] >> y[i] >> c[i];

  int min_a = *min_element(a.begin(),a.end());
  int min_b = *min_element(b.begin(),b.end());
  int ans = min_a + min_b;

  rep(i,M){
    ans = min(ans, (a[x[i]-1]+b[y[i]-1]-c[i]));
  }

  cout << ans;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;

    vector<ll> A(N);
    REP(i,N){
        REPi(j,i+1,N){
            ll a = j - i;
            ll b = abs(X-i) + abs(Y-j) + 1;
            ll n = min(a, b);
            A[n] += 1;
        }
    }

    REPi(i,1,N){
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	ll ans = 0;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>start(q);
	vector<int>end(q);
	vector<ll>count(n + 1);
	count[0] = 0;
	count[1] = 0;
	rep0(i, q - 1) {
		scanf("%lld%lld", &start[i], &end[i]);
	}
	REP(2, s.length()) {
		if (s[i - 2] == 'A' && s[i - 1] == 'C') {
			ans++;
		}
		count[i] = ans;

	}
	rep0(k, q - 1) {
		printf("%lld\n", count[end[k]] - count[start[k]]);
	}
	return 0;
} 


Measured memory_bytes: 2624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int r, d, x;
	cin>>r>>d>>x;
	for(int i=0; i<10; i++)
	{
		x = r*x - d;
		cout<<x<<"\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main()
{
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(ALL(a), greater<ll>());
    sort(ALL(b), greater<ll>());
    sort(ALL(c), greater<ll>());

    rep(i, x) cerr << a[i] << " ";
    cerr << endl;

    rep(i, y) cerr << b[i] << " ";
    cerr << endl;

    rep(i, z) cerr << c[i] << " ";
    cerr << endl;

    vector<ll> tmp1, tmp2;
    rep(i, x) rep(j, y)
    {
        tmp1.push_back(a[i] + b[j]);
    }
    sort(ALL(tmp1), greater<ll>());
    rep(i, tmp1.size())
    {
        cerr << tmp1[i] << " ";
    }
    cerr << endl;
    rep(i, min(k, x * y))
    {
        rep(j, z)
        {
            tmp2.push_back(tmp1[i] + c[j]);
        }
    }
    sort(ALL(tmp2), greater<ll>());

    rep(i, k)
    {
        cout << tmp2[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43112
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

bool compare(int &a, int &b) {
	return a > b;
}

int main()
{
	int x;
	vector<int> A;
	while (cin >> x && x != EOF) {
		A.push_back(x);
	}

	sort(A.begin(), A.end(), compare);

	cout << A[0] << endl;
	cout << A[1] << endl;
	cout << A[2] << endl;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  int h,w; cin>>h>>w;
  vector<vector<ll>> a(h, vector<ll>(w));
  rep(i, h) rep(j, w) cin>>a[i][j];

  vector<vector<int>> ans;
  for (int i=0; i<h; i++) {
    if (i%2 == 0) {
      for (int j=0; j<w-1; j++) {
        if (a[i][j]%2 == 1) {
          a[i][j]--;
          a[i][j+1]++;
          ans.push_back({i, j, i, j+1});
        }
      }
      if (i < h-1 && a[i][w-1]%2 == 1) {
        a[i][w-1]--;
        a[i+1][w-1]++;
        ans.push_back({i, w-1, i+1, w-1});
      }
    } else {
      for (int j=w-1; j>=1; j--) {
        if (a[i][j]%2 == 1) {
          a[i][j]--;
          a[i][j-1]++;
          ans.push_back({i, j, i, j-1});
        }
      }
      if (i < h-1 && a[i][0]%2 == 1) {
        a[i][0]--;
        a[i+1][0]++;
        ans.push_back({i, 0, i+1, 0});
      }
    }
  }
  cout << ans.size() << endl;
  for (auto v:ans) {
    printf("%d %d %d %d\n", v[0]+1, v[1]+1, v[2]+1, v[3]+1);
  }

  return 0;
}


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

int main(){
int a,b,ans=-1;
cin >>a>>b;
rep(i,10010){
    if(floor(i*0.08)==a&&floor(i*0.1)==b){
        if(i<10001)ans=i;
        break;
    }
}
cout <<ans<<endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,p; string s;
	cin >> n >> p >> s;
	if(p==2||p==5){
		ll ans = 0;
		for(int i=0; i<n; i++)
			if((s[i]-'0')%p==0)
				ans+=i+1;
		cout << ans << endl;
		return 0;
	}
	map<int,int>mp;
	mp[0]++;
	ll now = 0, ten = 1;
	ll ans = 0;
	for(int i=n-1; i>=0; i--){
		now = (now+(s[i]-'0')*ten)%p;
		ans += mp[now];
		mp[now]++;
		ten = (ten*10)%p;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 916
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(int)
    for i in list(map(int, input().rstrip('\n').split())):
        d[i]
    for i in range(n, 10 ** 10):
        s = str(i)
        b = True
        for j in range(len(s)):
            if int(s[j]) in d:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    slove()


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


int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<string> ans;
  map<string, int> mp;
  rep(i,n) {
    cin >> s[i];
    mp[s[i]]++;
  }
  int countmax=0;
  rep(i, n)
    countmax = max(countmax, mp[s[i]]);
  for (auto p : mp) {
  auto k = p.first;
  auto v = p.second;
  if (countmax == v)
    cout << k << endl;
  }
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    ll a, b, n; cin >> a >> b >> n;
    ll nb = min(b-1, n);
    ll ans = a * nb / b;
    ll mi = nb / b * a;
    cout << ans - mi << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,l,aji[202],mn=INF,sum=0;
    cin >> n >> l;
    rep(i,n){
        aji[i]=l+i;
        sum += aji[i];
        mn = min(mn,abs(aji[i]));
    }
    if(l < 0) mn *= -1;
    cout << sum - mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
const ll MOD =1e9 + 7;


int h,w,k;
bool iti[333][333]={};

int main(){
	int n;
	int c=0;
	cin>>h>>w>>k;
    rep(i,h){
        rep(j,w){
            char a;
            cin>>a;
            if(a=='#')iti[i][j]=1;
        }
    }
    int wk[333][333]={};
    rep(i,h){
        bool b=0;
        int m=0;
        rep(j,w){
            if(iti[i][j]){

                c++;
                m=c;
                wk[i][j]=m;
                b=1;
            }else{
                wk[i][j]=m;
            }
        }
        
        if(b==0&&i!=0){
            rep(j,w){
                wk[i][j]=wk[i-1][j];
            }
        }else{

            repr(j,w){
                if(wk[i][j]==0){
                    wk[i][j]=wk[i][j+1];
                }
            }
        }
    }
    repr(i,h){
        if(wk[i][0]==0){
            rep(j,w){
                wk[i][j]=wk[i+1][j];
            }
        }
    }
    rep(i,h){
            rep(j,w){
                cout<<wk[i][j]<<" ";
            }
            cout<<endl;
        
    }
    
    
	
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,f=0;
  cin>>n;
  while(n!=0)
  {
    a=n%10;
    if(a==7)
    {
      f=1;
      break;
    }
    n=n/10;
  }
  if(f)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
 
bool check(int i) {
    int tmp = 1;
    for(int a = 1; a <= i / 2; a++) {
        if(i % a == 0) {
            tmp++;
        }
    }
    if(tmp == 8) {
        return true;
    }else return false;
}
 
 
int main(void) {
    int n;
    cin >> n;
 
    int ans = 0;
    for(int i = 1; i <= n; i += 2) {
        if(check(i)) {
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"4 3 6"# => "safe",
// r#"6 5 1"# => "delicious",
// r#"3 7 12"# => "dangerous",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: i64,
        t: i64,
    }

    if x > t  { x - t } else { 0 }.to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

using cat = long long;

cat mod = 998244353;

cat pw(cat a, cat e) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2);
	x = x * x % mod;
	if(e&1) x = x * a % mod;
	return x;
}

cat om[22];

void ntt(cat * a, int n, bool rev = 0) {
	for(int i = 0, j = 0; i < n; ++i) {
		if(i < j) swap(a[i], a[j]);
		for(int k = n>>1; (j^=k) < k; k >>= 1) {}
	}
	for(int i = 2, e = 1; i <= n; i <<= 1, e++) {
		int len = i>>1;
		cat w = om[e];
		static cat om_pw[1<<19];
		om_pw[0] = 1;
		for(int j = 1; j < len; j++) om_pw[j] = om_pw[j-1] * w % mod;
		for(int j = 0; j < n; j += i) {
			cat * cur_ptr = om_pw;
			cat * l_ptr = a + j;
			cat * r_ptr = a + j + len;
			for(int k = 0; k < len; k++) {
				cat u = *l_ptr, v = (*r_ptr) * (*(cur_ptr++)) % mod;
				cat s = u + v, d = u - v;
				if(s >= mod) s -= mod;
				if(d < 0) d += mod;
				*(l_ptr++) = s;
				*(r_ptr++) = d;
			}
		}
	}
	if(rev) {
		cat n_inv = pw(n, mod-2);
		reverse(a+1, a+n);
		for(int i = 0; i < n; i++) a[i] = a[i] * n_inv % mod;
	}
}

int main() {
	for(int i = 0; i < 22; i++) om[i] = pw(3, (mod-1)>>i);
	int N, M;
	cin >> N >> M;
	cat fac[500010], inv[500010];
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= 500000; i++) fac[i] = fac[i-1] * i % mod;
	for(int i = 1; i <= 500000; i++) inv[i] = (i%2 == 0 && i > 2) ? inv[2] * inv[i/2] % mod : pw(i, mod-2);
	for(int i = 1; i <= 500000; i++) inv[i] = inv[i-1] * inv[i] % mod;
	cat A[1<<20];
	memset(A, 0, sizeof(A));
	cat N_pw = 1;
	for(int i = 0; i <= M; i++) {
		A[i] = inv[i] * N_pw % mod;
		N_pw = N_pw * N % mod;
	}
	ntt(A, 1<<20);
	cat B[1<<20];
	memset(B, 0, sizeof(B));
	cat M_pw = 1;
	for(int i = N; i >= 0; i--) {
		B[i] = inv[i] * inv[N-i] % mod * M_pw % mod;
		M_pw = M_pw * (mod-1-M) % mod;
	}
	ntt(B, 1<<20);
	cat C[1<<20];
	for(int i = 0; i < (1<<20); i++) C[i] = A[i] * B[i] % mod;
	ntt(C, 1<<20, 1);
	cat ans = 0;
	for(int i = 0; i <= M; i++) ans = (ans + C[i] * inv[M-i]) % mod;
	ans = ans * fac[N] % mod * fac[M] % mod * (N%2 ? mod-1 : 1) % mod;
	cout << ans << "\n";
}


Measured memory_bytes: 36736
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int64_t L,R;
  cin >> L >> R;
  
  int64_t a = L % 2019;
  int64_t b = R % 2019;
  set<int64_t> sss;
  
  if( (R - L)  >= 2018){
    
    cout << 0 << endl;
    
  }
  
  if( ( (R - L) < 2018 ) && (a >= b) ){
    
    cout << 0 << endl;
  }
  
  if( ( (R - L) < 2018 ) && (a < b) ){
    
    for(int i = a ; i <= b ; i++){
      
      for(int j = a ; j <= b ; j++){
        
        if(i == j){
          continue;
        }
        
        sss.insert( (i*j) % 2019 );
      }
    }
    cout << *begin(sss) << endl;
  }
      
}

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

int main(void){
  long long a=0,b=0,c,d,r,tmp;
  unsigned long long ans;
  cin >> a >> b;

  ans = a*b;
  c=a;
  d=b;

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a%b;
  while(r != 0){
    a = b;
    b = r;
    r = a%b;
  }

  cout << ans/b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int qq = 0;
void merge1(vector<int> &s, int l1, int r1, int l2, int r2){
    vector<int> temp;
    int i = l1;
    int j = l2;
    while (i <= r1 && j <= r2){
        qq++;
        if (s[i] < s[j]){
            temp.push_back(s[i++]);
        }
        else
            temp.push_back(s[j++]);
    }
    while (i <= r1){
        temp.push_back(s[i++]);
        qq++;
    }
    while (j <= r2){
        temp.push_back(s[j++]);
        qq++;
    }
    for (int i = 0; i < temp.size(); i++){
        s[l1++] = temp[i];
    }
    temp.clear();
}
void mergeSort(vector<int> &s, int index_start, int index_end){
    if (index_start < index_end){
        int mid = (index_start + index_end) / 2;
        mergeSort(s, index_start, mid);
        mergeSort(s, mid+1, index_end);
        merge1(s, index_start, mid, mid+1, index_end);
    }
}
int main()
{
    vector<int> s;
    int n, temp;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> temp;
        s.push_back(temp);
    }
    mergeSort(s, 0, n-1);
    for (int i = 0; i < s.size(); i++){
        if (i == 0)
            cout << s[i];
        else
            cout << " " << s[i] ;
    }
    cout << endl;
    cout << qq << endl;
    return 0;
}



Measured memory_bytes: 8004
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b < a) {
			System.out.println(a-1);
		}else System.out.println(a);
		sc.close();
	}
}

Measured memory_bytes: 21972
N = int(input())
W = []
for i in range(0,N):
    W.append(input())
    
result = 'Yes'

for i,w in enumerate(W):
    if i>0 and W[i-1][-1] != W[i][0]:
        result = 'No'

Wset = set(W)

if len(W) != len(Wset):
    result = 'No'
    
print(result)

Measured memory_bytes: 3064
from math import factorial

n,p=map(int,input().split())
a=list(map(int,input().split()))
even=[]
odd=[]
for i in a:
    if i%2==0:
        even.append(i)
    else:
        odd.append(i)

ev=len(even)
od=len(odd)
odd_sum=0

for i in range(od+1):
    if i%2==p and i<=od:
        odd_sum+=(factorial(od)//(factorial(od-i)*factorial(i)))

print(odd_sum*(2**ev))

Measured memory_bytes: 62152
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
#define _(i,a,n) for(int i=a;i<n;i++)
#define zero(a) a[0]=0
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
string s;
cin>>s;
ll ans=0;
for(int i=0;i<s.size();i++)
ans+=s[i]-'0';
if(ans%9==0)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

string s[100];

signed main()
{   
    int H,W; cin>>H>>W;
    REP(i,H) cin>>s[i];

    REP(i,H) REP(j,W){
        if(s[i][j]=='#') continue;

        int cnt=0;
        for(int dx=-1;dx<=1;dx++) for(int dy=-1;dy<=1;dy++){
            int nx=i+dx,ny=j+dy;
            if(0<=nx and nx<H and 0<=ny and ny<W and s[nx][ny]=='#') cnt++;
        }
        s[i][j]=(char)(cnt+'0');
    }
    REP(i,H) cout<<s[i]<<endl;
    
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func exec(stdin *Stdin, stdout *Stdout) {
	s := stdin.Read()
	x := (len(s) - 1) / 2
	if isPalindromic(s) && isPalindromic(s[:x]) && isPalindromic(s[x+1:]) {
		stdout.Println("Yes")
	} else {
		stdout.Println("No")
	}
}

func isPalindromic(s string) bool {
	n := len(s)
	for i := 0; i < n; i++ {
		if s[i] != s[n-i-1] {
			return false
		}
	}
	return true
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
n=int(raw_input())
for i in range(n):
    x1,y1,r1,x2,y2,r2=map(float,raw_input().split())
    d = ((x2-x1)**2+(y2-y1)**2)**0.5
    if d+r2< r1:
        print 2
    elif d+r1<r2:
        print -2
    elif r1+r2<d:
        print 0
    else:
        print 1 


Measured memory_bytes: 4712
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

vector<vector<int>> adj;
vector<int> node_value;

vector<bool> visited;
vector<int> final_value;

void dfs(int curr, int value)
{
	visited[curr] = true;
	final_value[curr] = value;

	for (int next : adj[curr])
	{
		if (visited[next]) continue;

		dfs(next, value + node_value[next]);
	}
}

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

	int N, Q;
	cin >> N >> Q;

	adj.assign(N, vector<int>());

	for (int i = 0; i < N - 1; i++)
	{
		int a, b;
		cin >> a >> b;

		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}

	node_value.assign(N, 0);

	for (int i = 0; i < Q; i++)
	{
		int p, x;
		cin >> p >> x;

		node_value[p - 1] += x;
	}

	visited.assign(N, false);
	final_value.assign(N, 0);

	dfs(0, node_value[0]);

	for (int i = 0; i < N; i++)
	{
		cout << final_value[i] << " ";
	}

	return 0;
}


Measured memory_bytes: 24320
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>


using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,  0, 1, -1, 1,  1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1, -1, 0,  0, 1, -1,  1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	ll N;
	cin >> N;
	vll A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];


	ll sum_A = 0;
	ll sum_B = 0;
	for (int i = 0; i < N; i++)
	{
		sum_A += A[i];
		sum_B += B[i];
	}

	if (sum_A < sum_B)
	{
		cout << -1 << endl;
		return 0;
	}
	else
	{
		ll ans = 0;
		ll need = 0;
		for (int i = 0; i < N; i++)
		{
			need += max(B[i] - A[i], ll(0));
			ans += B[i] - A[i] > 0;
		}

		if (need == 0)
		{
			cout << 0 << endl;
			return 0;
		}

		vll rest = {0};
		for (int i = 0; i < N; i++)
		{
			if (A[i] - B[i] > 0)
			{
				rest.emplace_back(A[i] - B[i]);
			}
		}

		sort(rest.begin(), rest.end(), greater<ll>());

		for (int i = 0; i < rest.size() - 1; i++)
		{
			rest[i + 1] += rest[i];
		}

		for (int i = 0; i < rest.size(); i++)
		{
			if (rest[i] >= need)
			{
				cout << i + 1 + ans << endl;
				return 0;
			}
		}


	}





}





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

using namespace std;

int n, a[14];

int main(){

    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int sum = 0;
    for(int i = 0; i < n-1; i++) sum += a[i];
    puts(sum > a[n - 1]? "Yes": "No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, k, r, s, p;
  scanf("%d%d%d%d%d", &n, &k, &r, &s, &p);
  char t[100001];
  scanf("%s", t);
  int point[256];
  point['r'] = p;
  point['s'] = r;
  point['p'] = s;
  int ans = 0;

  for (int i = 0; i < n; i++) {
    if (i < k || t[i] != t[i - k])
      ans += point[t[i]];
    else
      t[i] = ' ';
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")
from bisect import bisect_left


def solve(N: int, L: "List[int]"):
    # a<=b<=c
    L.sort()
    counter = 0
    for i in range(N-2):
        a = L[i]
        for j in range(i+1, N-1):
            b = L[j]
            k = bisect_left(L[j+1:], a+b)
            counter += k
    print(counter)
    return


def main():

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


if __name__ == '__main__':
    main()


Measured memory_bytes: 52060