akhauriyash/Code-Regression huggingface dataset:
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  int N, x = 0, MAX = 0;
  string S;
  cin >> N >> S;
  REP(i, N) {
    if (S[i] == 'I') {
      x++;
      MAX = max(MAX, x);
    } else {
      x--;
    }
  }

  cout << MAX << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int main(){
  const int n = getInt();
  printf("%s\n", n % 10 == 9 || n / 10 == 9 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 128
N = int(input())

exist = [False for i in range(8)]
colorful = 0
min = 0

rates = list(map(int, input().split(" ")))

for rate in rates:
    if rate >= 3200:
        colorful += 1
        continue
    if not exist[int(rate/400)]:
        exist[int(rate / 400)] = True
        min += 1

max_color = colorful + min
if min == 0:
    min = 1

result = str(min) + " " + str(max_color)
print(result)


Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    for (auto a : A)if (a == 0) {
        cout << 0 << endl;
        return 0;
    }

    double lsum = 0;
    for (auto a : A)lsum += log10(a);
    if (lsum > 18.5) {
        cout << -1 << endl;
    }
    else {
        ll res = 1;
        for (auto a : A)res *= a;
        if (res <= 1000'000'000'000'000'000) {
            cout << res << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4028
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

int N;
i64 a[3005];
i64 dp[3005][3005];

i64 slv(int left, int right)
{
  if (left > right) { return 0; }
  i64 &ret = dp[left][right];
  if(~ret) { return ret; }

  bool isTaro = ((left + (N-1 - right)) % 2 == 0);

  if (isTaro) {
    ret = max(
        slv(left+1, right) + a[left],
        slv(left, right-1) + a[right]
    );
  }
  else {
    ret = min(
        slv(left+1, right) - a[left],
        slv(left, right-1) - a[right]
    );
  }
  return ret;
}

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

  memset(dp, -1, sizeof(dp));
  cout << slv(0, N-1) << endl;

  return 0;
}



Measured memory_bytes: 70912
//Link : https://atcoder.jp/contests/arc066/tasks/arc066_b
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define mod 1000000007
int add(int x,int y) {
  int ret = x + y;
  if(ret>=mod) {
    ret -= mod;
    return ret;
  }
  if(ret<0) {
    ret += mod;
    return ret;
  }
  return ret;
}
ll n;
#define N 61
map<pair<int,ll>,int> dp;
int mm[N];
int solveDp(int ind,ll v) {
  if(ind<0) {
    return 1;
  }
  if(dp.count(make_pair(ind,v))) {
    return dp[make_pair(ind,v)];
  }
  int ret = 0;
  for(int a=0;a<2;++a) {
    for(int b=a;b<2;++b) {
      ll tmp = (v<<1) + a + b;
      ll u = n>>ind;
      if(u<tmp) continue;
      if(u-tmp>=2) {
        ret = add(ret, mm[ind]);
      } else {
        ret = add(ret, solveDp(ind-1, (v<<1) + a+b) );
      }
    }
  }
  return dp[make_pair(ind,v)] = ret;
}

void solve() {
  mm[0] = 1;
  for(int i=1;i<N;++i) {
    mm[i] = add(mm[i-1],add(mm[i-1],mm[i-1]));
  }
  scanf("%lld ",&n);
  printf("%d\n", solveDp(N-1,0));
}
int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  vector<char> s(S.size());
  vector<char> t(T.size());
  for(int i=0;i<S.size();i++){
    s[i] = S[i];
  }
  for(int i=0;i<T.size();i++){
    t[i] = T[i];
  }
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  
  S = "";
  T = "";
  
  for(int i=0;i<s.size();i++){
    S += s[i];
  }
  for(int i=0;i<t.size();i++){
    T += t[i];
  }
  if(S<T){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b+c>=22)
		printf("bust\n");
	else
		printf("win\n");
	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        final StringBuilder str = new StringBuilder(sc.next());
        final int n = Integer.parseInt(sc.next());
        for(int i = 0; i<n; i++){
            final String com = sc.next();
            final int a = Integer.parseInt(sc.next());
            final int b = Integer.parseInt(sc.next());
            if(com.equals("print")){
                out.println(str.substring(a, b+1));
            }else if(com.equals("reverse")){
                final StringBuilder p = new StringBuilder(str.substring(a, b+1));
                p.reverse();
                str.replace(a, b+1, p.toString());
            }else if(com.equals("replace")){
                str.replace(a, b+1, sc.next());
            }
        }
        out.flush();
    }
}

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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// #define ll long long
// bool isEven(ll n) {return (n%2!=0)?false:true;}

using namespace std;

//atcoder - dp
//a

int a[100005], memo[100005];
int n;

int dp(int i)
{
	if(i>=n-1)
		return 0;
	if(memo[i]!=-1)
		return memo[i];
	if(i<n-2)
	{
		memo[i] = min(abs(a[i]-a[i+1])+dp(i+1),
							abs(a[i]-a[i+2])+dp(i+2));
	}
	else if(i==n-2)
		memo[i] = abs(a[i]-a[i+1]) + dp(i+1);

	return memo[i];
}

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

	cin>>n;
	FOR0(i, n)
	{
    	cin>>a[i];
    	memo[i] = -1;
	}


	cout<<dp(0)<<endl;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

ll N;
ll A[SIZE];
ll MIN[SIZE],MAX[SIZE];
ll dp[SIZE][3];

int main(){

	scanf("%lld",&N);

	for(int i = 1; i <= N; i++){

		scanf("%lld",&A[i]);
	}

	for(int i = 1; i <= N; i++){

		MAX[i] = (i+1)/2;

		int rest = N-i;
		MIN[i] = (N/2)-((rest+1)/2);
	}

	for(int i = 0; i <= N; i++){
		for(int k = 0; k < 3; k++){
			dp[i][k] = -HUGE_NUM;
		}
	}

	ll ans = -HUGE_NUM;

	for(int i = 1; i <= N; i++){
		for(int k = MIN[i]; k <= MAX[i]; k++){
			if(k == 0){

				dp[i][k-MIN[i]] = max(dp[i][k-MIN[i]],0LL);

			}else if(k == 1){

				dp[i][k-MIN[i]] = max(dp[i][k-MIN[i]],A[i]);

			}else{

				for(int pre = i-5; pre <= i-2; pre++){
					if(pre < 0)continue;
					for(int a = MAX[pre]; a >= MIN[pre]; a--){
						if(a == k-1 && dp[pre][a-MIN[pre]] != -HUGE_NUM){

							dp[i][k-MIN[i]] = max(dp[i][k-MIN[i]],dp[pre][a-MIN[pre]]+A[i]);
						}
					}
				}
			}

			if(k == N/2){
				ans = max(ans,dp[i][k-MIN[i]]);
			}
		}
	}

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

	return 0;
}


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

def bubbleSort(A):
    n = len(A)
    flag = True
    i = 0
    while flag:
        flag = False
        for j in range(n-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                i += 1
                flag = True
    print(*A)
    print(i)
bubbleSort(A)


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

int main(){
  long long a, b, n;
  cin >> n;
  vector<int> c(n), d(n);
  a = b = 0;
  for(int i = 0; i < n; i++){
    cin >> c[i] >> d[i];
  }
  for(int i = 0; i < n; i++){
    if((a + c[n - i - 1]) % d[n - i - 1] == 0)
      continue;
    else{
      b = d[n - i - 1] - (a + c[n - i - 1]) % d[n - i - 1];
      a += b;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 1024
#include<iostream>  
#include<cstring>  
#include<cstdio>  
#include<cmath>  
#include<algorithm>  
  
using namespace std;  
  
bool s[15][10005]= {0};  
  
int n, m;  
  
int dfs(int x)  
{  
    if(x==n+1)  
    {  
        int sum=0;  
        int term=0;  
        for(int j=1;j<=m;j++)  
        {  
            for(int i=1;i<=n;i++)  
                if(s[i][j]==1)term++;  
            sum += term > n-term ? term : n-term;  
            term=0;  
        }  
        return sum;  
    }  
    int a=dfs(x+1);  
    for(int i=1;i<=m;i++)  
        s[x][i]=!s[x][i];  
    int b=dfs(x+1);  
    return a>b?a:b;
}  
  
int main()  
{  
    //freopen("in.in","r",stdin);  
    while(scanf("%d%d",&n,&m)!=EOF)  
    {  
        if(n==0&&m==0)break;   
        for(int i=1; i<=n; i++)  
            for(int j=1; j<=m; j++)  
                scanf("%d",&s[i][j]);  
        cout<<dfs(1)<<endl;  
    }  
    return 0;  
}


Measured memory_bytes: 3232
import java.io.*;
import java.io.ObjectInputStream.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = (long)1e9+7;
	//final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		slove(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void slove(String[] args) throws Exception{
		int N = nextInt();
		long X = nextLong();

		long[] len= new long[51];
		long[] p = new long[51];
		len[0]=1;
		p[0]=1;
		for(int i=1;i<51;i++) {
			len[i]=len[i-1]*2+3;
			p[i]=p[i-1]*2+1;
		}
		pw.println(f(N,X,len,p));
	}

	public static long f(int N , long X,long[] len , long[] p) {
		if(N==0) {
			if(X<=0) {
				return 0;
			}else {
				return 1;
			}
		}
		else if(X<=1+len[N-1]) {
			return f(N-1,X-1,len,p);
		}else {
			return p[N-1] + 1 + f(N-1,X-2-len[N-1],len,p);
		}
	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}



Measured memory_bytes: 25476
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//最大公約数をユークリッドの互除法を使って求める
//計算量はlog(max(a,b))
//typedef long long ll;
ll gcd(ll a, ll b) {
    if(a % b == 0)
    return b;
    return gcd(b, a % b);
}


 
int main() {

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n)    cin >> a[i];

    sort(all(a));
    int g = a[0];
    rep(i,n-1) {
        g = gcd(g,a[i+1]);
    }
    if(k<=a[n-1] && k%g == 0)   cout<<"POSSIBLE"<<endl;
    else    cout<<"IMPOSSIBLE"<<endl;

 return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		var k = (int)h[1];
		var s = new int[h[0]].Select(_ => read()).OrderByDescending(x => x[1]).ToArray();

		var g0 = s.Take(k).ToLookup(x => x[0], x => x[1]);
		var l0 = g0.SelectMany(g => g.Skip(1)).OrderBy(x => x).ToList();
		var l1 = s.Skip(k).Where(x => !g0.Contains(x[0])).GroupBy(x => x[0]).Select(g => g.First()[1]).OrderByDescending(x => x).ToList();

		var f = new long[Math.Min(l0.Count, l1.Count) + 1];
		f[0] = g0.SelectMany(x => x).Sum();
		for (int i = 1; i < f.Length; i++) f[i] = f[i - 1] + l1[i - 1] - l0[i - 1];
		Console.WriteLine(Enumerable.Range(0, f.Length).Max(i => f[i] + (long)(g0.Count + i) * (g0.Count + i)));
	}
}


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

int main()
{

	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, m, sum = 0;
	cin >> n >> m;
	vector <int> v(m);
	for(int i=0; i<m; ++i){
		cin >> v[i];
		sum += v[i];
	}
	if(n<sum)
	cout << "-1";
	else
	{
		cout << n-sum;
	}
	

	return 0;
}


Measured memory_bytes: 3648
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long w = long.Parse(input[0]);
		long h = long.Parse(input[1]);
    long x = long.Parse(input[2]);
    long y = long.Parse(input[3]);
		double answer = w*h/(double)2;
    int memo = 0;
    if(2*x == w && 2*y == h) memo = 1;

		Console.WriteLine(answer+" "+memo);
	}
}

