akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
from math import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    d=defaultdict(lambda:[0,0])
    zz=0
    for _ in range(N):
        a,b=map(int,input().split())
        g=gcd(a,b)
        if g==0:
            zz+=1
        else:
            a//=g
            b//=g
            if a<0:
                a*=-1
                b*=-1
            if a*b>0:
                d[(a,b)][0]+=1
            elif a*b<0:
                d[(-b,a)][1]+=1
            else:
                if a:
                    d[(1,0)][0]+=1
                else:
                    d[(1,0)][1]+=1
    l=[]
    other=0
    for k,a in d.items():
        if a[0] and a[1]:
            l.append((a[0],a[1]))
        else:
            other+=sum(a)
    ans=pow(2,other,MOD)
    ans%=MOD
    dp=[[0] for _ in range(len(l)+1)]
    dp[0]=1
    for i in range(len(l)):
        dp[i+1]=dp[i]*(pow(2,l[i][0],MOD)+pow(2,l[i][1],MOD)-1)
        dp[i+1]%=MOD
    ans*=dp[-1]
    ans-=1
    ans+=zz
    ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 129804
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    s = input()
    count =0

    for i in range(len(s)):
        if s[0] != "A":
            count += 2
        if s[i] =="C" :
            if i < len(s)-1 and i >1:
                count +=1
            else:
                count+=2
        elif i>0 and ( ord(s[i]) <97 or ord(s[i]) >122):
            count += 2

    if count == 1:
        print("AC")
    else:
        print("WA")



Measured memory_bytes: 5784
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 110
using namespace std;

int n, m, f[2][N][N][N], s1[N][N], s2[N][N], x, y, now, now1, l1, r1, l2, r2;
char S[N], map[N][N];

int main(){
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++){
		scanf("%s", S+1);
		for(int j=1; j<=m; j++)map[i][j]=S[j];
	}
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)if(map[i][j]=='E'){x=i; y=j;}
	memset(s1, 0, sizeof(s1)); memset(s2, 0, sizeof(s2));
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++){s1[i][j]=s1[i][j-1]+(map[i][j]=='o'?1:0); s2[i][j]=s2[i-1][j]+(map[i][j]=='o'?1:0);}
	
	memset(f, 0, sizeof(f)); now=0;
	for(int i=1; i<=n; i++){
		now1=now; now^=1;
		memset(f[now], 0, sizeof(f[now]));
		for(int j=i; j; j--){
			l1=max(x-(n-i), j); r1=min(x+(j-1), i);
			for(int i1=1; i1<=m; i1++)
				for(int j1=i1; j1; j1--){
					l2=max(y-(m-i1), j1); r2=min(y+(j1-1), i1);
					if(l1==j)f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now][j+1][j1][i1]+s1[j][r2]-s1[j][l2-1]);
					else f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now][j+1][j1][i1]);
					if(r1==i)f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now1][j][j1][i1]+s1[i][r2]-s1[i][l2-1]);
					else f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now1][j][j1][i1]);
					if(l2==j1)f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now][j][j1+1][i1]+s2[r1][j1]-s2[l1-1][j1]);
					else f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now][j][j1+1][i1]);
					if(r2==i1)f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now][j][j1][i1-1]+s2[r1][i1]-s2[l1-1][i1]);
					else f[now][j][j1][i1]=max(f[now][j][j1][i1], f[now][j][j1][i1-1]);
				}
		}
	}
	printf("%d", f[now][1][1][m]);
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define mp make_pair

const int K = 4;
ll MODS[] = {(ll)1e9 + 7, (ll)1e9 + 9, (ll)1e9 + 21, (ll)1e9 + 33};

ll bin_pow(ll x, ll p, ll mm) {
	if (p == 0) return 1;
	if (p & 1) return (x * bin_pow(x, p - 1, mm)) % mm;
	ll y = bin_pow(x, p / 2, mm);
	return (y * y) % mm;
}

struct PolyHash {
	ll x[K];

	PolyHash() : x() {}
	PolyHash(ll Z) {
		for (int i = 0; i < K; i++)
			x[i] = Z % MODS[i];
	}

	PolyHash operator + (const PolyHash &H) const {
		PolyHash res = PolyHash();
		for (int i = 0; i < K; i++) {
			res.x[i] = (x[i] + H.x[i]) % MODS[i];
		}
		return res;
	}

	PolyHash operator - (const PolyHash &H) const {
		PolyHash res = PolyHash();
		for (int i = 0; i < K; i++) {
			res.x[i] = (x[i] - H.x[i] + MODS[i]) % MODS[i];
		}
		return res;
	}

	PolyHash operator * (const PolyHash &H) const {
		PolyHash res = PolyHash();
		for (int i = 0; i < K; i++) {
			res.x[i] = (x[i] * H.x[i]) % MODS[i];
		}
		return res;
	}

