akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iostream>
#include<map>
#include<queue>
using namespace std;
#define ll long long
#define For(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define Fordown(i,a,b) for(int i=(int)a;i>=(int)b;--i)
#define re read()
#define inf 2100000000
#define mem(a,b)memset(a,b,sizeof(a))
const int N=1000000+10;
inline int read()
{
    int flag=1,ans=0;
    char ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-'){flag=-1;ch=getchar();}
    while(isdigit(ch)){ans=(ans<<3)+(ans<<1)+(ch-'0');ch=getchar();}
    return ans*flag;
}
int a[N],sum[3];
int n;
void init()
{
	n=re;
	For(i,1,n)
	{
		a[i]=re;
		if(a[i]%4==0)sum[2]++;
		else if(a[i]%2==0)sum[1]++;
		else sum[0]++;
	}
}
void work()
{
	int i=0;
	if(sum[1])i=1;
	if(sum[2]>=sum[0]+i-1)printf("Yes\n");
	else printf("No\n");
}
int main()
{
	init();
	work();
	return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
satisfy = 0
for i in range(len(a)):
    satisfy += b[a[i]-1]
    if i==0:
        continue
    if a[i]-a[i-1] == 1:
        satisfy += c[a[i-1]-1]
print(satisfy)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

//input
int H,W,N;


//processing




//dpTable
//int dp[100050];
int main(){
    cin >> H >> W >> N;
    cout << (N + max(H,W) - 1) / max(H,W) << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h)cin >> s[i];

    int l[h][w];
    int r[h][w];
    int d[h][w];
    int u[h][w];
    rep(i, h)rep(j, w){
        int x = h-i-1;
        int y = w-j-1;
        //cout << x << " & " << y << endl;
        if(s[i][j] == '#'){
            l[i][j] = 0;
            u[i][j] = 0;
        }
        else {
            l[i][j] = 1;
            u[i][j] = 1;
            if(j > 0)l[i][j]+=l[i][j-1];
            if(i > 0)u[i][j]+=u[i-1][j];
        }

        if(s[x][y] == '#'){
            r[x][y] = 0;
            d[x][y] = 0;
        }
        else {
            r[x][y] = 1;
            d[x][y] = 1;
            if(y < w-1)r[x][y]+=r[x][y+1];
            if(x < h-1)d[x][y]+=d[x+1][y];
        }
    }

    int ans = 0;
    rep(i, h)rep(j, w){
        int lamp = l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3;
        if(lamp > ans)ans = lamp;
    }
    cout << ans << endl;
}

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

int cnt;
long long gcd(long long a, long long b) {
  if( b == 0 ) return a;
  cnt++;
  return gcd( b, a % b );
}

int main() {
  for(long long a, b; cin >> a >> b, (a || b); ) {
    cnt = 0;
    if( a < b ) swap(a, b);
    
    long long g = gcd(a, b);
    cout << g << " " << cnt << endl;
  }
}

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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 2e5+1;

#define left(v) (2*(v)+1)
#define right(v) (2*(v)+2)

vector<ll> st(4*MAX+10);

void update(int pos, ll val, int v=0, int tl=0, int tr=MAX)
{
	if(tl==tr) {
		st[v]=val;
		return;
	}
	int tm=(tl+tr)/2;
	if(pos<=tm) {
		update(pos, val, left(v), tl, tm); 
	}
	else {
		update(pos, val, right(v), tm+1, tr);
	}
	st[v]=max(st[left(v)], st[right(v)]);
}

ll query(int v, int tl, int tr, int l, int r)
{
	if(l>r) return 0;
	if(tl==l and tr==r) {
		return st[v];
	}
	int tm=(tl+tr)/2;
	ll ans1=query(left(v), tl, tm, l, min(r, tm));
	ll ans2=query(right(v), tm+1, tr, max(l, tm+1), r);
	return max(ans1, ans2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n;
	cin>>n;
	vector<int> h(n);
	vector<ll> a(n);
	for(int i=0; i<n; i++) {
		cin>>h[i];
	}
	for(int i=0; i<n; i++) {
		cin>>a[i];
	}
	
	ll ans=0;
	for(int i=0; i<n; i++) {
		ll tmp=query(0, 0, MAX, 0, h[i])+a[i];
		
		ans=max(ans, tmp);
		update(h[i], tmp);
	}
	ans=st[0];
	cout<<ans<<"\n";
    return 0;
}



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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}



