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


void inc(int &x, int max_num) {
	x++;
	if (x > max_num) x = 1;
}


void dfs(int cur, int par, int col,
         int* ans, vector<pair<int, int>>* edges, int max_num) {
	for (int i = 0; i < (int)edges[cur].size(); i++) {
		int nxt = edges[cur][i].first, eid = edges[cur][i].second;
		if(nxt == par) continue;		
		ans[eid] = col;
		inc(col, max_num);
		dfs(nxt, cur, col, ans, edges, max_num);
	}
}


int main() {
    int N; cin >> N;
    vector<pair<int, int>> edges[N];
    for (int i = 0; i < N - 1; i++) {
        int a, b; cin >> a >> b; a--; b--;
        edges[a].push_back(make_pair(b, i));
        edges[b].push_back(make_pair(a, i));
    }

    int max_edge_num = 0;
	for (int i = 0; i < N - 1; i++) max_edge_num = max(max_edge_num, (int)edges[i].size());

    int ans[N - 1];
	dfs(1, -1, 1, ans, edges, max_edge_num);
	
	cout << max_edge_num << endl;
	for (int i = 0; i < N - 1; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



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

    if(isupper(a)){
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }
}


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

int main()
{
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int i = 0; i < h - b; i++)
  {
    for (int i = 0; i < a; i++)
      cout << 1;
    for (int i = 0; i < w - a; i++)
      cout << 0;
    cout << endl;
  }
  for (int i = 0; i < b; i++)
  {
    for (int i = 0; i < a; i++)
      cout << 0;
    for (int i = 0; i < w - a; i++)
      cout << 1;
    cout << endl;
  }
}

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

int main(){
  int N;
  string S, T;
  cin >> N >> S >> T;
  string A = "";
  
  for(int i = 0; i < N; i++){
    A = A + S.at(i) + T.at(i);
  }
  
  cout << A << endl;
}

Measured memory_bytes: 256
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;

//const int N = 1e3+1;
//ll n,m,k,q;


ll gcd(ll a, ll b){
    //总是将较小的数放在b中
    if(a < b){
        swap(a, b);
    }
    if(b == 0){
        return a;
    }
    else{
        return gcd(b, a%b);
    }
}

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

    int a,b;

    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int count[5][4][11];
    int i,n,b,f,r,v;
    
    
    for(b=0;b<5;b++){
        for(f=0;f<4;f++){
            for(r=0;r<11;r++){
                count[b][f][r] = 0;
            }
        }
    }
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        count[b][f][r]+=v;
    }
    
    for(b=1;b<5;b++){
        for(f=1;f<4;f++){
            for(r=1;r<11;r++){
                    printf("%2d",count[b][f][r]);
            }
            printf("\n");
            }
            if(b!=4){
                printf("####################\n");
        }
    }
    return 0;
}

Measured memory_bytes: 620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			int m = Integer.parseInt(br.readLine());
			int[][] matrix = new int[n][n];
			for(int i = 0; i < n; i++){
				Arrays.fill(matrix[i], -1);
			}
			
			for(int i = 0; i < m; i++){
				String[] tmpArray = br.readLine().split(",");
				int a = Integer.parseInt(tmpArray[0]);
				int b = Integer.parseInt(tmpArray[1]);
				int d = Integer.parseInt(tmpArray[2]) - 100;
				
				matrix[a][b] = d;
				matrix[b][a] = d;
			}
			
			int sum = MyPlim(matrix);
			System.out.println(sum/100);
		}
	}

	static int MyPlim(int[][] matrix){
        int result = 0;
        int n = matrix[0].length;
         
        int[] visited = new int[n];
        Arrays.fill(visited, 0);
         
        visited[0] = 1;
        int checked = 1;
         
        while(true){
            int min = Integer.MAX_VALUE;
            int minI = -1;
            int minJ = -1;
            for(int i = 0; i < n; i++){
                if(visited[i] == 0){
                    continue;
                }
                for(int j = 0; j < n; j++){
                    if(min > matrix[i][j] && matrix[i][j] >= 0 && visited[j] == 0){
                        min = matrix[i][j];
                        minI = i;
                        minJ = j;
                    }
                }
            }
             
            result += min;
//            System.out.println("("+minI+","+minJ+") added distance"+min);
            checked++;
            visited[minI] = 1;
            visited[minJ] = 1;
            matrix[minI][minJ] = -1;
            matrix[minJ][minI] = -1;
             
            if(checked == n){
                break;
            }
        }
         
        return result;
    }
}