	bool operator < (const PolyHash &H) const {
		for (int i = 0; i < K; i++) {
			if (x[i] != H.x[i])
				return x[i] < H.x[i];
		}
		return false;
	}
};

const int N = 500500;
const int M = N / 2;
PolyHash pw[N];
PolyHash a[N], b[N];
int c[N];
char s[N];
int L;
map<PolyHash, ll> mapchik;

void precalc() {
	pw[M] = PolyHash(1);
	ll PP = 27554547;
	pw[M + 1] = PolyHash(PP);
	for (int i = 0; i < K; i++) {
		pw[M - 1].x[i] = bin_pow(PP, MODS[i] - 2, MODS[i]);
	}
	for (int i = M + 2; i < N; i++)
		pw[i] = pw[i - 1] * pw[M + 1];
	for (int i = M - 2; i >= 0; i--)
		pw[i] = pw[i + 1] * pw[M - 1];
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	precalc();

	scanf("%d %s", &L, s);
	int pos = M;
	a[0] = 0;
	c[0] = pos;
	for (int i = 0; i < L; i++) {
		a[i + 1] = a[i];
		if (s[i] == '+') {
			a[i + 1] = a[i + 1] + pw[pos];
		} else if (s[i] == '-') {
			a[i + 1] = a[i + 1] - pw[pos];
		} else if (s[i] == '>') {
			pos++;
		} else if (s[i] == '<') {
			pos--;
		} else throw;
		c[i + 1] = pos;
	}
	b[L] = 0;
	for (int i = L - 1; i >= 0; i--) {
		b[i] = b[i + 1];
		if (s[i] == '+') {
			b[i] = b[i] + pw[pos];
		} else if (s[i] == '-') {
			b[i] = b[i] - pw[pos];
		} else if (s[i] == '>') {
			pos--;
		} else if (s[i] == '<') {
			pos++;
		} else throw;
	}

	PolyHash H = a[L];

/*
	for (int i = 0; i <= L; i++)
		printf("%llu ", a[i]);
	printf("\n");
	for (int i = 0; i <= L; i++)
		printf("%llu ", b[i]);
	printf("\n");
*/
	ll ans = 0;
	for (int i = L; i >= 0; i--) {
		PolyHash Z = H - H * pw[c[i]] - a[i];
		ans += mapchik[Z];
		mapchik[b[i]]++;
	}
	printf("%lld\n", ans);

	return 0;
}


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

using namespace std;

#define EPS 1e-10

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}

    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }

struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};

typedef Point Vector;

Point crosspointSS(const Segment &a,const Segment &b){
    Vector va = a.t-a.s, vb = b.t-b.s;
    double d = cross(vb,va);
    return a.s+va*cross(vb,b.t-a.s)*(1.0/d);
}

int main(){
    int Q;
    Segment s1,s2;
    cin >> Q;
    while(Q--){
        cin >> s1.s.x >> s1.s.y >> s1.t.x >> s1.t.y;
        cin >> s2.s.x >> s2.s.y >> s2.t.x >> s2.t.y;
        Point cp = crosspointSS(s1,s2);
        printf("%.12f %.12f\n",cp.x,cp.y);
    }
    return 0;
}

Measured memory_bytes: 1248
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int t = (n* 100)/ 108;
  int flag = 0;
  for(int i=t; i<=((n+1)*100)/108; i++) {
    if((i*108)/100 == n) {
      flag = 1;
      cout << i << '\n';
    }
  }
  if(flag == 0) cout << ":(\n";
  return 0;
}


Measured memory_bytes: 256
from math import ceil

def a():
    N = int(input())
    A = list(map(int,input().split()))
    INF = 10**13
    if N == 0:
        if A[0] == 1:
            return 1
        else:
            return -1

    BMAX = [INF] * (N+1)
    BMIN = [1] * (N+1)

    BMAX[0] = 1 - A[0]
    BMAX[N] = 0
    BMIN[0] = 1
    BMIN[N] = 0

    for i in range(N-1,-1,-1):
        BMAX[i] = min(BMAX[i],BMAX[i+1]+A[i+1])
        BMIN[i] = max(BMIN[i],ceil((BMIN[i+1]+A[i+1])/2))

    if BMIN[0] > BMAX[0]:
        return -1

    for i in range(1,N+1):
        BMAX[i] = min(BMAX[i],BMAX[i-1]*2-A[i])
        BMIN[i] = max(BMIN[i],BMIN[i-1]-A[i])
        if BMIN[i] > BMAX[i]:
            return -1
        
    return sum(BMAX)+sum(A)

print(a())

Measured memory_bytes: 84580
import java.util.Scanner;
import java.io.IOException;

public class Main {
	public static void main(String[] args)throws IOException{
		Scanner file = new Scanner(System.in);
		int x =file.nextInt();
		if(x>=1 && x<=100){
			System.out.println(x * x * x);
		}
	}
}

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


#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