int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    int a,b; cin >> a >> b;cout << a - b + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if (a < b) {
            System.out.println("a < b");
        }
        if (a > b) {
            System.out.println("a > b");
        }
        if (a == b){
            System.out.println("a == b");
        }
    }
}



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

using namespace std;

void solve() {
    int n, m; cin >> n >> m;
    if (m < n) cout << "No"; else cout << "Yes";
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << ' ' << x << ' ' << y << endl;

  return 0;
}


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

int main(){
    long long x, y; cin >> x >> y;
    long long ans = 1LL;
    for (int i = 1; ; ++i){
        long long tmp = x*(1LL << i);
        if(tmp > y) break;
        ans = i + 1;
    }
    cout << ans << endl; 
    return 0;
}

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

int n, v[55];
double m;
int main() {
	int i;
	cin>>n;
	for(i=0; i<n; i++) cin>>v[i];
	sort(v, v+n);
	m = v[0];
	for(i=1; i<n; i++) m = (m + v[i]) / 2.0;
    printf("%.9f", m);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var hi = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            if (nk[0] <= nk[1])
            {
                Console.WriteLine(0);
                return;
            }

            Array.Sort(hi);
            for (var i = 0; i < nk[1]; i++)
            {
                hi[hi.Length - i - 1] = 0;
            }
            Console.WriteLine(hi.Sum());
        }
    }
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

