akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int x = sc.nextInt();

      int cnt = 0;
      for(int i = 0; i <= a; i++) {
        for(int j = 0; j <= b; j++) {
          for(int k = 0; k <= c; k++) {
            if((i*500)+(j*100)+(k*50)==x) {
              cnt++;
            }
          }
        }
      }
      
      System.out.println(cnt);
      
	}
}

Measured memory_bytes: 21972
solve :: Int -> String
solve largeN = h ++ " " ++ n ++ " " ++ w
  where
      l = [1 .. 3500]
      h:n:w:_ = fmap show $ head [[h, n, ((largeN * h * n) `div` (4 * h * n - largeN * n - largeN * h))] | h <- l, n <- l, (4 * h * n - largeN * n - largeN * h) > 0, (largeN * h * n) `mod` (4 * h * n - largeN * n - largeN * h) == 0]

main :: IO ()
main = do
  largeN <- readLn :: IO Int
  putStrLn $ solve largeN


Measured memory_bytes: 764
x, k, d = gets.split(" ").map(&:to_i)
x = x.abs
if x - d * k > 0
    ans = x - d * k
else
    k -= x / d
    x -= x / d * d
    x = (x - d) if k % 2 == 1
    ans = x.abs
end
puts ans


Measured memory_bytes: 14344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
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 (long long 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(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
  	if(n==k){
      return 1;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// vector<vector<int>> A(3, vector<int>(4));
int main() {
    ll a,b,x;
    cin>>a>>b>>x;
   ll c=b/x;
  ll d=(a-1)/x;
  	if(a==0&&x!=1){
      c+=1;
    }
    cout<<c-d<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int d(ll n) {
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    vector<ll> rui(n + 1);
    rui[0] = 0;
    map<ll, ll> mp;
    mp[0]++;
    rep1(i, n) {
        ll a;
        cin >> a;
        rui[i] += rui[i - 1] + a;
        mp[rui[i]]++;
    }
    ll ans = 0;
    for(auto p : mp) ans+= p.second * (p.second - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 17164
INF = 10 ** 20
def get_dist(r1, r2):
  return ((r1 + r2) ** 2 - (r1 - r2) ** 2) ** (1 / 2)

def minimum_width(rest, r, dic):
  if (rest, r) in dic:
    return dic[(rest, r)]
  if rest == ():
    return r

  ret = INF
  lenr = len(rest)
  for c in rest:
    next_rest = list(rest)
    next_rest.remove(c)
    ret = min(ret, minimum_width(tuple(next_rest), c, dic) + get_dist(r, c))
  dic[(rest, r)] = ret
  return ret


while True:
  try:
    lst = list(map(int, input().split()))
    w = lst[0]
    cakes = lst[1:]
    cakes.sort()
    lenc = len(cakes)
    dic = {}
    ans = INF
    for i in range(lenc):
      ans = min(ans, minimum_width(tuple(cakes[j] for j in range(lenc) if i != j), cakes[i], dic) + cakes[i])
    if w >= ans:
      print("OK")
    else:
      print("NA")
  except EOFError:
    break


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, sum = 0, x = 0, a;
  cin >> n;
  vector<int> ten(0);
  vector<int> nwot(0);
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a%10 == 0) ten.push_back(a);
    else nwot.push_back(a);
    sum += a;
  }
  if (nwot.size()) sort(nwot.begin(), nwot.end());

  while (sum%10 == 0 && x < nwot.size()) {
    sum -= nwot[x];
    x++;
  }
  x = 0;
  while (sum%10 == 0 && x < ten.size()) {
    sum -= ten[x];
    x++;
  }
  cout << sum << '\n';

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
//int i,j,k,l;
int a,b,c,d,e,f,g,h;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int main(void)
{
    scanf("%d %d",&h,&a);
    b=h/a;
    if (h%a==0)
    {
        printf("%d\n",b);
    }else
    {
        printf("%d\n",b+1);
    }
    
    
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll fond[27];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >>n;
    string c;
    F0R(i,n) {
      cin >> c;
      fond[c[0] - 65]++;
    }

    char pool[5] = {'M','A','R','C','H'};
    // F0R(i,5) cout << fond[pool[i] - 65]<<endl;
    vector<string> nabors;
    F0R(i,5) {
      FOR(j,i+1,5){
        string temp = "";
        F0R(z,5){
          if(z != j && z != i)
            temp +=string(1,pool[z]);
        }
        nabors.pb(temp);
        // cout << temp<<endl;
      }
    }

  ll sum = 0;
  F0R(i,sz(nabors)){
    ll partial = 1;
    F0R(j,nabors[i].length())
      partial *= fond[nabors[i][j] - 65];
    sum += partial;
  }

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

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#define MAX 101


int min(int,int);

int main(){

  int n,i,j=0,k,l,q;
  int r[MAX];
  int c[MAX];
  int m[MAX][MAX];
  int p[MAX];

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++){
    scanf("%d%d",&r[i],&c[i]);   
    p[i] = r[i];
  }

  p[i] = c[i-1];

  
  // make m[][]
  for(i = 1 ; i <= n ; i++){
    m[i][i] = 0;
  }
  
  for(l = 2 ; l <= n ; l++){
    
    for( i = 1 ; i <= n-l+1 ; i++){
      j = i+l-1;
      m[i][j] = 100000;
      
      for( k = i ; k <= j-1 ;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];

	m[i][j] = min(m[i][j],q);
      }

    }

  }

  printf("%d\n",m[i-1][j]);

  
  return 0;
}
    

int min(int a,int b){
  if(a < b) return a;
  else return b;
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
long long x;
long long solve(){
    long long a = x/11;
    long long ans = 0;
    ans += a * 2;
    x -= a * 11;
    if(x > 0){
        ans += x/7 + 1;
    }
    return ans;
}
int main(){
    cin >> x;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

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

    cout<<N/3<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
#define M 500


int main(void){
  int i, j, n, q, S[N], T[M], a, b, count=0;
  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]);

  for(i=0; i<n ;i++){
    for(j=0; j<q ;j++){
    
a = S[i];
    b = T[j];
    if(a == b) { count++; T[j] = -1; }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
   ll N;
   cin>>N;
   vector<ll> C(N);
    vector<ll> S(N);
     vector<ll> F(N);

     for(ll i=0;i<N-1;i++)cin>>C[i]>>S[i]>>F[i];


     for(ll i=0;i<N-1;i++){
       ll t = 0;
      for(ll j=i;j<N-1;j++){
       ll tt=0;
        if(S[j]-t>=0){
          tt=S[j]-t;
        }
        else{
          ll P = ((t-S[j])/F[j]);
          if((t-S[j])%F[j]==0){
            tt=0;
          }
          else{
            tt = F[j] - (t - (S[j]+F[j]*P));
          }
        }



        t += C[j]+tt;
      }
      cout<<t<<endl;
     }
     cout<<0<<endl;



}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    S = input()

    # 10文字までしかないので、一個ずつ見ていっても良いのでは
    result = 10**10
    for i in range(0, len(S) - 2):
        result = min(abs(753 - int(S[i:i+3])), result)

    print(result)


main()


Measured memory_bytes: 5836
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,ans=0;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    if(A.at(i)==i+1 && i<N-1){
      int a=A.at(i);
      int b=A.at(i+1);
      A.at(i)=b;
      A.at(i+1)=a;
      ans++;
    }
    else if(i==N-1 && A.at(i)==i+1){
      int a=A.at(i);
      int b=A.at(i-1);
      A.at(i)=b;
      A.at(i-1)=a;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a[3][3], n, m[3][3];
	memset(m, 0, sizeof(m));
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	int b[n];
	cina(b, n);
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < n; ++k) {
				if (a[i][j] == b[k])
					m[i][j] = 1;
			}
		}
	}
	for (int i = 0; i < 3; ++i) {
		if (m[i][0] && m[i][1] && m[i][2]) {
			cout << "Yes";
			return 0;
		}
	}
	for (int i = 0; i < 3; ++i) {
		if (m[0][i] && m[1][i] && m[2][i]) {
			cout << "Yes";
			return 0;
		}
	}
	if ((m[0][0] && m[1][1] && m[2][2]) || (m[0][2] && m[1][1] && m[2][0])) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            List<long> lunlun = new List<long>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            int ps = 0;
            while (lunlun.Count < K == true)
            {
                int pe = lunlun.Count;
                for (int i = ps; i < pe; i++)
                {
                    long N = lunlun[i] * 10;
                    if (lunlun[i] % 10 != 0)
                    {
                        lunlun.Add(N + (lunlun[i] % 10 - 1));
                    }
                    lunlun.Add(N + (lunlun[i] % 10));
                    if (lunlun[i] % 10 != 9)
                    {
                        lunlun.Add(N + (lunlun[i] % 10 + 1));
                    }
                }
                ps = pe;
            }
             lunlun.Sort();
             Console.WriteLine(lunlun[K-1]);

            


        }
    }
}