int main() {
  Bint x;
  cin >> x;
	Bint mon = 100;
  int num = 0;
  while(x > mon){
  	mon *= 101;
    mon/= 100;
    num++;
  }
  cout << num << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, count=0, flag=1;
  cin >> N;
  
  vector<int> data(N);
  for(int i=0;i<N;i++) cin >> data.at(i);
  
  while(true){
    for(int i=0; i<N; i++){
      if(data.at(i)%2==0) data.at(i) /= 2;
      else flag=0;
    }
    if(flag==0) break;
    count++;
  }
  
  cout << count << endl;
}
      
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  string MARCH = "MARCH";
  map<char, ll> mp;
  REP(i, N) {
    string S;
    cin >> S;
    REP(i, 5) {
      if (S[0] == MARCH[i]) {
        mp[S[0]]++;
      }
    }
  }

  ll ans = 0;
  REP(i, 5) {
    FOR(j, i + 1, 5) {
      FOR(k, j + 1, 5) { ans += mp[MARCH[i]] * mp[MARCH[j]] * mp[MARCH[k]]; }
    }
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)

Acum = A.cumsum()

Apair = np.subtract.outer(Acum, Acum) + A
Apair = np.tril(Apair).ravel()
Apair = Apair[Apair > 0]

d = 45  # 10*9*1000 = 1<<40ぐらい
ans = 0
while d >= 0:
    Atmp = np.bitwise_and(np.right_shift(Apair, d), 1)
    if np.count_nonzero(Atmp) >= K:
        ans += 2 ** d
        Apair = Apair[np.nonzero(Atmp)]
    d -= 1

print(ans)


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

char s[105][105];
int ans[105][105];

int main() {
    int H, W; cin >> H >> W;
    rep(i, H){
        rep(j, W){
            cin >> s[i][j];
        }
    }

    if(s[0][0] == '.'){
        ans[0][0] = 0;
    } else {
        ans[0][0] = 1;
    }

    for (int j = 1; j < W; j++){
        if(s[0][j-1] == '.' && s[0][j] == '#'){
            ans[0][j] = ans[0][j-1] + 1;
        } else {
            ans[0][j] = ans[0][j-1];
        }
    }

    for (int j = 1; j < H; j++){
        if(s[j-1][0] == '.' && s[j][0] == '#'){
            ans[j][0] = ans[j-1][0] + 1;
        } else {
            ans[j][0] = ans[j-1][0];
        }
    }

    for (int i = 1; i < H; i++){
        for (int j = 1; j < W; j++){
            int kouho1;
            if(s[i-1][j] == '.' && s[i][j] == '#'){
                kouho1 = ans[i-1][j] + 1;
            } else {
                kouho1 = ans[i-1][j];
            }
            int kouho2;
            if(s[i][j-1] == '.' && s[i][j] == '#'){
                kouho2 = ans[i][j-1] + 1;
            } else {
                kouho2 = ans[i][j-1];
            }

            ans[i][j] = min(kouho1, kouho2);
        }
    }

    cout << ans[H-1][W-1] << endl;

    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;

	ll lcm;
	cin >> lcm;

	bool dame = 0;
	ll a, g, bai;

	rep1(i, N - 1) {
		cin >> a;
		g = __gcd(lcm, a);
		bai = a / g;
		if (lcm > 2e9 || !(bai & lcm / g & 1)) {
			dame = 1;
			break;
		}
		lcm = lcm * bai;
	}

	if (dame) co(0);
	else {
		ll kotae = (lcm / 2 + M) / lcm;
		co(kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    static int mod = 1000000007;

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = nextInt();

        int[][] grid = new int[n][n];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                grid[i][j] = nextInt();
            }
        }

        int[] dp = new int[1 << n]; // mask represents the women that are not matched yet

        dp[0] = 1;

        for (int j = 0; j < (1 << n) - 1; j++) {
            int i = Integer.bitCount(j);
            for (int k = 0; k < n; k++) {
                if (grid[i][k] == 1 && (j & (1 << k)) == 0) {
                    int m2 = j ^ (1 << k); // caret is XOR
                    dp[m2] = add_self(dp[m2], dp[j]);
                }
            }
        }

        out.println(dp[(1 << n) - 1]);

        out.close();
    }

    static int add_self(int a, int b) {
        a += b;
        if (a >= mod) a -= mod;

        return a;
    }
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto H=in(),W=in(),D=in();
	vll MI(H*W),C(H*W,0);
	REP(i,H){
		REP(j,W){
			MI[in()-1] = j+i*W;
		}
	}
	REP(i,H*W){
		if(i+D<H*W){
			ll u=MI[i]%W,v=MI[i]/W;
			ll x=MI[i+D]%W,y=MI[i+D]/W;
			C[i+D] += C[i]+abs(u-x)+abs(v-y);
		}
	}

	auto Q=in();
	LOOP(Q){
		auto L=in()-1,R=in()-1;
		out(C[R]-C[L]);
	}
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std ;
int main(){
    int a, b, c, d, e, k ;
    cin>>a>>b>>c>>d>>e>>k;
    if  (e-a>k){
        cout<<":("<<endl;
    }
    else{
        cout<<"Yay!"<<endl;
    }
    return 0 ;
}