void solve() {
	long long x, y; cin >> x >> y;
	long long ans = LINF;
	if (x <= y) {
		chkmin(ans, y - x);
	}
	if (-x <= y) {
		chkmin(ans, y + x + 1);
	}
	if (x >= y) {
		chkmin(ans, x - y + 2);
	}
	if (x <= -y) {
		chkmin(ans, -y - x + 1);
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 764
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
{
Console.ReadLine();
var ia = Console.ReadLine().Split(' ').Select(i=>(double)int.Parse(i)).ToArray();
double t=ia[0]-ia[1];
Console.WriteLine(Console.ReadLine().Split(' ').Select(i=>int.Parse(i)).Select((i,n)=>new{N=n,I=Math.Abs(t-i*0.006)}).OrderBy(i=>i.I).ToArray()[0].N+1);
}
}

Measured memory_bytes: 13548
#include <cstdio>
#include <iostream>
#define max4(a, b, c, d) max(a, max(b, max(c, d)))
using namespace std;

int main() {
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%lld\n", max4(1ll * a * c, 1ll * b * d, 1ll * a * d, 1ll * b * c));
	return 0;
}



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

signed main() {

    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

int H,W,n;

int main()
{
	//freopen("1.in","r",stdin);
	scanf("%d%d%d",&H,&W,&n);
	printf("%d\n",n%max(H,W)==0?n/max(H,W):n/max(H,W)+1);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const long long FACTOR= (long long) 1e9 + 7;
const long long MAXNUM= (long long) 1e5 + 1;

long long fac[MAXNUM];
long long ifac[MAXNUM];

int main(){
    long long N,M;
    long long a,b,ans;
    cin >> N >> M;

    fac[0] = 1;
    ifac[0] = 1;
    for(long long i=0; i<MAXNUM; i++){
        fac[i+1] = fac[i]*(i+1) % FACTOR; // (i+1)! (mod FACTOR)
    }

    a=max(N,M);
    b=min(N,M);

    if( a-b >= 2 ){
        cout << 0 << endl;
        return 0;
    }

    if( a==b ){
        ans= (fac[a]*fac[b]*2) % FACTOR;
    }else{
        ans=fac[a]*fac[b] % FACTOR;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
    long long int N,i,M=0,A=0,R=0,C=0,H=0,ans;
    char name[11];
    scanf("%lld",&N);
    for(i=0;i<N;i++){
        scanf("%s",name);
        if(name[0] == 'M'){
            M++;
        }else if(name[0] == 'A'){
            A++;
        }else if(name[0] == 'R'){
            R++;
        }else if(name[0] == 'C'){
            C++;
        }else if(name[0] == 'H'){
            H++;
        }
    }
    
    ans = (M*A*R)+(M*A*C)+(M*A*H)+(M*R*C)+(M*R*H)+(M*C*H)+(A*R*C)+(A*R*H)+(A*C*H)+(R*C*H);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
def prime(n):
    memo = []
    for i in range(2,int(n**0.5)+1):
        while n%i == 0:
            memo.append(i)
            n //= i
    if n != 1:
        memo.append(n)
    return memo
        
    
a,b = map(int,input().split())    

aa = list(set(prime(a)))
bb = list(set(prime(b)))

count = 1

for i in aa:
    if i in bb:
        count += 1

print(count)

Measured memory_bytes: 38896
<?php
fscanf(STDIN, '%d', $n);
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
$q = array_map('intval', explode(' ', trim(fgets(STDIN))));
$arr = junretsu($n);
sort($arr);
foreach ($arr as $i => $v) {
    if (implode('', $v) === implode('', $p)) $a = $i + 1;
    if (implode('', $v) === implode('', $q)) $b = $i + 1;
}
$ans = abs($a - $b);
echo $ans . PHP_EOL;

function junretsu($n)
{
    if ($n === 1) return [[1]];
    $arr = [];
    foreach (junretsu($n - 1) as $v) {
        for ($i = 0; $i < $n; $i++) {
            $arr2 = $v;
            array_splice($arr2, $i, 0, $n);
            $arr[] = $arr2;
        }
    };
    return $arr;
}

Measured memory_bytes: 23416
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;

ll T[100001], A[100001];
ll cand[100001], kaku[100001];
ll mod = 1000000007;
int main(void) {
    int N;
    bool flag = true;
    cin >> N;
    REP(i, N) cin >> T[i];
    REP(i, N) cin >> A[i];
    if(T[N-1] != A[0]) {
        cout << 0 << endl;
        return 0;
    }
    cand[0] = 1;
    FOR(i, 1, N) {
        if(T[i] > T[i-1]) {
            cand[i] = 1;
            kaku[i] = T[i];
        }
        else {
            cand[i] = T[i];
            kaku[i] = -1;
        }
    }
    cand[N-1] = 1;
    for(int i=N-2; i>=0; --i) {
        if(kaku[i] != -1 && A[i] < kaku[i]) {
            flag = false;
            break;
        }
        if(A[i] > A[i+1]) cand[i] = 1;
        else cand[i] = min(cand[i], A[i]);
    }
    if(flag == false) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    REP(i, N) {
        ans = (ans*cand[i])%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c;
  int q=0;
  cin>>a>>b>>c;
  while(true){
    b=b-a;
    if(q==c||b<0){
      cout<<q<<"\n";
      break;
    }
    q++;
  }
}


Measured memory_bytes: 256
import bisect

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A, B, C = sorted(A), sorted(B), sorted(C)

ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    c = n - bisect.bisect_right(C, b)
    if a > 0 and c > 0:
        ans += a*c

print(ans)


Measured memory_bytes: 23360
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
 
 
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s.length()<=n) cout<<s;
	else {
		for(int i=0; i<n; i++) {
			cout<<s[i];
		}
		cout<<"...\n";
	}
}


Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\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;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int h_max = 1005;
const int w_max = 1005;

signed main(){
    int h,w;
    cin >> h >> w;
    string S[h+1];
    REP(i,h) cin >> S[i];

    int dp[h_max][w_max];
    REP(i,w_max) dp[0][i] = 0;
    REP(i,h_max) dp[i][0] = 0;
    dp[1][1] = 1;
    REP(i,h){
        REP(j,w){
            if(i == 0 and j == 0) continue;
            if(S[i][j] == '#') dp[i+1][j+1] = 0;
            else{
                dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j];
                dp[i+1][j+1] %= MOD;
            }
        }
    }
    cout << dp[h][w] << endl;

}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int res = INF;
    int right = 0;
    map<int, int> mp;
    queue<int> que;
    for(int left = 0; left < n; left++)
    {
        while(right < n && mp.size() < k)
        {
            if(v[right] <= k)
            {
                que.push(v[right]);
                mp[v[right]]++;
            }
            right++;
        }
        if(mp.size() == k) res = min(right - left, res);
        if(left == right) right++;
        else if(v[left] == que.front()) 
        {
            int head = que.front(); que.pop();
            mp[head]--;
            if(mp[head] == 0) mp.erase(head);
        }
    }
    cout << (res != INF ? res : 0) << endl;
    return 0;
}


Measured memory_bytes: 8416
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
b = S()
ans = ''
if b == 'A':
    ans = 'T'
if b == 'C':
    ans = 'G'
if b == 'G':
    ans = 'C'
if b == 'T':
    ans = 'A'
print(ans)

Measured memory_bytes: 38640
#include <stdio.h>
#include <string.h>
int a[11][331];
bool e[11];
void m(int d, int s){
    for(int i=0;i<10;i++){
        if(e[i])continue;
        a[d][s+d*i]++;
        if(d<10){
            e[i]=true;
            m(d+1,s+d*i);
            e[i]=false;
        }
    }
}
int main(void){
    memset(a,0,sizeof(a));
    memset(e,0,sizeof(e));
    m(1,0);
    int n,s;
    while(~scanf("%d%d",&n,&s)){
        if(n<0||n>10||s<0||s>330)puts("0");
        else printf("%d\n",a[n][s]);
    }
    return 0;
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
#define cinspeed ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 100010;

using namespace std;
typedef long long ll;

bool st[N],is[N];
int primes[N],cnt;

void getprimes(int n)
{
    for(int i = 2;i <= n ;i++)
    if(!st[i])
    {
        primes[cnt++] = i;
        is[i] = true;
        for(int j = i + i; j <= n;j += i) st[j] = true;
    }
}

int main()
{
    cinspeed;
    int x;
    cin >> x;

    getprimes(N);

    for(int i = x;;i++)
    {
        if(is[i] == true)
        {
            cout << i <<"\n";
            break;
        }
    }



    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

const long long LINF = 1e18;

long long h[100010];
long long dp[100010];

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

  for (int i = 0; i < 100010; ++i) {
    dp[i] = LINF;
  }

  dp[0] = 0;
  for (int i = 1; i < N; ++i) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N-1] << endl;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var Q = cin.ReadInt;
            var S = cin.Read;
            var chars = S.ToCharArray();
            var c = new int[N];
            var count = 0;
            for (int i = 0; i < N; i++)
            {
                c[i] = count;
                if (i < N - 1 && chars[i] == 'A' && chars[i + 1] == 'C')
                {
                    count++;
                }
            }
            var ans = new int[Q];
            for (int i = 0; i < Q; i++)
            {
                var l = cin.ReadInt - 1;
                var r = cin.ReadInt - 1;
                ans[i] = c[r] - c[l];
            }
            foreach (var a in ans)
            {
                Console.WriteLine(a);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 17480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n, m; cin >> n >> m;
    vector<ll> a(n); ll res = 0;
    for(int i=0; i<n; ++i){cin >> a[i]; res += a[i];}
    if(n-res>=0){cout << n - res << endl;}
    else{cout << -1 << endl;}
    return 0;
}

Measured memory_bytes: 11084
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

int a, b, c, x, y, res = INT_MAX;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> a >> b >> c >> x >> y;

 	for (int i = 0; i <= 2 * max(x, y); i+=2) {
 		res = min(res, a * max(0, x - i / 2) + b * max(0, y - i / 2) + c * i);
 	}

 	cout << res << endl;

    return 0;
}

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

const int MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<bool> is_broken(N + 1, false);
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        is_broken[a] = true;
    }
    vector<int> dp(N + 1);
    dp[0] = 1;
    if (!is_broken[1]) dp[1] = 1;
    for (int i = 2; i <= N; i++) {
        if (!is_broken[i]) {
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= MOD;
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int n, i, x, y, nr, s, nod, j;
int viz[105], d[105], t[105], w[105];
long long sum, sol;
vector<int> v[105];
void solve(int nod, int dist){
    int i, nr = 0;
    viz[nod] = 1;
    for(i = 0; i < v[nod].size(); i++){
        if(viz[ v[nod][i] ] == 0){
            nr++;
            solve(v[nod][i], dist + 1);
        }
    }
    d[dist + 1] = max(d[dist + 1], nr);
}
void dfs(int nod){
    viz[nod] = 1;
    for(int i = 0; i < v[nod].size(); i++){
        int vecin = v[nod][i];
        if(viz[vecin] == 0){
            d[vecin] = d[nod] + 1;
            t[vecin] = nod;
            dfs(vecin);
        }
    }
}
int main(){
    cin>> n;
    for(i = 1; i < n; i++){
        cin>> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1);
    nod = 1;
    for(i = 2; i <= n; i++){
        if(d[i] > d[nod]){
            nod = i;
        }
    }
    memset(viz, 0, sizeof(viz) );
    memset(t, 0, sizeof(t));
    dfs(nod);
    nod = 1;
    for(i = 2; i <= n; i++){
        if(d[i] > d[nod]){
            nod = i;
        }
    }
    while(nod != 0){
        w[++nr] = nod;
        nod = t[nod];
    }
    s = nr / 2 + nr % 2;
    memset(d, 0, sizeof(d));
    memset(viz, 0, sizeof(viz));
    if(nr % 2 == 0){
        viz[ w[nr / 2] ] = viz[ w[nr / 2 + 1] ] = 1;
        d[1] = 2;
        solve(w[nr / 2], 1);
        solve(w[nr / 2 + 1], 1);
        sol = 1;
        for(i = 1; i <= s; i++){
            sol = sol * d[i];
        }
    }
    else{
        viz[ w[nr / 2 + 1] ] = 1;
        d[1] = 1;
        solve(w[nr / 2 + 1], 1);
        sol = 1;
        for(i = 1; i <= s; i++){
            sol = sol * d[i];
        }
        nod = w[nr / 2 + 1];
        for(i = 0; i < v[nod].size(); i++){
            memset(viz, 0, sizeof(viz));
            memset(d, 0, sizeof(d));
            d[1] = 2;
            viz[ v[nod][i] ] = viz[nod] = 1;
            solve(nod, 1);
            solve(v[nod][i], 1);
            if(d[s + 1] != 0){
                continue;
            }
            sum = 1;
            for(j = 1; j <= s; j++){
                sum = sum * d[j];
            }
            sol = min(sol, sum);
        }
    }
    cout<< s <<" "<< sol;
}


Measured memory_bytes: 256
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

Measured memory_bytes: 26780
# require 'benchmark'

# result = Benchmark.realtime do

  def divide_sort(array)
    # @count += 1
    length = array.length

    if length <= 1
      return array
    end

    left_array = divide_sort(array[0..((length-1)/2)])
    right_array = divide_sort(array[((length+1)/2)..(length-1)])
    i = 0

    while i < length do
      if left_array[0] < right_array[0]
        @count += 1
        array[i] = left_array.shift
        else
          @count += 1
          array[i] = right_array.shift
      end

      i += 1
      if left_array.length == 0
        while i < length do 
          @count += 1
          array[i] = right_array.shift
          i += 1
        end

      elsif right_array.length == 0
        while i < length do
          @count += 1
          array[i] = left_array.shift
          i += 1
        end
      end
    end
    return array
  end
# end
@count = 0
# buffer = []
array_num = gets.to_i
array = gets.to_s.split(" ").map(&:to_i)

# @count += 1

buffer = divide_sort(array)

# merge_sort(new_array_left,new_array_right)

# puts "処理概要 #{result}s"

puts buffer.join(" ")
puts @count


Measured memory_bytes: 65212
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m;
  cin >> m;
  vector<ll> d(m), c(m);
  rep(i, m) cin >> d[i] >> c[i];
  ll sum = 0, digit = 0;
  rep(i, m) {
    sum += d[i]*c[i];
    digit += c[i];
  }
  ll ans = digit-1+(sum-1)/9;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int in = Integer.parseInt(br.readLine());
			System.out.println(in * 2 * Math.PI);
		}
	}
}