Measured memory_bytes: 13140
from itertools import combinations_with_replacement as R

N,M,Q = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(Q)]

print(max([sum((d if S[b-1] - S[a-1] == c else 0) for a,b,c,d in L) for S in R(range(1, M+1), N)]))

Measured memory_bytes: 12544
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define Max 100001
#define inf 1000000000000000
using namespace std;
int n,m,flag;
int first[Max * 2],nextv[Max * 2],u[Max * 2],v[Max * 2],s[Max * 2];
long long vis[2][Max],l = -inf,r = inf,ans;
void dfs(int from,int tag,long long va) {
    if(flag)return;
    int k = first[from];
    while(k != -1) {
        if(flag)return;
        int vtag = (tag == 1);
        int to = v[k];
        long long lva = s[k] - va;
        if(vis[vtag][to] != inf) {
            if(vis[vtag][to] == lva) {
                k = nextv[k];
                continue;
            }
            else {
                flag = 1;
                return;
            }
        }
        vis[vtag][to] = lva;
        if(vtag)r = min(r,lva);
        else l = max(l,-lva);
        dfs(to,-tag,lva);
        k = nextv[k];
    }
}
int main() {
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    for(int i = 1;i <= n;i ++) {
        vis[0][i] = vis[1][i] = inf;
    }
    for(int i = 0;i < m;i ++) {
        scanf("%d%d%d",&u[i],&v[i],&s[i]);
        u[i + m] = v[i];
        v[i + m] = u[i];
        s[i + m] = s[i];
        nextv[i] = first[u[i]];
        first[u[i]] = i;
        nextv[i + m] = first[u[i + m]];
        first[u[i + m]] = i + m;
    }
    dfs(1,1,0);///dfs遍历所有点和第一个点的关系，如果有冲突flag为1
    if(!flag) {///遍历后无冲突
        long long temp = -1;
        for(int i = 1;i <= n;i ++) {
            if(vis[0][i] != inf && vis[1][i] != inf) {
                long long d = (vis[1][i] - vis[0][i]) / 2;
                if(d < 0) {///解是负数 不成立
                    flag = 1;
                    break;
                }
                if(temp == -1)temp = d;
                else if(temp != d) {///解不一致
                    flag = 1;
                    break;
                }
            }
        }
        if(temp != -1 && !flag) {///有环 且各关系无冲突
            if(temp > l && temp < r)ans = 1;
        }
        else if(r - l - 1 > 0) ans = r - l - 1;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


using Graph = vector<vector<int> >;
Graph g;


mint dp0[100010];
mint dp1[100010];

void dfs(int v,int p){
    dp0[v]=dp1[v]=1;
    for(int x:g[v]){
        if(x==p)continue;
        dfs(x,v);
        dp0[v]*=dp1[x];
        dp1[v]*=dp0[x]+dp1[x];
    }
}

int main(){
    ll n;
    cin >> n;
    g.resize(n);
    rep(i,n-1){
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0,-1);
    cout << dp0[0]+dp1[0] << endl;
}

Measured memory_bytes: 18440
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    rep(i, s.size()) {
        string z = s.substr(i) + s.substr(0, i);
        if (t == z) {
            put("Yes");
            return 0;
        }
    }
    put("No")
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int ans=1;
    for(int i=2;i<32;i++){
        int p=i;
        while(p*i<=n){
            p*=i;
            ans=max(ans,p);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{

  int A[ 210 ];
  int m, min, max, dummy, gap, line;
  int i;

  while( scanf( "%d %d %d", &m, &min, &max ), m ){

    gap = 0;
    
    for( i = 1; i <= m; i++ ){
      scanf( "%d", &A[ i ] );
    }

    for( i = min; i <= max; i++ ){
      dummy = A[ i ] - A[ i + 1 ];

      if( dummy >= gap ){
	gap = dummy;
	line = i;
      }
    }

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

  return 0;

}

Measured memory_bytes: 1804
#include<stdio.h>
int W,H,map[20][20]={{0}};
char tile[20][21];
void search(int h,int w){
	if(tile[h][w]=='#'||map[h][w]==1||h<0||h>=H||w<0||w>=W)return;
	map[h][w]=1;
	search(h,w+1);
	search(h,w-1);
	search(h-1,w);
	search(h+1,w);
}
void init(void){int i,j;
		for(i=0;i<20;i++){for(j=0;j<20;j++)map[i][j]=0;}
}
int main(void){
	int i,j,memH,memW,p;
	while(1){
	p=0;
	init();
	scanf("%d%d",&W,&H);
	if(W==0&&H==0)break;
	for(i=0;i<H;i++){scanf("%s",tile[i]);}
	for(i=0;i<H;i++){for(j=0;j<W;j++){if(tile[i][j]=='@'){memH=i;memW=j;}}}
	search(memH,memW);
		for(i=0;i<H;i++){for(j=0;j<W;j++){if(map[i][j]==1)p++;}}
	printf("%d\n",p);
	}
	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
const int MM=4e5+5;
int n,m,tot;
int to[MM*5],nxt[MM*5],c[MM*5],h[MM+MN],cnt;
inline void ins(int s,int t,int c){
	to[++cnt]=t;nxt[cnt]=h[s];::c[cnt]=c;h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];::c[cnt]=c;h[t]=cnt;
}
int dis[MN+MM];
map<int,int>mp[MN];
typedef pair<int,int>pii;
priority_queue<pii,vector<pii>,greater<pii> >q;
int main(){
	scanf("%d%d",&n,&m);tot=n;
	for(reg int i=1,s,t,c;i<=m;i++){
		scanf("%d%d%d",&s,&t,&c);
		if(!mp[s][c])mp[s][c]=++tot,ins(mp[s][c],s,1);
		if(!mp[t][c])mp[t][c]=++tot,ins(mp[t][c],t,1);
		ins(mp[s][c],mp[t][c],0);
	}
	memset(dis,0x3f,sizeof(dis));
	dis[1]=0;q.push(make_pair(0,1));
	while(!q.empty()){
		reg pii v=q.top();q.pop();
		if(v.first!=dis[v.second])continue;
		for(reg int i=h[v.second];i;i=nxt[i])
			if(dis[to[i]]>v.first+c[i])
				dis[to[i]]=v.first+c[i],
				q.push(make_pair(dis[to[i]],to[i]));
	}
	if(dis[n]==0x3f3f3f3f)puts("-1");
	else printf("%d\n",dis[n]/2);
	return 0;
}

Measured memory_bytes: 49016
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int x = 0;
	int n;
	string s;
	cin >> n >> s;
	int counter = 0;
	int max = 0;
	for (int i = 0; i < n; i++) {
		if (s.at(i) == 'I') {
			counter++;
		}
		else {
			counter--;
		}
		if (max < counter) max = counter;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,a[1000005],tmp[1000005],num,top,an;
ll f[1000005],sum[1000005],sf[1000005];
vector<int>s[1<<20],x[1<<20];
int main()
{
	scanf("%d",&n);
	top=1;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]^=a[i-1];
		if(a[i]==0)top++;
		else
		{
			if(s[a[i]].empty()||s[a[i]][s[a[i]].size()-1]!=top)
			{
				s[a[i]].push_back(top);
				x[a[i]].push_back(1);
			}
			else x[a[i]][s[a[i]].size()-1]++;
		}
	}
	an=a[n];
	for(int v=1;v<(1<<20);v++)
	{
		if(s[v].empty())continue;
		int n=s[v].size();
		for(int i=0;i<n;i++)
		{
			tmp[i+1]=s[v][i];
			f[i+1]=0;
		}
		tmp[n+1]=top;
		f[1]=x[v][0];
		sum[1]=f[1]*(tmp[2]-tmp[1])%MOD;
		sf[1]=f[1];
		for(int i=2;i<=n;i++)
		{
			if(i!=n)f[i]=(sum[i-1]+1)*x[v][i-1]%MOD;
			else f[i]=sum[i-1]+1;
			sf[i]=(sf[i-1]+f[i])%MOD;
			sum[i]=(sum[i-1]+sf[i]*(tmp[i+1]-tmp[i]))%MOD;
		}
		if(n==1)f[n]=sf[n]=1;
		if(an==0)ans+=(sf[n]-f[n]+f[n]*x[v][n-1])%MOD;
		else if(v==an)ans+=f[n];
	}
	if(an)
	{
		ans%=MOD;
		if(ans<0)ans+=MOD;
		printf("%lld\n",ans);
		return 0;
	}
	ll num=1;
	for(int i=1;i<top-1;i++)num=num*2%MOD;
	ans+=num;
	ans%=MOD;
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 79616
n = int(input())
ans = 0
SQRT = int(n ** 0.5)
for m in range(1,SQRT + 1):
    b = int(n/m)
    ans += m * (m + b) * (b + 1 - m)
ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6
print(ans)

Measured memory_bytes: 9312
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		sc.close();

		for(int i = 0; i < N; i++) {
			if(i == K-1) {
				String ans = String.valueOf(S.charAt(K - 1)).toLowerCase();
				System.out.print(ans);
			}else {
				System.out.print(S.charAt(i));
			}
		}
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if((a>c&&b<c)||(a<c&&b>c)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    map<int, int> mp;
    rep(i, N) {
        mp[B[i]] = i;
    }
    int ans = 0;
    rep(i, N) {
        ans += (mp[A[i]] + i) % 2;
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 5760
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    suma = sum(a)
    ans = 0
    can = 1
    for i,ai in enumerate(a):
        if ai > can:
            print(-1)
            exit()
        suma -= ai
        ans += can
        if (can-ai)*2 >= suma:
            can = suma
        else:
            can = (can-ai)*2

    print(ans)




    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 87064
n = int(input())
h = list(map(int, input().split()))
dp = [0, abs(h[1] - h[0])]
for i in range(n - 2):
    dp.append(min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 1] + abs(h[i + 2] - h[i + 1])))
print(dp[-1])

Measured memory_bytes: 20508
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


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

    string ans;
    while(n > 0){
        n--;
        int tmp = n % 26;
        // tmp--;
        char ts = 'a' + tmp;
        n /= 26;
        ans.push_back(ts);
    }

    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  int in;
  int m_in = 200000;
  int cn = 0;
  for(;N-->0;){
    scanf("%d", &in);
    if(m_in >= in){
      cn++;
      m_in = in;
    }
  }
  
  printf("%d\n", cn);
  
  return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n;
  cin >> n;
  
  bool flag = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      if (n == i*j) {
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=-1,j;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  for(int i=1;i<n;i++){
    if(c<min(a[0]-a[i],a[i])){
      c=min(a[0]-a[i],a[i]);
      j=i;
    }
  }
  cout<<a[0]<<" "<<a[j]<<endl;
}

Measured memory_bytes: 640
/**
*    author:  yuya1234
*    created: 10.07.2020 10:22:07
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
int solve(int l,int r,int* h){
  int nmin=INT_MAX-1;
  FOR(i,l,r)
  {
    nmin=min(nmin,h[i]);
  }

  FOR(i,l,r)
  {
    h[i]-=nmin;
  }
  return nmin;
}

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

  int n;
  cin>>n;

  int h[n];
  REP(i,n)cin>>h[i];

  int ans=0;
  for(;;)
  {
    bool flg=true,flg0=false;
    int l=0,r=0;
    REP(i,n)
    {
      if(h[i]!=0)flg=false;

      if(!flg0 && h[i]>0)
      {
        l=i;
        r=i;
        flg0=true;
      }
      else if(flg0 && h[i]==0)
      {
        r=i-1;
        break;
      }
      else if(flg0 && h[i]>0)
      {
        r=i;
      }
    }
    if(flg)break;
    
    ans+=solve(l,r,h);
  }

  cout<<ans<<endl;

  return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << end
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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 T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m; cin >> n >> m;
    vl a(n),b(n),c(m),d(m);
    rep(i,n)cin >> a[i] >> b[i];
    rep(i,m)cin >> c[i] >> d[i];

    rep(i,n){
        int idx;
        ll mi = L_INF;
        rep(j,m){
            ll ans = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(chmin(mi,ans))idx=j+1;
        }
        cout << idx << endl;
    }
}


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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int sum = a+b;
    string s;
    cin >> s;
    int ni = 0, no = 0;
    for (int i=0; i<n; i++) {
        if (s[i] == 'a') {
            if (ni+no < sum) {
                cout << "Yes" << endl;
                ni++;
            } else {
                cout << "No" << endl;
            }
        }
        else if (s[i] == 'b') {
            if (ni+no < sum && no < b) {
                cout << "Yes" << endl;
                no++;
            } else {
                cout << "No" << endl;
            }
        }
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 896
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,k
    integer(int32):: x,y,i,j,black,ans=0
    character(1),allocatable:: c(:,:)

    read*, h,w,k
    allocate(c(w,h))
    do y=1,h
        block; character(w):: inpt_c
            read*, inpt_c
            do x=1,w
                c(x,y) = inpt_c(x:x)
            end do
        end block
    end do

    do i=0,2**h-1
        do j=0,2**w-1
            black = count_black(i,j)
            if (count_black(i,j) == k) ans=ans+1
        end do
    end do
    print'(i0)', ans
contains
    function count_black(i,j) result(ret)
        integer(int32):: i,j,ret
        integer(int32):: x,y

        ret=0
        do y=1,h
            if (btest(i,y-1)) cycle
            do x=1,w
                if (btest(j,x-1))cycle
                if (c(x,y) == '#') ret=ret+1
            end do
        end do
    end function
end program main

Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=998244353;
const ll N = 2e5+10;



ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)*1LL)%mod;
}

void solve(){
    ll s,w;
    cin>>s>>w;
    w>=s?cout<<"unsafe\n":cout<<"safe\n";
    


    

       
}



int main(){

    
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        ll T=1;
        //cin>>T;
        while(T--){
            solve();
        }
        return 0;

}

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

int main() {
	int a,b,c,x,cnt=0;
	cin>>a>>b>>c>>x;
	x/=50;
	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				if(10*i+2*j+k==x){
					cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

class Node{
    public:
    int location;
    int p, l, r;
    Node(){}
};

class Point{
    public:
    int id, x, y;
    Point(){}
    Point (int id, int x, int y): id(id), x(x), y(y) {}
    bool operator < (const Point &p) const {
        return id < p.id;
    }

    void print(){
        printf("%d\n", id);
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x;}
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y;}

int makeKDTree(int l, int r, int depth){
    if(!(l<r)) return NIL;
    int mid = (l+r)/2;
    int t = np++;
    if(depth%2==0){
        sort(P+l, P+r, lessX);
    } else {
        sort(P+l, P+r, lessY);
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth+1);
    T[t].r = makeKDTree(mid+1, r, depth+1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if(sx <= x && x <= tx && sy <= y && y <= ty) {
        ans.push_back(P[T[v].location]);
    }


    if(depth%2 == 0){
        if(T[v].l != NIL){
            if(sx <= x) find(T[v].l, sx, tx, sy, ty, depth+1, ans);
        }
        if(T[v].r != NIL){
            if(x <= tx) find(T[v].r, sx, tx, sy, ty, depth+1, ans);
        }
    } else {        
        if(T[v].l != NIL){
            if(sy <= y) find(T[v].l, sx, tx, sy, ty, depth+1, ans);
        }
        if(T[v].r != NIL){
            if(y <= ty) find(T[v].r, sx, tx, sy, ty, depth+1, ans);
        }
    }
}

int main(){
    int x, y;
    scanf("%d", &N);
    for(int i=0;i<N;i++){
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;

    int root = makeKDTree(0, N, 0);

    int q;
    scanf("%d", &q);
    int sx, tx, sy, ty;
    vector<Point> ans;
    for(int i=0;i<q;i++){
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for(int j=0;j<ans.size();j++){
            ans[j].print();
        }
        printf("\n");
    }

    return 0;

}



Measured memory_bytes: 15828
void main()
{
    long n, k;
    rdVals(n, k);

    long total = 1;
    foreach (i; k .. n+1)
    {
        long l = (i * (i - 1)) >> 1;
        long r = i * n - l;
        total = (total + r - l + 1) % mod;
    }

    total.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

int main() {

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

	int a[100][100];
	int b[100];
	int c;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	for (int i = 0; i < n; i++) {
		int c = 0;
		for (int j = 0; j < m; j++) {
			c += a[i][j] * b[j];
		}
		cout << c << endl;
	}

	return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a==2 && b==28 || a==1 && b==31 || a==3 && b==31  || a==4 && b==30 || a==5 && b==31 || a==6 && b==30 || a==7 && b==31 ||a==8 && b==31 || a==9 && b==30 || a==10 && b==31 || a==11 && b==30 || a==12 && b==31){
    if(d==1)
      cout<<"1"<<endl;
  }
  else
    cout<<"0"<<endl;
  return(0);
}
    

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

int main(){
	int n;cin>>n;
	int ans=0;
	for(int i=1;(i*i)<n;i++){
		if(i*i<n) ans+=1;
		int k = n/i;
		if(n%i==0) ans+=((k-i-1)*2);
		else ans+=((k-i)*2);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3668
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff

long long N;
vector<pair<long long, long long> > point;

double dis(double x, double y, long long x2, long long y2)
{
    return (x-x2)*(x-x2)+(y-y2)*(y-y2);
}

int main()
{
    long long i,j,k,l,tst=0,ans=0, csno=0,x,y;
    double mnX=1e10,mxX=0,mnY=1e10,mxY=0, xL, xR, yL, yR, tmpmnY, tmpmxY, mxRadiL, mxRadiR, cmpL,cmpR;
    cin>>N;
    while(N--)
    {
        cin>>x>>y;
        point.push_back({x,y});
        mnX = min(1.0*x,mnX);
        mxX = max(1.0*x,mxX);
        mnY = min(1.0*y,mnY);
        mxY = max(1.0*y,mxY);
    }

    while(mxX-mnX>0.000000001)
    {
        xL = (2.0*mnX+1.0*mxX)/3.0;

        tmpmnY = mnY;
        tmpmxY = mxY;
        do
        {
            yL = (2.0*tmpmnY+1.0*tmpmxY)/3.0;
            yR = (1.0*tmpmnY+2.0*tmpmxY)/3.0;

            mxRadiL = 0;
            mxRadiR = 0;
            for(i=0; i<point.size(); i++)
            {
                mxRadiL = max(mxRadiL,dis(xL,yL,point[i].first,point[i].second));
                mxRadiR = max(mxRadiR,dis(xL,yR,point[i].first,point[i].second));
            }
            if(mxRadiL>mxRadiR) tmpmnY=yL;
            else tmpmxY = yR;
        }while(tmpmxY-tmpmnY>0.000000001);
        cmpL=mxRadiL;

        xR = (1.0*mnX+2.0*mxX)/3.0;

        tmpmnY = mnY;
        tmpmxY = mxY;
        do
        {
            yL = (2.0*tmpmnY+1.0*tmpmxY)/3.0;
            yR = (1.0*tmpmnY+2.0*tmpmxY)/3.0;

            mxRadiL = 0;
            mxRadiR = 0;
            for(i=0; i<point.size(); i++)
            {
                mxRadiL = max(mxRadiL,dis(xR,yL,point[i].first,point[i].second));
                mxRadiR = max(mxRadiR,dis(xR,yR,point[i].first,point[i].second));
            }
            if(mxRadiL>mxRadiR) tmpmnY=yL;
            else tmpmxY = yR;
        }while(tmpmxY-tmpmnY>0.000000001);
        cmpR=mxRadiL;

        if(cmpL>cmpR) mnX = xL;
        else mxX= xR;
    }
    double radi = sqrt(mxRadiL);
    cout<<precision(10)<<radi<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.io.IOException; 
import java.io.InputStream; 
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List; 

class Main{ 

	static long mod =924844033;
	static long[] fact;
	static long[][] dp;
	static int w,n;

	static void solve(){ 
		n = ni();
		int k=ni();
		fact = new long[n+1];
		fact[0]=1;
		for(int i=1;i<=n;++i)fact[i]=(fact[i-1]*i)%mod;
		// dp[i][j] : サイズiの頂点でj個選ぶ通り
		dp = new long[n+1][n+1];
		dp[1][0]=dp[2][0]=dp[2][1]=1;
		for(int i=3;i<=n;++i)for(int j=0;j<i;++j){
			if(j==0)dp[i][j]=1;
			else dp[i][j]=(dp[i-1][j]+dp[i-2][j-1])%mod;
		}
		List<Integer> sets = new ArrayList<>();
		for(int i=1;i<=Math.min(n, k);++i){
			int size = 0;
			for(int j=i;j<=n;j+=k)++size;
			sets.add(size);
			sets.add(size);
		}

		long[][] dp2 = new long[sets.size()+1][n+1];
		dp2[0][0]=1;
		for(int i=0;i<sets.size();++i){
			for(int j=0;j<=n;++j){
				for(int l=0;l<=sets.get(i);++l){
					if(j-l<0)break;
					dp2[i+1][j] = (dp2[i+1][j] + (dp2[i][j-l]*dp[sets.get(i)][l])%mod)%mod;
				}
			}
		}
		int m = sets.size();

		long ans = 0;
		for(int i=0;i<=n;++i){
			ans = (ans + ((fact[n-i]*dp2[m][i]%mod)*(i%2==1 ? -1:1)+mod)%mod)%mod;
		}
		out.println(ans);
	}
 
 
 
 
	public static void main(String[] args){ 
		 solve(); 
		 out.flush(); 
	 } 
	 private static InputStream in = System.in; 
	 private static PrintWriter out = new PrintWriter(System.out); 
 
	 private static final byte[] buffer = new byte[1<<15]; 
	 private static int ptr = 0; 
	 private static int buflen = 0; 
	 private static boolean hasNextByte(){ 
		 if(ptr<buflen)return true; 
		 ptr = 0; 
		 try{ 
			 buflen = in.read(buffer); 
		 } catch (IOException e){ 
			 e.printStackTrace(); 
		 } 
		 return buflen>0; 
	 } 
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;} 
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);} 
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;} 
 
	 private static double nd(){ return Double.parseDouble(ns()); } 
	 private static char nc(){ return (char)skip(); } 
	 private static String ns(){ 
		 StringBuilder sb = new StringBuilder(); 
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b); 
		 return sb.toString(); 
	 } 
	 private static int[] nia(int n){ 
		 int[] res = new int[n]; 
		 for(int i=0;i<n;++i)res[i]=ni(); 
		 return res; 
	 } 
	 private static long[] nla(int n){ 
		 long[] res = new long[n]; 
		 for(int i=0;i<n;++i)res[i]=nl(); 
		 return res; 
	 } 
	 private static int ni(){ 
		 int res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	 } 
	 private static long nl(){ 
		 long res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	} 
} 



Measured memory_bytes: 162388
#include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,k;
  int build[4][3][10]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    build[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	cout << " ";
	cout << build[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
  return 0;
}


Measured memory_bytes: 3120
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def gcd(a, b):
    while b: a, b = b, a % b
    return a

def main():
    md = 1000000007
    n = II()
    cnt = {}
    cnt[(0, 0)] = [0, 0]
    zero = 0
    for _ in range(n):
        a, b = MI()
        if a * b == 0:
            if a == b == 0:
                zero += 1
            elif a == 0:
                cnt[(0, 0)][0] += 1
            else:
                cnt[(0, 0)][1] += 1
            continue
        par = a * b > 0
        a = abs(a)
        b = abs(b)
        g = gcd(a, b)
        a //= g
        b //= g
        if par:
            cnt.setdefault((a, b), [0, 0])
            cnt[(a, b)][1] += 1
        else:
            cnt.setdefault((b, a), [0, 0])
            cnt[(b, a)][0] += 1
    # print(cnt)
    ans = 1
    for x, y in cnt.values():
        cur = pow(2, x, md) + pow(2, y, md) - 1
        ans = ans * cur % md
    ans += zero
    ans = (ans - 1) % md
    print(ans)

main()


Measured memory_bytes: 132808