akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define ljm 998244353
#define MAXN 200005
#define MAXM 1000006
#define endl putchar('\n')

int g[MAXM],f[MAXM],prime[78500],iv[MAXM];
bool vis[MAXM];

inline int max(int a,int b) {return a<b?b:a;}
int Mod(int a) {return a<ljm?a:a-ljm;}
long long fast_pow(long long a,int b)
{
	a%=ljm;
	long long ans=1;
	while(b) {
		if(b&1) ans=ans*a%ljm;
		b>>=1; a=a*a%ljm; 
	}
	return ans;
}
long long inv(int n)
{
	if(iv[n]) return iv[n];
	else return iv[n]=fast_pow(n,ljm-2);
}
void init(int n)
{
	static int cnt=0;
	long long k;
	g[1]=1;
	for(int i=2;i<=n;++i) {
		if(!vis[i]) prime[++cnt]=i,g[i]=inv(i)*(1ll-i+ljm)%ljm;
		for(int j=1;j<=cnt && (k=(long long)i*prime[j])<=n;++j) {
			vis[k]=true;
			if(i%prime[j]) g[k]=(long long)g[i]*g[prime[j]]%ljm;
			else {
				g[k]=(long long)g[i]*inv(prime[j])%ljm;
				break;
			}
		}
	}
	for(int i=1;i<=n;++i) {
		//if(!f[i]) continue; /* f[i]定义时并没有要求 i 一定在数列 {an} 中，所以这句不能写。 */
		for(int j=i<<1;j<=n;j+=i) f[i]=Mod(f[i]+f[j]);
	}
}
int read()
{
	char ch=getchar();int x=0;
	while(ch<'0' || ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') x=(x*10)+(ch^48),ch=getchar();
	return x;
}
int main()
{
	int n,s,m,ans;
	n=read();
	m=0;
	s=0;
	for(int i=1,a;i<=n;++i) {
		a=read();
		f[a]=Mod(f[a]+a);
		s=Mod(s+a);
		m=max(m,a);
	}
	init(m);
	ans=0;
	for(int i=1;i<=m;++i) ans=(ans+(long long)g[i]*f[i]%ljm*f[i])%ljm;
	printf("%lld",(ans-s+ljm)*inv(2)%ljm);
	return 0;
} 

Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+10;
vector<ll> g[M];
int col[M];
ll n,m;
bool Color(int u){
    for(int i=0; i<g[u].size(); ++i) {
        int v = g[u][i];
        if(!col[v]){
            col[v] = !col[u];
            if(!Color(v)) return false;
        }
        else if(col[v] == col[u])
            return false;
    }
    return true;
}

int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    while(cin>>n>>m){
        for(int i=0;i<=n;++i) g[i].clear(),col[i]=0;
        for(int i=0;i<m;++i){
            cin>>a>>b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        col[1] = 1;
        bool flag=Color(1);
        if(flag) {
            a=b=0;
            for(int i=1;i<=n;++i) {
                if(col[i]) ++a;
                else ++b;
            }
            cout<<a*b-m<<endl;
        }else cout<<n*(n-1)/2-m<<endl;
    }
    return 0;
}


Measured memory_bytes: 12672
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long x = in.nextLong();
            long y = in.nextLong();

            int ans = 1;
            long prev = x;

            while (prev * 2 <= y) {
                ans++;
                prev *= 2;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n, k;
	cin >> n >> k;
	long long ans = 0;
	for (long long i = k; i <= n; i++) {
		long long min = i * (i - 1) / 2;
		long long max = (n + n - i + 1) * i / 2;
		ans = (ans + (max - min + 1)) % 1000000007;
	}
	cout << (ans + 1) % 1000000007 << endl;
}

Measured memory_bytes: 3612
n=int(input())
D,X=map(int,input().split())
cnt=0
for _ in range(n):
    A=int(input())
    cnt+=1
    t=1
    if A>D: continue
    for i in range(2,D+1):
        if i%(t*A+1)==0:
            cnt+=1;t+=1
print(cnt+X)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
    int r,g,b,n;
    int i,j,k;
    int sum=0;
    int count=0;

    scanf("%d",&r);
    scanf("%d",&g);
    scanf("%d",&b);
    scanf("%d",&n);
    
    for(i=0; i<=n; i++){
        if(r*i > n) break;
        for(j=0; j<=n; j++){
            //printf("%d %d, %d %d,, ",i,j,r,g);
            if(r*i + g*j > n) break;
            if((n - r*i - g*j) % b != 0) {
                continue;
            }else{
                count++;
                //printf("%d %d#\n",i,j);
            }
            
        }
    }
    printf("%d\n",count);
    return 0;
}

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

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  for(i=0;i<n;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  int now=a.at(0);
  bool out=false;
  for(i=1;i<n;i++)
  {
    if(a.at(i)!=now)now=a.at(i);
    else out=true;
  }
  if(out)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
using namespace std;
const int N=5e5+5;
const int mod=998244353;
int n,k,fac[N],inv[N],ans=0;
inline int qpow(int x,int y) {int ret=1;for (;y;y>>=1,x=1LL*x*x%mod) if (y&1) ret=1LL*ret*x%mod;return ret;}
inline void init()
{
	fac[0]=1;
	FOR(i,1,k) fac[i]=1LL*fac[i-1]*i%mod;
	inv[k]=qpow(fac[k],mod-2);
	For(i,k-1,0) inv[i]=1LL*inv[i+1]*(i+1)%mod;
}
inline int C(int x,int y) {return 1LL*fac[x]*inv[y]%mod*inv[x-y]%mod;}
int main()
{
	scanf("%d%d",&n,&k);
	init();
	if (k<n) {printf("0\n");exit(0);}
	FOR(i,n,k) ans=(1LL*ans+C(k-1,i-1))%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
from collections import deque

s = input()
q=int(input())
deq = deque()
deq.append(s)
fl = False
for i in range(q):
    a=[i for i in input().split()]
    if a[0]=="1":
        fl = not fl
    else:
        if a[1]=="1":
            if fl:
                deq.append(a[2])
            else:
                deq.appendleft(a[2])
        else:
            if fl:
                deq.appendleft(a[2])
            else:
                deq.append(a[2])
if fl:
    s=''.join(deq)
    print(s[::-1])
else:
    print(''.join(deq))


Measured memory_bytes: 6900
n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans = 0
if n == 1:
  print(0)
  quit()
for f in factorization(n):
  count = 0
  for i in range(1,f[1]+1):
    count += i
    if count <= f[1]:
      ans += 1
    else:
      break
print(ans)

Measured memory_bytes: 63388
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>
using namespace std;

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

  int N; 
  cin >> N;
  
  vector<double> a(N);
  
  double res1 = 0;
  double res2 = 0;
  
  for (int i=0; i<N; ++i) {
    cin >> a[i];
    
    res1 += 1/a[i];
  }
  
  cout << fixed << setprecision(10) << 1/res1;
}

Measured memory_bytes: 256
/**
       **********    ************
	  Author : Avi J Patel
	  University : DAIICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 1000000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define min_heap priority_queue<int, vector<int>, greater<int>>
#define max_heap priority_queue<int>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> 

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
bool sortbytwo(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first>b.first) return true;
	else if(a.first==b.first) return a.ss<b.ss;
	else return false;
}
bool sortbystring(const string &a, const string &b)
{
	string c=a+b;
	string d=b+a;
	if(c>=d) return true;
	else return false;
}
ull powr(ull x1, ull n1) {
    if(x1==0)
    {
        return 0;
    }
    ull result=1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1);
        }
        n1=n1>>1;
        x1=(x1*x1);
    }
    return result;
}
//vector<int> graph[200090];
//int vi[200090];
//void dfs(int i)
//{
//	vi[i]=1;
//	for(int j=0;j<graph[i].size();j++)
//	{
//		if(vi[graph[i][j]]==0)
//		{
//			dfs(graph[i][j]);
//		}
//	}
//}
int main()
{
	FAST
	string s;
	cin>>s;
	cout<<char(s[0]+1);
	return 0;
}
















Measured memory_bytes: 256
#ifndef VS
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<math.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {
	cww() { CIN_ONLY{ ios::sync_with_stdio(false); cin.tie(0); } }
}star;
#define DEBUG if(0)
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r) { bool a = l>r; if (a)l = r; return a; }
template <typename T>inline bool chmax(T &l, T r) { bool a = l<r; if (a)l = r; return a; }

namespace _DSU {
	const int BUF = 212345 * 2;
	int ptr = 0;
	int mem[BUF];
	int* get(int size) {
		ptr += size;
		return mem + ptr - size;
	}
	void reset() {
		ptr = 0;
	}
}
class UF {
private:
	int *par, *rank;
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
public:
	UF(int n) :par(_DSU::get(n + 10)), rank(_DSU::get(n + 10)) {
		REP(i, n)par[i] = i, rank[i] = 0;
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		if (rank[x] < rank[y])swap(x, y);
		par[y] = x;
		if (rank[x] == rank[y])rank[x]++;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

double x[212345];
double y[212345];
int a[212345];
int b[212345];
typedef pair<double, int> P;
double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return sqrt(dx*dx + dy*dy);
}
int main() {
	cout << fixed;
	cout << setprecision(10);
	int N, M;
	while (cin >> N >> M) {
		double all = 0;
		vector<P> edge;
		REP(i, N)cin >> x[i] >> y[i];
		REP(i, M) {
			cin >> a[i] >> b[i];
			a[i]--; b[i]--;
			double c = dist(a[i], b[i]);
			edge.push_back(P(-c, i));
			all += c;
		}
		sort(ALL(edge));
		UF uf(N);
		double ret = 0;
		REP(i, M)if (uf.unite(a[edge[i].second], b[edge[i].second]))ret += edge[i].first;
		cout << all + ret << endl;
		_DSU::reset();
	}
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define ld long double
#define int long long
using namespace std;
const int N = 1e5 + 50;
const int mod = 1e9 + 7;
const int inf = 1e17;
int dx[] = {0, 1, -1, 0, -1, 1, 1, -1};
int dy[] = {1, 0, 0, -1, -1, 1, -1, 1};
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int arr[5], k;
	for(int i = 0; i < 5; i++){
		cin >> arr[i];
	}
	cin >> k;
	for(int i = 0; i < 5; i++){
		for(int j = i + 1; j < 5; j++){
			int d = abs(arr[i] - arr[j]);
			if(d > k){
				cout << ":(";
				return 0;
			}
		}
	}
	cout << "Yay!";
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Trim();
        var k = int.Parse(Console.ReadLine());

        Console.WriteLine(new string(s.Select(x => s[k - 1] == x ? x : '*').ToArray()));
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int N,i;
   scanf("%d",&N);
   for(i=1;i<10;i++)
   {
       if((N%i)==0&&(N/i)>0&&(N/i)<10)
	   {
	      printf("Yes");
		  return 0;
	   }
   }
   printf("No");
}

Measured memory_bytes: 128
#include<bits//stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>h(n,0);
    for(int i=0;i<n;i++)
    cin>>h[i];

    vector<int>dp(n,INT_MAX);
    dp[0]=0;

    for(int i=1;i<n;i++)
    {
     	for(int j=i-1;j>=0&&j>=i-k;j--)
     	{
     	 dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);	
     	}
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    int d, t, s; cin >> d >> t >> s;
    if (d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,K; cin >> H>>W>>K;
    dump(K)

    if(W==1)
    {
        cout << 1 << endl;
        return 0;
    }

    LL dp[105][10] = {};
    LL move[10][10] = {};

    REP(i,1 << (W-1))
    {
        bool ok = 1;
        REP(j,W-2)
        {
            if((((i >> j) & 1) == 1) && (((i >> j+1) & 1) == 1)) ok = 0;
        }
        if(!ok) continue;

        REP(j,W)
        {
            dump(i)
            dump(j)
            dump(i >> (W-1))
            dump(i >> (W-1) & 1)
            if(j == 0)
            {
                if((i >> (W-2) & 1) == 0)
                {
                    move[j][j]++;
                    dump("nothing")
                }
                else
                {
                    move[j][j+1]++;
                    dump("move")
                }
            }
            else if(j == W-1)
            {
                if((i & 1) == 0)
                {
                    move[j][j]++;
                    dump("nothing")
                }
                else move[j][j-1]++;
            }
            else
            {
                if(i >> (W-j-1) & 1 == 1) move[j][j-1]++;
                else if(i >> (W-j-2) & 1 == 1) move[j][j+1]++;
                else move[j][j]++;
            }
        }
    }
    REP(i,4) REP(j,4)
    {
        dump(i)
        dump(j)
        dump(move[i][j])
    }

    dp[0][0] = 1;
    REP(i,102)
    {
        REP(j,W)
        {
            REP(k,W)
            {
                dp[i+1][j] =(dp[i+1][j]+ dp[i][k] * move[k][j])%MOD;
            }
        }
    }
    dump("finish")
    cout << dp[H][K-1] << endl;





}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter

def isOdd(x):
  return x % 2

def solve(n,a):
  d = Counter(a)
  return sum(1 for x in d.values() if isOdd(x))


def main():
  N = int(input())
  a = [int(input()) for _ in range(N)]
  print(solve(N,a))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 20708
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a + b / 2);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



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

int board[510][510];
using Pos = pair<int, int>;

int main() {
  int H, W;
  cin >> H >> W;
  for(int h = 1; h <= H; ++h) {
    for(int w = 1; w <= W; ++w) {
      cin >> board[h][w];
    }
  }
  vector<Pos> ps;
  for(int h = 1; h <= H; ++h) {
    if(h % 2 == 1) {
      for(int w = 1; w <= W; ++w) {
        ps.push_back(Pos(h, w));
      }
    } else {
      for(int w = W; w >= 1; --w) {
        ps.push_back(Pos(h, w));
      }
    }
  }
  vector<pair<Pos, Pos>> p2p;
  for(int i = 0; i < ps.size() - 1; ++i) {
    auto p = ps[i];
    if(board[p.first][p.second] % 2 == 1) {
      auto n = ps[i + 1];
      p2p.push_back(make_pair(p, n));
      board[p.first][p.second]--;
      board[n.first][n.second]++;
    }
  }
  cout << p2p.size() << endl;
  for(auto pp : p2p) {
    cout << pp.first.first << " " << pp.first.second << " " << pp.second.first << " "
         << pp.second.second << endl;
  }

  return 0;
}

Measured memory_bytes: 7152
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a, b, x  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = b // x - a // x
ans += 1 if a % x == 0 else 0
#ans += 1 if b % x == 0 else 0
print(ans)


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


const int N = 2e5 + 7;

int a[N];

int main(){
	int k, n;
	scanf("%d%d", &k, &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int ans = a[1] + k - a[n];
	for (int i = 2; i <= n; i++){
		ans = max(ans, a[i] - a[i - 1]);
	}
	printf("%d", k - ans);
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = str(input())

def _next(c, N):
    b = int.from_bytes(c.encode("utf-8"), "little") - 65
    return (b + N) % 26

def _decode(b):
    return (b + 65).to_bytes(1, "little")
    
ls = [_decode(_next(s, N)).decode("utf-8") for s in S]

print("".join(ls))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int A,B;cin>>A>>B;
  int S=__gcd(A,B);
  int ans=1;
  for(int i=2;i*i<=S;i++){
    bool f=false;
    while(S%i==0){
      S/=i;
      f=true;
    }
    ans+=f;
  }
  if(S>1)ans++;
  fin(ans);
}


Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main() {
	double n=0.5,m=6,n2=30;
	int a,b,n4,e=0;
	cin>>n4;
	for(int i=0;i<n4;i++){
		string d;
		cin>>d;
		d+=":";
		string h;
		e=0;
		for(int j=0;j<d.length();j++){
			if(d[j]==':'){
				if(e==0)
					a=atoi(h.c_str());
				else
					b=atoi(h.c_str());
				h="";
				e++;
			}
			else
				h+=d[j];
		}
		double n3,m3;
		n3=0;
		n3+=(a*n2+b*n);
		m3=0;
		m3+=b*m;
		double c=n3-m3;
		if(c<0)
			c=0-c;
		if(360-c<c){
			c=360-c;
		}
		if(c>=90&&c<=180)
			printf("safe\n");
		else if(c>=0&&c<30)
			printf("alert\n");
		else
			printf("warning\n");
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c;
  cin >> a >> b >> c;
  map<int,int> mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  cout << mp.size() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
int main()
{
	int n,k;
	cin >> n >> k;

	ll ans=0;
/*	int tmp;
	if(k%2){
		tmp = n/k;
		ans=tmp*tmp*tmp;
	}else{
		tmp = n/k;
		ans=tmp*tmp*tmp;
		if(n%k >= k/2){
			tmp++;
		}
		ans += tmp*tmp*tmp;
		}
		*/
	ll cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % k == 0) cnt1 += 1;
		if (k % 2 == 0 and i % k == k / 2) cnt2 += 1;
	}
	if (cnt1 or cnt2) {
		ans += cnt1 * cnt1 * cnt1;
		ans += cnt2 * cnt2 * cnt2;
	}

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

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll X, Y, Z, K, ans=0, tmp=0;
vector<ll> Xs, Ys, Zs, XYs;