Measured memory_bytes: 25468
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		List<List<Node>> ls=new ArrayList<>();
		
		for(int i=0;i<n;i++)ls.add(new ArrayList<Node>());
		for(int i=0;i<n;i++) {
			int u=Integer.parseInt(in.next()),k=Integer.parseInt(in.next());
			for(int j=0;j<k;j++) {
				int v=Integer.parseInt(in.next()),
						c=Integer.parseInt(in.next());
				ls.get(u).add(new Node(v,c));
			}
		}
		
		int visit[]=new int[n],parent[]=new int[n],d[]=new int[n];
		for(int i=0;i<n;i++) {
			parent[i]=-1; d[i]=Integer.MAX_VALUE;
		}
		d[0]=0;

		while(true) {
			int u=-1,min=Integer.MAX_VALUE;

			for(int i=0;i<n;i++) {
				if(visit[i]<2 && d[i]<min) {
					min=d[i];
					u=i;
				}
			}

			if(u==-1)break;
			visit[u]=2;

			for(int i=0;i<ls.get(u).size();i++) {
				Node v=ls.get(u).get(i);
				if(visit[v.v]<2 && d[u]+v.c<d[v.v]) {
					d[v.v]=d[u]+v.c;
					parent[v.v]=u;
					visit[v.v]=1;
				}
			}
		}
		
		for(int i=0;i<n;i++)System.out.println(i+" "+d[i]);
	}

}

