akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    char a, b, res;
	cin >> a >> b;
    if (a == b) {
        res = 'H';
    } else {
        res = 'D';
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>
 
int main(){
  uint64_t n0=2, n1=1;
  unsigned n; std::cin >> n;
  
  if(n==0){
    std::cout << n0 << std::endl;
    return 0;
  }
  if(n==1){
    std::cout << n1 << std::endl;
    return 0;
  }
  
  for(int i=2; i<=n;i++){
    uint64_t newn = n0+n1;
    n0 = n1;
    n1 = newn;
  }
  std::cout << n1 << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
const long long mod=1e9+7;
typedef long long ll;
using namespace std;
ll f[1000010], revf[1000010];
ll qpow (ll a, ll b)
{
	ll ret=1;
	while (b)
	{
		if (b&1) ret = (ret*a)%mod;
		a = (a*a)%mod;
	b>>=1;
	}
	return ret;
}
void init ()
{
	f[0] = 1;
	revf[0] = qpow (f[0], mod-2);
	for (ll i=1; i<1000010; i++)
	{
		f[i] = i*f[i-1]%mod;
		revf[i] = qpow (f[i], mod-2);
	}
}
ll C(ll n, ll m)
{
	return (f[n]*revf[m])%mod*revf[n-m]%mod;
}
ll count_ways(ll a,ll b,ll c,ll d)
{
	ll tot=(c-a)+(d-b);
	ll down=(c-a);
	ll ret=C(tot,down);
	return ret;
}
int main()
{
	init ();
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	ll tot = count_ways (1, 1, h, w);
	for (ll i=1; i<=b; i++)
	{
		ll tmp = count_ways (1, 1, h-a, i)*count_ways (h-a+1, i, h, w)%mod;
		while (tot < tmp) tot += mod;
		tot = (tot-tmp)%mod;
	}
	cout << tot << endl;
	return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			List<List<int>> lists = new List<List<int>>();
			var rc = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int r = rc[0];
			for (int i = 0; i < r; ++i) {
				List<int> list = new List<int>();
				var array = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
				foreach (var item in array) {
					list.Add(item);
				}

				lists.Add(list);
			}

			for (int i = 0; i < r; ++i) {
				int sum = 0;
				for (int j = 0; j < lists[i].Count; ++j) {
					sum += lists[i][j];
				}

				lists[i].Add(sum);
			}

			List<int> totallist = new List<int>();
			for (int j = 0; j < lists[0].Count; ++j) {
				int sum = 0;
				for (int i = 0; i < lists.Count; ++i) {
					sum += lists[i][j];
				}

				totallist.Add(sum);
			}

			lists.Add(totallist);

			for (int i = 0; i < lists.Count; ++i) {
				for (int j = 0; j < lists[i].Count; ++j) {
					Console.Write($"{lists[i][j]}");

					if (j < lists[i].Count - 1) {
						Console.Write(" ");
					} else {
						Console.WriteLine("");
					}
				}
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 20496
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC138_c solver = new ABC138_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC138_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] v = new int[N];
            for (int i = 0; i < N; i++) {
                v[i] = in.nextInt();

            }
            Arrays.sort(v);
            double ans = 0;
            for (int i = 1; i < N; i++) {
                if (i == 1) {

                    ans = (v[i - 1] + v[i]) * 0.5;
                } else {
                    ans = (ans + v[i]) * 0.5;
                }

            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

bool is_enable(int n, vector<int> e, vector<int> o) {

    if (!(e.size() == (n + 1) / 2)) return false;
    if (!(o.size() == n / 2)) return false;

    sort(e.begin(), e.end());
    sort(o.begin(), o.end());
    vector<int> tmp;
    rep(i, e.size()) {
        tmp.push_back(e[i]);
        if (o.size() > i) tmp.push_back(o[i]);
    }


    rep(i, tmp.size() - 1) {
        if (!(tmp[i] <= tmp[i + 1])) return false;
    }
    return true;

}

int calc(vector<P> v) {
    int n = v.size();

    vector<int> tmp;
    for (P p : v) tmp.push_back(p.first);
    sort(tmp.begin(), tmp.end());

    vector<int> rank(n, -1);
    rep(i, n) {
        rep(j, n) {
            if (
                    v[j].first == tmp[i] &&
                    i % 2 == v[j].second &&
                    rank[j] == -1
                    ) {
                rank[j] = i;
                break;
            }
        }
    }


    int ans = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (rank[j] > rank[i]) ans++;
        }
    }

    return ans;
}


int main() {
//    cout << bitset<15>(20259) << endl;
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    int ans = INT_MAX;
    rep(i, 1 << n) {

        vector<int> e, o;
        vector<P> tmp;

        rep(j, n) {

            if (j % 2 == 0) {
                if ((i >> j) & 1) {
                    o.push_back(b[j]);
                    tmp.push_back({b[j], 1});
                } else {
                    e.push_back(a[j]);
                    tmp.push_back({a[j], 0});
                }
            } else {
                if ((i >> j) & 1) {
                    e.push_back(b[j]);
                    tmp.push_back({b[j], 0});
                } else {
                    o.push_back(a[j]);
                    tmp.push_back({a[j], 1});
                }
            }
        }

        bool ok = is_enable(n, e, o);
        if (!ok) continue;
        int cost = calc(tmp);
        cmin(ans, cost);
    }
    ans = ans == INT_MAX ? -1 : ans;
    cout << ans << endl;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
G = [None] * N
for i in range(N):
    G[i] = list(map(int, input()))

nodes = [[] for i in range(N)]
for i in range(N):
    for j in range(N):
        if G[i][j]:
            nodes[i].append(j)
            nodes[j].append(i)

def bfs(start):
    visited = list2d(N, N, 0)
    group = [-1] * N
    que = deque()
    que.append((start, 1))
    mx = 0
    while que:
        u, cnt = que.popleft()
        if group[u] == -1:
            group[u] = cnt
        elif group[u] == cnt:
            continue
        else:
            return -1
        mx = max(mx, cnt)
        for v in nodes[u]:
            if visited[u][v]:
                continue
            visited[u][v] = visited[v][u] = 1
            que.append((v, cnt+1))
    return mx

ans = -1
for i in range(N):
    ans = max(ans, bfs(i))
print(ans)


Measured memory_bytes: 59332
#include <stdio.h>
#define N 10000
#define Q 500
#define NOT_FOUND 0

int linearSearch(int *A, int n, int v){
  int i=0;
  A[n] = v;
  while(A[i] != v){
    i++;
    if(i == n) return NOT_FOUND;
  }
  // printf("%d ",A[i]);
  return 1;
}

int main(){
  int i,n,q,c=0;
  int S[N];
  int T[Q+1];

  // input
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d ", &S[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) scanf("%d ", &T[i]);

  // search
  for(i=0; i<q; i++) c = c+linearSearch(S,n,T[i]);

  // output
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 644
#include <iostream>
using namespace std;
int main(){
    int n,m,q;
    cin >> n >> m >> q;
    int a[n+1][n+1]={{0,0}};
    for (int i=1; i<=m; i++){
        int l,r;
        cin >> l >> r;
        a[l][r]++;
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n; j++){
            a[i][j]+=a[i][j-1];
        }
    }
    for (int i=0; i<q; i++){
        int l,r;
        cin >> l >> r;
        int rails=0;
        for (int j=l; j<=r; j++){
            rails+=a[j][r]-a[j][l-1];
        }
        cout << rails<<endl;
    }
}


Measured memory_bytes: 1920
n = int(input())
n_new = n
out = []
while n_new > 0:
  if n_new <= 26:
    out.insert(0, str(n_new))
    break
  if n_new % 26 == 0:
    out.insert(0, str(26))
    n_new = int((n_new / 26) - 1)
  else:
    out.insert(0, str(n_new % 26))
    n_new = int(n_new / 26)
ans = ''
for i in out:
  ans = ans + chr(64 + int(i))
print(ans.lower())

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<long long> s(n+1, 0);
	for(int i = 1; i <= n; i++){
		cin >> s[i];
		s[i] += s[i-1];
	}
	vector<long long> v;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < i; j++){
			v.push_back(s[i] - s[j]);
		}
	}
	long long ans = 0;
	for(int i = 39; i >= 0; i--){
		long long nex = ans + (1LL << i);
		int cnt = 0;
		for(long long x : v){
			long long hoge = (x & nex);
			if(hoge == nex) cnt++;
		}
		if(cnt >= k) ans = nex;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) << num << endl;
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n; cin >> n;
    vector<Pll> a(n);
    rep(i,n){
        cin >> a[i].fi;
        a[i].se=i+1;
    }
    sort(ALL(a));
    reverse(ALL(a));
    ll dp[n+1][n+1];
    rep(i,n+1)rep(j,n+1) dp[i][j]=0;
    rep(i,n+1){
        rep(j,n+1){
            if(i>0&&i+j-1<n) chmax(dp[i][j],dp[i-1][j]+a[i+j-1].fi*(a[i+j-1].se-i));
            if(j>0&&i+j-1<n) chmax(dp[i][j],dp[i][j-1]+a[i+j-1].fi*(n+1-j-a[i+j-1].se));
        }
    }
    ll ans=0;
    rep(i,n+1) chmax(ans,dp[i][n-i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 34936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,D;
  cin >> N >> D;
  
  int X,Y,i;
  double l;
  int n=0;
  
  for(i=0;i<N;i++){
    cin >> X >> Y;
    l=sqrt(pow(X,2)+pow(Y,2));
    if(l<=D) n++;
  }
  cout << n<<endl;
	return 0;
}

Measured memory_bytes: 3676
n=int(input());c=0;d=0
a=list(map(int,input().split()))
for i in a :
    if i%2==0 :
        c+=1
        if i%3==0 or i%5==0 :
            d+=1
if c==d :
    print("APPROVED")
else :
    print("DENIED")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

bool dfs(int v,int t,vi& a,vvi& g){
	a[v]=t;
	for(auto u:g[v]){
		if(a[u]==0){
			if(dfs(u,-t,a,g)) return 1;
		}
		if(a[u]==t) return 1;
	}
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vvi g(n);
		for(int i=0;i<m;i++){
			int u,v;
			cin>>u>>v;
			u--;v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		vi a(n);
		if(dfs(0,1,a,g)){
			cout<<0<<endl;
			continue;
		}
		int x=0,y=0;
		for(int i=0;i<n;i++){
			if(a[i]>0) x++;
			else y++;
		}
		vi res;
		if(x%2==0) res.push_back(x/2);
		if(y%2==0&&x!=y) res.push_back(y/2);
		cout<<res.size()<<endl;
		sort(res.begin(),res.end());
		for(auto i:res) cout<<i<<endl;
	}
}


Measured memory_bytes: 3216
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    x = II()
    print((1999 - x) // 200 + 1)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 67544
# -*- coding: utf-8 -*-
import fractions
# input
a, b, c, d = map(int, input().split())
f = c*d//(fractions.gcd(c, d))
# calc
# cでわり切れる数
ac = (a-1)//c
bc = b//c
# dで割り切れる数
ad = (a-1)//d
bd = b//d
# かぶり
af = (a-1)//f
bf = b//f
# output
print((b-a+1)-((bc-ac)+(bd-ad)-(bf-af)))


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

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

    int ans = 1;
    for (int i = 1; pow(2, i) <= n; i++) {
        ans = pow(2, i);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> S;
  N = S.size();
  ;
}

int dp[2020201][3];
void solve() {
  rep(i, 0, N + 3) rep(j, 0, 2) dp[i][j] = -INF;

  dp[0][0] = 0;
  rep(i, 0, N) {
    rep(pre, 0, 2) {
      rep(d, 1, 3) {
        if (dp[i][pre] >= 0) {
          if (pre == d) {
            if (d == 1) {
              if (S[i - 1] == S[i]) continue;
            } else {
              if (S[i - 2] == S[i] && S[i - 1] == S[i + 1]) continue;
            }
          }
          dp[i + d][d] = max(dp[i + d][d], dp[i][pre] + 1);
        }
      }
    }
  }
  cout << max(dp[N][1], dp[N][2]) << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 6660
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int n;
  cin >> n;
  vector<int>sa(n+1);
  vector<int>sb(n+1);
  sa[0]=0;
  sb[0]=0;
  rep(i,n){
    int a;
    cin >> a;
    sa[i+1]=sa[i]+a;
  }
  rep(i,n){
    int b;
    cin >> b;
    sb[i+1]=sb[i]+b;
  }
  int ans=0;
  rep(i,n){
    int sum=sa[i+1]-sa[0]+sb[n]-sb[i];
    if(ans<sum)ans=sum;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int x[15][15];

int main() {
    ios_base::sync_with_stdio(0);
    int n, d; cin >> n >> d;
    for (int i=0;i<n;i++) {
        for (int j=0;j<d;j++) cin >> x[i][j];
    }

    int cnt = 0;
    for (int i=0;i<n;i++) for (int j=i+1;j<n;j++) {
        int dd = 0;
        for (int k=0;k<d;k++) dd += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        int pp = sqrt(dd);
        if (pp*pp==dd) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	ll n,i;
  	cin>>n;
  	vector<ll>v(n),a(n);
  	for(i=0;i<n;i++){
  		a[i]=1e18;
	  }a[0]=0;
  	for(i=0;i<n;i++){
  		cin>>v[i];
	  }for(i=0;i<n;i++){
	  	if(i+1<n){
	  		a[i+1]=min(a[i+1],a[i]+abs(v[i]-v[i+1]));
		  }if(i+2<n){
		  	a[i+2]=min(a[i+2],a[i]+abs(v[i]-v[i+2]));
		  }
	  }//for(i=0;i<n;i++)	cout<<a[i]<<" ";
	  cout<<a[n-1];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple

int main(){
  int h,w,n; cin >> h >> w >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  int ans[100][100] = {};
  int index = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a[index] == 0) index++;
      ans[i][(i%2 == 0)?j:w-j-1] = index+1;
      a[index]--;
    }
  }
  
  rep(i,h){
    rep(j,w){
      if(j==w-1)
        cout << ans[i][j];
      else
        cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
using System;

namespace Watch
{

	class Watch
	{
		static void Main()
		{
			int h;
			int m;
			int s;
			
			s = int.Parse(Console.ReadLine());
			
			h = s / (60 * 60);
			s -= (h * 60 * 60);
			
			m = s / 60;
			s -= (m * 60);

			Console.WriteLine(h + ":" + m + ":" + s + "\r");

		}
	}

}

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	string N;
	cin >> N;
	cou((N == "AAA" || N == "BBB" ? "No" : "Yes"));
	rep(i, 1000) {
		rep(j, 1000) {
			rep(k, 100) {
				N = "処理";
			}
		}
	}
}

Measured memory_bytes: 256
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
int a[200];
set < int > st;
int cnt[200];

int32_t main(){
    migmig
    cin >> n;
    for(int i = 0 ; i < n ; i ++)
        cin >> a[i] , st.insert(a[i]) , cnt[a[i]]++;
    sort(a , a + n);
    if(a[0]==1 and a[1] == 1)
        if(n==2)
            dokme("Possible")
        else
            dokme("Impossible")
    if(a[n-1]!=a[n-2])
        dokme("Impossible");
    if(a[n-1]%2 and cnt[a[n-1]/2+1]!=2)
        dokme("Impossible")
    if(a[n-1]%2==0 and cnt[a[n-1]/2]!=1)
        dokme("Impossible")
    for(int i = a[n-1] ; i >= (a[n-1] + 1)/2; i --)
        if(!st.count(i))
            dokme("Impossible")
        else
            st.erase(i);
    if(st.size() == 0)dokme("Possible")
    dokme("Impossible")
    return(0);
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[401][401];
ll mx=10000000000000000ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n+1];
    ll s[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    s[0]=0;

    for(int i=1;i<=n;i++)
        s[i]=s[i-1]+a[i];

    for(int i=n;i>=1;i--)
    {
        dp[i][i]=0;
        for(int j=i+1;j<=n;j++)
        {
            dp[i][j]=mx;
            for(int k=i;k<j;k++)
                dp[i][j]=min(dp[i][j],s[j]-s[i-1]+dp[i][k]+dp[k+1][j]);
        }
    }
    cout<<dp[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define SG string
#define DB double
#define LL long long
using namespace std;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	LL r=-2;LL num=Read();
	if(num==0){
        printf("0\n");return 0;
    }
    int res[100]={0};
    int cnt=0;
    while(num!=0){
        int mod=num%r;
        num/=r;
        if(mod<0){
            mod-=r;
            num++;
        }
        res[cnt++]=mod;
    }
    for(int i=cnt-1;i>=0;i--)
        printf("%d",res[i]);
	return 0;
}

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

struct Card{
  char c;
  int num;
};

Card a[40];
Card t[40];

int main(){
  int N; cin >> N;
  for( int i = 0; i < N; i++ ){
    cin >> a[i].c >> a[i].num;
    t[i] = a[i];
  }

  // bubble sort
  for( int i = 0; i < N - 1; i++ ){
    for( int j = N - 1; j >= 1; j-- ){
      if( t[j - 1].num > t[j].num ){
	Card tmp = t[j - 1];
	t[j - 1] = t[j];
	t[j] = tmp;
      }
    }
  }
  
  // selection sort
  for( int i = 0; i < N - 1; i++ ){
    int minj = i;
    for( int j = i; j < N; j++ ){
      if( a[j].num < a[minj].num ){
	minj = j;
      }
    }
    if( minj != i ){
      Card t = a[minj];
      a[minj] = a[i];
      a[i] = t;
    }
  }

  bool stable = true;
  for( int i = 0; i < N; i++ ){
    cout << t[i].c << t[i].num;
    if( i == N - 1 ) cout << endl;
    else cout << " ";

    if( t[i].c != a[i].c ) stable = false;
  }
  cout << "Stable" << endl;

  for( int i = 0; i < N; i++ ){
    cout << a[i].c << a[i].num;
    if( i == N - 1 ) cout << endl;
    else cout << " ";
  }
  if( stable ) cout << "Stable" << endl;  
  else cout << "Not stable" << endl;
}



Measured memory_bytes: 3108
n,a,b = map(int,input().split())
h=[int(input()) for i in range(n)]
def solve(t):
    cur = 0
    for i in range(n):
        cur +=max(-(-(h[i]-b*t)//(a-b)),0)
    return cur <= t

def binary_search(l,r):
    while abs(r-l) >1:
        mid = (l+r)//2
        if solve(mid):#判定のとこは別で
            r = mid
        else:
            l = mid
    return r
print(binary_search(0,10**9+1))

Measured memory_bytes: 50264
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	string s; cin >> s;
	printf("%s\n",((s.size()%2 == 0)^(s[0]==s.back()))?"Second":"First");
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
class UnionFind:
    """Union-Find(素集合データ構造)"""
    def __init__(self, n: int):
        """
        Constructer(Initialize parameter in this class)

        Parameters
        ----------
        n : int
            Number of node
        
        Yields
        -----
        root : list
            When value is postive, express root of the node.
            When it is negative, express this node is root and size of set.
        """

        self.root = [-1] * n

    def find(self, x: int):
        """
        Search root of node x

        Parameters
        ----------
        x : int
            node x

        Returns
        -------
        x : int
            Root of node x
        """

        if self.root[x] < 0:
            return x
        self.root[x] = self.find(self.root[x])
        return self.root[x]
    
    def unite(self, x: int, y: int):
        """
        Unite two set including node x and node y into one set.

        Parameters
        ----------
        x, y : int
            Node number

        Returns
        -------
        unite_result : bool
            False : Already two node include same set.
            True  : United
        """

        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.root[x] > self.root[y]:
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x
        return True

    def same(self, x: int, y: int):
        """
        Determine if x and y are in same set.

        Parameters
        ----------
        x, y : int
            Node number

        Returns
        -------
        result : bool
            Determining result
        """

        return self.find(x) == self.find(y)
    
    def size(self, x: int) -> bool:
        """
        Return size of set including node x.

        Parameters
        ----------
        x : int
            Node number

        Returns
        -------
        Size of set : int
        """

        return self.root[self.find(x)] * -1


def main():
    N, M = map(int, input().split())

    lst = UnionFind(N)
    for _ in range(M):
        a, b = map(int, input().split())
        lst.unite(a - 1, b - 1)

    ans = -1
    for i in lst.root:
        if i < 0:
            ans += 1
    print(ans)
    # print(lst.root)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10796
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
string str;
map<string,int>m;
queue<string>q;
int dir[]={1,-1,4,-4};

void bfs()
{
    q.push("01234567");
    while(!q.empty())
    {
        string temp=q.front();
        q.pop();
        int pos=temp.find('0');
        for(int i=0;i<4;++i)
        {
            int x=pos+dir[i];
            if(x>=0&&x<8&&(!(pos==3&&i==0))&&(!(pos==4&&i==1)))
            {
                string u=temp;
                swap(u[x],u[pos]);
                if(m[u]==0)
                {
                    m[u]=m[temp]+1;
                    q.push(u);
                }
            }
        }
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    bfs();
    m["01234567"]=0;
    while(1)
    {
        str="";
        int n=8,b;
        while(n--)
        {
            if(!(cin>>b))return 0;
            str+=b+'0';
        }
        printf("%d\n",m[str]);
    }

}



Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[110000][3];

int main()
{
    int n;
    cin >> n;
    rep(i,n){
        int p[3];
        cin >> p[0] >> p[1] >> p[2];
        rep(j,3)rep(k,3){
            if(j == k)continue;
            dp[i+1][j] = max(dp[i+1][j],dp[i][k]+p[j]);
        }
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7;

int cnt[N];
bool red[N];

signed main()
{
    IO_OP;
    
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cnt[i] = 1;
    red[1] = true;
    while (m--) {
        int x, y;
        cin >> x >> y;
        if (red[x]) {
            red[y] = true;
            cnt[x]--, cnt[y]++;
            if (cnt[x] == 0) red[x] = false;
        } else {
            cnt[x]--, cnt[y]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (red[i]) ans++;
    cout << ans << endl;

}

Measured memory_bytes: 768
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<assert.h>
#include<math.h>
#include<algorithm>
//#include<iostream>
using namespace std;

int n;
#define maxn 1000007
struct Hash
{
	int first[maxn],Next[maxn],list[maxn],Min[maxn],len;
	Hash() {memset(first,0,sizeof(first));len=0;}
	int hash(int x) {return x%maxn;}
	void insert(int x,int val)
	{
		int v=hash(x);
		for (int i=first[v];i;i=Next[i])
			if (list[i]==x) {Min[i]=min(Min[i],val);return;}
		len++;
		list[len]=x;
		Min[len]=val;
		Next[len]=first[v];
		first[v]=len;
	}
	int get(int x)
	{
		int v=hash(x);
		for (int i=first[v];i;i=Next[i])
			if (list[i]==x) return Min[i];
		return 0x3f3f3f3f;
	}
}h;
char s[maxn];
int f[maxn];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	h.insert(0,0);int now=0;
	for (int i=1;i<=n;i++)
	{
		now^=1<<(s[i]-'a');f[i]=h.get(now)+1;
		for (int j=0;j<26;j++)
			f[i]=min(f[i],1+h.get(now^(1<<j)));
		h.insert(now,f[i]);
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 13184
#include<stdio.h>
int main()
{
    int N, K;
    // 整数の入力
    scanf("%d", &N);
    scanf("%d", &K);

    printf("%d\n", N-(K-1));
/*
    // スペース区切りの整数の入力
    scanf("%d %d",&b,&c);
    // 文字列の入力
    scanf("%s",s);
    // 出力
    printf("%d %s\n",a+b+c,s);
*/
    return 0;
}
        

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

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

    long* T;
    long* A;
    NEW(T,N);
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%ld%ld",&T[i],&A[i]);
    }

    long t=T[0];
    long a=A[0];
    for(int i=1;i<N;i++){
        long c1=t/T[i];
        if(t%T[i]!=0) c1++;
        long c2=a/A[i];
        if(a%A[i]!=0) c2++;

        t=T[i]*MAX(c1,c2);
        a=A[i]*MAX(c1,c2);
    }
    printf("%ld\n",t+a);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli a,b;
	cin>>a>>b;
	if(a==b)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}
 
const int N=1e5+5;
bool v[N];
int cnt[N];
string s;
int n,m,ac,wa;
 
signed main(){
	read(n);read(m);
	while(m--){
		int p;
		read(p);
		cin>>s;
		if(s=="AC"){
			if(!v[p]) ac++,v[p]=1,wa+=cnt[p];
		}
		else{
			if(!v[p]) cnt[p]++;
		}
	}
	write(ac),putchar(' ');write(wa);
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,q;
    cin >> n >> q;
    string s; cin >> s;
    vector<int> vec(n);
    for(int i = 1; i < n; i++){
        if(s[i] == 'C' && s[i-1] == 'A') vec[i] = vec[i-1]+1;
        else vec[i] = vec[i-1];
    }
    for(int i = 0; i < q; i++){
        int l,r; cin >> l >>r;
        l--; r--;
        int ans = vec[r]-vec[l];
        if(l != 0 && vec[r]=='A' && vec[r+1]=='C') ans--;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int n; cin >> n;
    if (n % 2 == 0) cout << n / 2 << endl;
    else cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long


typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void solve() {
	int h; cin >> h;
    int cnt = 0;
    while(h > 1) {
        ++cnt; 
        h /= 2;
    }
    int ans = 1;
    rep(i, cnt + 1) {
        ans *= 2LL;

    }
    cout << ans - 1 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))

s=[0]*n
a.sort()
s[0]=a[0]
for i in range(1,n):
    s[i]=s[i-1]+a[i]
res=0
l=0
r=2*a[-1]+1
while r>l+1:
    x=(l+r)//2
    res=0
    for ai in a:
        j=x-ai
        cnt=bisect.bisect_left(a,j)
        res+=(n-cnt)
    if res<m:
        r=x
    else:
        l=x
ans=0
c=0
for ai in a:
    cnt=bisect.bisect_left(a,l-ai)
    ans=ans+ai*(n-cnt)+(s[-1]-s[cnt-1]) if cnt!=0 else ans+ai*(n-cnt)+s[-1]
    c+=(n-cnt)
ans-=(c-m)*l
print(ans)


Measured memory_bytes: 90008
class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                System.out.println(i + "x" + j + "=" + i * j);
            }
        }
    }
}


Measured memory_bytes: 24084
/*figure2.c*/

#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b && b < c) {
		printf("Yes\n");
	}else {
		printf("No\n");
	}
	return 0;
}

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

#define SZ(a) (int)a.size()
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;

string a[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main() {

  string s;
  cin >> s;
  
  int i = 0;
  
  while(a[i] != s) i++;
  
  cout << (7-i) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  while(true){
   int x = sc.nextInt();
   int y = sc.nextInt();
   int s = sc.nextInt();
   if(x==0 && y==0 && s==0) break;
   int max=-1;
   for(int j=1;j<s;++j){
    for(int i=1;i<s;++i){
     if( ((j*(100+x))/100) + ((i*(100+x))/100) == s){
      if( max < ((j*(100+y))/100) + ((i*(100+y))/100) ) {
       max = ((j*(100+y))/100) + ((i*(100+y))/100);
      }
     }
    }
   }
   System.out.println(max);
  }
 }
}


Measured memory_bytes: 29316
k,q = map(int,input().split())
d = list(map(int,input().split()))

def query(n,x,m):
    res = n-1
    n -= 1
    x %= m
    s1 = 0
    t1 = 0
    for i in range(k):
        s1 += d[i]%m
        if d[i]%m==0:
            t1 += 1
    s2 = 0
    t2 = 0
    for i in range(n%k):
        s2 += d[i]%m
        if d[i]%m==0:
            t2 += 1
    x += s1*(n//k)+s2
    res -= x//m
    res -= t1*(n//k)+t2
    return res

for i in range(q):
    n,x,m = map(int,input().split())
    print(query(n,x,m))

Measured memory_bytes: 51176
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int i,j,k,l,x,y,z,n,f[10010]={};
    scanf("%d",&n);
    for(i=1; i<100; i++){
        for(j=i; j<100; j++){
            for(k=j; k<100; k++){
                for(l=1; l<=n; l++){
                    if(i*i+j*j+k*k+i*j+j*k+k*i==l){
                        if(i!=j && j!=k && k!=i)f[l]+=6;
                        else if(i==j && j==k)f[l]++;
                        else{f[l]+=3;}
                    }
                }
            }
        }
    }
    for(i=1; i<=n; i++){
        printf("%d\n",f[i]);
    }
    return 0;
}

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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}

mkv vin(int n){
    mkv v;
    fo(i,n){
        int t;cin>>t;v.pb(t);
    }
    return v;
}

vector<int>ch;
const int N=1e6+10;
int p[N+10];
int q[N+10];


bool prime()
{
    for(int i=2;i<N;i++){
        int cnt=0;
        if(p[i])cnt++;
        if(!q[i]){
            for(int j=i+i;j<=N;j+=i){
                q[i]=1;
                if(p[j]){
                    cnt++;
                }
                if(cnt>1)
                    return false;
            }
        }
    }
    return true;
}

void solve()
{
    int n;cin>>n;
    int a[n];fo(i,n)cin>>a[i];
    bool c=1;
    fo(i,n){
        if(p[a[i]]&&a[i]!=1){
            c=0;
            break;
        }
        p[a[i]]=1;
    }
    if(c){
        c=prime();
    }
    int gcd=a[0];
    for(int i=1;i<n;i++){
        gcd=__gcd(gcd,a[i]);
    }
  //  dbg(gcd)
    if(c&&gcd==1){
        cout<<"pairwise coprime"<<endl;
        return;
    }
    if(gcd==1){
        cout<<"setwise coprime"<<endl;
        return;
    }
    cout<<"not coprime"<<endl;

}

int main()
{
  //  fastio();
//    test
    solve();
}


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

int main(){
  vector<int> v(3);
  cin>>v[0]>>v[1]>>v[2];
  sort(v.begin(),v.end());
  if(v[0]==5 && v[1]==5 && v[2]==7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n,a,b; cin>>n>>a>>b;
    ll x=0;
    if(a+b>=n) x=n-(a+b);
    cout << min(a,b) << " " << abs(x) << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int cnt_A {A/D + ((A%D)?1:0)};
  int cnt_C {C/B + ((C%B)?1:0)};
  if (cnt_A >= cnt_C) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    P student[n];
    P ans[n];
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        student[i] = P(a, b);
        ans[i] = P(-1, INF);
    }
    rep(i, m) {
        int c, d;
        cin >> c >> d;
        rep(j, n)if(ans[j].se > abs(student[j].fi - c) + abs(student[j].se - d)) {
            ans[j].fi = i + 1;
            ans[j].se = abs(student[j].fi - c) + abs(student[j].se - d);
        }
    }

    rep(i, n) cout << ans[i].fi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll n, ans = 300000;
  string s;
  cin >> n >> s;
  ll sumLeft[n], sumRight[n];
  sumLeft[0] = sumRight[n - 1] = 0;
  for (ll i = 1; i < n; i++) {
    sumLeft[i] = sumLeft[i - 1];
    if (s[i - 1] != 'E') sumLeft[i] += 1;
  }
  for (ll i = n - 2; i >= 0; i--) {
    sumRight[i] = sumRight[i + 1];
    if (s[i + 1] != 'W') sumRight[i] += 1;
  }
  for (ll i = 0; i < n; i++) if (sumLeft[i] + sumRight[i] < ans) ans = sumLeft[i] + sumRight[i];
  cout << ans << endl;
}


Measured memory_bytes: 5380