Measured memory_bytes: 28808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll D;
ll c[27];
ll s[366][27];
ll ans[366];

void solve(){
    rep(i,1,D){
        cin>>ans[i];
    }
}

void score(){
    ll last[366][27];
    rep(i,1,26)last[0][i]=0;
    ll now_score=0;
    rep(i,1,D){
        now_score+=s[i][ans[i]];
        rep(j,1,26){
            if(j!=ans[i]){
                last[i][j]=last[i-1][j];
            }else{
                last[i][j]=i;
            }
            now_score-=(c[j]*(i-last[i][j]));
        }
        cout<<now_score<<endl;
    }
}

int main(){fastio
    cin>>D;
    rep(i,1,26)cin>>c[i];
    rep(i,1,D){
        rep(j,1,26){
            cin>>s[i][j];
        }
    }
    solve();
    
    score();
    return 0;
}



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

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

  vector<int> v(n);
  rep(i, n) cin >> v[i];

  sort(v.rbegin(), v.rend());

  double ans = 0;
  rep(i, n) {
    if (i != n - 1) {
      ans += pow(0.5, i + 1) * v[i];
    } else {
      ans += pow(0.5, i) * v[i];
    }
  }
  printf("%.10f\n", ans);
  return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int n,q;
vi ans(200005,0);
void solve(vector<vi> &g, int i, int prev){

    //DEBUG_VEC(g[i]);
    REP(j,g[i].size()){
        if(g[i][j]==prev) continue;
        //DEBUG2(j, g[i][j]);
        ans[g[i][j]] += ans[i];
        solve(g, g[i][j], i);
    }
}

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

    vector<vi> g(n);

    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        g[a-1].emplace_back(b-1);
        g[b-1].emplace_back(a-1);
    }

    REP(i,q){
        int p,x;
        cin>>p>>x;
        ans[p-1] += x;
    }

    solve(g, 0, -1);

    REP(i,n){
        cout<<ans[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

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

bool is_square(int x) {
    int i;
    bool ans = false;
    for(i = 1; i <= sqrt(x); i++) {
        if (pow(i, 2) == x) {
            ans = true;
        }
    }
    return ans;
}

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

    int tmp = stoi(to_string(a) + to_string(b));

    string ans = "No";
    if (is_square(tmp)) {
        ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3700
#include <stdio.h>




int main(void){
    int N;
    scanf("%d",&N);
    long long int A[N];
    for(int i=0;i<N;i++)scanf("%lld",&A[i]);
    int l=0;
    int r=0;
    long long int Xo=A[0];
    long long int Pl=A[0];
    long long int ans=0;
    while(1){
        if(Xo==Pl){ans+=l-r+1;l++;
            if(l>=N)break;
        else {
            Xo^=A[l];
            Pl+=A[l];
        }
        }
        else {
            Xo^=A[r];
            Pl-=A[r];
            r++;
        }
        
    }
    printf("%lld",ans);
    
    return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

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

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int A[maxn];

int check(){
	int has=0,pos=0;
	REP(i,1,n)if(A[i]&1)pos=i;else has++;
	if(has&1)return 1;
	if(n-has>2||A[pos]==1)return 2;
	return 0;
}

void print(int f,int now){
	f--;
	if(f^now)puts("Second");else puts("First");
}

void Work(){
	if(check())return print(check(),0);
	int now=0;
	for(;;){
		now^=1;
		int g=0;
		REP(i,1,n)if(A[i]&1)g=__gcd(g,A[i]-1);else g=__gcd(g,A[i]);
		REP(i,1,n)if(A[i]&1)A[i]=(A[i]-1)/g;else A[i]/=g;
		if(check())return print(check(),now);
	}
}

void Init(){
	read(n);
	REP(i,1,n)read(A[i]);
}


int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace AtCoder
{
  class Practice
  {
    static void Main()
    {
    	int N = int.Parse(Console.ReadLine());
        string[] input= Console.ReadLine().Split(' ');
        int[] slimeColor = new int[N];
        int Counter = 0;

        for(var i = 0; i < N; i++)
        {
            slimeColor[i] = int.Parse(input[i]);
            if(i >= 1 )
            {
                if(slimeColor[i-1] == slimeColor[i])
                {
                    var insert = 4545;
                    slimeColor[i] = insert;
                    Counter++;
                }
            }
        }
        
        Console.WriteLine("{0}",Counter);

    }
  }
}

Measured memory_bytes: 11220
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    p = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]

    print(7 - p.index(S))


if __name__ == '__main__':
    main()


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

constexpr int64_t MOD = 1e9 + 7;

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

    vector<vector<int64_t>> dp(61, vector<int64_t>(3));
    dp[60][0] = 1;
    for (int i = 60; i-1 >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                int s = min(2l, 2*j + (n >> (i-1) & 1) - k);
                if (s >= 0) dp[i-1][s] = (dp[i-1][s] + dp[i][j]) % MOD;
            }
        }
    }

    cout << (dp[0][0] + dp[0][1] + dp[0][2]) % MOD << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int score_a = 0;
  int score_b = 0;
  
  for(int i=0; i<N; i++){
    if(i %2 == 0){
      score_a = score_a + vec.at(i);
    }
    else{
      score_b = score_b + vec.at(i);
    }
  }
  
  cout << score_a -score_b << endl;
  
}