class Node{
	int v,c;
	Node(int a,int b){
		v=a;
		c=b;
	}
}



Measured memory_bytes: 38132
from math import gcd, ceil
from functools import reduce
import sys

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N, M = map(int, input().split())
a = [int(i)//2 for i in input().split()]

s = set()
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    s.add(cur)
    if len(s) >= 2:
        print(0)
        sys.exit()
lcm = lcm_list(a)
print((M//lcm+1)//2)

Measured memory_bytes: 20532
fn main() {
    let n: usize = read();
    let mut a = vec![vec![0;n];n];

    let mut stack = vec![(0,n,1)];
    while let Some((l,len,lv)) = stack.pop() {
        if len > 1 {
            for i in l..l+len/2 {
                for j in l+len/2..l+len {
                    a[i][j] = lv;
                }
            }
            stack.push((l,len/2,lv+1));
            stack.push((l+len/2,(len+1)/2,lv+1));
        }
    }

    for i in 0..n-1 {
        for j in i+1..n {
            print!("{} ",a[i][j]);
        }
        print!("\n");
    }
}
fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}

fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int k, a, b;
    cin >> k >> a >> b;
    for (Int i = 0; i < (Int)10000; i++) {
        if (a <= k * i and k * i <= b) {
            print("OK");
            return 0;
        }
    }
    print("NG");
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
typedef struct{
  char suit;
  int number;
}Card;
Card *BubbleSort(Card *,int);
Card *SelectionSort(Card *,int);
void isStable(Card *,Card *,int);
int main(void){
  int N,i;
  Card C[36];
  Card *Cbub,*Csel;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf(" %c%d",&C[i].suit,&C[i].number);
  Cbub=BubbleSort(C,N);
  for(i=0;i<N;i++){
    printf("%c%d",Cbub[i].suit,Cbub[i].number);
    if(i!=N-1)printf(" ");
  }
  printf("\nStable\n");
  Csel=SelectionSort(C,N);
  for(i=0;i<N;i++){
    printf("%c%d",Csel[i].suit,Csel[i].number);
    if(i!=N-1)printf(" ");
  }
  isStable(Cbub,Csel,N);
  return 0;
}
Card *BubbleSort(Card *C,int N){
  Card *Cbub;
  int flag=1,j,temp;
  char c;
  Cbub=(Card *)malloc(sizeof(Card)*N);
  for(j=0;j<N;j++)
    Cbub[j]=C[j];
  while(flag){
    flag=0;
    for(j=N-1;j>0;j--){
      if(Cbub[j].number<Cbub[j-1].number){
        temp=Cbub[j].number;
        Cbub[j].number=Cbub[j-1].number;
        Cbub[j-1].number=temp;
        c=Cbub[j].suit;
        Cbub[j].suit=Cbub[j-1].suit;
        Cbub[j-1].suit=c;
        flag=1;
      }
    }
  }
  return Cbub;
}
Card *SelectionSort(Card *C,int N){
  Card *Csel;
  int i,j,minj,temp;
  char c;
  Csel=(Card *)malloc(sizeof(Card)*N);
  for(i=0;i<N;i++)
    Csel[i]=C[i];
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++)
      if(Csel[j].number<Csel[minj].number)minj=j;

    if(minj!=i){
      temp=Csel[i].number;
      Csel[i].number=Csel[minj].number;
      Csel[minj].number=temp;
      c=Csel[i].suit;
      Csel[i].suit=Csel[minj].suit;
      Csel[minj].suit=c;
    }
  }
  return Csel;
}
void isStable(Card *Cbub,Card *Csel,int N){
  int i=0,check=0;
  while(i<N){
    if(Cbub[i].suit!=Csel[i].suit || Cbub[i].number!=Csel[i].number){
      check=1;
      break;
    }
    i++;
  }
  if(check==0)printf("\nStable\n");
  else printf("\nNot stable\n");
}


