akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
int powermod(int x,int y,int m) 
{ 
    if(y==0) 
        return 1; 
    int p=powermod(x,y/2,m)%m; 
    p=(p*p)%m; 
    return (y%2==0)?p:(x*p)%m; 
}
void shikhar7s(int cas)
{
    int n,m,i;
    cin>>n>>m;
    int fac[m+5],faci[m+5];
    fac[0]=1;
    int ans=0,p=1;
    rep(i,1,m+1)
    {
        fac[i]=(fac[i-1]*i)%mod;
        faci[i]=powermod(fac[i],mod-2,mod);
    }
    int d;
    fr(i,n+1)
    {
        d=fac[m-i];
        p=fac[i];
        p=(p*fac[n-i])%mod;
        p=powermod(p,mod-2,mod);
        d=(d*p)%mod;
        if(i%2)
        ans=(ans-d+mod)%mod;
        else
            ans=(ans+d)%mod;
    }
    ans=(ans*fac[m])%mod;
    ans=(ans*fac[n])%mod;
    p=powermod(fac[m-n],mod-2,mod);
    ans=(ans*p)%mod;
    ans=(ans*p)%mod;
    cout<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 11340
#include <stdio.h>

int main(){
    int n, i, j, k;
    char s[10];
    long long int m=0, a=0, r=0, c=0, h=0, head[5], cnt=0;
    int x[10] = {0,0,0,0,0,0,1,1,1,2};
    int y[10] = {1,1,1,2,2,3,2,2,3,3};
    int z[10] = {2,3,4,3,4,4,3,4,4,4};

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%s", s);
        if(s[0] == 'M')
            m++;
        if(s[0] == 'A')
            a++;
        if(s[0] == 'R')
            r++;
        if(s[0] == 'C')
            c++;
        if(s[0] == 'H')
            h++;
    }

    head[0] = m;
    head[1] = a;
    head[2] = r;
    head[3] = c;
    head[4] = h;

    for(i=0; i<10; i++){
        cnt += head[x[i]] * head[y[i]] * head[z[i]];
    }

    printf("%lld\n", cnt);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();

			if(H == 0 && W == 0) {
				break;
			}

			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W;j++) {
					System.out.print("#");
				}
				System.out.println();
			}

			System.out.println();
		}
	}

}


Measured memory_bytes: 34964
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

#define deg_to_rad(deg) (((deg)/360)*2*M_PI)

int main(){
    double a, b, x;
    cin >> a >> b >> x;

    double lo = 0, hi = 90;
    while(hi - lo > 1e-8){
        const double mid = (hi + lo) / 2.0;
        const double rad = deg_to_rad(mid);
        const double rad2 = M_PI / 2 - rad;
        const double aheight = sin(rad) * a;
        const double bheight = sin(rad2) * b;
        double vol = 0;
        if(aheight >= bheight){
            const double aheight2 = bheight / cos(rad2);
            vol = aheight2 * a * b / 2.0;
        }else{
            const double y = aheight / tan(rad2);
            const double z = aheight / sin(rad2);
            vol = (
                a * a * z / 2.0 + a * (a * cos(rad) + y) * (bheight - aheight)
            );
        }
        if(vol < x){
            hi = mid;
        }else{
            lo = mid;
        }
    }
    printf("%.8f\n", lo);
    return 0;
}


Measured memory_bytes: 384
// class練習用
#include <bits/stdc++.h>
using namespace std;

class jewel {
  int v;
  int c;
  
 public:
  void input(int a, int b);
  int ret();
};

void jewel::input(int a, int b) {
  v = a;
  c = b;
}

int jewel::ret() {
  if(v - c > 0) return v - c;
  return 0;
}