Measured memory_bytes: 256
def myAnswer(S:list)->str:
   dic ={"W":0,"N":0,"E":0,"S":0}
   for s in S:
      dic[s]+=1
   if(min(dic["W"],dic["E"])==0 and max(dic["W"],dic["E"])>=1):
      return "No"
   elif(min(dic["N"],dic["S"])==0 and max(dic["N"],dic["S"])>=1):
      return "No"
   else:
      return "Yes"

def modelAnswer():
   tmp=1
def main():
   S = list(input())
   print(myAnswer(S[:]))

if __name__ == '__main__':
   main()

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

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

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

const int MAX = 1e6 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

class Combination{
    private:
        vector<long long> fac, finv, inv;
    
    public:
        Combination(){
            fac = finv = inv = vector<long long> (MAX);

            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < MAX; i++){
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        long long getCom(int n, int k){
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
        }
};

int main(){
    int X, Y;
    cin >> X >> Y;

    int N = X + Y;
    if (N % 3 != 0) {
        puts("0");
        return 0;
    }

    Combination C = Combination();

    if (X > Y) swap(X, Y);

    if (X < N / 3) {
        puts("0");
        return 0;
    }
 
    int a = N / 3 + 1;
    int b = X - (N / 3 - 1);

    ll ans = C.getCom(a - 1, b - 1);

    cout << ans << endl;
}

Measured memory_bytes: 23680
#include <iostream>
using namespace std;
int main(){
    string str;
    for (int i = 0; i < 10000; i++){
        getline(cin, str);
        int N = atoi(str.c_str());
        if (N != 0){
            cout << "Case " << i + 1 << ": " << N << endl;
        } else {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3180
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
  
using namespace std;
  
#define RY 3
#define N 9
  
typedef struct board {
  int O[N];
  int ling;
  vector<int> path;
  
  bool operator < (const board &t) const {
    for (int i = 0; i < N; i++) {
      if (O[i] == t.O[i]) continue;
      else if (O[i] < t.O[i]) return true;
      else return false;
    }
    return false;
  }
} cubic;
 
int xx[4] = { 0, 1, 0, -1 };
int yy[4] = { 1, 0, -1, 0 };
  
bool fingoal(cubic b) {
  for (int i = 0; i < N-1; i ++)
    if (b.O[i] != i+1) return false;
  
  return true;
}
  
void meltd(cubic b) {
  map<cubic, bool> visited;
  queue<cubic> q;
  q.push(b);
  
  while (!q.empty()) {
    cubic bcur = q.front(); q.pop();
    visited[bcur] = true;
  
    if (fingoal(bcur)) {
      cout << bcur.path.size() << endl;
      return;
    }
  
    for (int i = 0; i < 4; i ++) {
      cubic b = bcur;
      int nx = (bcur.ling / RY) + xx[i];
      int ny = (bcur.ling % RY) + yy[i];
  
      if (nx < 0 || nx > 2 || ny < 0 || ny > 2) continue;
  
      b.ling = nx * RY + ny;
      swap(b.O[b.ling], b.O[bcur.ling]);
  
      if (visited[b]) continue;
  
      b.path.push_back(b.ling);
      q.push(b);
    }
  }
}
  
int main() {
  cubic b;
  
  for (int i = 0; i < N; i++) {
    cin >> b.O[i];
    if (b.O[i] == 0) b.ling = i;
  }
  
  meltd(b);
}

Measured memory_bytes: 54112
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <algorithm>
using namespace std;
using iL = long long;
using iUL = unsigned long long;
using dL = long double;
#define rep(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define brep(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

#define MOD 1000000007L

template <typename T>
T gcd(T a, T b)
{
    if (a < b)
        swap(a, b);
    return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

int main()
{
    //----------------
    iUL n, m, l;
    string s, t;
    cin >> n >> m >> s >> t;
    l = lcm(n, m);
    iUL n2 = l / n;
    iUL m2 = l / m;
    iUL max = n * m / l;
    bool b = true;
    for (iUL i = 0; i < max; ++i)
    {
        if (s[m2 * i] != t[n2 * i])
        {
            b = false;
            break;
        }
    }
    if (b)
        cout << l << endl;
    else
        cout << "-1" << endl;

    //----------------
    return 0;
}

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

using namespace std;

int main(void){

  double x[1000];
  double y[1000];
  int i = 0;
  char ten;
  while( cin >> x[i] >> ten >> y[i] ){
    i++;
  }

  double S = 0;
  for( int j = 0 ; j < i ; j++ ){
    int J = j + 1;
    if( J == i ) J = 0;
    S =  S + x[J]*y[j] - x[j]*y[J];
  }
  S = abs(S)/2;
  printf("%.6f", S);
  cout << endl;
  return 0;
}

Measured memory_bytes: 1284
#include<stdio.h>
 
int main(){
	char a,b,c;
	scanf("%c%c%c", &a,&b,&c);
	if(a=='R'&&b=='R'&&c=='R'){
		printf("3\n");
	}
	else if(a=='S'&&b=='S'&&c=='S'){
		printf("0\n");
	}
	else if(a=='R'&&b=='R'&&c=='S'){
		printf("2\n");
	}
	else if(a=='R'&&b=='S'&&c=='R'){
		printf("1\n");
	}
	else if(a=='R'&&b=='S'&&c=='S'){
		printf("1\n");
	}
	else if(a=='S'&&b=='R'&&c=='R'){
		printf("2\n");
	}
	else if(a=='S'&&b=='R'&&c=='S'){
		printf("1\n");
	}
	else if(a=='S'&&b=='S'&&c=='R'){
		printf("1\n");
	}
 
	
	return 0;
}

Measured memory_bytes: 1552
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		int n=sc.nextInt();
		int k=sc.nextInt();
		int [] a=new int [n];
		boolean ok=false;
		boolean greater=false;
		int g=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			if(a[i]==k)
				ok=true;
			if(a[i]>k)
				greater=true;
			g=gcd(a[i], g);
		}
		if(greater && k%g==0)
			ok=true;
		pw.println(ok? "POSSIBLE" : "IMPOSSIBLE");
		pw.flush();
		pw.close();
	}
	
	static int gcd(int a,int b){
		return b==0? a : gcd(b,a%b);
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

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



int main(void){
int a,b;
scanf("%d %d",&a,&b);

if(a<b){printf("a < b\n");}
else if(a==b){printf("a == b\n");}
else {printf("a > b\n");}

return 0;
}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define LLFOR(i, a, b) for(long long i = (a); i < (b); ++i)
#define LLRFOR(i, a, b) for(long long i = (a); i >= (b); i--)
#define SORT(v, n) sort(v, v+n)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define LLREP(i, n) for(long long i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)
#define LLRREP(i, n) for(long long i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define ret return

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

int MAX(int a,int b){if(a>b){return a;}return b;}
int MIN(int a,int b){if(a<b){return a;}return b;}
int GCD(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){int c=GCD(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int POW(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
ll LLMAX(ll a,ll b){if(a>b){return a;}return b;}
ll LLMIN(ll a,ll b){if(a<b){return a;}return b;}
ll llGCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
ll llLCM(ll a,ll b){ll c=llGCD(a,b);a/=c;return a*b;}
ll llnCr(ll a,ll b){ll i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
ll llnHr(ll a,ll b){return llnCr(a+b-1,b);}
ll llpow(ll a,ll b){ll i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(){
	//solve AXCxxx-X
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	if(n % 2 == 0) cout << n << endl;
	else cout << 2 * n << endl;

	ret 0; 
}

Measured memory_bytes: 256
#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 ;
#define ll long long
#define ld float
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000003
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
const ll N = 1e6 + 3 ;
vector<ll> fact(N,0) , invFac(N,0) ;
ll powMod( ll base , ll expo )
{
    ll ans = 1 ;
    while( expo > 0 ){
        if( expo & 1 ){

            ans = ( ans * base ) % hell ;
        }
        base = ( base * base ) % hell ;
        expo >>= 1 ;
    }
    return ans ;
}
ll add( ll x , ll y ){
    return ( x + y ) % hell ;
}
ll sub( ll x , ll y ){
    ll ans = x ;
    ans = ( x - y + hell ) % hell ;
    ans = ( ans + hell ) % hell ;
    return ans; 
}
ll mult( ll x , ll y ){
    ll ans = ( x * y ) % hell ;
    ans = ( ans + hell ) % hell ;
    return ans ;
}
ll inv( ll x ){
    return powMod( x , hell -2 ) ;
}
ll C( ll x , ll y )
{
    if( x < y || y < 0 )return 0 ;
    ll ans = mult( fact[x] , mult( invFac[y] , invFac[x-y] ) ) ;
    //cout << "x :  " << x << " y : " << y << " C(x,y) : " << ans << "\n" ;
    return ans ;
}
void solve()
{
    ll q , x , d , n ;
    cin >> q ;
    while( q-- )
    {
        cin >> x >> d >> n ;
        if( d == 0 ){
            cout << powMod(x,n) << "\n" ;
        }
        else
        {
            x = mult( x , inv(d) ) ;
            if( x + n - 1 >= hell )
                cout << "0\n" ;
            else
                cout << mult( powMod(d,n) , mult( fact[x+n-1] , invFac[max(0LL,x-1)] ) ) << "\n" ;
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fact[0] = 1 ;
    rep( i , 1 , N )
        fact[i] = ( fact[i-1] * i ) % hell ;
    invFac[N-1] = inv(fact[N-1]) ;
    for( ll i = N - 2 ; i >= 0 ; i-- ){
        invFac[i] = ( invFac[i+1] * (i+1) ) % hell ;
    }
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

const ll mod = 1000000000 + 7;

ll mod_pow(ll a, ll n, ll mod){
    a %= mod;
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        n = n >> 1;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> c(n);
    rep(i, 0, n) cin >> c[i];
    sort(c.begin(), c.end(), greater<ll>());
    ll ans = 0;
    ll n1 = mod_pow(2, n-1, mod);
    ll n2 = mod_pow(2, n-2, mod);
    rep(i, 0, n) {
        ll coeff = (n1 + i * n2) % mod;
        ans += (coeff * c[i]) % mod;
        ans %= mod;
    }
    ans *= mod_pow(2, n, mod);
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 4808
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var A = sc.ReadIntArray(N);

        var ans = LINF;
        for (int y = -100; y <= 100; y++)
        {
            long c = 0;
            for (int i = 0; i < N; i++)
            {
                var x = A[i];
                c += (long)Math.Pow(x - y, 2);
            }
            //Console.WriteLine(y + ", " + c);
            ans = Math.Min(ans, c);
        }
        Console.WriteLine(ans);
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  ll x;
  cin >> x;
  ll ans=0;
  ans+=1000*(x/500);
  x%=500;
  ans+=5*(x/5);
  cout << ans << endl;
  return 0;     
}


Measured memory_bytes: 256
from collections import defaultdict


def solve():
    N = int(input())
    if N == 1:
        print(1)
        exit()
    xy = [[0, 0] for _ in range(N)]
    for i in range(N):
        xy[i][0], xy[i][1] = map(int, input().split())
    
    dxy = defaultdict(int)
    for i in range(N - 1):
        for j in range(i + 1, N):
            dxy[(xy[i][0] - xy[j][0], xy[i][1] - xy[j][1])] += 1
            dxy[(xy[j][0] - xy[i][0], xy[j][1] - xy[i][1])] += 1
    
    zeros = max(dxy.values())
    print(N - zeros)


if __name__ == '__main__':
    solve()


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

class Scanner
{
    private string[] Line;
    private int Index;

    public Scanner()
    {
        Line = new string[0];
        Index = 0;
    }

    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(' ');
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;

    }

    public int NextInt()
    {
        return int.Parse(Next());
    }
}

struct S
{
    public int Num, Sum;

    public S(int num, int sum)
    {
        this.Num = num;
        this.Sum = sum;
    }
}

class Program
{
    private int N, Z, W;
    private int[] A;

    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        Z = sc.NextInt();
        W = sc.NextInt();
        A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = sc.NextInt();
        }
    }

    public void Solve()
    {
        Scan();
        int a = 0;
        int b = 0;
        if (N >= 2)
        {
            a = Math.Abs(A[N - 1] - A[N - 2]);
        }
        b = Math.Abs(A[N - 1] - W);
        Console.WriteLine(Math.Max(a, b));
    }

    static public void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>

using namespace std;

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

	const int L = S.length();

	long long ans = 0;
	int nW = 0;

	for (int i = 0; i < L; ++i) {
		if (S[i] == 'W') {
			ans += i - nW;
			++nW;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream> 

using namespace std;

int main()
{
    int A;
    cin>>A;
    
    if(A>=400 and A<=599) cout<<"8";
    else if(A>=600 and A<=799) cout<<"7";
    else if(A>=800 and A<=999) cout<<"6";
    else if(A>=1000 and A<=1199) cout<<"5";
    else if(A>=1200 and A<=1399) cout<<"4";
    else if(A>=1400 and A<=1599) cout<<"3";
    else if(A>=1600 and A<=1799) cout<<"2";
    else if(A>=1800 and A<=1999) cout<<"1";
}

Measured memory_bytes: 3088
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int max = Math.min(a,b);
        int min = Math.max(0, a + b - n);

        System.out.println(max + " " + min);
        
    } 
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0;i<n;i++)cin >> h[i];
    vector<int>dp(n,1<<30);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        if(i+1<n)dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1]-h[i]));
        if(i+2<n)dp[i+2] = min(dp[i+2],dp[i] + abs(h[i+2]-h[i]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
  string s;
  cin >> s;
  string ans;
  if(s == "Sunny"){
    ans = "Cloudy";
  }else if(s == "Cloudy"){
    ans = "Rainy";
  }else if(s == "Rainy"){
    ans = "Sunny";
  }
  cout << ans << endl;
}


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

int main(void){
    int n; cin >> n;
    double a[n];

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

    double sum = 0;

    for (int i=0;i<n;i++){
        sum += 1/a[i];
    }

    cout << 1/sum << endl;
    return 0;
}

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

class Program {
  static void Main() {
    var g = new[] { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
    var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
    Console.WriteLine(g[a[0]] == g[a[1]] ? "Yes" : "No");
  }
}

Measured memory_bytes: 13396
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1

comb1 = 1
for i in range(n-a+1, n+1):
    comb1 *= i
    comb1 %=  mod
for i in range(1, a+1):
    comb1 *= pow(i, mod-2, mod)
    comb1 %=  mod

comb2 = 1
for i in range(n-b+1, n+1):
    comb2 *= i
    comb2 %=  mod
for i in range(1, b+1):
    comb2 *= pow(i, mod-2, mod)
    comb2 %=  mod
ans -= (comb1 + comb2)
print(ans % mod)

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

int main(){
 int n;
 cin>>n;
 int num[4][3][10]={};
 for(int i=0;i<n;i++){
  int b,f,r,v;
 cin>>b>>f>>r>>v;
 num[b-1][f-1][r-1] += v;
}
 for(int i=0;i<4;i++){
 if(i) cout<<"####################"<<endl;
 for (int j=0;j<3;j++){
 for (int k=0;k<10;k++){
  cout<<" "<<num[i][j][k];
 }
 cout<<endl;
}
}
}


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

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll N, K;
ll A[201010], F[201010];

bool can(ll x) {
  ll cnt = 0;
  rep(i, 0, N) {
    ll limit = x / F[i];
    cnt += max(0LL, A[i] - limit);
  }
  return cnt <= K;
}

int main() {
  cin >> N >> K;
  rep(i, 0, N) { cin >> A[i]; }
  rep(i, 0, N) { cin >> F[i]; }
  sort(A, A + N);
  sort(F, F + N, greater<ll>());

  ll ub = 1e+13;
  ll lb = -1;
  while (ub - lb > 1) {
    ll mid = (ub + lb) / 2;
    if (can(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  cout << ub;
}


Measured memory_bytes: 6768
import java.util.Arrays;
import java.util.Scanner;

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();
		int k = sc.nextInt();


		int ans = 0;
		int[] data = {a,b,c};	
		
		Arrays.sort(data);
		for(int i = 0;i < k;i++){
			data[2] *= 2;
		}
		System.out.println(data[2]+data[1]+data[0]);


	}






}




class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 21844
length = int(input())
eles = [int(l) for l in input().split()]

times = 0
for i in range(length):
    flag = 1
    while flag > 0:
        flag = 0
        for j in range(length-1, 0, -1):
            if eles[j] < eles[j - 1]:
                _temp = eles[j]
                eles[j] = eles[j-1]
                eles[j-1] = _temp
                flag = 1
                times += 1

print(*eles)
print(times)

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


int dot_product(vector<int> A, vector<int> B, int c) {
  int r = 0;
  for (int i = 0; i < A.size(); i++) {
    r += (A.at(i) * B.at(i));
  }
  r = r + c;
  return r;
}


int main() {
  int N, M, C;
  cin >> N >> M >> C;

  vector<int> b;

  for (int i = 0; i < M; i++) {
    int input;
    cin >> input;
    b.push_back(input);
  }

  vector<vector<int> > A;
  for (int i = 0; i < N; i++) {
    vector<int> vect;
    for (int j = 0; j < M; j++) {
      int input;
      cin >> input;
      vect.push_back(input);
    }
    A.push_back(vect);
  }

  
  int ans = 0;

  for (int i = 0; i < N; i++) {
    vector<int> a = A.at(i);
    int dot = dot_product(a, b, C);
    if (dot > 0) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
H,W = map(int,input().rstrip().split(" "))
N = int(input())
a = list(map(int,input().rstrip().split(" ")))
ans = [[0 for _ in range(W)]for _ in range(H)]
nowx = 0
nowy = 0
iki = True
for i in range(N):
    for j in range(a[i]):
        ans[nowy][nowx] = i+1
        if iki:
            nowx += 1
            if nowx >= W:
                nowx = W - 1
                nowy += 1
                iki = False
        else:
            nowx -= 1
            if nowx < 0:
                nowx = 0
                nowy += 1
                iki = True
for i in range(H):
    print(" ".join(map(str,ans[i])))

Measured memory_bytes: 73996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e6+1;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, k;
	cin >> n >> k;
	int a[n], ans = 0, ind = 0;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	while(ind < (n - 1))
		ind += (k - 1), ans++;
	cout << ans;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
	scanf("%d%d",&a,&b);
	int cnt=1;
	if(b==1) {
		printf("0");
		exit(0);
	}
	for(int i=a;i<b;i+=a-1)
		cnt++;
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

int main() {
    Int a, b;
    cin >> a >> b;
    if (a >= 13) {
        dump(b);
    }
    else if (6 <= a) {
        dump(b / 2);
    }
    else {
        dump(0);
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
def gcd(a,b): 
	if a == 0: 
		return b 
	return gcd(b % a, a) 

def lcm(a,b): 
	return (a*b) / gcd(a,b) 

input = input().split(' ')
a = int(input[0])
b = int(input[1])
print(int(lcm(a, b))) 



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int, int> pii;
int gcd(int a, int b){
    if(a%b==0) return b;
    return gcd(b,a%b);
}

int n;
bool used[17]={};
pii p[16];
vector<pii> l;
int solve(int curr){
    if(used[curr]) return solve(curr+1);
    if(curr == n){
        int ret = 0;
        for(int i=0; i<n/2; i++){
            for(int j=i+1; j<n/2; j++){
                if(l[i] == l[j]) ret++;
            }
        }
        return ret;
    }
    int ret = 0;
    for(int i=curr+1; i<n; i++){
        if(used[i]) continue;
        int a = p[curr].first -p[i].first;
        int b = p[curr].second -p[i].second;
        if(a == 0){
            b = 1;
        }else if(b == 0){
            a = 1;
        }else{
            if(a < 0){
                a = -a;
                b = -b;
            }
            int d = gcd(a, abs(b));
            a /= d;
            b /= d;
        }
        used[i] = true;
        l.emplace_back(a, b);
        ret = max(ret, solve(curr+1));
        l.pop_back();
        used[i] = false;
    }
    return ret;
}

int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> p[i].first >> p[i].second;
    }
    cout << solve(0) << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
int main()
{
int n ,r;
cin>>n>>r;
if(n>=10){
    cout<<r;
}
else
    cout<<100*(10-n)+r;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  
  int cnt1 = 0, cnt2 = 0;
  rep(i,n-1) if(s[i] == 'W' && s[i+1] == 'B') cnt1++;
  rep(i,n-1) if(s[i] == 'B' && s[i+1] == 'W') cnt2++;
  
  int ans = cnt1 + cnt2;
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

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

    unsigned long long ans = 1;
    vector<unsigned long long> a(n);
    for (auto &_a : a) {
        cin >> _a;
        if (_a == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    for (auto _a: a) {
        if (_a <= 1000000000000000000 / ans) ans *= _a;
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

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

def ask(n):
    print(n, flush=True)
    resp = input().rstrip()[0]
    if resp == 'V':
        exit()
    return resp

def condition(L,R,resp_L,resp_R):
    if (R-L)&1:
        return resp_L == resp_R
    else:
        return resp_L != resp_R

resp = ask(0)

L = 0
R = N
resp_L = resp
resp_R = resp
for _ in range(19):
    M = (L + R) // 2
    resp_M = ask(M)
    if condition(L,M,resp_L,resp_M):
        R,resp_R = M,resp_M
    else:
        L,resp_L = M,resp_M


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

const int N = int(1e5) + 10;

int x, y, a, b, c;
int p[N];
int q[N];
int r[N];
priority_queue<pii> pq;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	for (int i = 1; i <= a; i++) {
		scanf("%d", &p[i]);
		pq.push({p[i], 0});
	}
	for (int i = 1; i <= b; i++) {
		scanf("%d", &q[i]);
		pq.push({q[i], 1});
	}
	for (int i = 1; i <= c; i++) {
		scanf("%d", &r[i]);
		pq.push({r[i], 2});
	}

	ll ans = 0LL;
	int cnt[3] = {0, 0}, lim[3] = {x, y, INT_MAX}, tot = 0;
	while (tot < x + y) {
		int val = pq.top().x, col = pq.top().y; pq.pop();
		if (cnt[col] + 1 > lim[col]) continue;
		cnt[col]++;
		tot++;
		ans += val;
	}

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

	return 0;
}

Measured memory_bytes: 7536
N, Y = map(int, input().split())
for i in range(N+1):
  for j in range(N-i+1):
    k = N - i - j
    if 10000*i + 5000*j + 1000*k == Y:
      print(i, j, k)
      exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i = a ; i <= b;i++)
using namespace std;
void debug(int x){
    cerr<<x<<endl;
}
void debug(vector<int> v){
    for(int i = 0 ; i<v.size(); i++) cerr<<v[i]<<" ";
    cerr<<"\n";
}
void debug(int *A, int N){
    for(int i = 0 ; i < N;i++) cerr<<A[i]<<" ";
    cerr<<endl;
}
void debug(int *A, int i, int j){
    for(int k = i;k<=j;k++) cerr<<A[k]<<" ";
    cerr<<endl;
}
void scan(vector<int> &h,int N){
    for(int i = 0 ; i < N;i++){
        scanf("%d",&h[i]);
    }
}




int main(){
             int N;
             scanf("%d",&N);
             vector<int> dp(3,0);
             //dp[i] is the maximum cost given that last activity was i
             for(int days = 0; days<N; days++){
                  int a, b,c;
                  cin>>a>>b>>c;
                  int temp_a = max({dp[0], dp[1] + a, dp[2] + a});
                  int temp_b= max({dp[1], dp[0] + b, dp[2] + b});
                  int temp_c = max({dp[2], dp[0] + c, dp[1] + c});
                  dp[0] = temp_a; dp[1] = temp_b; dp[2] = temp_c;
              //   cout<<endl; debug(dp);
             }
             cout<<max({dp[0],dp[1],dp[2]})<<endl;    
}


Measured memory_bytes: 764