Measured memory_bytes: 2072
N = int(input())
num = list(map(int, input().split()))
dp_odd = [0, num[0]]
dp_even = max(num[0], num[1])
for i in range(2, N):
  if (i + 1) % 2 == 1:
    dp_odd = [max(dp_odd[0] + num[i], dp_even), dp_odd[1] + num[i]]
  else:
    dp_even = max(dp_even + num[i], dp_odd[1])

if N % 2 == 0:
  print(dp_even)
else:
  print(dp_odd[0])

Measured memory_bytes: 31564
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        if ((a * b) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

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


#define int long long 

const int N = 3003;

int dp[N][N][4], r, c;

int v[N][N];


int f(int i, int j, int k) {
	if(i == r && j == c) {
		if(!k) return 0;
		return v[i][j];
	}
	int res = 0;
	if(~dp[i][j][k]) {
		return dp[i][j][k];
	}
	if(i + 1 <= r) {
		res = max(res, f(i + 1, j, 3));
		if(k) {
			res = max(res, f(i + 1, j, 3) + v[i][j]);
		}
	}
	if(j + 1 <= c) {
		res = max(res, f(i, j + 1, k));
		if(k) {
			res = max(res, f(i, j + 1, k - 1) + v[i][j]);
		}
	}
	return dp[i][j][k] = res;
}


int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k; cin >> r >> c >> k;
	for(int i = 1; i <= k; i++) {
		int x, y, z; cin >> x >> y >> z;
		v[x][y] += z;
	}

	
	memset(dp, -1, sizeof dp);
	cout << f(1, 1, 3) << endl;
}