signed main(){
    cin >> X >> Y >> Z >> K;
    for(int i=0;i<X;i++) {
        ll a;
        cin >> a;
        Xs.push_back(a);
    }
    for(int i=0;i<Y;i++) {
        ll a;
        cin >> a;
        Ys.push_back(a);
    }
    for(int i=0;i<Z;i++) {
        ll a;
        cin >> a;
        Zs.push_back(a);
    }
    for(int i=0;i<X;i++) {
        for(int j=0;j<Y;j++) {
            XYs.push_back(Xs[i]+Ys[j]);
        }
    }
    sort(XYs.begin(), XYs.end());
    priority_queue<pair<ll,ll>> PQ;
    for(int i=0;i<Z;i++) {
        PQ.push(make_pair(XYs.back()+Zs[i],XYs.size()-1));
    }
    int i=0;
    while(i!=K) {
        pair<ll,ll> p = PQ.top();
        tmp = p.first;
        PQ.pop();
        if(p.second>=1) PQ.push(make_pair(XYs[p.second-1]+tmp-XYs[p.second],p.second-1));
        cout << tmp << endl;
        i++;
    }
    return 0;
}

Measured memory_bytes: 10616
N,K=map(int,input().split())
A=[int(a)-1 for a in input().split()]
city=0
if K<=N:
    for k in range(K):
        city=A[city]
    print(city+1)
