akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans = 1;
  int N;
  cin >> N;

  FOR(i, 1, N + 1) { ans = (ans * i) % MOD; }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 150005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

Map cnt;

ll modpow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

void factrization(ll N) {
    for(ll i=2; i*i<=N; i++) {
        while(N%i==0) {
            cnt[i]++;
            N/=i;
        }
    }
    
    if(N!=1) {
        cnt[N]++;
    }
    
}


int main(void) {
    ll N, M;
    cin >> N >> M;
    ll fact[MAX];
    ll rfact[MAX];
    ll i;
    ll ans=1;
    
    fact[0]=rfact[0]=1;
    for(i=1; i<MAX; i++) {
        fact[i]=i*fact[i-1]%MOD;
        rfact[i]=modpow(fact[i], MOD-2);
    }
    
    factrization(M);
    
    for(auto itr=cnt.begin(); itr!=cnt.end(); itr++) {
        ans*=fact[N+itr->second-1]*rfact[N-1]%MOD*rfact[itr->second]%MOD;
        ans%=MOD;
    }
    
    prin(ans);
 
}


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const int mod = 1000000007;

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

    ll X, Y; cin >> X >> Y;

    ll a = X;
    ll ans = 0;

    while (a <= Y) {
        ans++;
        a <<= 1;
    }

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

Measured memory_bytes: 256
N=int(input())
A=[]
mod=10**9+7
for i in range(N):
    a=int(input())
    A.append((a,-1))
for i in range(N):
    a=int(input())
    A.append((a,1))
A.sort()
a=0
s=A[0][1]
ans=1
for i in range(2*N):
    if A[i][1]==s:
        a+=1
    else:
        ans*=a
        ans%=mod
        a-=1
    if a==0 and i<2*N-1:
        s=A[i+1][1]
    #print(a,s,ans)
print(ans)