Measured memory_bytes: 356296
#include <iostream>

int main() {

  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N, a, b, ans = 0;
  std::cin >> N;
  for (int i = 0; i < N; i++ ){
    std::cin >> a >> b;
    ans += b - a + 1;
  }
  std::cout << ans << '\n';
}


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

int main() {
  string str;

  cin >> str;
  for(int i = 0;i < str.size();i++){
    if(i % 2 == 0)cout << str.at(i);
  }

  cout << endl;
}

Measured memory_bytes: 512
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;

namespace mine
{
    typedef long long ll;
    const int MAX_N=110000,MAX_M=410000;
    const int INF=0x3f3f3f3f;
    int mymax(int x,int y) {return x>y?x:y;}
    int mymin(int x,int y) {return x<y?x:y;}

    int bin[20];
    struct Edge
    {
        int x,y,c;
    };
    vector<Edge> q;
    void main()
    {
        bin[0]=1;for(int i=1;i<20;i++) bin[i]=bin[i-1]<<1;

        int mx;scanf("%d",&mx);//0~mx-1
        int nowmx=0;
        for(int i=18;i>=0;i--)
            while(nowmx+bin[i]-1<=mx-1)
            {
                q.push_back( (Edge){1,20-i,nowmx} );
                nowmx+=bin[i];
            }

        printf("20 %d\n",18*2+q.size());
        for(int i=2;i<=19;i++) printf("%d %d %d\n%d %d 0\n",i,i+1,bin[19-i],i,i+1);
        for(int i=0;i<q.size();i++) printf("%d %d %d\n",q[i].x,q[i].y,q[i].c);
    }
};