int main() {
  int n;
  cin >> n;
  
  vector<int> v(n), c(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> c.at(i);
  }
  
  int ans = 0;
  jewel j[n];
  for(int i = 0; i < n; i++){
    j[i].input(v.at(i), c.at(i));
    ans += j[i].ret();
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, a, b; /* 与えられる値 */
	int i;

	/* データセット毎の処理 */
	while (scanf("%d%d%d", &n, &a, &b) == 3 && n > 0 && a > 0 && b > 0) {
		int memo[1000001] = {1}; /* カウント可能か */
		int count = 0; /* カウント可能な正整数の個数 */

		/* n 以下の a*i+b*j (i, j >= 0) を総当たりで調べる */
		for (i = 1; i <= n; i++) {
			/* i - a または i - b がカウント可能なら i もカウント可能である */
			if ((i >= a && memo[i - a]) || (i >= b && memo[i - b])) {
				memo[i] = 1;
				count++;
			}
		}
		/* カウント不可能な個数を出力する */
		printf("%d\n", n - count);
	}

	return 0;
}

Measured memory_bytes: 4512
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#include <sstream>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
typedef pair<double, double> pdd;
typedef pair<int,int> pii;
const double EPS = 10e-6;
int c[2000][2000]={};
string x,y;
int dp(int o,int p)
{
	if(o==x.size()||p==y.size())return 0;
	if(c[o][p]!=-1)return c[o][p];
	int ans =0;
	if(x[o]==y[p])
	{
		ans=max(dp(o+1,p+1)+1,max(dp(o+1,p),dp(o,p+1)));
	}
	else ans=max(dp(o+1,p),dp(o,p+1));

	return c[o][p]=ans;
}

int main ()
{
	int n;
	cin>>n;
	rep(i,n)
	{
		
		cin>>x>>y;
		memset(c, -1, sizeof(c));
		cout<<dp(0,0)<<endl;;
	}



}

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

namespace ConsoleApp15
{
    class Class115
    {
        static void Main()
        {
            var NMK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NMK[0], M = NMK[1], K = NMK[2];
            int[] A = new int[N];
            
            Union_Find friends = new Union_Find(N);
            var block = new List<int>[N];
            for (int i = 0; i < N; i++) block[i] = new List<int>();
            
            for(int i = 0; i < M; i++)
            {
                var r = Console.ReadLine().Split().Select(x=>int.Parse(x)-1).ToArray();
                friends.Unite(r[0], r[1]);
                A[r[0]]++;
                A[r[1]]++;
            }
            
            for(int i = 0; i < K; i++)
            {
                var r = Console.ReadLine().Split().Select(x=>int.Parse(x)-1).ToArray();
                block[r[0]].Add(r[1]);
                block[r[1]].Add(r[0]);
            }

            var ans = new int[N];
            for(int i = 0; i < N; i++)
            {
                var res = friends.getMem(i) - A[i] - 1;
                foreach (int j in block[i])
                    if (friends.Root(i) == friends.Root(j)) res--;
                ans[i] = res;
            }
            Console.WriteLine(string.Join(" ",ans));
        }
    }
    public class Union_Find
    {
        private int[] data;
        public Union_Find(int size)
        {
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }
        public bool Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);
            if (x != y)
            {
                if (data[y] < data[x])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                data[x] += data[y];
                data[y] = x;
            }
            return x != y;
        }
        public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
        public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
        public int getMem(int x) => -data[Root(x)];
    }
}