else:
    visited=[-1]*N
    for k in range(K):
        if visited[city]!=-1:
            roop_start=visited[city]
            cycle_num=k-roop_start
            break
        visited[city]=k
        city=A[city]
    K=(K-roop_start)%cycle_num+roop_start
    city=0
    for k in range(K):
        city=A[city]
    print(city+1)


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

using namespace std;

typedef unsigned long long int ulli;

int main(){
	/*
	freopen("input.txt","r",stdin);
	freopen("input.txt","w",stdout);
	*/
	int n;
	cin >> n;
	
	map<string,int> dict;
	int max=  0;
	vector<string> strs;
	for(int i = 0 ; i < n; i++){
		string in;
		cin >> in;
		dict[in]++;
		if(dict[in] > max){
			strs.erase(strs.begin(),strs.end());
			strs.push_back(in);
			max = dict[in];
		}
		else if(dict[in] == max){strs.push_back(in);}
	}
	sort(strs.begin(),strs.end());
	for(int i = 0; i < strs.size(); i++){
		cout << strs[i] << endl;
	}
} 


Measured memory_bytes: 26736
from fractions import gcd

lcm = lambda x, y: x*y//gcd(x, y)
calc = lambda mod, a, b: (b//mod-a//mod) if a%mod != 0 else (b//mod-a//mod+1) 

a, b, c, d = map(int, input().split())

print(b-a+1-calc(c, a, b)-calc(d, a, b)+calc(lcm(c, d), a, b))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    print((1900*M+100*(N-M))*(1LL<<M))
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i, b, n) for(int i=b;i<(int)n;i++)
#define rep(i, n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it, o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;