Measured memory_bytes: 256
function Main(input) {
  lines = input.split('\n')
  k = input.split(' ')[0] * 1
  x = input.split(' ')[1] * 1
  min = x - k + 1
  max = x + k - 1 
  if (min < -1000000) {
      min = -1000000
  }
  if (max > 1000000) {
      max = 1000000
  }
  i = min
  ans = min
  i++
  while (i <= max) {
      ans += ' ' + i++ 
  }
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

int main(){
    int N;
    char s[100000];
    int c[100000];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> s[i];
    for(int i = 0; i < N; i++){
        if(i != N - 1 && s[i] == s[i+1]) c[i] = 0;
        else if(i == N - 1 && s[i] != s[i - 1]) c[i] = 1;
        else c[i] = 1;
    }
    int ans = 0;
    for(int i = 0; i < N; i++) ans += c[i];
    cout << ans << endl;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
namespace Lesson03
{
    class MainClass
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }



        public static void Main (string[] args)
        {
            List<string[]> arr_result = new List<string[]>();
            arr_result = getinputdata ();

            int S = int.Parse(arr_result[0][0]);

            int h = S / 60 / 60;
            int m =(S - (h * 60 * 60))/60;
            int s = S - (h * 60 * 60) - (m * 60);

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




        }
    }
}

Measured memory_bytes: 9320
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int a[3];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a+3);
    printf("%d %d %d\n", a[0], a[1], a[2]);


    return 0;
}



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