int main()
{
    mine::main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n,m;
	cin >> n;
	map<string,int> s;
	rep(i,n){
		string a;
		cin>>a;
		s[a]++;
	}
	cin >> m;
	map<string,int> t;
	rep(i,m){
		string a;
		cin>>a;
		t[a]++;
	}
	int ans = 0;
	for(auto i=s.begin(); i!=s.end(); i++){
		int tmp=i->second;
		for(auto j=t.begin(); j!=t.end(); j++){
			if(i->first == j->first){
				tmp-=j->second;
			}
		}
		ans = max(ans,tmp);
	}
	cout << ans << endl;
}

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

int main(){
	int a, b, c;
	long long ans;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) ans = 0;
	else{
		ans = min(1LL * b * c, 1LL * a * c);
		ans = min(ans, 1LL * a * b);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];

	int64_t sum = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			sum += (int64_t)v[i] * v[j];
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//高速累乗 繰り返し自乗法
int modPow(int x, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1)res = res*x%MOD;
		x = x*x%MOD;
		n >>= 1;
	}
	return res;
}

signed main() {
	int N; cin >> N;
	vector<int> cnt(N, 0);
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	if (N % 2) {
		if (cnt[0] != 1) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 2; i < N; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	else {
		for (int i = 1; i < N; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	cout << modPow(2, N / 2) << endl;
	return 0;
}

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

 long long int lucas_N =0;

void lucas(long long int L0,long long int L1, int n)
{
  if(n != 1){
    lucas_N = L0 + L1;
    //printf("%ld", lucas_N);
    lucas(L1, lucas_N , n-1); 
  }
}

int main()
{

    int  N;
 // 整数の入力
    scanf("%d", &N);
  
    if(N>=2){
      lucas(2,1,N);
    } else {
      lucas_N =1;
    }

printf("%ld\n", lucas_N);

    return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
A = list(map(int, input().split()))
vote_sum = sum(A)
cnt = 0
y = "Yes"
n = "No"

for i in range(N):
	if (A[i]*4*M) >= vote_sum:
		cnt += 1

if cnt >= M:
	print(y)
else:
	print(n)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);

  ll k, s;
  cin >> k >> s;
  ll ans = 0;
  rep(i, k+1){
    ll yz = s-i;
    if(yz>=0){
      ll temp = min(yz, k)-max(yz-k,(ll)0)+1;
      if(temp>0) ans+=temp;
      else continue;
      
    }
    else{
      break;
    }
  }
  cout << ans << '\n';
        return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> a(m), b(m); for (int i = 0; i < m; ++i) cin >> a[i] >> b[i], --a[i], --b[i];
  reverse(begin(a), end(a));
  reverse(begin(b), end(b));
  V<lint> res(m);
  UnionFind uf(n);
  res[0] = (lint) n * (n - 1) / 2;
  for (int i = 0; i < m - 1; ++i) {
    if (!uf.same(a[i], b[i])) {
      res[i + 1] = res[i] - (lint) uf.size(a[i]) * uf.size(b[i]);
      uf.unite(a[i], b[i]);
    } else {
      res[i + 1] = res[i];
    }
  }
  for (int i = 0; i < m; ++i) {
    cout << res[m - 1 - i] << '\n';
  }
}

Measured memory_bytes: 3328