//ハマったらチェックリスト見ろ!!

class DisJointSet{
public:
    vector<int> v;//親の添字を入れる
    DisJointSet(int n){//初期化
        v = vector<int>(n);
        rep(i, n)v[i] = i;
    }
    int find(int x){//親を返す
        if(v[x] == x)return x;
        else return v[x] = find(v[x]);
    }
    void unite(int x, int y){//xとyをくっつける
        x = find(x);
        y = find(y);
        if(x == y)return;
        v[x] = y;
    }
    bool same(int x, int y){//xとyが同じ集合かどうか
        return find(x) == find(y);
    }
};

vector<vector<int> > V;

vector<int> countSize(int now, map<int, int> &visited, int c){
    if(visited.count(now)){
        if(visited[now] != c){
            vector<int> tmp(2);
            tmp[0] = -1;
            return tmp;
        }
        else return vector<int>(2);
    }
    visited[now] = c;
    c = (c+1)%2;

    vector<int> ret(2);
    ret[0] = ret[1] = 0;
    ret[c] = 1;
    rep(i, V.size()){
        if(V[now][i] == 0)continue;
        vector<int> tmp = countSize(i, visited, c);
        if(min(tmp[0], tmp[1]) == -1)return tmp;
        ret[0] += tmp[0];
        ret[1] += tmp[1];
    }
    return ret;
}