Measured memory_bytes: 14816
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
const int N = 201;
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;
char s1[N], s2[N];
int main()
{
#ifndef ONLINE_JUDGE  
  //  freopen("in.txt","r" ,stdin);
    // freopen("out.txt", "w", stdout);
#endif 
    
    while (~scanf("%s%s", s1, s2))
    {
        const char *f[] = {"LESS", "GREATER", "EQUAL"};
        int a1 = strlen(s1), a2 = strlen(s2);
        if (a1 > a2)
            puts("GREATER");
        else if (a1 < a2)
            puts("LESS");
        else
        {
            int c = 2;
            for (int i = 0; i < a1; i++)
            {
                if (s1[i] > s2[i])
                {
                    c = 1;
                    break;
                }else if (s1[i] < s2[i])
                {
                    c = 0;
                    break;
                }
            }
            puts(f[c]);
        }
    }
    return 0;
}

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

int main(){
  int Inf = 1000000;
  int n,m;
  cin >> n >> m;
  int c[100000+5];
   for (int i=0; i<n+5; i++){
    c[i+1] = Inf; 
  }
  for (int i=0; i<m; i++){
    int x,y;
    cin >> x >> y;
    c[x] = min(c[x], y); 
  }
  int i=1;
  int k=-1;
  int s=0;
  for (int i=1; i<=n; i++){
    if (c[i] == Inf){
      true;
    } else if(i < k){
      k = min(c[i],k);
    } else {
      s += 1;
      k = c[i];
    }
  }
  cout << s;
}

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