Measured memory_bytes: 34004
#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 h, w, k;
  cin >> h >> w >> k;
  vector<int> totH(h);
  vector<int> totW(w);
  int totBl = 0;
  int ans = 0;
  vector<vector<char>> c(h, vector<char> (w));
  rep(i,h) {
    rep(j,w) {
      cin >> c[i][j];
      if (c[i][j] == '#') {
        totBl++;
        totH[i]++;
        totW[j]++;
      }
    }
  }

  for (int bitH = 0; bitH < (1<<h); ++bitH) {
    for (int bitW = 0; bitW < (1<<w); ++bitW) {
      int bl = totBl;
      vector<int> hLine;
      vector<int> wLine;
      rep(i,h) {
        if ((bitH>>i) & 1) {
          hLine.push_back(i);
          bl -= totH[i];
        }
      }
      rep(i,w) {
        if ((bitW>>i) & 1) {
          wLine.push_back(i);
          bl -= totW[i];
        }
      }
      for (auto hi : hLine) {
        for (auto wi : wLine) {
          if (c[hi][wi] == '#') bl++;
        }
      }
      if (bl == k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
import sys, fractions
def input():
    return sys.stdin.readline()[:-1]
N = int(input())

if N%2:
    print(0)
    exit()

ans = 0
for i in range(1,30):
    k = (5**i)*2
    if k>N:
        break
    ans += N//k
print(ans)

Measured memory_bytes: 5048
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

ll a,b,c,d[100005] = {},n,m;
string s,t;

int main(){
    
    cin >> n >> a;

    if((n+1)/2 >= a)YES;
    else NO;
    
	return  0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nm = ReadIntArray();
            var n = nm[0];
            var m = nm[1];
            var a = new List<string>();
            var b = new List<string>();
            for (var i = 0; i < n; i++)
            {
                a.Add(ReadString());
            }
            for (var i = 0; i < m; i++)
            {
                b.Add(ReadString());
            }

            for (var i = 0; i <= a.Count - b.Count; i++)
            {
                var from = 0;
                var index = a[i].IndexOf(b[0], from);
                while (index >= 0)
                {
                    if (Enumerable.Range(0, b.Count).All(v => a[i + v].IndexOf(b[v], from) == index))
                    {
                        Console.WriteLine($"Yes");
                        return;
                    }
                    from = index + 1;
                    index = a[i].IndexOf(b[0], from);
                }
            }
            Console.WriteLine("No");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


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

int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  a--; b--; c--; d--;
  string s;
  cin>>s;
  
  if(c<d){
    for(int i=a+1;i<d-1;i++){
      if(s[i]==s[i+1]&&s[i]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
  }else{
    for(int i=a+1;i<c-1;i++){
      if(s[i]==s[i+1]&&s[i]=='#'){
        cout<<"No"<<endl;
        return 0;
      }     
    }
    bool ok = true;
    for(int i=b;i<=d;i++){
      if(s[i-1]==s[i]&&s[i]==s[i+1]&&s[i]=='.') ok = false;
    }
    if(ok){
      cout<<"No"<<endl;
      return 0;
    }else{
      cout<<"Yes"<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(long long I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M;
  cin >> N >> M;
  ll ans = 0;
  FOR(x,1,sqrt(M)+1) {
    if(M % x == 0) {
      if(x * N <= M) {
        ans = max(ans, x);
      }
      if(M / x * N <= M) {
        ans = max(ans, M / x);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import time
st = time.time()

d = int(input())
clist = list(map(int,input().split()))
last_c = [0]*26
select_c = [0]*26
for i in range(26):
    select_c[i] = []

slist = [0] * d
for i in range(d):
    slist[i] = list(map(int,input().split()))

tlist = [0]*d
satisfy = [0]*(d+1)

#貪欲法
for i in range(0,d):
    max = 0
    max_n = 0
    for n in range(26):
        if i > 0:
            curr = slist[i][n] + satisfy[i-1]
        else:
            curr = slist[i][n]
        minus = 0
        for j in range(26):
            if n != j:
                minus -= clist[j] * (i - last_c[j])
        curr += minus
        if curr > max:
            max = curr
            max_n = n
    satisfy[i] = max
    last_c[max_n] = i+1 
    select_c[max_n].append(i+1)
    tlist[i] = max_n+1

try:

    import random
    import numpy as np

    sum = 0
    total_c = 0


    for i in range(d):
        sum += slist[i][tlist[i]-1]

    ct = time.time()

    for i in range(len(select_c)):
        start = 1
        c_change = 0
        if select_c[i] == []:
            c_change = np.sum(np.arange(d+1))
        else:
            for j in range(len(select_c[i])):
                end = select_c[i][j]
                if end > start:
                    c_change += np.sum(np.arange(end-start+1))
                start = end
            end = d+1
            c_change += np.sum(np.arange(end-start))
            start = end
        total_c += clist[i]*c_change

    current_max = sum - total_c

    import bisect
    while ct-st < 1.9:
        change_d = random.randint(1,d)
        change_d_to_c = random.randint(0,len(select_c)-1)
        for x in range(len(select_c)):
            try:
                ind = select_c[x].index(change_d)
                change = x
                s_change = slist[change_d-1][ind]
                select_c[x].remove(change_d)
                break
            except:
                None

        s_change2 = slist[change_d-1][change_d_to_c]

        bisect.insort(select_c[change_d_to_c],change_d)
        #calc
        sum2 = sum - s_change + s_change2
        total_c2 = 0
        for i in range(len(select_c)):
            start = 1
            c_change = 0
            if select_c[i] == []:
                c_change = np.sum(np.arange(d+1))
            else:
                for j in range(len(select_c[i])):
                    end = select_c[i][j]
                    if end > start:
                        c_change += np.sum(np.arange(end-start+1))
                    start = end
                end = d+1
                c_change += np.sum(np.arange(end-start))
                start = end
            total_c2 += clist[i]*c_change

        if sum - total_c < sum2 - total_c2:
            sum = sum2
            total_c = total_c2
            tlist[change_d-1] = change_d_to_c+1
        else:
            bisect.insort(select_c[change],change_d)
            select_c[change_d_to_c].remove(change_d)

        ct = time.time()
except:
    None
#remove first
for i in tlist:
    print(i)

Measured memory_bytes: 27888
import sys
import numpy as np

if __name__ == '__main__':
    n = int(sys.stdin.readline().rstrip())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    q = int(sys.stdin.readline().rstrip())
    dic = {}
    for a in A:
        dic[a] = dic.get(a, 0) + 1

    # keys = list(dic.keys())
    # values = list(dic.values())
    # summ = np.array(keys).dot(np.array(values))
    summ = sum([k*v for k, v in dic.items()])
    for i in range(q):
        b, c = list(map(lambda x: int(x), sys.stdin.readline().split()))

        diff = c*dic.get(b,0) - b*dic.get(b,0)
        dic[c] = dic.get(c, 0) + dic.get(b, 0)
        dic[b] = 0
        summ += diff
        print(summ)

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

using namespace std;

int main() {
    int s;
    double w, h;
    vector<int> ans;
    while (scanf("%d,%lf,%lf!", &s, &w, &h) != EOF) {
        double bmi = w / (h * h);
        if (bmi >= 25.0) ans.push_back(s);
    }

    for (int i = 0; i < ans.size(); i++)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
#define ll long long

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    string S;
    cin >> S;
    bool flag_mmyy = false;
    bool flag_yymm = false;
    string month[12] = {"01","02","03","04","05","06","07","08","09","10","11","12"};
    for(auto i:month){
        if(S.compare(0, 2, i)==0) flag_mmyy = true; //trueならMMYY確定
        if(S.compare(2, 2, i)==0) flag_yymm = true;
    }

    if(flag_mmyy == true   && flag_yymm == true)  cout << "AMBIGUOUS" << endl;
    if(flag_mmyy == true   && flag_yymm == false) cout << "MMYY" << endl;
    if(flag_mmyy == false  && flag_yymm == true)  cout << "YYMM" << endl;
    if(flag_mmyy == false  && flag_yymm == false) cout << "NA" << endl;

    return 0;
}

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

int main()
{
	int a[101][101],b[101],n,m,i,j,c[101];
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
			cin>>a[i][j];
		c[i] = 0;
	}
	for(i=1;i<=m;i++)
		cin>>b[i];
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
			c[i] = c[i]+a[i][j]*b[j];
	}
	for(i=1;i<=n;i++)
		cout<<c[i]<<endl;
	return 0;
 } 


Measured memory_bytes: 3132
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main(){
	fast;
	ll n,k,r,s,p;
	string str;
	cin>>n>>k>>r>>s>>p;
	cin>>str;
	ll dp[3][n];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<k;i++)
	{
		for(int j=i;j<n;j+=k)
		{
			if(i==j)
			{
				if(str[j]=='r')
				{
					dp[0][j]=0;
					dp[1][j]=0;
					dp[2][j]=p;
				}
				else if(str[j]=='s')
				{
					dp[0][j]=r;
					dp[1][j]=0;
					dp[2][j]=0;
				}
				else
				{
					dp[0][j]=0;
					dp[1][j]=s;
					dp[2][j]=0;
				}
				continue;
			}
            
            if(str[j]=='r')
				{
                
			for(int z=0;z<3;z++)
			{
				
					if(z==0)
					{
						dp[0][j]=max(dp[1][j-k],dp[2][j-k]);
					}
					else if(z==1)
					{
						dp[1][j]=max(dp[0][j-k],dp[2][j-k]);
					}
					else
					{
						dp[2][j]=p+max(dp[0][j-k],dp[1][j-k]);
					}
				}
            }
				else if(str[j]=='s')
				{
                    
                    for(int z=0;z<3;z++)
                    {
                    
                        if(z==0)
                        {
                            dp[0][j]=r+max(dp[1][j-k],dp[2][j-k]);
                        }
                        else if(z==1)
                        {
                            dp[1][j]=max(dp[0][j-k],dp[2][j-k]);
                        }
                        else
                        {
                            dp[2][j]=max(dp[0][j-k],dp[1][j-k]);
                        }
                    }
                }
                    else
                    {

                for(int z=0;z<3;z++)
                {

                        if(z==0)
                        {
                            dp[0][j]=max(dp[1][j-k],dp[2][j-k]);
                        }
                        else if(z==1)
                        {
                            dp[1][j]=s+max(dp[0][j-k],dp[2][j-k]);
                        }
                        else
                        {
                            dp[2][j]=max(dp[0][j-k],dp[1][j-k]);
                        }
                   }
			}
		}
	}
	ll ans=0;
	for(int i=max(k-1,n-1);i>=max(k-1,n-1)-k+1;i--)
	{
		ll maxx = -INF;
		for(int z=0;z<3;z++)
		{
			maxx=max(maxx,dp[z][i]);
		}
		ans+=maxx;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2768
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


 int a,b;
	 cin>>a>>b;

	 if(b%a==0){
	 	cout<<a+b<<endl;
	 }
	 else{
	 	cout<<b-a<<endl;
	 }

 return 0;
}









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


int main(){
  int n, m;
  int x, y;
  int z;
  int xn[100];
  int yn[100];
  bool ans = false;
  scanf("%d%d%d%d", &n, &m, &x, &y);

  for(int i = 0; i < n; i++){
    scanf("%d", &xn[i]);
  }
  for(int i = 0; i < m; ++i){
    scanf("%d", &yn[i]);
  }

  z = x + 1;

  if(x > y){
    printf("War\n");
    return 0;
  }

  while(z <= y){
    ans = false;
    for(int i =0; i < n; i++){
      if(z <= xn[i]){
        ans = true;
        break;
      }
    }

    for(int i = 0; i < m; ++i){
      if(z > yn[i]){
        ans = true;
        break;
      }
    }
    if(ans == false) break;
    z++;
  }

  if(ans){
    printf("War\n");
  } else {
    printf("No War\n");
  }

}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  string ans="";
  rep(i,n){
    if(i%2==0)ans+=s[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

const long long MOD = 1e9 + 7;
long long dp[101][100001];

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	dp[0][0] = 1;
	vector<long long> ps(k+1);
	for (int i = 1; i <= n; i++) {
		ps[0] = dp[i-1][0];
		for (int j = 1; j <= k; j++) ps[j] = (ps[j-1] + dp[i-1][j]) % MOD;
		
		for (int j = 0; j <= k; j++) {
			dp[i][j] = ps[j];
			int x = j - a[i-1];
			if (x > 0) dp[i][j] = (dp[i][j] + MOD - ps[x-1]) % MOD;
		}
	}
	
	cout << dp[n][k] << endl;
}


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

typedef long long ll;
const int N = 2000006;

int a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	ll ans = 0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		ans += x-1;
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (1e2) + 5;
vector<int> a, ans;
int n;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x; scanf("%d", &x);
		a.push_back(x);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = a.size() - 1; j >= 0; --j) {
			if (a[j] == j + 1) {
				ans.push_back(j + 1);
				a.erase(a.begin() + j);
				break;
			}
		}
	}
	if (ans.size() == n) {
		reverse(ans.begin(), ans.end());
		for (int i = 0; i < n; ++i) {
			printf("%d\n", ans[i]);
		}
	} else {
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[2100009], b[100009], N, c[100009], s[100009], NN, ori[100009];
vector<int> vec;
map<int, int> mp, rmp;
long long tot;

void upd(int x, int v)
{
	x += NN;
	while (x) {
		a[x] += v;
		x = x / 2;
	}
}

int query(int A, int B, int l, int r, int x)
{
	if (l >= r) return 0;
	if (l <= A && B <= r) return a[x];
	int mid = (A + B) / 2;
	int retL = 0, retR = 0;
	if (l < mid) retL = query(A, mid, l, r, x + x);
	if (mid < r) retR = query(mid, B, l, r, x + x + 1);
	return retL + retR;
}

long long fun(int v)
{
	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] >= v) c[i] = 1;
		else c[i] = -1;
	}
	s[0] = c[0];
	for (int i = 1; i < n; i++) {
		s[i] = s[i - 1];
		s[i] += c[i];
	}
	for (int i = 0; i < 2 * NN; i++) {
		a[i] = 0;
	}
	upd(s[0] + n, 1);
	if (s[0] >= 0) cnt++;
	for (int i = 1; i < n; i++) {
		int tmp = query(0, NN, 0, s[i] + n + 1, 1);
		cnt += tmp;
		if (s[i] >= 0) cnt++;
		upd(s[i] + n, 1);
	}
	return cnt;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ori[i];
		vec.pb(ori[i]);
	}
	sort(vec.begin(), vec.end());
	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	for (int i = 0; i < (int)vec.size(); i++) {
		mp[vec[i]] = i;
		rmp[i] = vec[i];
	}
	for (int i = 0; i < n; i++) {
		b[i] = mp[ori[i]];
	}
	N = 1;
	while (N < n + 1) N = N << 1;
	NN = N << 1;
	tot = (n) * 1LL * (n - 1) / 2 + n;
	int l = -1, r = (int)vec.size();
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		long long C = fun(mid);
		if (tot/2 + 1 < C) l = mid;
		else r = mid;
	}
	long long C = fun(r);
	if (C < tot - C) r = l;
	cout << rmp[r] << E;
	//system("pause");
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

using namespace std;

int main(int argc, char const *argv[]) {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<ll>> v(n, std::vector<ll> (4));
	for (size_t i = 0; i < n; i++) {
		std::cin >> v[i][1] >> v[i][2] >> v[i][3];
	}

	std::vector<std::vector<int>> ss;
	for (int i = -1; i < 2; i+=2) {
		for (int j = -1; j < 2; j+=2) {
			for (int k = -1; k < 2; k+=2) {
				ss.push_back(std::vector<int> {i,j,k});
			}
		}
	}

	ll ans = 0;
	for (size_t i = 0; i < ss.size(); i++) {
		for (size_t j = 0; j < v.size(); j++) {
			v[j][0] = ss[i][0] * v[j][1] + ss[i][1] * v[j][2] + ss[i][2] * v[j][3];
		}
		sort(v.begin(), v.end());
		reverse(v.begin() , v.end());
		ll kari = 0;
		for (size_t j = 0; j < m; j++) {
			kari += v[j][0];
		}
		ans = max(ans,kari);
	}

	std::cout << ans << '\n';

	return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n;
  cin >> n;
  if (n <= 599)
    cout << 8 << endl;
  else if (n <= 799)
    cout << 7 << endl;
  else if (n <= 999)
    cout << 6 << endl;
  else if (n <= 1199)
    cout << 5 << endl;
  else if (n <= 1399)
    cout << 4 << endl;
  else if (n <= 1599)
    cout << 3 << endl;
  else if (n <= 1799)
    cout << 2 << endl;
  else if (n <= 1999)
    cout << 1 << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3648
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
N = []
M = []
for i in range(n):
    N.append(readl())
for i in range(m):
    t = list(readl())
    t.append(i + 1)
    M.append(t)

for i in N:
    s = 0xFFFFFFFF
    index = 0
    nx = i[0]
    ny = i[1]
    for j in M:
        mx = j[0]
        my = j[1]
        mindex = j[2]
        t = abs(nx - mx) + abs(ny - my)
        if s > t:
            s = t
            index = mindex
    print(index)


Measured memory_bytes: 6480
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    string str;
    cin >> str;
    int r = 0;
    for(int i = 0; i < str.length(); i++){
        if(str[i] == 'R') r++;
    }
    int exr = 0;
    for(int i = 0; i < r; i++){
        if(str[i] == 'R') exr++;
    }
    cout << r - exr << endl;
    return 0;
}


Measured memory_bytes: 3692
/*
 * 1167.c: Pollock's conjecture
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* constant */

#define MAX_N	(1000000)
#define MAX_THN	(200)

/* global variables */

static int sums[MAX_N + 1], osums[MAX_N + 1];
static int thns[MAX_THN], othns[MAX_THN];

/* subroutines */

void min_sums(int *sums, int n_thn, int *thns) {
  int i, j, k, s1, thn;

  for (i = 0; i <= MAX_N; i++) sums[i] = i;

  for (k = 0; k < n_thn; k++) {
    thn = thns[k];
    for (i = thn; i <= MAX_N; i++) {
      j = i - thn;
      s1 = sums[j] + 1;
      if (sums[i] > s1) sums[i] = s1;
    }
  }
}

/* main */

int main(int argc, char **argv) {
  int k, n, n_thn, n_othn, thn;

  n_thn = n_othn = 0;
  for (k = 0;; k++) {
    thn = k * (k + 1) * (k + 2) / 6;
    if (thn >= MAX_N) break;
    thns[n_thn++] = thn;
    if (thn & 1) othns[n_othn++] = thn;
  }

  min_sums(sums, n_thn, thns);
  min_sums(osums, n_othn, othns);

  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;

    printf("%d %d\n", sums[n], osums[n]);
  }

  return 0;
}

Measured memory_bytes: 8412
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    int sl = s.size();
    ll ans = 0;
    ll sum = 0;
    bool keta = false;
    for(int i = sl-1; i >= 0; i--) {
        int d = s[i] - '0';
        sum += d;
        if (keta) d++;
        keta = false;
        //int nine = 0;
        // int j = i-1;
        // while(j >=0 && s[j] == '9') {
        //     nine++;
        //     j--;
        // }
        if (d > 5 || (d == 5 && i > 0 && s[i-1] - '0' > 4) ) {
            ans += 10 - d;
            keta = true;
        }
        else ans += d;
        //cerr << ans << endl;
    }
    if (keta) ans++;

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1948
n, m = map(int,raw_input().split())
matrix = []
for i in range(n):
    matrix.append(map(int,raw_input().split()))
 
vector = []
for i in range(m):
    vector.append(int(raw_input()))
 
for row in range(n):
    sum = 0
    for col in range(m):
        sum += vector[col] * matrix[row][col]
    print sum

Measured memory_bytes: 6592
#include <iostream>
using namespace std;
int main(void)
{
    // Your code here!
    int A, B;
    cin >> A >> B;
    if (A >= 13) cout << B << endl;
    else if (A >= 6 && A <= 12) cout << B / 2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

right_dict = { chr(65 + i):i + 1 for i in range(26) }

s_list = [i for i in s]

new_list=[]
for word in s_list:
    num = right_dict[word]
    if num + n > 26:
        right_num = num + n -26
        for k,v in right_dict.items():
            if v == right_num:
                new_list.append(k)
    else:
        right_num = num + n
        for k,v in right_dict.items():
            if v == right_num:
                new_list.append(k)
print(''.join(new_list))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define d double
#define lli	long long int
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
lli sod(lli n)
{
	lli ans=0;
	while(n)
	{
		ans+=(n%10);
		n/=10;
	}
	return ans;
}
int main()
{
	lli a,b;
	cin >> a >> b;
	if(a==1)
	{
		if(b==2)	cout << "3" << endl;
		else	cout << "2" << endl;
	}
	else if(a==2)
	{
		if(b==3)	cout << "1" << endl;
		else	cout << "3" << endl;
	}
	else
	{
		if(b==1)	cout << "2" << endl;
		else	cout << "1" << endl;
	}
	
	
	
	
	
	
	
	
	return 0; 
}

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

int main(void) {
    double x1, y1, x2, y2;
    
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%lf\n", sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)));
    
    return 0;
}


Measured memory_bytes: 3280
N, M = map(int, input().split())
E = [set() for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  E[a].add(b)
  E[b].add(a)
ok = False
c = 0
ns = E[c]
for n in ns:
  ns2 = E[n]
  if N-1 in ns2:
    ok = True
    break
if ok:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")


Measured memory_bytes: 67708
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if(a + b <= k){
        cout << 0 << " " << 0 << endl;
    }
    else if(a - k < 0){
        ll p = k - a;
        b -= p;
        cout << 0 << " " << b << endl;
    }
    else{
        cout << a - k << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

map<ll,ll> prime_factor(ll n){
  map<ll,ll> res;
  for(ll i = 2; i * i <= n; i++){
    while(n%i==0){
      ++res[i];
      n/=i;
    }
  }
  if(n!=1) res[n] = 1;
  return res;
}

const ll p = 1000000007;
ll extgcd(ll a, ll b, ll& x, ll& y){
  int d = a;
  if(b!=0){
    d = extgcd(b,a%b, y, x);
    y -= (a/b)*x;
  }else{
    x = 1; y = 0;
  }
  return d;
}
ll mod_inv(ll n){
  ll x,y;
  extgcd(n,p,x,y);
  return (p+x%p)%p;
}

int main(){
  ll n,m;
  cin >> n >> m;
  map<ll,ll> factor = prime_factor(m);

  ll ans = 1;
  for(auto b : factor){
    int x = b.second;
    ll num = 1, den = 1;
    REP(i,x){
      num = num * (x+n-1-i) % p;
      den = den * (x-i) % p;
    }
    ans *= num*mod_inv(den)%p;
    ans = ans % p;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int A = 0, B = 0;
	cin >> A >> B;
	if (A == 1)
	{
		A = 14;
	}
	if (B == 1)
	{
		B = 14;
	}
	if (A > B)
	{
		cout << "Alice";
	}
	if (A == B)
	{
		cout << "Draw";
	}
	if (A < B)
	{
		cout << "Bob";
	}
}



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

#define ll long long
#define Speed ios_base::sync_with_stdio(false); cin.tie(NULL)

int main()
{
    ll n;
    cin>>n;
    vector<ll> A;
    map<ll,ll> mp;
    for(ll i=0;i<n;i++)
    {
        ll c;cin>>c;
        A.push_back(c);
    }

    for(ll i=0;i<n;i++)
    {
        mp[A[i]]=i+1;
    }

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

    for(auto x: A)
    {
        cout<<mp[x]<<" ";
    }
}

Measured memory_bytes: 10300
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/

double func(ll a, ll b) {
    return (double)(100 * b) / (a + b);
}



int main() {

    ll A, B, C, D, E, F;
    ll water = 0, suger = 0;
    double noudo, ma = -1;
    cin >> A >> B >> C >> D >> E >> F;

    double ans1, ans2;

    for (int a = 0; a*A * 100 <= F; a++) {
        for (int b = 0; a*A * 100 + b*B * 100 <= F; b++) {
            for (int c = 0; a*A * 100 + b*B * 100 + c*C <= F; c++) {
                for (int d = 0; a*A * 100 + b*B * 100 + c*C + d*D <= F; d++) {
                    if (c*C + d*D > (a*A + b*B)*E) break;
                    water = (a*A * 100 + b*B * 100);
                    suger = (c*C + d*D);
                    noudo = (double)suger / (water + suger);
                    if (ma < noudo) {
                        ma = noudo;
                        ans1 = water + suger;
                        ans2 = suger;
                    }
                }
            }
        }
    }

    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a;
	int c5 = 0, c7 = 0;
	for(int i = 1; i <= 3; ++i){
		cin>>a;
		if(a == 5) c5++;
		if(a == 7) c7++;
	}
	if(c5 == 2 && c7 == 1)
		cout<<"YES";
	else 
		cout<<"NO";
	
	return 0;
}


Measured memory_bytes: 256
# PyPyだとなぜか1ケースだけTLEする。Pythonでは通る。

import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**5 + 5)  # 再帰回数の上限！！

n = int(input())
A = [int(input()) - 1 for i in range(n-1)]

M = [[] for i in range(n)]
for i in range(n-1):
    M[A[i]].append(i+1)

# 0-indexedの場合
V = [0] * n

# print(M)

def des(x):
    D = [0] * len(M[x])
    V[x] = 1
    for ii in range(len(M[x])):
        i = M[x][ii]
        if V[i] == 0:
            V[i] = 1
            D[ii] = des(i)
    if len(D) > 1:
        D.sort(reverse=True)
    # print(x,D)
    ans = 0
    for i in range(len(D)):
        D[i] += i+1
        ans = max(ans, D[i])
    return ans

print(des(0))

Measured memory_bytes: 119724
import qualified Data.Map as M
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main::IO()
main=do
    _ <- readLn::IO Int
    as <- map (fst . fromJust . B.readInteger) . B.words <$> B.getLine

    let bs = gen (as ++ [0])  M.empty
        cs = M.toDescList $ M.filter ( > 1) bs
        ds = case cs == [] of
                  True -> 0
                  False ->  if snd (cs !! 0) > 3 then fst (cs !! 0) ^ 2
                                                 else fst (cs !! 0) * fst (cs !! 1)
    print $ ds

gen::[Integer] -> M.Map Integer Int -> M.Map Integer Int
gen (a:as) me  
    |null as = me
    |M.notMember a me = gen as (M.insert a 1 me)
    |M.member a me = gen as (M.insert a ((me M.! a) + 1) me)


Measured memory_bytes: 98684
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

int main() {
  FASTIO();

  ll h, n;
  cin >> h >> n;
  ll tot = 0;
  for (int i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    tot += x;
  }
  if (tot >= h) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 888
package main

import (
	"fmt"
)

func main() {
	var valume []int
	valume = append(valume, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
	var k int
	fmt.Scan(&k)
	fmt.Print(valume[k-1])
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

int main(){
  long long int A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;

  long long int V_W = V - W;
  long long int A_B = abs(A - B);
  if (A_B <= V_W * T) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 3636