int main() {
    int N;
    cin >> N;
    rep(i, N)V.push_back(vector<int>(N));
    rep(i, N)rep(j, N)V[i][j] = 1;
    int M ;
    cin >> M;
    DisJointSet ds(N), ds2(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        V[a][b] = V[b][a] = 0;
        ds2.unite(a,b);
    }
    rep(i, N)V[i][i] = 0;


    rep(i, N)rep(j, N)if(V[i][j]){
                cerr << "begin" <<endl;
                cerr << i <<' ' << j <<endl;
                ds.unite(i, j);
            }
    set<int> used;
    vector< vector<int> > ANS;

    rep(i, N){
        if(used.count(ds.find(i)) != 0)continue;
        map<int, int> visited;
        vector<int> tmp = countSize(i, visited, 0);
        if(min(tmp[0], tmp[1]) == -1){
            cout << -1 <<endl;
            return 0;
        }
        ANS.push_back(tmp);
        used.insert(ds.find(i));
    }


    set<int> SUM;
    SUM.insert(0);

    FOR(it1, ANS){
        set<int> next;
        FOR(it2, SUM){
            next.insert(*it2 + (*it1)[0]);
            next.insert(*it2 + (*it1)[1]);
        }
        SUM = next;
    }

    int ans = 1e9;
    FOR(it, SUM){
        int a = *it;
        int b = N - a;
        ans = min(ans, a*(a-1)/2 + b*(b-1)/2);
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
  string col;
  
  rep(i, N) {
    cin >> col;
    if(col=="Y"){
      break;
    }
  }
  
  if(col=="Y"){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
  
}

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


int main()
{
    long long n,a;
    scanf("%lld%lld",&n,&a);
    if(n<5){
        printf("%lld\n",n);
        return 0;
    }
    long long ans=n;
    for(int i=2;;i++)
    {
        long long t=pow(1.0*n,1.0/i);
        //printf("%lf\n",(log((long double)1.0*n)/log((long double)1.0*i)));
        long long tmp=1;
        for(int j=1;j<=i;j++)
        {
            tmp=tmp*t;
        }
        if(tmp>=n) t--;
        tmp=1;
        for(int j=1;j<=i;j++)
        {
            tmp=tmp*t;
        }
        if(tmp>=n) t--;
        tmp=1;
        for(int j=1;j<=i;j++)
            tmp=tmp*t;
        if(t==1) break;
        long long tans=(i-1)*a+t*i;
        int cnt=1;
        while(tmp<n){
            //printf("%lld %lld\n",tmp,t);
            tans++;
            tmp=tmp/t*(t+1);
            cnt++;
            if(cnt>50)
            return 0;
        }
        ans=min(ans,tans);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
al=[[0 for j in range(9)] for i in range(9)]

ans=0
for i in range(1,n+1):
    l=list(str(i))
    if l[-1]!='0':
        r=l[::-1]
        if l==r:
            ans-=0
        al[int(l[0])-1][int(l[-1])-1]+=1
for i in range(9):
    for j in range(9):
        k=al[i][j]
        if i==j:
            ans+=k*k
        else:
            ans+=al[i][j]*al[j][i]
print(ans)
      

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cout<<"ACL";
  }
  cout<<endl;
  return 0;
}


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

int N, K;
#define MAX_N 100000
int P[MAX_N]; vector<int> C[MAX_N];
int D[MAX_N];
set<pair<int, int>> S;
int R;

void see(int v, int d) {
  D[v] = d;
  for(int w : C[v]) see(w, d + 1);
}
void erase(int v, int d) {
  S.erase({D[v], v});
  if(d == 0) return;
  for(int w : C[v]) erase(w, d - 1);
}
int main() {
  cin >> N >> K;
  for(int v = 0; v < N; ++v) {
    int a; cin >> a; --a; P[v] = a; if(v != 0) C[a].push_back(v);
  }
  see(0, 0);
  if(P[0] != 0) ++R;
  for(int v = 0; v < N; ++v) if(D[v] > K) S.insert({D[v], v});
  while(!S.empty()) {
    int v = S.rbegin()->second;
    for(int i = 0; i < K - 1; ++i) v = P[v];
    ++R; erase(v, K - 1);
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 14336
while line = gets
t,h,s = line.split.map(&:to_i)
break if t == -1 && h == -1 && s == -1
lt = (t * 3600) + (h * 60) + s

rt = 120 * 60 - lt
rt3 = 3 * rt
printf("%02d:%02d:%02d\n",(rt / 3600),(rt / 60) % 60,rt % 60)
printf("%02d:%02d:%02d\n",rt3 / 3600, (rt3 / 60) % 60, rt3 % 60)
end


Measured memory_bytes: 6880
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P, int> PI;
typedef pair<P, P > PP;

struct edge {
	int from,to;
	int cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

int n, m, l, k, a, h;
vector<edge> G[105];
int d[105][105], C[105][105];
bool L[105];

void dijkstra(int s) {
	priority_queue<PI, vector<PI>, greater<PI> > que;
	rep(i, 105) {
		rep(j, 105) {
			d[i][j] = INF;
		}
	}

	d[s][m] = 0;
	que.push(PI(P(0, m), s));

	while(que.size()) {
		PI p = que.top();
		que.pop();

		int cost = p.first.first;
		int t = p.first.second;
		int v = p.second;
		if(d[v][t] < cost) continue;

		if(L[v]) {
			REP(i, t+1, m+1) {
				if(d[v][i] > d[v][t] + (i - t)) {
					d[v][i] = d[v][t] + (i - t);
					que.push(PI(P(d[v][i], i), v) );
				}
			}
		}

		rep(i, G[v].size()) {
			edge e = G[v][i];
			int nt = t - e.cost;
			if(nt >= 0 && d[e.to][nt] > d[v][t] + e.cost) {
				d[e.to][nt] = d[v][t] + e.cost;
				que.push(PI(P(d[e.to][nt], nt), e.to));
			}
		}
	}
}


int main() {
	while(cin >> n >> m >> l >> k >> a >> h) {
		if(n == 0 && m == 0 && l == 0 && k == 0 && a == 0 && h == 0) break;

		rep(i, 105) G[i].clear();
		memset(L, 0, sizeof(L));

		rep(i, l) {
			int x;
			cin >> x;
			L[x] = true;
		}

		rep(i, k) {
			int s, t, c;
			cin >> s >> t >> c;
			G[s].push_back(edge(t, c));
			G[t].push_back(edge(s, c));
		}

		dijkstra(a);

		int ans = INF;
		rep(i, m + 1) {
			ans = min(ans, d[h][i]);
		}
		//
		// rep(i, n) {
		// 	cout << "i:" << i << " |";
		// 	rep(j, m + 1) {
		// 		cout << "(";
		// 		if(d[i][j] == INF) cout << "X";
		// 		else cout << d[i][j];
		// 		cout << ",";
		// 		cout << C[i][j];
		// 		cout << ") ";
		// 	}
		// 	cout << endl;
		// }

		if(ans == INF) cout << "Help!" << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
#define int long long
#define double long double
#define fst first
#define snd second
#define fr(s,n,i) for(int i=s;i<n;i++)
#define times(n) for(int i=0;i<n;i++)
#define fr_(s,n,i) for(int i=s;i>=n;i--)
#define srt(v) sort(v.begin(), v.end());
#define upr(v, aim, ind) int ind; ind=(int)distance(v.begin(), upper_bound(v.begin(),v.end(), aim))
#define sz(v) (int)v.size()
#define ers(v, i) v.erase(v.begin() + i)
#define last(v) v[sz(v) - 1]
#define swp(v, i, j) int buf = v[j]; v[j] = v[i]; v[i] = buf
#define shout(a) cout << a << endl
#define dshout(a) printf("%.16Lf\n", a)
#define pr pair<int, int>
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vd vector<double>
#define vdd vector<vd>
#define mx(a, b) a = max(a, b)
#define mn(a, b) a = min(a, b)
#define mulM(a,b,c) a = a * b % c
#define squM(a,b) a = a * a % b
#define mpr(a,b) make_pair(a,b)
#define iinp(a) int a; cin >> a
#define sinp(a) string a; cin >> a
#define dinp(a) double a; cin >> a
#define ios() ios_base::sync_with_stdio(0);cin.tie(0)

int MOD = 998244353;
int INF = ~(1LL << 63);

int powM(int base, int exp){
    int ret = 1;
    int buf = base;
    while(exp > 0){
        if(exp & 1){
            ret *= buf;
        }
        squM(buf, MOD);
        exp >>= 1;
    }
    return ret;
}
int combM(int a, int b){
    if(b == 0){
        return 1;
    }
    if(a-b < b){
        return combM(a, a-b);
    }
    int ans = 1;
    fr(1,b+1,i){
        ans *= a + 1 - i;
        ans /= i;
    }
    return ans;
}
void solve();
signed main() {
    ios();
    solve();
    return 0;
}

void solve(){
    int n;
    vi v;
    cin >> n;
    fr(0,n,i){
        int buf;
        cin >> buf;
        v.emplace_back(buf);
    }
    int ans = 0;
    fr(0,n,i){
        int buf;
        cin >> buf;
        if(v[i] > buf){
            ans += (v[i] - buf);
        }
    }
    cout << ans << endl;
}


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

int main(void){
	ll r,d,x;
	cin>>r>>d>>x;
	ll ans[100];
	ans[0]=r*x-d;
	for(int i=1;i<11;i++){
		ans[i]=r*ans[i-1]-d;
	}
	for(int i=0;i<10;i++){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ct=0
for i in range(n):
    ans=0
    a=list(map(int,input().split()))
    for j in range(m):
        if (b[j]==0)or(a[j]==0):
            pass
        else:
            ans+=(b[j]*a[j])
    ans+=c
    if ans>0:
        ct+=1
print(ct)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
   int N, K, tmp;
   cin >> N >> K;
   map<int, int> log;
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      log[tmp]++;
   }
   vector<int> A;
   for (map<int, int>::iterator it = log.begin(); it != log.end(); ++it) {
      A.push_back(it->second);
   }
   sort(A.begin(), A.end());
   int var = (int)A.size();
   int ans = 0;
   if (var <= K) ans = 0;
   else {
      for (int i = 0; i < var - K; i++) {
         ans += A[i];
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 10748
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<long, long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
long long dist[100010];
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	long long N,K,Q;
	cin >> N >> K >> Q;

	vector<long long>A(N,0);
	for (long long i = 0; i < Q;++i) {
		int q;
		cin >> q;
		A[q-1]++;
	}
	long long must = Q - K;

	for (int i = 0; i < N;++i) {
		if (must < A[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 5632
import java.io.*;
import java.util.Calendar;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line;
            while((line = br.readLine()) != null) {
            		String[] list = line.split(" ", 0);
            		int month = Integer.parseInt(list[0]);
            		int day = Integer.parseInt(list[1]);
            		if(month == 0 && day == 0) {
            			break;
            		}
            		String date = tellMeDate(month, day);
            		System.out.println(date);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

   private static String tellMeDate(int month, int day) {
	   
	   Calendar cal = Calendar.getInstance();
	   int year = 2004;
	   cal.set(year, month - 1, day);
	   switch (cal.get(Calendar.DAY_OF_WEEK)) { 
	    case Calendar.SUNDAY:
	    		String date = "Sunday";
	    		return date; 
	    case Calendar.MONDAY:  
	        //????????\
	    	String date1 = "Monday";
	    		return date1;
	    case Calendar.TUESDAY: 
	        //????????\
	    	String date2 = "Tuesday";
	        return date2;
	    case Calendar.WEDNESDAY: 
	        //?°´?????\
	    	String date3 = "Wednesday";
	        return date3;
	    case Calendar.THURSDAY:
	        //??¨?????\
	    	String date4 = "Thursday";
	        return date4;
	    case Calendar.FRIDAY:
	        //????????\
	    	String date5 = "Friday";
	        return date5;
	    case Calendar.SATURDAY:
	        //????????\
	    	String date6 = "Saturday";
	        return date6;
	}
	   return null;
   }
}

Measured memory_bytes: 25880
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include <unordered_set>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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 COM(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;
}

vector<vector<ll>> v(100010);
bool used[100010];
ll n,k;
ll ans;

void dfs(ll x){ // form x
  if(used[x] || v[x].size()==0)return;
  used[x]=true;
  ll color=inf;
  if(x==0)color=k-1;
  else color=k-2;
  ll choose=v[x].size();
  rep(i,v[x].size()){
    if(used[v[x][i]])choose--;
  }
  if(choose==0)return;
  ans*=COM(color,choose);
  ans%=mod;
  ans*=fac[choose];
  ans%=mod;
  for(int i=0;i<v[x].size();i++){
    dfs(v[x][i]);
  }
}


int main(){
  cin >> n >> k;
  ans=k;
  COMinit();
  rep(i,n-1){
    ll x,y;
    cin >> x >> y;
    x--,y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0);
  cout << ans << endl;
return 0;}

Measured memory_bytes: 20096
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] abx = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long num = abx[1] / abx[2] - abx[0] / abx[2];
            if (abx[0] % abx[2] == 0)
            {
                Console.WriteLine(num + 1L);
                return;
            }
            else
            {
                Console.WriteLine(num);
                return;
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 28212
use std::cmp;

fn main(){
  let q: usize = read();

  for _ in 0 .. q {
    let vcan: Vec<u32> = read_vec();
    let c = vcan[0];
    let a = vcan[1];
    let n = vcan[2];

    let can = cmp::min(c, cmp::min(a, n));
    let c1 = c - can;
    let a1 = a - can;

    let cca = cmp::min(c1 / 2, a1);
    let c2 = c1 - 2 * cca;

    let ccc = c2 / 3;
    
    println!("{}", can + cca + ccc);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



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

string s;
int cnt=0,mx=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	for(int i=0;i<s.size();i++){
		cnt=0;
		if(s[i]=='A'|| s[i]=='C'|| s[i]=='G'|| s[i]=='T'){
			cnt=1;
			for(int j=i+1;j<s.size();j++){
				if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T'){
					cnt++;
				}
				else{
					if(cnt>mx)
						mx=cnt;
					break;
				}
			}
		}
		if(cnt>mx)
			mx=cnt;
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 256