using namespace std;

#define int long long

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef unordered_map<int,int> mii;
typedef unordered_map<char,int> mci;
typedef unordered_map<string,int> msi;

#define pb push_back
#define f first
#define s second 
 
vvi graph(100001);
vi dp(100001);
vi vis(100001,false);

void dfs(int s) {
   vis[s]=true;
   int ans = -1;
   for(auto u : graph[s]) {
        if(!vis[u]) {
            dfs(u);
        }
        ans  = max(ans,dp[u]);
   }
   ans = ans + 1;
   dp[s] = ans;
}


void solve() {
    int n,m,u,v;cin>>n>>m;
    for(int i=0;i<m;i++) {
        cin>>u>>v;
        graph[u].pb(v);
    }
    for(int i=1;i<=n;i++) {
        if(!vis[i]) {
            dfs(i);
        }
    }
    int ans= -1;
    for(int i=1;i<=n;i++) {
        ans = max(ans,dp[i]);
    }
    cout<<ans<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //#ifdef ONLINEJUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int tc; tc=1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}

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

using namespace std;

int main(){
    long long N;
    cin>>N;

    deque<long long> arr;

    while(N!=0){
        long long tmp=N%10;
        arr.push_front(tmp);
        N/=10;
    }

    vector<pair<long long,long long>> nana;

    for(long long i=0;i<arr.size()-2;i++){
        long long si=arr[i]*100+arr[i+1]*10+arr[i+2];
        nana.emplace_back(make_pair(abs(si-753),si));

    }

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


    

    cout<<nana[0].first<<endl;
}

Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#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>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12032
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
ans = 0
m = len(s)
size = m // 2
cnt_ss = m - 1
cnt_s = 0
for i in range(m):
    if s[cnt_s] == s[cnt_ss]:
        if cnt_s != size:
            cnt_s += 1
        if cnt_ss != size:
            cnt_ss -= 1
    elif s[cnt_s] == 'x':
        cnt_s += 1
        ans += 1
        m += 1
    elif s[cnt_ss] == 'x':
        cnt_ss -= 1
        ans += 1
        m -= 1
    else:
        print(-1)
        exit()
    size = m // 2
    if cnt_ss == cnt_s == size:
        break
print(ans)


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

int main() {
  int N,M,X,Y,i,j;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for(i=0; i<N; i++)
    cin >> x.at(i);
  for(i=0; i<M; i++)
    cin >> y.at(i);
  for(i=Y; i>X; i--) {
    for(j=0; j<N; j++)
      if(x.at(j) >= i)
        break;
    if(j!=N)
      continue;
    for(j=0; j<M; j++)
      if(y.at(j) < i)
        break;
    if(j!=M)
      continue;
    break;
  }
  
  if(i!=X)
    cout << "No War";
  else
    cout << "War";
  cout << endl;
}

Measured memory_bytes: 256
import sys

N = int(input())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7

count = [0] * N
for i in a:
    count[i] += 1
count[0] += 1
for i in count[1-N%2::2]:
    if i != 2:
        print(0)
        sys.exit()
s = N // 2
print(pow(2, s, mod))


Measured memory_bytes: 14008
#include <iostream>
#include <cstdlib>
#define llint long long

using namespace std;

llint H, W, D;
llint A[305][305];
llint Q;
llint X[90005], Y[90005];
llint sum[90005];

int main(void)
{
	cin >> H >> W >> D;
	for(int y = 1; y <= H; y++){
		for(int x = 1; x <= W; x++){
			cin >> A[x][y];
			X[A[x][y]] = x;
			Y[A[x][y]] = y;
		}
	}
	
	for(int i = D; i <= H*W; i++){
		sum[i] = sum[i-D] + abs(X[i] - X[i-D]) + abs(Y[i] - Y[i-D]);
	}
	
	llint L, R;
	cin >> Q;
	for(int q = 0; q < Q; q++){
		cin >> L >> R;
		cout << sum[R] - sum[L] << endl;;
	}
	return 0;
}

Measured memory_bytes: 3968
cards = [int(s) for s in input().split()]
if (cards[3] - cards[0])<= 0:
  print(cards[3])
else:
  d = cards[3] - (cards[0] + cards[1])
  if d > 0:
    print(cards[0]-d)
  else:
    print(cards[0])

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

ans=[0]*(N+1)
t=int(N**0.5+1)
for x in range(1, t):
    for y in range(1, t):
        for z in range(1, t):
            v=x*x+y*y+z*z+x*y+y*z+z*x
            if v<=N: ans[v]+=1
for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 9484
N, K = map(int, input().split())
A = input().split()
A_MAP = {}
for i in range(N):
    A_MAP[str(i+1)] = A[i]

route_hash = {'1': 0}
current_pos = '1'
next_pos = ''
counter = 0
breaked = False
while counter < K:
    next_pos = A_MAP[current_pos]
    counter+=1
    if next_pos in route_hash:
        breaked = True
        break
    route_hash[next_pos] = counter # たどり着くまでにかかった回数
    current_pos = next_pos

if not breaked:
    print(current_pos)
    exit()

remain = K - counter
counter -= route_hash[next_pos]
remain = remain % counter

current_pos = next_pos
for i in range(remain):
    next_pos = A_MAP[current_pos]
    route_hash[next_pos] = counter # たどり着くまでにかかった回数
    current_pos = next_pos
print(current_pos)


Measured memory_bytes: 61492
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

const int INF=1e9;
const int MX=1e5+5;
int n,k,id[MX],l[MX],r[MX];
vector<int> adj[MX];
bool ok;

void dp(int u,int p){
	l[u]=-INF,r[u]=INF;
	if(~id[u]) l[u]=r[u]=id[u];
	for(int v:adj[u]) if(v!=p){
		dp(v,u);
		if(l[v]==-INF) continue;
		if(l[u]==-INF) l[u]=l[v]-1,r[u]=r[v]+1;
		else{
			if(abs(l[u])%2==abs(l[v])%2){
				ok=false;
				return;
			}
			l[u]=max(l[u],l[v]-1);
			r[u]=min(r[u],r[v]+1);
		}
	}
	if(l[u]>r[u]) ok=false;
}

void make(int u,int p){
	if(u==1&&id[u]==-1) id[u]=l[u];
	for(int v:adj[u]) if(v!=p){
		if(id[v]==-1){
			if(l[v]<=id[u]-1&&id[u]-1<=r[v]) id[v]=id[u]-1;
			else id[v]=id[u]+1;
		}
		make(v,u);
	}
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n;
	for(int i=0;i<n-1;++i){
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	cin>>k;
	memset(id,-1,sizeof id);
	for(int i=0;i<k;++i){
		int v,p;
		cin>>v>>p;
		id[v]=p;
	}
	ok=true;
	dp(1,-1);	
	if(!ok){
		cout<<"No\n";
		return 0;
	}
	make(1,-1);
	cout<<"Yes\n";
	for(int i=1;i<=n;++i) cout<<id[i]<<'\n';
}

Measured memory_bytes: 13824
#include<stdio.h>

int main(void)
{

    int W,H;
    int i,j;

    scanf("%d %d",&H,&W);

    while(W != 0 && H != 0){
      for(i = 0;i<H;i++){
        for(j=0;j<W;j++){
          if((i+j) % 2 == 0)
            printf("#");
          else
            printf(".");
        }
        printf("\n");
      }

      scanf("%d %d",&H,&W);
      printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

const int N = 101, INF = 1e9;
int f[N][N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            if (i != j) 
                f[i][j] = INF;

    vector <vector <int> > ed;
    for (int i = 0; i < m; ++i) {
        int u, v, c;
        cin >> u >> v >> c;
        ed.app({u, v, c});
        f[u][v] = f[v][u] = c;
    }   

    for (int k = 1; k <= n; ++k)
        for (int u = 1; u <= n; ++u)
            for (int v = 1; v <= n; ++v)
                f[u][v] = min(f[u][v], f[u][k] + f[k][v]);

    int ans = 0;
    for (auto e : ed) {
        int u = e[0], v = e[1], c = e[2];

        bool us = 0;
        for (int s = 1; s <= n; ++s)
            for (int t = 1; t <= n; ++t)
                us |= f[s][u] + c + f[v][t] == f[s][t];
        ans += !us;
        
    }   
    cout << ans << endl;
}


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

using namespace std;
//using namespace __gnu_pbds;

typedef long long int	ll;
typedef long double	ld;
typedef pair<int,int>   ii;
typedef vector< ii >   vii;
typedef vector<int>     vi;
typedef vector< vi >   vvi;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mm 1000005
#define nn 5005
#define xx real()
#define yy imag()
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define cases ll t;  cin>>t;   while(t--)
#define check(a,n) forn(iiii,int(n)) cout<<int(a[iiii])<<" "; cout<<endl
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_io;
    ll ans=0,x,y,t=1;
    cin>>x>>y;
    while(t<=1e18)
    {
        if(x*t<=y) ans++;
        else break;
        t*=2;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
<?php
$input = STDIN;

$n = intval(trim(fgets($input)));

$taro = 0;
$hanako = 0;
for ($i = 0; $i < $n; $i++) {
    list($t, $h) = explode(' ', trim(fgets($input)));
    $result = strcasecmp($t, $h);
    if ($result < 0) {
        $hanako += 3;
    } elseif ($result == 0) {
        $taro++;
        $hanako++;
    } else {
        $taro += 3;
    }
}

print "{$taro} {$hanako}\n";


Measured memory_bytes: 9232
// Math = ♥️

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

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll h, w;
    cin >> h >> w;

    ll ans = min((h % 3) * w, (w % 3) * h);

    if (h % 3 == 2) {
        ans = min(ans, w);
    }

    if (w % 3 == 2) {
        ans = min(ans, h);
    }

    for (int x = 1; x < h; x++) {
        ll arr[3];
        arr[0] = x * w;
        arr[1] = (w / 2) * (h - x);
        arr[2] = (w - (w / 2)) * (h - x);
        sort(arr, arr + 3);
        ans = min(arr[2] - arr[0], ans);
    }

    for (int x = 1; x < w; x++) {
        ll arr[3];
        arr[0] = x * h;
        arr[1] = (h / 2) * (w - x);
        arr[2] = (h - (h / 2)) * (w - x);
        sort(arr, arr + 3);
        ans = min(arr[2] - arr[0], ans);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

int n;
ll m, v, p;
ll a[100010];
ll pref[100010];
int ans;

int main() {
    scanf("%d%lld%lld%lld", &n, &m, &v, &p);
    for (int i = 0; i < n; i++)
        scanf("%lld", &a[i]);
    sort(a, a + n);
    reverse(a, a + n);//排到序 
    for (int i = 0; i < n; i++)
        pref[i + 1] = pref[i] + a[i];
    ans = p;
    for (int i = p; i < n; i++) {
        if (a[i] + m < a[p - 1]) break;
        ll cur = v - (n - (i - p + 1));
        if (cur <= 0) {
            ans++;
            continue;
        }
        if (cur * m <= (i - p + 1) * (a[i] + m) - (pref[i] - pref[p - 1]))
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1664
import itertools  

N,M,Q=map(int,input().split())
As = list(itertools.combinations_with_replacement(range(1,M+1),N))

nums=[[0,0,0,0]for i in range(Q)]
ans =[]
for i in range(Q):
    nums[i] = list(map(int, input().split()))

for A in As:
    t=0
    for i in range(Q):
        if A[nums[i][1]-1]-A[nums[i][0]-1] == nums[i][2]:
            t += nums[i][3]  

    ans.append(t)

print(max(ans))

Measured memory_bytes: 25096
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll x;
  cin >> x;
  
  ll i = 100;
  ll ans = 0;
  while (i < x){
    i = (ll)(i * 1.01);
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

#define max(a,b) a > b ? a : b

int main() {

    int N, M;

    cin >> N >> M;

    if (N == M)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n; cin >> n;
	long long maxa = 0, ans = 0;
	for (int i = 0; i < n; ++i) {
		long long a; cin >> a;
		if (maxa > a) ans += maxa - a;
		maxa = max(maxa, a);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 900000000000000000
signed main(void) {
    int k,s;cin>>k>>s;
    int ans=0;
    rep(i,k+1)rep(j,k+1){
        if(s-i-j<=k&&s-i-j>=0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string ch;
	cin>>ch;
	int a=0,b=0;
	a=(ch[0]-'0')*10+ch[1]-'0';
	b=(ch[2]-'0')*10+ch[3]-'0';
	if(a<=12&&a>0)
	  if(b<=12&&b>0)
	    cout<<"AMBIGUOUS";
	  else
	    cout<<"MMYY";
	else if(b<=12&&b>0)
	    cout<<"YYMM";
	  else
	    cout<<"NA";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    string s;
    cin >> s;
    bool b;
    b = false;
    rep(i, 3) {
        if (s.at(i) == s.at(i+1)) {
            b = true;
            break;
        }
    }
    if (b == false) {
        cout << "Good" << endl;
        }
    else {
        cout << "Bad" << endl;
        }
    }


Measured memory_bytes: 256
#include <cstdio>

const int m = 1000000007;
long long b[2001];
long long c[2001][2002];
long long dp[2001][2002];

int main() {
    int n, k, i, j;
    long long ans = 0;
    
    scanf("%d %d", &n, &k);
    
    b[0] = b[1] = 1;
    for (i = 2; i <= n; i++) b[i] = b[i - 1] * 2 % m;
    
    for (i = 0; i <= n; i++) {
        c[i][0] = c[i][i] = 1;
        for (j = 1; j < i; j++) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % m;
    }
        
    
    dp[0][0] = 1;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= n; j++) {
            if (i > 0) dp[i][j] += dp[i - 1][j + 1];
            if (j > 0) dp[i][j] += dp[i][j - 1];
            if (dp[i][j] >= m) dp[i][j] -= m;
        }
    }
    
    if (n == k) {
        ans = dp[n - 1][0];
    } else {
        for (i = n - k; i < n; i++) {
            ans += c[i - 1][n - k - 1] * dp[n - i - 1][i - n + k] % m;
            if (ans >= m) ans -= m;
        }
        
        ans = ans * b[n - k] % m;
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 54144
#include <iostream>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    if ((n / 100 == 7) || ((n / 10) % 10 == 7) || (n % 10 == 7)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
    int n,cnt=0;
  cin >> n;
  string s = to_string(n);
  
  for (int i = 0; i < s.size(); i++) {
    cnt += (int)s.at(i) - '0';
  }
  if (n % cnt == 0) {
    cout << "Yes" << endl;
  }
  else if (n % cnt != 0) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,t;
	int a[200005],b[200005];
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			b[i]=a[i];
		}
		sort(a,a+n);
		for(int j=0;j<n;j++)
		{
			if(b[j]==a[n-1])
			m=j;
			if(a[n-2]==b[j])
			t=j;
		}
		for(int i=0;i<n;i++)
		{
			if(i!=m)
			printf("%d\n",a[n-1]);
			else
			printf("%d\n",a[n-2]);
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#coding:UTF-8
def maxHeapify(A,i,n):
    l=2*i
    r=2*i+1
    if l <=n and A[l]>A[i] :
        largest=l
    else:
        largest=i
    if r<=n and A[r]>A[largest]:
        largest=r
    if largest!=i:
        A[i],A[largest]=A[largest],A[i]
        maxHeapify(A,largest,n)

def MH(A,n):
    for i in range(int(n/2),0,-1):
        maxHeapify(A,i,n)
    A.remove(-1)
    for i in range(len(A)):
        A[i]=str(A[i])
    print(" "+" ".join(A))        
if __name__=="__main__":
    H=int(input())
    A=input().split(" ")
    for i in range(len(A)):
        A[i]=int(A[i])
    A=[-1]+A
    MH(A,H)

Measured memory_bytes: 49492
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
//#define int ll
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

double r;

signed main(){
  cin>>r;
  printf("%.10lf\n",2.0*3.1415926535*r);
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = (int)1e5 + 100;
ll a[maxN];
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    srand(228);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    int cnt = 0;
    ll mn = (ll)1e18;
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            cnt ^= 1;
            a[i] = -a[i];
        }
        sum += a[i];
        mn = min(mn, a[i]);
    }
    if (cnt % 2 == 0) {
        cout << sum;
    }
    else {
        cout << sum - 2 * mn;
    }
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

const int MOD = 1e9 + 7;

ll mulm(ll x, ll y){
	return ((x%MOD)*(y%MOD))%MOD;
}

ll powm(ll x, ll y){
  	if(y==0) return 1;
  	else if(y==1) return x;
	else if(y%2==0) return mulm(powm(x, y/2),powm(x, y/2));
  	else return mulm(mulm(powm(x, y/2),powm(x, y/2)), x);
}

void Main()
{
	int n;
  	cin >> n;
	vi a(n), b(n);
  	rep(i,n) cin >> a[i];
	sort(rall(a));
	
  	rep(i,n) {
      	if(a[i] + 1 != n-(i/2)*2) {
        	cout << 0 << endl;
      		return;
        }
    }
  
  	cout << powm(2,n/2) << endl;
    return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 1024
/*
    Author: Arham_doshi
    @quote "Code like there's no tommorow!"
     ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
    */
    #include <bits/stdc++.h>
     
    #define int         long long
    #define double      long double
    #define pb          push_back
    #define pf          push_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    #define x           first
    #define y           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define hell        998244353 
    #define PI          3.141592653589
    #define bs(v,n)     binary_search(all((v)),(n))
    #define lb(v,n)     lower_bound(all((v)),(n))
    #define ub(v,n)     upper_bound(all((v)),(n))
    #define fo(i,l,u)   for(i=l;i<u;i++)
    #define rfo(i,l,u)  for(i=l;i>=u;i--)
    #define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
    #define _init(b)     memset(b,-1,sizeof(b))
    #define _init0(b)     memset(b,0,sizeof(b))
     
    using namespace std;
     
    int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
    bool mod(double a,double b) {return a/b - floor(a/b);}
     
    int occurs(vi v,int n){
    auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
     
    int logb(int base, int x) {
        return (log(x) / log(base));
    }
     
     
    int a[100005],b[100005];
     
     
    int cost(int n,int k){
        if(n<0)return 0;
        else if(b[n]!=-1)return b[n];
        else{
            int i=n;
            fo(i,1,k+1){
                if(n-i>=0){
                    if(b[n]==-1) b[n]=cost(n-i,k)+abs(a[n]-a[n-i]);
                    else b[n]=min(b[n],cost(n-i,k)+abs(a[n]-a[n-i]));
                }
                else break;
                
            }
            //b[n]=min(cost(n-1)+abs(a[i]-a[i-1]),cost(n-2)+abs(a[i]-a[i-2]));
            return b[n];
        }
    }
     
     
     
    signed main()
    {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        int i,j,x,t,n,k;
       cin>>n>>k;
       _init(b);
       _init0(a);
       fo(i,0,n){
           cin>>x;
           a[i]=x;
       }
       
       b[0]=0;
       b[1]=abs(a[0]-a[1]);
       
         cout<<cost(n-1,k);
     
        return 0;
    }

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main() {
	int i, j, k;
	int r, c;
	int b;
	cin >> r >> c;
	int rsum[100] = {};
	int csum[100] = {};
	int sum = 0;
	for (i = 0; i < r; i++) {
		cin >> b;
		cout << b;
		rsum[i] += b;
		csum[0] += b;
		for (j = 1; j < c; j++) {
			cin >> b;
			cout << " " << b;
			rsum[i] += b;
			csum[j] += b;
		}
		cout << " " << rsum[i] << endl;
		sum += rsum[i];
	}
	cout << csum[0];
	for (j = 1; j < c; j++) {
		cout << " " << csum[j];
	}
	cout << " " << sum << endl;
	return 0;
}



Measured memory_bytes: 3084
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int n; vector<vector<vector<double>>> dp;
double ans(int x,int y,int z){
	if(dp[x][y][z]>=0) return dp[x][y][z];
	if(x==0&&y==0&&z==0) return 0;
	double res=0.0;
	if(x>0) res+=ans(x-1,y,z)*x;
	if(y>0) res+=ans(x+1,y-1,z)*y;
	if(z>0) res+=ans(x,y+1,z-1)*z;
	res+=n; res*=1.0/(x+y+z);
	return dp[x][y][z]=res;
}

int main() {
	cin>>n;
	dp.resize(n+1);
	rep(i,0,n+1){
		dp[i].resize(n+1);
		rep(j,0,n+1) dp[i][j].resize(n+1,-1);
	}
	int cnt1=0,cnt2=0,cnt3=0;
	rep(i,0,n){
		int p1; cin>>p1;
		if(p1==1) cnt1++;
		if(p1==2) cnt2++;
		if(p1==3) cnt3++;
	}
	cout.precision(10);
	cout<<fixed<<ans(cnt1,cnt2,cnt3)<<endl;
	return 0;
}

Measured memory_bytes: 216192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)
const int mod=998244353;
int main()
{
    fast;
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double degh=(((h*360)/12)+((m*30)/60))*(pi/180.0);
    double degm=(m*6)*(pi/180.0);
    //cout<<degh<<" "<<degm<<endl;
    double hx=a*cos(degh);
    double hy=a*sin(degh);
    double mx=b*cos(degm);
    double my=b*sin(degm);
    double ans=sqrt(pow((hx-mx),2)+pow((hy-my),2));
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 4148
for i in range(int(input())):
    m, n = map(int, input().split())

    if m*n < 0:
        m, n = -n, m
    m = abs(m); n = abs(n)
    l = max(abs(m), abs(n))
    cnt = 0
    for p in range(l+1):
        for q in range(l+1):
            if p == 0: continue
            if (p*m + q*n) % (p**2 + q**2) < 1 and (p*n - q*m) % (p**2 + q**2) < 1:
                cnt += 1
    print("CP"[cnt == 2])

Measured memory_bytes: 7576
#include<iostream>
using namespace std;
 
int main(){
  char b;
  cin >> b;
  switch(b){
    case 'A':
        cout << 'T';
      	break;
    case 'T':
        cout << 'A';
      	break;
    case 'C':
        cout << 'G';
      	break;
    case 'G':
        cout << 'C';
      	break;
  }
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Problem Specific Parameter:

const int limit = 100010;

int n;
int a[3][limit];
int idx[limit];
bool flip[limit];

void no_exit() {
	puts("No");
	exit(0);
}

int data[limit];

void add(int p) {
	for (int i = p + 1; i < limit; i += i & -i) {
		data[i]++;
	}
}

int sum(int p) {
	int ret = 0;
	for (int i = p + 1; i > 0; i -= i & -i) {
		ret += data[i];
	}
	return ret;
}

int calc(vector<int> &x) {
	rep(i, limit) data[i] = 0;
	const int m = x.size();
	int ret = 0;
	rep(i, m) {
		ret ^= (i - sum(x[i])) % 2;
		add(x[i]);
	}
	return ret;
}

int main(void) {
	cin >> n;
	rep(i, 3)rep(j, n) cin >> a[i][j];

	rep(j, n) {
		const int cmin = min(a[0][j], a[2][j]);
		const int cmax = max(a[0][j], a[2][j]);

		if (cmin + 1 != a[1][j] or cmin + 2 != cmax) no_exit();
		if ((cmin - 1) % 3 != 0) no_exit();

		idx[j] = (cmin - 1) / 3;
		if (j % 2 != idx[j] % 2) no_exit();
		if (cmin != a[0][j]) flip[j] = true;
	}

	int flipo = 0, flipe = 0;
	vector<int> odd, even;

	rep(j, n) {
		if (j % 2) {
			flipo ^= flip[j];
			odd.push_back(idx[j]);
		} else {
			flipe ^= flip[j];
			even.push_back(idx[j]);
		}
	}

	int swapo = calc(odd), swape = calc(even);
	if (flipo != swape or flipe != swapo) no_exit();
	puts("Yes");
	return 0;
}

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

 int main() {
   string s, t;
   cin >> s >> t;
   bool a = false;
   int l = s.length();

   for (int i = 0; i < l; i++) {
     if (s == t) {
       a = true;
       break;
     }
     s = s.back() + s.substr(0, l-1);
   }
   if (a) {
     cout << "Yes" << '\n';
   }else{
     cout << "No" << '\n';
   }
 }


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll ans=0;
  vll v(n);
  rep(i,n){
    ll a,b; cin>>a>>b;
    ans-=b;
    v[i]=a+b;
  }
  sort(v.rbegin(),v.rend());
  rep(i,n){
    if(i%2==0) ans+=v[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
using namespace std;

int main(){
    int N;
    string A, B, C; 
    cin >> N >> A >> B >> C;
    int cnt = 0;
    for (int i=0;i<N;i++){
        if (A[i] == B[i]){
            if (B[i] != C[i]) cnt++;
        }
        else if (B[i] == C[i]) cnt++;
        else if (A[i] == C[i]) cnt++;
        else cnt+=2;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256