int main() {
    int n;
    int v[100000];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> v[i];

    map<int, int> m1;
    map<int, int> m2;
    for (int i = 0; i < n; i += 2) m1[v[i]]++;
    for (int i = 1; i < n; i += 2) m2[v[i]]++;

    int evenMaxCount = 0;
    int evenMax = 0;
    for (pair<int, int> p : m1) {
        if (p.second > evenMaxCount) {
            evenMaxCount = p.second;
            evenMax = p.first;
        }
    }

    int oddMaxCount = 0;
    int oddMax = 0;
    for (pair<int, int> p : m2) {
        if (p.second > oddMaxCount) {
            oddMaxCount = p.second;
            oddMax = p.first;
        }
    }

    if (evenMax == oddMax) {
        int even2ndCount = 0;
        int even2nd = 0;
        for (pair<int, int> p : m1) {
            if (p.second > even2ndCount && p.first != evenMax) {
                even2ndCount = p.second;
                even2nd = p.first;
            }
        }

        int odd2ndCount = 0;
        int odd2nd = 0;
        for (pair<int, int> p : m2) {
            if (p.second > odd2ndCount && p.first != oddMax) {
                odd2ndCount = p.second;
                odd2nd = p.first;
            }
        }
        
        if (even2ndCount >= odd2ndCount) evenMax = even2nd;
        else oddMax = odd2nd;
    }

    int ans = 0;
    for (int i = 0; i < n; i += 2) {
        if (v[i] != evenMax) ans++;
    }
    for (int i = 1; i < n; i += 2) {
        if (v[i] != oddMax) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 8576
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
  
N, A, B = map(int, input().split())

ans = 0
for n in range(N+1):
  if digitSum(n)>=A and digitSum(n)<=B:
    ans += n
    
print(ans)

Measured memory_bytes: 42348
k = gets.to_i
hash = Hash.new(0)
an = 0
i = 0
flg = true
while flg
  i += 1
  an = an * 10 + 7
  an %= k
  if an == 0
    flg = false
  end
  if hash[an] == 0
    hash[an] = 1
  else
    i = -1
    flg = false
  end
end
puts i

Measured memory_bytes: 51252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

//Be careful 1-indexed
template<typename T>
struct BinaryIndexedTree{
    private:
    vector<T> dat;
    public:
    BinaryIndexedTree(int sz){
        dat.assign(++sz,0);
    }
    void add(int k,T x){
        for (;k<=dat.size();k+=k&-k) dat[k]+=x;
    }
    T sum(int k){
        T ret=0;
        for (;k>0;k-=k&-k) ret+=dat[k];
        return ret;
    }
    int lower_bound(T x){
        if (x<=0) return 0;
        int lb=0,r=1;
        while(r<dat.size()) r<<=1;
        for (;r>0;r>>=1){
            if (lb+r<dat.size()&&dat[lb+r]<x){
                x-=dat[lb+r];
                lb+=r;
            }
        }
        return lb+1;
    }
    T query(int l,int r){ //[l,r)
        return sum(r-1)-sum(l-1);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<int,int> mB,mW;
    BinaryIndexedTree<int> BITB(2*N),BITW(2*N);
    rep2(i,1,2*N+1){
        char c; int a; cin >> c >> a;
        if (c=='B'){
            mB[a]=i;
            BITB.add(i,1);
        }
        else mW[a]=i;
    }
    vector<vector<int>> dp(N+1,vector<int>(N+1,INF));
    dp[0][0]=0;
    rep(i,N+1){
        for (auto x:mW) BITW.add(x.second,1);
        rep(j,N+1){
            if (i+1<=N) chmin(dp[i+1][j],dp[i][j]+BITB.sum(mB[i+1]-1)+BITW.sum(mB[i+1]-1));
            if (j+1<=N) chmin(dp[i][j+1],dp[i][j]+BITB.sum(mW[j+1]-1)+BITW.sum(mW[j+1]-1));
            if (j+1<=N) BITW.add(mW[j+1],-1);
        }
        if (i+1<=N) BITB.add(mB[i+1],-1);
    }
    cout << dp[N][N] << endl;
}

Measured memory_bytes: 16256
#include "stdio.h"
#include "math.h"
#define N 30

int Eratosthenes_sieve(int n){
    int count=0;
    int a[n+1],i;
    int j=2;
    for (i = 0; i < n+1; i++) {
        a[i]=1;
    }
    for (i = 2; i < (int)sqrt((double)n)+1; i++) {
        if (a[i]==1) {
            while (i*j<=n) {
                a[i*j]=0;
                j++;
            }
            j=2;
        }
    }
    for (i = 2; i < n+1; i++) {
        if (a[i]==1)count++;
    }
    return count;
}

int main() {
    int n[N],i,j;
    i=0;
    while(scanf("%d",&n[i])!=EOF)i++;
    for (j = 0; j < i; j++) {
        printf("%d\n",Eratosthenes_sieve(n[j]));
    }
    return 0;
}

Measured memory_bytes: 4496
#include<stdio.h>
int main(void)
{
	int i,j,num1[30+1],num2[30+1];
	for(i=1;i<=30;i++) {
		num2[i]=0;
	}
	for(j=1;j<=28;j++) {
		scanf("%d",&num1[j]);
	}
	for(i=1;i<=30;i++) {
		for(j=1;j<=28;j++) {
			if(i==num1[j]) {
				num2[i]++;
			}
		}
	}
	for(i=1;i<=30;i++) {
		if(num2[i]==0) {
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 596
N = input()
T_A = input().split()
T = int(T_A[0])
A = int(T_A[1])
H_list = list(map(int, input().split()))

i = 1
i_H_list = []
for H in H_list:
    ave_T = T - H * 0.006
    i_H_list.append([i, abs(A - ave_T)])
    i += 1

min_diff = -1
min_diff_i = -1
for i in range(len(H_list)):
    if min_diff > i_H_list[i][1] or min_diff == -1:
        min_diff = i_H_list[i][1]
        min_diff_i = i_H_list[i][0]
print(min_diff_i)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN ((1<<13) + 5)
#if !testing
	#define cerr if(0)cout
#endif

int dp[MAXN];
int cost[1005];
vector <int> v[1005];
int32_t main() {
	IAMSPEED
	int n,m; cin >> n >> m;
	FOR(i,1,m) {
		int a,b; cin >> a >> b;
		cost[i] = a;
		FOR(j,1,b) {
			int x; cin >> x;
			v[i].pb(x-1);
		}
	}
	// set testing to 0 when submitting to judge
	FOR(i,0,MAXN-1) dp[i] = inf;
	dp[(1<<n)-1] = 0;
	DEC(bm,(1<<n)-1,0) {
		FOR(i,1,m) { // all keys
			int nbm = bm;
			for (auto j : v[i]) {
				nbm |= (1<<j);
				nbm ^= (1<<j);
			}
			minself(dp[nbm],dp[bm]+cost[i]);
		}
	}
	if (dp[0]==inf) cout << -1;
	else cout << dp[0];
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int d = (b-1)/a + 1;
	int e = c/a;
	if(d<=e)
	{
		printf("OK");
	}
	else printf("NG");
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N; cin >> N;
	vector<pair<ll, ll>> po(N), P(N);
	vector<ll> mi(2, 1e15), mx(2, -1e15);
	for (int i = 0; i < N; i++) {
		cin >> po[i].first >> po[i].second;
		P[i].first = po[i].first - po[i].second;
		P[i].second = po[i].first + po[i].second;
		mi[0] = min(mi[0], P[i].first);
		mx[0] = max(mx[0], P[i].first);
		mi[1] = min(mi[1], P[i].second);
		mx[1] = max(mx[1], P[i].second);
	}

	cout << max(mx[0] - mi[0], mx[1] - mi[1]) << endl;


}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,XX;
  int syu=0;
  cin >> A >> B >> C >> XX;
  for (int X=0;X<=A*500;X+=500){
    for (int Y=0;Y<=B*100;Y+=100){
      for (int Z=0;Z<=C*50;Z+=50){
        if (X+Y+Z==XX){
          syu++;
        }
      }
    }
  }
  cout << syu << endl;
}


Measured memory_bytes: 3596
n = int(input())
line = list(map(int,input().split()))
#print(str(line) + "■")

c = 0
for i in range(n-2):
    alist = []
    alist.append(line[i])
    alist.append(line[i+1])
    alist.append(line[i+1+1])
    if alist[0] == max(alist) and alist[2] == min(alist):
        c += 1
    elif  alist[0] == min(alist) and alist[2] == max(alist):
        c += 1
    else:
        pass
print(c)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count=1;
    while(true){
      int a = sc.nextInt();
      if(a==0){
        break;
      }
      System.out.println("Case "+count+": "+a);
      count = count+1;
    }
  }
}



Measured memory_bytes: 41548
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP2(i,n,s) for(int i=(int)s;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

    bool f = false;
    int m = a%b, n = m;
    do {
        n = (n+a)%b;
        if (n == c) {
            f = true;
            break;
        }
    } while((n+a)%b != m);

    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main()
{
	int n;
	cin>>n;
	long long int s=0,a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s=(s^a[i]);
	}
	for(int i=1;i<=n;i++)
		cout<<(s^a[i])<<" ";
}



Measured memory_bytes: 5144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
using namespace std;

int score[14][4];
int rate[10];

typedef pair<int, int> card;
typedef vector<card> cards;

int toNum(char a)
{
	if(isdigit(a)) return a-'0';
	if(a=='T') return 10;
	if(a=='J') return 11;
	if(a=='Q') return 12;
	if(a=='K') return 13;
	return a-'A'+1;
}

int toNum2(char a)
{
	if(a=='S') return 0;
	if(a=='C') return 1;
	if(a=='H') return 2;
	
	return 3;
}

cards input()
{
	cards in;
	for(int i=0; i<5; i++)
	{
		string s;
		cin >> s;
		in.push_back(make_pair(toNum(s[0]), toNum2(s[1])));
	}
	
	sort(in.begin(), in.end());
	
	return in;
}

vector<int> calcPair(cards in)
{
	vector<int> ret;
	int num[14]={0};
	for(int i=0; i<5; i++)
	{
		num[in[i].first]++;
	}
	
	for(int i=1; i<=13; i++)
	{
		if(num[i]!=0) ret.push_back(num[i]);
	}
	
	sort(ret.begin(), ret.end());
	
	return ret;
}

bool isFlash(cards in)
{
	for(int i=1; i<5; i++)
		if(in[0].second!=in[i].second) return false;
		
	return true;
}

int isStraight(cards in, vector<int> pr)
{
	if(pr.size()!=5) return 0;
	
	int num[14]={0};
	for(int i=0; i<5; i++)
	{
		num[in[i].first+(4-i)]++;
	}
	
	if(num[in[4].first]==5) return 1;
	if(num[in[4].first]==4&&in[4].first==13&&num[5]) return 2;
	
	return 0;
}

int total(cards in)
{
	int ret=0;
	for(int i=0; i<5; i++)
		ret+=score[in[i].first][in[i].second];
		
	return ret;
}


int calc(cards in)
{
	vector<int> pr=calcPair(in);
	int ret=0,sz=pr.size();
	
	if(pr[sz-1]==2) ret=1;
	if(pr[sz-1]==2&&pr[sz-2]==2) ret=2;
	if(pr[sz-1]==3) ret=3;
	if(isStraight(in,pr)!=0) ret=4;
	if(isFlash(in)) ret=5;
	if(pr[sz-2]==2&&pr[sz-1]==3) ret=6;
	if(pr[sz-1]==4) ret=7;
	if(isStraight(in,pr)!=0&&isFlash(in)) ret=8;
	if(isStraight(in,pr)==2&&isFlash(in)) ret=9;
	
	return total(in)*rate[ret];
}

int main()
{
	bool flg=true;
	int N;
	while(cin >> N)
	{
		if(flg) flg=false;
		else cout << endl;
		
		for(int i=0; i<4; i++)
		for(int j=0; j<13; j++)
			cin >> score[j+1][i];
		
		rate[0]=0;
		for(int i=0; i<9; i++)
			cin >> rate[i+1];
			
		for(int i=0; i<N; i++)
		{
			cards cs=input();
			cout << calc(cs) << endl;
		}
	}
}

Measured memory_bytes: 936
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


vector<vec> g;
int col[210000];
int dfs(int x,int p,int c){
    col[x]=c;
    for(auto e:g[x]){
        if(e==p)continue;
        dfs(e,x,c^1);
    }
}
main(){
    ios
    int A=in(),B=in(),m=in();
    vec a,b;
    int mi1=INT_MAX,mi2=INT_MAX;
    rep(i,A)a.pb(in()),chmin(mi1,a.back());
    rep(i,B)b.pb(in()),chmin(mi2,b.back());
    int ans=mi1+mi2;
    rep(i,m){
        int x=in(),y=in(),c=in();
        chmin(ans,a[x-1]+b[y-1]-c);
    }
    cout<<ans<<endl;
}


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

int main(){
  string s;
  cin >> s;
  int n;
  cin >> n;
  
  vector<char> head,tail;
  bool r=false;
  int cnt_h=0,cnt_t=0;
  rep(i,n){
    int t;
    cin >> t;
    if(t==1){
      r=1-r;
    }else{
      int f;
      char c;
      cin >> f >> c;
      if((!r and f==1) or (r and f==2)){head.push_back(c);cnt_h++;}
      else {tail.push_back(c);cnt_t++;}
    }
  }
  if(r==true){
    reverse(s.begin(), s.end());
    rep(i,cnt_t) cout << tail[cnt_t-1-i];
    cout << s;
    rep(i,cnt_h) cout << head[i];
  }else{
  rep(i,cnt_h) cout << head[cnt_h-1-i];
  cout << s;
  rep(i,cnt_t) cout << tail[i];
  }
}

Measured memory_bytes: 3884
#include<iostream>
#include<stdlib.h>
#include<time.h>

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

using namespace std;

class Node {
public:
	string name;
	Node* child[2];

	Node(void) {
		child[0] = nullptr;
		child[1] = nullptr;
	}
	Node(string str) {
		child[0] = nullptr;
		child[1] = nullptr;
		name = str;
	}

	int count(void) {
		int temp = 1;
		temp += child[0] != nullptr ? child[0]->count() : 0;
		temp += child[1] != nullptr ? child[1]->count() : 0;
		return temp;
	}

	int insert(string str) {
		if (name == str) return 0;
		if (name > str) {
			if (child[0] == nullptr) child[0] = new Node(str);
			else child[0]->insert(str);
		}
		else {
			if (child[1] == nullptr) child[1] = new Node(str);
			else child[1]->insert(str);
		}
		return 0;
	}
};

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

	cin >> str;
	Node root(str);

	for (int i = 1; i < N; i++) {
		cin >> str;
		root.insert(str);
	}

	cout << root.count() << endl;

	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    char a[h][w];
    rep(i, h) {
        rep(j, w) cin >> a[i][j];
    }

    int t[h] = {};
    int y[w] = {};

    rep(i, h) {
        rep(j, w) {
            if(a[i][j] == '#') break;
            if(j == w-1) t[i]++;
        }
    }

    rep(j, w) {
        rep(i, h) {
            if(a[i][j] == '#') break;
            if(i == h-1) y[j]++;
        }
    }

    int cntt = 0;
    int cnty = 0;
    rep(i, h) {
        if(t[i]>0) cntt++;
    }
    rep(i, w) {
        if(y[i]>0) cnty++;
    }

    char ans[h-cntt][w-cnty];
    int cntx = 0;
    rep(i, h) {
        int cntyy = 0;
        rep(j, w) {
            if(t[i]==0 && y[j]==0) {
                char tmp = a[i][j];
              	cout << tmp;
            }
            if(j==w-1 && t[i] == 0) cout << endl;
        }
        cntx++;
    }

    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int A, B, M;
	cin >> A >> B >> M;
	vector<int>a(A), b(B), c(M);
	for (int i = 0; i < A; i++){
		cin >> a[i];
	}
	for (int i = 0; i < B; i++){
		cin >> b[i];
	}

	int minA = *min_element(a.begin(), a.end());
	int minB = *min_element(b.begin(), b.end());
	int ans = minA + minB;
	for (int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y >> c[i];
		x--, y--;
		ans = min(ans, a[x] + b[y] - c[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
from collections import defaultdict


def solve():
    N, M, *A = map(int, open(0).read().split())
    
    cumsum = [0] * (N + 1)
    for i in range(N):
        cumsum[i + 1] = cumsum[i] + A[i]
    
    mods = defaultdict(int)
    for num in cumsum:
        mods[num % M] += 1
    
    ans = 0
    for val in mods.values():
        ans += val * (val - 1) // 2
    print(ans)


if __name__ == '__main__':
    solve()


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

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
	while(x->left != NIL) x = x->left;
	return x;
}

Node * find(Node *u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

Node * treeSuccessor(Node *x) {
	if (x->right != NIL) return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node *z) {
	Node *y;
	Node *x;

	if (z->left == NIL || z->right == NIL) y = z;
	else y = treeSuccessor(z);

	if (y->left != NIL) {
		x = y->left;
	} else {
		x = y->right;
	}

	if (x != NIL) {
		x->parent = y->parent;
	}

	if (y->parent == NIL) {
		root =x;
	} else {
		if (y == y->parent->left) {
			y->parent->left = x;
		} else {
			y->parent->right = x;
		}
	}

	if (y != z) {
		z->key = y->key;
	}

	free(y);
}

void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	while (x != NIL) {
		y = x;
		if (x->key == k) return;
		else if (x->key > k) x = x->left;
		else x = x->right;
	}
	Node* u = (Node*)malloc(sizeof(Node));
	u->key = k;
	u->left = u->right = NIL;
	u->parent = y;
	if (y == NIL) {
		root = u;
		return;
	}
	if (y->key > k) y->left = u;
	else y->right = u;
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, i, x;
	string com;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node *t = find(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		} else if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		} else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if (com == "delete") {
			scanf("%d", &x);
			treeDelete(find(root, x));
		}
	}
}



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

int main(){
	int i = 0;
	double a, b, c, d, e, f;
	double x, y;
	while (cin >> a >> b >> c >> d >> e >> f){
		
		x = (c*e - f*b) / (a*e - b*d);
		y = (c - a*x) / b;
		cout << fixed << setprecision(3) << x + 0.0001 << " " << setprecision(3) << y + 0.0001 << '\n';
	}

	return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>
#include <limits.h>

#define NIL -1
#define WHITE 0
#define BLACK 1
#define MAX 100

int matrix[MAX][MAX];
int n;

void prim(){

    int i;
    int d[n],pi[n],color[n];
    int mincost;
    int u;
    int v;
    int sum = 0;

    for( i = 0 ; i < n ; i++ ){
        d[i] = INT_MAX;
        pi[i] = NIL;
        color[i] = WHITE;
    }

    d[0] = 0;
    pi[0] = NIL;

    while( 1 ){

        mincost = INT_MAX;

        for( i = 0 ; i < n ; i++ ){
            if( color[i] != BLACK && d[i] < mincost ){
                mincost = d[i];
                u = i;
            }

        }

        if( mincost == INT_MAX ){
            break;
        }

        color[u] = BLACK;

        for( v = 0 ; v < n ; v++ ){

            if( color[v] != BLACK && matrix[u][v] != INT_MAX ){
                
                if( matrix[u][v] < d[v] ){
                    
                    pi[v] = u;
                    d[v] = matrix[u][v];

                }
            }
        }

    }

    for( i = 0 ; i < n ; i++ ){
        if( pi[i] != NIL ){
            sum += matrix[i][pi[i]];
        }
    }

    printf("%d\n",sum);

}

int main(){

    int i,j;
    scanf("%d",&n);

    for( i = 0 ; i < n ; i++ ){
        for( j = 0 ; j < n ; j++ ){
            scanf("%d",&matrix[i][j]);
            if( matrix[i][j] == NIL ){
                matrix[i][j] = INT_MAX;
            }
        }
    }

    prim();

    return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a, b;
		
		a = scan.nextInt();
		b = scan.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b");
		}
	}

}

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

const int mx=1e5+1;
int n,k;
int h[mx],dp[mx];
int solve(int s) //s->no of stone
{
    if(s==n) return 0;
    if(dp[s]!=-1) return dp[s];
    int ret=INT_MAX;
    for(int i=1;i<=2;i++){
        if((i+s)<=n) ret=min(ret,abs(h[s+i]-h[s])+solve(s+i));
    }
    return dp[s]=ret;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);    return 0;

    cin>>n;
    for(int i=1;i<=n;i++) cin>>h[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(1);

    return 0;
}


Measured memory_bytes: 7512
import java.util.Scanner;

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

    int n = sc.nextInt();
    int t = sc.nextInt();
    int a = sc.nextInt();
    Double sum_height = 0d;
    Double tt = 0d;
    Double sub = Double.MAX_VALUE;
    int index = 0;

    for(int i=0; i<n; i++){
      tt = t - sc.nextInt() * 0.006;
      if(sub>Math.abs(tt-a)){
        sub = Math.abs(tt-a);
        index = i+1;
      }
    }
    System.out.println(index);


  }
}

Measured memory_bytes: 24276
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,0,N) cin >> A[i];

    bool ok = true;
    for(int i=0; i<N; i++) {
        if(i == 0) {
            if(A[i] != 0) ok = false;
        }
        else {
            int diff = A[i] - A[i-1];
            if(diff > 1) ok = false;
        }
    }

    if(!ok) cout << -1 << endl;
    else {
        int ans = 0, tmp = 0, prev = 0;
        for(int i=0; i<N; i++) {
            if(A[i] == 0) prev = 0;
            else {
                if(prev + 1 == A[i]) tmp++;
                else {
                    ans += tmp;
                    tmp = A[i];
                }
                prev = A[i];
            }
        }
        ans += tmp;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e5 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int in()
{
  int x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  int k = in() , a = in() , b = in() ;
  if(a > b) swap(a , b) ;
  int t = (b / k) - (a - 1) / k ;
  if(t) puts("OK") ;
  else puts("NG") ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3592