Measured memory_bytes: 68696
#include<stdio.h>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
int main(){
int sum=0,i,n,q,a;
string c;
queue<string> s;
queue<int> que;
scanf("%d %d\n",&n,&q);
for(i=0;i<n;i++){
cin >> c >> a;
que.push(a);
s.push(c);
}
while(!que.empty()){
a=que.front();
if(a>q){
a=a-q;
que.pop();
que.push(a);
c=s.front();
s.pop();
s.push(c);
sum=sum+q;
}
else{
que.pop();
c=s.front();
s.pop();
cout << c << ' ' << sum+a << endl;
sum=sum+a;
}
}
return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll = V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define INF 1e16
#define mod 1e9+7


int main(){
  ll R,G,B,n;
  cin>>R>>G>>B>>n;
  ll x,d=0,u=mod,count=0;
  for(ll i=0;;i++){
    for(ll j=0;;j++){
      x=n-R*i-G*j;
      if(x%B==0&&x>=0){
        count++;
      }
/*      for(ll k=0;k<30;k++){
      if(x<B*((d+u)/2)){
        u=B*((d+u)/2);
      }
      if(x>B*((d+u)/2)){
        d=B*((d+u)/2);
      }
      else{
        count++;
        break;
      }
      }*/
      if(R*i+G*j>n)break;
    }
    if(R*i>n)break;
  }
  co(count);
}


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

using namespace std;
typedef pair<int, int> pii;

int main(void) {
  int n;
  while (cin >> n, n) {
    vector<pii> v(n);
    set<pii> st;
    for (int i = 0; i < n; i++) {
      cin >> v[i].first >> v[i].second;
      st.insert(v[i]);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        pii d = pii(v[i].second - v[j].second, v[j].first - v[i].first);
        pii v1 = pii(v[i].first + d.first, v[i].second + d.second);
        pii v2 = pii(v[j].first + d.first, v[j].second + d.second);
        if (st.find(v1) == st.end() || st.find(v2) == st.end()) continue;
        ans = max(ans, d.first * d.first + d.second * d.second);
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3172
#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<int,int>;

int main() {
  ll s;
  cin >> s;
  int x1 = 0, y1 = 0;
  int x2 = 1e9, y2 = 1;
  int y3 = (s + x2 - 1) / x2;
  int x3 = x2 * y3 - s;
  printf("%d %d %d %d %d %d\n", x1, y1, x2, y2, x3, y3);
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int n;
	long long ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
)

// 回文: 上から読んでも下から読んでも同じ言葉になる文句
func main() {
	count := 0
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan(){
		text := stdin.Text()
		n1, n2 := Split(text)
		if n1 == Reverse(n2) {
			fmt.Println(0)
			break
		}
		n1Rune := []rune(n1)
		//fmt.Println(n1Rune)
		n2ReversedRune := []rune(Reverse(n2))
		//fmt.Println(n2ReversedRune)
		for i:=0;i<len(n1);i++ {
			if n1Rune[i] != n2ReversedRune[i] {
				count = count + 1
			}
		}
		fmt.Println(count)
	}
}

func Reverse(input string) string {
	inputRune := []rune(input)
	reverse := ""
	for i:=len(inputRune)-1;i>=0;i-- {
		reverse = reverse + string(inputRune[i])
	}
	return reverse
}

func Split(input string) (n1 string, n2 string) {
	inputRune := []rune(input)
	inputLength := len(inputRune)
	halfLength := inputLength/2
	if len(inputRune)%2 == 0 {
		n1 = string(inputRune[:halfLength])
		n2 = string(inputRune[halfLength:])
	} else {
		n1 = string(inputRune[:halfLength])
		n2 = string(inputRune[halfLength:])
	}
	return
}

type PalindromePhilia interface {
	Reverse(input string) string
	Split(input string) string
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define N 100100

int n,cnt,c;
char s[N];
long long k;

int main()
{
	scanf("%s",s); n=strlen(s);
	scanf("%lld",&k);
	for (int i=0;i<n;i++)
		if (s[i]=='1') cnt++; else
		{
			c=s[i]-'0';
			break;
		}
	if (cnt>=k) puts("1");
	else printf("%d\n",c);
	return 0;
}

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

int main(){
int N;
   cin>>N;
  vector<int>H(N);
  for(int i=0; i<N; i++){
   cin>>H[i]; }
  
  int count=0;
  for(int i=0; i<N; i++){
    bool flag=true;
    for(int j=0; j<i; j++){
     if(H[i]<H[j]){flag=false; break;}
    }
   if(flag){count++;} 
  }
  cout<<count<<endl;
  
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll r,g;
  cin >> r >> g;

  cout << 2*g-r << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		int answer = 0;
		sc.close();
		int i;
		for(i = 1; answer < x; i++){
			answer += i;
		}
		System.out.println(i-1);

	}

}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int leftWeight = a + b, rightWeight = c + d;
  if(leftWeight > rightWeight){
    cout << "Left" << endl;
  }else if(rightWeight > leftWeight){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int data[4],money[4]={6000,4000,3000,2000};
	memset(data,0,sizeof(data));
	for(int i=0;i<4;i++){
		int a,b;
		cin>>a>>b;a--;
		cout<<b*money[a]<<endl;
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
ll n,ans;
int main(void){
    
    cin>>n;
    for(int i=1;i<=n;i++){
        int r=0;
        for(int j=1;j<=i;j++)if(i%j==0)r++;
        if(i%2==1&&r==8)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
array_O = Array.new()
n = gets.chomp.to_i
array_A = gets.split(" ").map{|x|x.to_i}
q = gets.chomp.to_i
array_M = gets.split(" ").map{|x|x.to_i}
1.upto(n) { |i|
array_A.combination(i) {|arr|array_O.push(arr.inject {|sum, s| sum + s } )}
array_O.uniq!
}
q.times {|i|
if(array_O.include?(array_M[i]))
  print "yes"
else
  print "no"  
end
printf("\n")
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
// #define int long long 

using namespace std;

int32_t main()
{
	fio;
	int n,a,b;
	cin>>n>>a>>b;
	int ans=(b/n)*n;
	if(ans>=a && ans<=b)
	{
		cout<<"OK"<<endl;
	}
	else
	{
		cout<<"NG"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3544
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String arggs[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int mx=(int)1e4;
        int arr[]=new int[mx+1];
        for(int i=1;i<=100;i++)
        {
            for(int j=1;j<=100;j++)
            {
                for(int k=1;k<=100;k++)
                {
                    int ans=i*i+j*j+k*k+i*j+j*k+i*k;
                    if(ans<=mx)
                    arr[ans]++;
                }
            }
        }
        int n=Integer.parseInt(br.readLine());
        
        for(int i=1;i<=n;i++)
        pw.println(arr[i]);
        /*int arr[]=new int[n];
        String str[]=br.readLine().split(" ");
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        int cntr=0;
        for(int i=0;i<n;i++)
        {
            if(i%2==0&&arr[i]%2!=0)
            cntr++;
        }
        pw.println(cntr);*/
        pw.flush();
        pw.close();
    }
}

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

const int INF=1000000000;

int main(){
	int a,b;
	int s[5002],t[5002];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
	}
	for(int i=0;i<b;i++){
		scanf("%d",&t[i]);
	}

	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;

	int ret=0;
	for(int i=0;i<b-ret;i++){
		int p=0,q=i;
		int cnt=0;
		while(1){
			if(s[p]==t[q]){
				if(p>=memo[q])break;
				memo[q]=p;
				cnt++;
				p++;
				q++;
			}
			else {
				p++;
			}
			if(p==a){
				ret=max(ret,cnt);
				break;
			}
		}
	}

	printf("%d\n",ret);
}

Measured memory_bytes: 1084
k=int(input())
cnt=1
flag=True
if k%2==0:
    flag=False
    print(-1)
else:
    keta=10
    tmp=0
    while cnt<=10**6:
        tmp+=pow(keta,cnt-1,k)*7
        if tmp%k==0:
            print(cnt)
            flag=False
            break
        cnt+=1
if flag:
    print(-1)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,m,a[N],b[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)a[i]=i==1,b[i]=1;
	while(m--){
		int x,y;scanf("%d%d",&x,&y);
		if(a[x]){
			if(b[x]==1)a[x]=0;
			a[y]=1;
		}
		b[x]--,b[y]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

V,E=MI()
g=[[] for _ in range(V+1)]
for i in range(E):
    u,v,d=MI()
    g[u].append((v,d))
    g[v].append((u,d))
f=LI()
T=I()
order=[0]*T

'''
for i in range(T):
    n=I()
    if n>0:
        oid,v=MI()
        order[i]=v
'''

def rand_move():
    move=[]
    state=0 # on vertex
    cur=1
    
    for t in range(T//2):
        move.append(-1)
    for t in range(T//2,T):
        if state==0:
            r=len(g[cur])
            dest,dist=g[cur][random.randint(0,r-1)]
            state=1
            move.append(dest)
            dist-=1
            if dist==0:
                state=0
                cur=dest
        else:
            move.append(dest)
            dist-=1
            if dist==0:
                state=0
                cur=dest
    return move

move=rand_move()


# recieve info
def interactive():
    
    for i in range(T):
    
    	# the number of new order
    	Nnew = int(input())
    	for j in range(Nnew):
    		new_id, dst = map(int, input().split())

    	# the number of items transfered into the car at time t.
    	Nput = int(input())

    	for j in range(Nput):
    		put_id = int(input())
    
    	# insert your code here to get more meaningful output
    	# you have to output a command here
    	print(move[i])
    	sys.stdout.flush()
    
    	vardict = input()
    	if vardict == 'NG':
    		sys.exit()
    
    	# the number of orders that have been delivered at time t.
    	Nachive = int(input())
    	for j in range(Nachive):
    		achive_id = int(input())
    
    return            
    
interactive()


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

int main(){
    long N;cin>>N;
    vector<long> sum(N+1,0);
    vector<long> array(N+1,0);
    for(long i=0;i<N;i++){
        long a;cin>>a;
        array[i]=a;
        sum[a]++;
    }
    long res=0;
    for(long i=0;i<N+1;i++){
        res+=sum[i]*(sum[i]-1)/2;
    }
    for(long i=0;i<N;i++){
        long m=array[i];
        long ans = res-(sum[m]-1);
        cout<<ans<<endl;
    }
}

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

int c[505], f[505], s[505], res[505];

int main()
{
    int n, curt = 0;
    cin>>n;
    for(int i = 1; i < n; i++)
        scanf("%d %d %d", c + i, s + i, f + i);
    res[n] = 0;
    res[n - 1] = s[n - 1] + c[n - 1];
    for(int i = n - 2; i >= 1; i--)
    {
        int j = i;
        curt = s[j];
        while(j < n)
        {
            curt += c[j];
            if(j == n - 1)
                break;
            if(s[j + 1] <= curt)
            {
                int nm = ceil((curt - s[j + 1]) / (double)f[j + 1]);
                curt = s[j + 1] + (nm * f[j + 1]);
            }
            else
            {
                curt = s[j + 1];
            }
            j++;
        }
        res[i] = curt;
    }
    for(int i = 1; i <= n; i++)
        printf("%d\n", res[i]);
    return 0;
}


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

using namespace std;

long long dp(long long curr, pair<long long, long long> n_w, long long W, long long w0, const vector<long long>& v, const vector<long long>& w
        , map<pair<long long, pair<long long, long long>>, long long>& memo) {

    auto p = make_pair(curr, n_w);
    if (memo.count(p) > 0) {
        return memo[p];
    }
    long long N = v.size();
    if (curr == N) {
        return 0LL;
    }

    long long ret = dp(curr + 1, n_w, W, w0, v, w, memo);
    pair<long long, long long> next_nw = make_pair(n_w.first + 1, n_w.second + w[curr]);
    if (w0 * next_nw.first + next_nw.second <= W) {
        long long take = v[curr] + dp(curr + 1, next_nw, W, w0, v, w, memo);
        ret = max(ret, take);
    }

    memo.insert(make_pair(p, ret));
    return ret;
}

void Main() {
    long long N, W;
    cin >> N >> W;
    vector<long long> w(N, 0LL), v(N, 0LL);
    for (long long i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    long long w0 = w[0];
    for (long long i = 0; i < N; ++i) {
        w[i] -= w0;
    }

    map<pair<long long, pair<long long, long long>>, long long> memo;
    long long ans = dp(0, make_pair(0, 0), W, w0, v, w, memo);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 11168
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int c = 0;
    for(int i = 0; i < n; i++){
        int num; cin >> num;
        while(num % 2 == 0){
            c++; num/= 2;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[1010][1010];
signed main() {
    int N, K; cin >> N >> K;
    dp[0][0] = 1;
    for(int i=0; i<K; i++) {
        for(int j=0; j<=N; j++) {
            for(int k=0; j+k*(K-i)<=N; k++) {
                int nj = j+k*(K-i);
                (dp[i+1][nj] += dp[i][j]) %= MOD;
            }
        }
    }

    int ans = dp[K][N];
    cout << ans << endl;
    return 0;
}



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

int main(){
  
  int n,m;
  cin >> n;
  m = n;
  
  int w = 0;
  string ans = "No";
  
  for(int i=0; i<8; i++){
    w += n%10;
    n /= 10;
  }
  
  if(m%w == 0)ans = "Yes";
  
  cout << ans << endl;
  
  return 0;
}

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

#define inf 1000000007
 
int main(){
  int n, d;
  cin >> n >> d;
  int s[n][d];
  for(int i=0; i<n; ++i){
    for(int j=0; j<d; ++j){
      cin >> s[i][j];
    }
  }
  int ans = 0;
  int a;
  for(int i=0; i<n-1; ++i){
    for(int j=i+1; j<n; ++j){
      a = 0;
      for(int k=0; k<d; ++k){
        a += (s[i][k] - s[j][k])*(s[i][k] - s[j][k]);
      }
      int b = (int)sqrt((double)a);
      if (b*b == a) {
        ans+=1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
v = [x2 - x1, y2 - y1]
s = [x2 - v[1], y2 + v[0]]
t = [s[0] - v[0], s[1] - v[1]]
print(s[0], s[1], t[0], t[1])

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

int main(){
  string w;
  cin >> w;
  vector<int> vec(26);
  for(int i = 0; i < w.size(); i++){
  vec[w[i]-'a'] += 1;
  }
  for(int i = 0; i < 26; i++){
    if(vec[i] % 2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


void ink_small(int w, int h, std::vector<int> &image, int x, int y){
	image[y * w + x]++;

	if(y - 1 >= 0){
		image[(y - 1) * w + x]++;
	}
	if(y + 1 < h){
		image[(y + 1) * w + x]++;
	}
	if(x - 1 >= 0){
		image[y * w + x - 1]++;
	}
	if(x + 1 < w){
		image[y * w + x + 1]++;
	}

	return;
}

void ink_middle(int w, int h, std::vector<int> &image, int x, int y){

	ink_small(w, h, image, x, y);

	if((y - 1) >= 0){
		if((x - 1) >= 0){
			image[(y - 1) * w + x - 1]++;
		}
		if((x + 1) < w){
			image[(y - 1) * w + x + 1]++;
		}
	}
	if((y + 1) < h){
		if((x - 1) >= 0){
			image[(y + 1) * w + x - 1]++;
		}
		if((x + 1) < w){
			image[(y + 1) * w + x + 1]++;
		}
	}

	return;
}

void ink_large(int w, int h, std::vector<int> &image, int x, int y){
	ink_middle(w, h, image, x, y);

	if((y - 2) >= 0){
		image[(y - 2) * w + x]++;
	}
	if((y + 2) < h){
		image[(y + 2) * w + x]++;
	}
	if((x - 2) >= 0){
		image[y * w + x - 2]++;
	}
	if((x + 2) < w){
		image[y * w + x + 2]++;
	}

	return;
}

void print(int w, int h, const std::vector<int> &image){
	for(int y = 0; y < h; y++){
		int offset = y * w;
		for(int x = 0; x < w; x++){
			std::cout << image[offset + x];
		}
		std::cout << std::endl;
	}
	return;
}

int main(int argc, char **argv){
	int w = 10;
	int h = 10;
	std::vector<int> image(w * h, 0);
	int x, y, s;
	char tmp;
	int count_zero = 0;
	int max = 0;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> x >> tmp >> y >> tmp >> s){
#else
	while(std::cin >> x >> tmp >> y >> tmp >> s){
#endif
		
		if(s == 1){
			ink_small(w, h, image, x, y);
		}
		else if(s == 2){
			ink_middle(w, h, image, x, y);
		}
		else{
			ink_large(w, h, image, x, y);
		}

		//print(w, h, image);
	}

	for(int y = 0; y < h; y++){
		int offset = y * w;
		for(int x = 0; x < w; x++){
			int val = image[offset + x];
			if(val == 0){
				count_zero++;
			}
			max = std::max(max, val);
		}
	}

	std::cout << count_zero << std::endl;
	std::cout << max << std::endl;
	
	return 0;
}


Measured memory_bytes: 3104
def string_to_complex(s):
    a, b, c, d = map(int, s.split())
    return (a + b * 1j, c + d * 1j)

def dot(c1, c2):
    return c1.real * c2.real + c1.imag * c2.imag

def cross(c1, c2):
    return c1.real * c2.imag - c1.imag * c2.real

def cross_point(p1, p2, p3, p4):
    crs1 = cross(p2 - p1, p3 - p1)
    crs2 = cross(p2 - p1, p4 - p1)
    if crs1 == 0 and crs2 == 0:
        if p1 == p3 or p1 == p4:
            return p1
        elif p2 == p3 or p2 == p4:
            return p2
        else:
            return None
    crs3 = cross(p4 - p3, p1 - p3)
    crs4 = cross(p4 - p3, p2 - p3)
    if crs1 * crs2 <= 0 and crs3 * crs4 <= 0:
        base = p4 - p3
        hypo1 = p1 - p3
        hypo2 = p2 - p3
        d1 = abs(cross(base, hypo1)) / abs(base)
        d2 = abs(cross(base, hypo2)) / abs(base)
        return p1 + d1 / (d1 + d2) * (p2 - p1)
    else:
        return None

def contain(polygon):
    flag = False
    for a, b in zip(polygon[0:], polygon[1:] + [polygon[0]]):
        if a.imag > b.imag:
            a, b = b, a
        if a.imag <= 0 and b.imag > 0 and cross(a, b) > 0:
            flag = not flag
    return flag

def solve():
    def dfs_contain(goal, edges, cross_points):
        cur_edge = edges[-1]
        for next_edge, next_cp in adj_edge[cur_edge]:
            if next_edge == goal:
                if contain(cross_points + [next_cp]):
                    break
            elif next_edge not in edges and unchecked[next_edge] and DP[next_edge]:
                edges.append(next_edge)
                cross_points.append(next_cp)
                if dfs_contain(goal, edges, cross_points):
                    break
                e = edges.pop()
                DP[e] = False
                cross_points.pop()
        else:
            return False
        return True
            
    from sys import stdin
    lines = stdin.readlines()
    
    from itertools import combinations
    
    while True:
        n = int(lines[0])
        if n == 0:
            break
        
        edges = enumerate(map(string_to_complex, lines[1:1+n]))
        adj_edge = [[] for i in range(n)]
        
        for e1, e2 in combinations(edges, 2):
            n1, t1 = e1
            n2, t2 = e2
            cp = cross_point(*t1, *t2)
            if cp:
                adj_edge[n1].append((n2, cp))
                adj_edge[n2].append((n1, cp))
        
        flag = True
        while flag:
            for i, ae in enumerate(adj_edge):
                if len(ae) == 1:
                    ne, cp = ae.pop()
                    adj_edge[ne].remove((i, cp))
                    break
            else:
                flag = False
        
        unchecked = [True] * n
        
        for e in range(n):
            unchecked[e] = False
            DP = [True] * n
            if dfs_contain(e, [e], []):
                print('yes')
                break
        else:
            print('no')
        
        del lines[:1+n]

solve()


Measured memory_bytes: 6672
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b, c;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		if (a + b >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#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<int,int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> ans;
    if (n%2) {
        for (int l = 1, r = n-1; l < r; l++, r--) {
            ans.emplace_back(l,r);
        }
    } else {
        bool flag = false;
        for (int l = 1, r = n-1; l < r; l++, r--) {
            if (!flag&&r-l <= n/2) {
                --r;
                flag = true;
            }
            ans.emplace_back(l,r);
        }
    }
    rep(i,m) {
        printf("%d %d\n", ans[i].first, ans[i].second);
    }
    return 0;
}

Measured memory_bytes: 4224
a = int(input())
b = input()
ans = 0
for i in range(1, a-1):
    c = b[:i]
    d = b[i:]
    e = 0
    f = []
    for j in range(len(c)):
        for k in range(len(d)):
            if c[j] == d[k] and c[j] not in f:
                e += 1
                f.append(c[j])
                break
    ans = max(ans, e)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
        return 0;
    }
    VI v, w;
    if (x == 2) {
        v.push_back(x+1);
        v.push_back(x);
        v.push_back(x-1);
        if (n != 2) v.push_back(x+2);
        
        for (long i = 1; v.size() + w.size() < 2 * n - 1; i++) {
            if (i < x - 1 || i > x + 2) {
                w.push_back(i);
            }
        }
    } else {
        v.push_back(x-1);
        v.push_back(x);
        v.push_back(x+1);
        v.push_back(x-2);
        
        for (long i = 1; v.size() + w.size() < 2 * n - 1; i++) {
            if (i < x - 2 || i > x + 1) {
                w.push_back(i);
            }
        }
    }
    cout << "Yes" << endl;
    REP(i,w.size() / 2) {
        cout << w[i] << endl;
    }
    REP(i,v.size()) {
        cout << v[i] << endl;
    }
    REPI(i,w.size() / 2, w.size()) {
        cout << w[i] << endl;
    }
}



Measured memory_bytes: 3184
from itertools import *
n = int(input())
Ls = list(map(int, input().split()))
ans = 0
if n <= 2:
  print('0')
  exit()
else:
  for v in combinations(Ls, 3):
    l = list(v)
    l.sort(reverse = False)
    if l[2] < l[1] + l[0] and len(set(l)) == 3:
      ans += 1
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int n,l;
	int min = 999999;
	cin >> n;
	cin >> l;
	int sum = 0;
	int apples[n];
	rep(i,n){
		apples[i] = l+i;
		if(abs(min)>abs(l+i)){
			min = l+i;
		}
		sum += l+i;
	}
	cout<<sum-min;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    List<Integer> prime = new ArrayList<>();
    for (int i = 2; i <= N; i++) {
      boolean isPrime = true;
      for (int j = 2; j < i; j++) {
        if (i%j == 0) {
          isPrime = false;
          break;
        }
      }
      if (isPrime) {
        prime.add(i);
      }
    }
    
    int[] factor = new int[N+1];
    for (int i = 2; i <= N; i++) {
      for (int p : prime) {
        if (p > i) {
          break;
        }
        int n = i;
        while (n > 1 && n%p == 0) {
          factor[p]++;
          n /= p;
        }
      }
    }
    
    long ans = 1;
    for (int i = 2; i <= N; i++) {
      if (factor[i] > 0) {
        ans = ans * (factor[i]+1) % 1000000007;
      }
    }
 
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	for (int i = a; i <= b; i++)
	{
		if (c%i == 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3116
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
#define inf 20021225
#define bs 331
#define ull unsigned long long
using namespace std;
map<ull,int> f[20]; char ch[40]; int col[20],n; ll ans;
ull pw[20];
void calc(int fl)
{
	ull x=0,y=0;
	int p=0,q=n;
    for (int i=1;i<=n;i++)
        if(col[i]>0) x+=(ull)col[i]*pw[p],p++;
        else y+=(ull)col[i]*pw[q],q--;
	if(fl)	ans+=f[p][x+y];
	else	f[q][x+y]++;
}
void dfs1(int x)
{
	if(x>n){calc(0); return;}
	col[x]=ch[x]-'a'+1; dfs1(x+1); col[x]=-col[x]; dfs1(x+1);
}
void dfs2(int x)
{
	if(x<=n){calc(1); return;}
	col[2*n-x+1]=ch[x]-'a'+1; dfs2(x-1); col[2*n-x+1]=-col[2*n-x+1]; dfs2(x-1);
}
int main()
{
	scanf("%d",&n); scanf("%s",ch+1); pw[0]=1; for(int i=1;i<=n;i++) pw[i]=pw[i-1]*bs;
	dfs1(1); dfs2(2*n); printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace edamat {
template <class T>
struct CumulativeSum {
    ::std::vector<T> data;

    CumulativeSum(){};
    CumulativeSum(int sz) : data(sz, 0){};
    CumulativeSum(::std::vector<T> v) { build(v); }

    void add(int k, T x) { data[k] += x; }
    void build() {
        for(int i = 1; i < data.size(); i++) data[i] += data[i - 1];
    }
    void build(::std::vector<T> &v) {
        data = v;
        for(int i = 1; i < data.size(); i++) data[i] += data[i - 1];
    }
    T query(int k) {
        if(k < 0) return (0);
        return (data[::std::min(k, (int)data.size() - 1)]);
    }
    T query(int l, int r) {
        if(l < 0 || r > data.size()) return (0);
        return query(r - 1) - query(l - 1);
    }
};
}  // namespace edamat

void solve() {
    int n, k;
    std::cin >> n >> k;
    std::vector<i64> _(n);
    rep(i, n) std::cin >> _[i];
    edamat::CumulativeSum<i64> cs(_);
    std::vector<i64> a;
    rep(l, n) {
        repeat(r, l + 1, n + 1) {
            a.emplace_back(cs.query(l, r));
        }
    }
    int idx;
    for(idx = 63; idx >= 0; idx--) {
        int cnt = 0;
        rep(j, a.size()) {
            if((a[j] >> idx) & 1) cnt++;
        }
        // std::cout << idx << " " << cnt << std::endl;
        if(cnt >= k) {
            break;
        }
    }
    // std::cout << idx << std::endl;
    // rep(i, a.size()) std::cout << a[i] << " \n"[i == a.size() - 1];
    for(int i = idx; i >= 0; i--) {
        std::vector<i64> tmp;
        rep(j, a.size()) {
            if((a[j] >> i) & 1) {
                tmp.push_back(a[j]);
            }
        }
        if(tmp.size() >= k) {
            a = tmp;
        }
        // rep(i, a.size()) std::cout << a[i] << " \n"[i == a.size() - 1];
    }

    i64 ans = a[0];
    rep(i, k) {
        ans &= a[i];
    }
    std::cout << ans << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 6392
#include<stdio.h>

#define Array_MAX 100000

int partition(int *A,int p,int r){
  int x = A[r];
  int i=p-1,j,tmp;
  for(j=p;j<r;j++){
    
    if(A[j]<=x){
      i+=1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
      tmp = A[i+1];
      A[i+1]=A[r];
      A[r]=tmp;
  

    return i+1;
}
  

int main(){
  
  int A[Array_MAX];
  int  i,n;
  int fond;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&A[i]);

  fond=partition(A,0,n-1);
  for(i=0;i<fond;i++) printf("%d ",A[i]);
  printf("[%d] ",A[fond]);
  for(i=fond+1;i<n-1;i++)  printf("%d ",A[i]);
  printf("%d\n",A[n-1]);


  return 0;
}

Measured memory_bytes: 988
n = int(input())
A = list(map(int, input().split()))

Colors = []
High_scorer = []
for a in A:
    if a < 400:
        Colors.append("Gray")
    if 400 <= a and a < 800:
        Colors.append("Brown")
    if 800 <= a and a < 1200:
        Colors.append("Green")
    if 1200 <= a and a < 1600:
        Colors.append("Light_blue")
    if 1600 <= a and a < 2000:
        Colors.append("Blue")
    if 2000 <= a and a < 2400:
        Colors.append("Yellow")
    if 2400 <= a and a < 2800:
        Colors.append("Orange")
    if 2800 <= a and a < 3200:
        Colors.append("Red")
    if 3200 <= a:
        High_scorer.append(a)

MIN = len(set(Colors))
H = len(High_scorer)

if MIN >= 1:
    print(MIN, (MIN+H))
elif MIN == 0:
    print(1, H)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

int sec(int h,int m,int s) {
    return (h*3600+m*60+s);
}
void time(int second,int *h,int *m,int *s) {
    *h=second/3600;
    second%=3600;
    *m=second/60;
    second%=60;
    *s=second;
}
signed main() {
    REP(i,3) {
        int bh,bm,bs;
        int ah,am,as;
        cin>>bh>>bm>>bs;
        cin>>ah>>am>>as;
        int h,m,s;
        time(sec(ah,am,as)-sec(bh,bm,bs),&h,&m,&s);
        printf("%d %d %d\n", h,m,s);
    }
    return 0;
}

Measured memory_bytes: 3168
class Line:
    def __init__(self,p1,p2):
        if p1[1] < p2[1]:self.s=p2;self.e=p1
        elif p1[1] > p2[1]:self.s=p1;self.e=p2
        else:
            if p1[0] < p2[0]:self.s=p1;self.e=p2
            else:self.s=p2;self.e=p1
def dot(a,b):return a[0]*b[0] + a[1]*b[1]
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
def dif(a,b):return [x-y for x,y in zip(a,b)]
def isOn(l,m):
    a = dif(l.e,l.s);b = dif(m.s,l.s);c = dif(m.e,l.s)
    d = dif(m.e,m.s);e = dif(l.s,m.s);f = dif(l.e,m.s)
    g = lambda a, b : cross(a,b)==0 and dot(a,b)>0 and dot(b,b)<dot(a,a)
    if g(a,b) or g(a,c) or g(d,e) or g(d,f):return True
    else:return False
        
    
def InterSection(l,m):
    a = dif(l.e,l.s);b = dif(m.e,l.s);c = dif(m.s,l.s)
    d = dif(m.e,m.s);e = dif(l.e,m.s);f = dif(l.s,m.s)
    if isOn(l,m):return True
    elif l.s == m.e or l.s == m.s or l.e == m.e or l.e == m.s:return True
    elif cross(a,b) * cross(a,c) >= 0 or cross(d,e) * cross(d,f) >= 0:return False
    else:return True

q = int(input())
for i in range(q):
    x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]
    a = [x0,y0] ; b = [x1,y1] ; c = [x2,y2] ; d = [x3,y3]
    l1 = Line(a,b) ; l2 = Line(c,d)
    if InterSection(l1,l2):print(1)
    else:print(0)

Measured memory_bytes: 7912
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    int n,m;
    cin>>n>>m;

    vector<string > v(n);
    forn(i,0,n)
    {
        cin>>v[i];
    }

    v2l dp(n,vl(m,0));

    dp[0][0] = 1;

    forn(i,1,m)
    {
        if(v[0][i] != '#') dp[0][i] = dp[0][i-1];
    }

    forn(i,1,n)
    {
        if(v[i][0] != '#') dp[i][0] = dp[i-1][0];
    }

    forn(i,1,n)
    {
        forn(j,1,m)
        {
            if(v[i][j] != '#') dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
    

    cout<<dp[n-1][m-1];
 




    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n;i++){
        cin >> a[i];
    }
    for(int i=0; i<n-1;i++){
        cout << a[n-1-i] << " ";
    }
    cout << a[0] << endl;
}


Measured memory_bytes: 3104
N,M,P = map(int,input().split())
E = []
for i in range(M):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  c=-c+P
  E.append([a,b,c])
  
def BellmanFord(s,g):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(N)]
  dist[s]=0
  rout=[]
  
  #辺の緩和
  for i in range(N):
    for edge in E:
      if dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        if i==N-1: dist[edge[1]]=-inf
  for i in range(N):
    for edge in E:
      if dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
  if dist[g] == -inf:return -1
  return max(0,-dist[g])
print(BellmanFord(0,N-1))

Measured memory_bytes: 47960
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	if(a==3||a==5||a==7)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
#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<int, int>;

int solve(vector<int> v1, vector<int> v2) {
  map<int, int> mp1;
  for (auto x : v1) mp1[x]++;
  int max_idx1, max_v1 = 0;
  for (auto x : mp1) {
    if (max_v1 < x.second) {
      max_idx1 = x.first;
      max_v1 = x.second;
    }
  }
  int ans1 = v1.size() - max_v1;

  map<int, int> mp2;
  for (auto x : v2) mp2[x]++;
  int max_v2 = 0;
  for (auto x : mp2)
    if (x.first != max_idx1) max_v2 = max(max_v2, x.second);
  int ans2 = v2.size() - max_v2;

  return ans1 + ans2;
}

int main() {
  int n, v;
  cin >> n;
  vector<int> v1, v2;
  rep(i, n) {
    cin >> v;
    if (i % 2 == 0)
      v1.push_back(v);
    else
      v2.push_back(v);
  }

  cout << min(solve(v1, v2), solve(v2, v1)) << endl;
  return 0;
}


Measured memory_bytes: 9208
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

typedef long long ll;
int main() {
    int n;
    std::cin >> n;
    std::map<ll, ll> m;
    ll sum = 0;
    m[0] = 1LL;
    for (int i = 0; i < n; ++i) {
        ll a;
        std::cin >> a;
        sum += a;
        ++m[sum];
    }
    ll ans = 0;
    for (std::map<ll, ll>::iterator it = m.begin(); it != m.end(); ++it) {
        ll v = it->second;
        ans += v * (v - 1LL) / 2LL;
    }
    std::cout << ans << std::endl;
//    std::fill(ss.begin(), ss.end(), 0);
}

Measured memory_bytes: 12800
#include <iostream>
#include <limits.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

int main(void){
    long long n, p;
    cin >> n >> p;
    
    if (p == 1 || n >= 40) {
        cout << 1 << endl;
        return 0;
    }
    
    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    
    long long prod = p, primes = 2, powers = 1, prime_p[100], prime_q[100];
    
    for (int i = 1; i <= 100; i++) {
    	prime_p[i] = prime_q[i] = 0;
    }
    
    
    while (prod >= primes) {
    	while (prod % primes == 0) {
    		if (prime_q[powers] > 0) prime_q[powers]++;
    		else {
    			prime_p[powers] = primes;
    			prime_q[powers]++;
    		}
    		prod /= primes;
    		if (prod % primes != 0) powers++;
    	}
    	primes++;
    	if (primes > pow(p, 0.5)) {
    	    prime_p[powers] = prod;
    		prime_q[powers]++;
    		powers++;
    	    break;
    	}
    }
    powers--;
    
    long long ans = 1;
    for (int i = 1; i <= powers; i++) {
    	while (prime_q[i] >= n) {
    	    ans *= prime_p[i];
    	    prime_q[i]-= n;
    	}
    }
    
    cout << ans << endl;
    
//    for (int i = 1; i <= powers; i++) {
//    	cout << prime_p[i] << " " << prime_q[i] << endl;
//    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

ll gcdl(ll a,ll b){ // log N
    while((a%=b)&&(b%=a));
    return a+b;
}

ll lcml(ll a,ll b){
    return a/gcdl(a,b)*b;
}

int gcd(int a,int b){ // log N
    while((a%=b)&&(b%=a));
    return a+b;
}

int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

int main(){
    int n,X;
    cin>>n>>X;
    n--;
    int x;
    cin>>x;
    x-=X;
    int g=abs(x);
    REP(i,n){
        cin>>x;
        x-=X;
        g=gcd(g,abs(x));
    }
    cout<<g<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a[105], sum;
int main() {
    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    sort (a, a+n);
    if (sum%10==0) {
        int k = 0;
        for (int i=0;i<n;i++) {
            if (a[i]%10) {
                k = a[i];
                break;
            }
        }
        if (k==0) sum = 0;
        else sum -= k;
    }   
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 256