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

#pragma GCC optimize("O3")
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define gc getchar_unlocked
typedef long long ll;
typedef long double ld;
const double PI=acos(-1.0);
const int mod = 1000000007;




int main()
{
    FASTIO
	
	ll l,r,ans;
	cin>>l>>r;
	if(r-l>2020)
	ans=0;
	else
	{
	    ans=2019;
	    for(ll i=l;i<r;i++)
	    for(ll j=i+1;j<=r;j++)
	    ans=min(ans,(i*j)%2019);
	}

    cout<<ans;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int h, w;
bool s[21][21] = {}, done[21][21] = {};

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

int main()
{
	cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
		string tmp;
		cin >> tmp;
		for (int j = 0; j < w; j++)
		{
			if (tmp[j] == '.')
			{
				s[i][j] = 1;
			}
			else
			{
				s[i][j] = 0;
			}
		}
	}

	int ans = 0;
	for (int sy = 0; sy < h; sy++)
	{
		for (int sx = 0; sx < w; sx++)
		{
			vector<vector<int>> tmp_dist(h, vector<int>(w, INF));
			if (s[sy][sx] == 0)
			{
				continue;
			}
			for (int i = 0; i < 20; i++)
				for (int j = 0; j < 20; j++)
					done[i][j] = false;

			queue<pair<int, int>> q;
			q.push(make_pair(sy, sx));
			tmp_dist[sy][sx] = 0;
			done[sy][sx] = true;
			while (!q.empty())
			{
				auto now = q.front();
				q.pop();
				for (int i = 0; i < 4; i++)
				{
					int ny = now.first + dy[i];
					int nx = now.second + dx[i];
					if (!done[ny][nx] && s[ny][nx] && 0 <= ny && ny < h && 0 <= nx && nx < w)
					{
						done[ny][nx] = true;
						tmp_dist[ny][nx] = min(tmp_dist[ny][nx], tmp_dist[now.first][now.second] + 1);
						q.push(make_pair(ny, nx));
					}
				}
			}
			int tmp_ans = 0;
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					if (!s[i][j])
						continue;
					tmp_ans = max(tmp_ans, tmp_dist[i][j]);
				}
			}
			ans = max(ans, tmp_ans);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
typedef pair<ll,ll> P;
ll n,m[4];
ll a[] = {1,2,4,8};
int main(){
    REP(i,4)
        cin >> m[i];
    cin >> n;

    n *= 4;
    P p[4];

    REP(i,4){
        p[i] = P(m[i] * a[4 - i - 1],i);
    }
    sort(p,p+4);
    ll ans = m[0] * n;
    REP(i,4){
        if(p[i].sc == 0)
            break;
        ll l = n / a[p[i].sc];
        ans = ans + m[p[i].sc] * l - m[0] * l * a[p[i].sc];
        n -= l * a[p[i].sc];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define REP(i,n) for(int i=0;i<(n);i++)
#include <queue>
#include <string>
#include <iostream>
using namespace std;

int main(){
        int n,q,time_sum = 0;
        typedef struct process{
                string name;
                int time;
        } process_t;
        queue<process_t> Q;
        cin >> n >> q;
        REP(i,n){
                process_t process_in;
                cin >> process_in.name >> process_in.time;
                Q.push(process_in);
        }
        while(! Q.empty()){
        process_t temp = Q.front();
        Q.pop();
        if(temp.time - q > 0){
                time_sum += q;
                temp.time -= q;
                Q.push(temp);
        }
        else{
                time_sum += temp.time;
                cout << temp.name << " " << time_sum << endl;
        }
}
}

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

int main(){
	string s;
	int p_mx;
	cin >> s;
	map<char, int> m;
	rep(i, s.size()){
		m[s[i]]++;
	}
	p_mx = s.size()/2;
	
	cout << p_mx - m['p'] << endl;
	
	return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	long INF = (long) (1e19);

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long k = sc.nextLong();
		INF = k + 1;
		long[] f = new long[m + 1];
		f[0] = 1;
		char[][] s = new char[n][];
		for (int i = 0; i < n; ++i) {
			s[i] = sc.next().toCharArray();
		}
		for (int j = 0; j < m; ++j) {
			for (int i = 0; i < n; ++i) {
				if (j + s[i].length > m)
					continue;
				f[j + s[i].length] = add(f[j + s[i].length], f[j]);
			}
		}
		if (f[m] < k) {
			System.out.println("-");
			return;
		}
		boolean[][] cap = new boolean[n][m + 1];
		for (int i = 0; i < n; ++i) {
			cap[i][0] = true;
		}
		String ans = "";
		long[] g = new long[m + 1];
		g[0] = 1;
		boolean[][] h = new boolean[n][];
		for (int i = 0; i < n; ++i) {
			h[i] = new boolean[s[i].length + 1];
			if (s[i].length <= m) {
				h[i][0] = true;
			}
		}
		for (int T = 0; T < m; ++T) {
			char c = '*';
			long sum = 0;
			boolean flag = false;
			for (int i = 0; i < 26; ++i) {
				c = (char) ('a' + i);
				long tmp = 0;
				for (int u = 0; u < n; ++u) {
					for (int v = 1; v <= Math.min(s[u].length, T + 1); ++v) {
						if (h[u][v - 1] && s[u][v - 1] == c) {
							tmp = add(tmp, mul(g[T + 1 - v], f[m - (T + 1) - (s[u].length - v)]));
						}
					}
				}
				if (add(tmp, sum) >= k) {
					k -= sum;
					flag = true;
					break;
				}
				sum = add(sum, tmp);
			}
			if (!flag)
				throw new AssertionError();
			ans += c;
			if (k == 0)
				break;
			for (int i = 0; i < n; ++i) {
				for (int j = h[i].length - 1; j >= 1; --j) {
					h[i][j] = s[i][j - 1] == c && h[i][j - 1];
				}
			}
			for (int i = 0; i < n; ++i) {
				h[i][0] = T + s[i].length + 1 <= m;
			}
			for (int i = 0; i < n; ++i) {
				if (h[i][s[i].length]) {
					g[T + 1] = add(g[T + 1], g[T + 1 - s[i].length]);
				}
			}
		}
		System.out.println(ans);
	}

	long add(long a, long b) {
		if (a + b < 0 || a + b >= INF) {
			return INF;
		} else {
			return a + b;
		}
	}

	long mul(long a, long b) {
		if (a * b < 0 || a * b >= INF) {
			return INF;
		} else {
			return a * b;
		}
	}

	void solve(ArrayList<Integer>[] g, int h, int w) {
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 43476
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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

long long gcd(long long x, long long y){
	return y==0 ? x:gcd(y,x % y);
}
long long lcm(long long x, long long y){
    return x*y/gcd(x,y);
}

long long N,M,lcmm,step,a,b;

int main(){
    cin>>N>>M;
    lcmm=lcm(N,M);
    char S[N],T[M];
    rep(i,N)cin>>S[i];
    rep(i,M)cin>>T[i];
    N=lcmm/N;
    M=lcmm/M;
    step=lcm(N,M);
    for(long long i=0;i<lcmm;i+=step){ 
        a=i/N;
        b=i/M;
        if(S[a]!=T[b]){
            out(-1);
            return 0;
        }
    }
    printf("%llu\n",lcmm);
}

Measured memory_bytes: 384
#include <stdio.h>

main(){
  int tx[200], ty[200], dx[]={-1,0,1,0}, dy[]={0,1,0,-1},n,i;
  int num, d, max, min,a ,b;

  tx[0]=0;
  ty[0]=0;

  while(1){
    scanf("%d", &n);
    if(n==0) break;

    for(i=1;i<n;i++){
      scanf("%d %d", &num, &d);
      tx[i]=tx[num]+dx[d];
      ty[i]=ty[num]+dy[d];
    }

    max=-201;
    min=201;

    for(i=0;i<n;i++){
      if(tx[i]<min) min=tx[i];
      if(tx[i]>max) max=tx[i];
    }
    a=max-min+1;
    max=-201;
    min=201;

    for(i=0;i<n;i++){
      if(ty[i]<min) min=ty[i];
      if(ty[i]>max) max=ty[i];
    }
    b=max-min+1;

    printf("%d %d\n", a, b);
  }
  return 0;
}

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

int main(void)
{
	int N, longest = 0, len_sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int len; cin >> len;
		len_sum += len;
		if (len > longest)longest = len;
	}
	len_sum -= longest;
	if (len_sum > longest)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;
vector<int> a;

int main()
{
	int n;
	cin >> n;
	
	for (int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}

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

	cout << abs(a.at(0) - a.at(n-1)) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 175, task a, 2020/08/15
//ms,
/*
*/

int main(void){
  int64_t x, k, d;
  int64_t ans;
  cin >>x >>k >>d;

  if(abs(x)/d > k) ans=abs(x)-k*d;
  else{
    if((k - abs(x)/d)%2) ans = -1*(abs(x) - (abs(x)/d + 1)*d);
    else ans = (abs(x) - (abs(x)/d)*d);
  }

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


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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  
  vector<int> x;
  
  for (int i=1; i<=min(a,b); i++){
    if (a%i==0&&b%i==0) x.push_back(i);
  }
  
  reverse(x.begin(),x.end());
  
  cout << x.at(k-1) << endl;
  
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

flag = True
for i in l:
  if (i%3 != 0 and i%2 == 0) and (i%5 != 0 and i%2 == 0):
    flag = False
    break
    
if flag:
  print("APPROVED")
  
else:
  print("DENIED")


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

int main() {
  int n,k;
  cin>>n>>k;
  
  int i,ans=1;
  for(i=0;i<n;i++){
    if(ans*2>=ans+k)
      ans+=k;
    else ans*=2;
  }
  cout<<ans;

}

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

string S;
ll K;
const ll hoshii = 5.0e15;

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

    for (int i = 0; i < S.length(); i++) {
        K -= pow(S[i] - '0', hoshii);
        if (K <= 0) {
            cout << S[i] << endl;
            break;
        }
    }

    return 0;
}

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

int main(){
  char s[10010];
  int n,x,p;
  cin >> n;
  cin >> s;
  p = strlen(s);
  for (int i=0; i < p; i++){
    x = s[i] - 'A';
    x = (x+n)%26;
    s[i] = 'A' + x;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
def LI():
	return [ int(s) for s in input().split() ]
 
A = LI()
 
A12 = abs(A[0]-A[1])
A23 = abs(A[1]-A[2])
A31 = abs(A[2]-A[0])
 
print(min(A12+A23,A23+A31,A31+A12))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int x,y;
    cin >> x >> y;
    rep(i,x+1){
        if(4*i + 2*(x-i) == y){
            dunk("Yes");
            return 0;
        }
    }
    dunk("No");
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(){
  int n,i,j, ans = 10e9;
  scanf("%d",&n);
  char dir[n + 10];
  scanf("%s", dir);
  int east[n],west[n];
  for (i = 0; i < n; i++) {east[i] = 0; west[i] = 0;}
  for (i = 0; i < n; i++){
    int cnt = 0;
    if(dir[i] == 'E') east[i]++;
    else if (dir[i] == 'W') west[i]++;
    if(i) {east[i] += east[i - 1];west[i] += west[i-1];}
  }
  for (i = 0; i < n; i++){
    int num;
    if(i) num = west[i - 1] + east[n - 1] - east[i];
    else num = east[n - 1] - east[i];
    if (ans > num) ans = num;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 2816
n, d = map(int, input().split())
x = []
for _ in range(n):
    X = list(map(int, input().split()))
    x.append(X)

def dist(r1, r2):
    ans = 0
    for i in range(len(r1)):
        ans += (r1[i] - r2[i])**2
    return ans**(1/2)

ans = 0
for i in range(n):
    for j in range(i):
        if dist(x[i], x[j])%1 == 0:
            ans += 1
        else:
            continue

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    string S;
    cin >> S;
    
    if(S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
a, b, c = map(int, input().split())
lis = sorted([a, b, c])
ans = 0
if (lis[1]-lis[0]) % 2 == 0:
    ans += ((lis[1]-lis[0]) // 2)
    ans += lis[2] - lis[1]
else:
    ans += ((lis[1]-lis[0]) // 2) + 1
    ans += lis[2] - lis[1] + 1
print(ans)

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

int main() {
	int A, B;
	cin >> A >> B;
	for (int n = ceil((double) A / 0.08); n < floor((double) (A + 1) / 0.08);
			n++) {
		if (floor((double) n * 0.10) == B) {
			cout << n << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3684
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static final void main(String[] args) {
        Main m = new Main();
        m.init();
        m.solve();
        out.flush();
    }

    // ========================================================================= //

    public void init() {

    }

    public void solve() {
        int r = sc.nextInt();
        int g = sc.nextInt();
        out.println(g * 2 - r);
    }
}


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

namespace ABC111C
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ans = 0;

            if (input.Distinct().Count() == 1)
            {
                ans = input.Length / 2;
            }
            else
            {
                var input1 = input.Select((x, i) => new { x, i }).Where(x => x.i % 2 == 0).Select(x => x.x);
                var input2 = input.Select((x, i) => new { x, i }).Where(x => x.i % 2 == 1).Select(x => x.x);

                var group1 = input1.GroupBy(x => x).OrderByDescending(x => x.Count()).ToArray();
                var group2 = input2.GroupBy(x => x).OrderByDescending(x => x.Count()).ToArray();

                if (group1.First().Key != group2.First().Key)
                {
                    ans = group1.Skip(1).Sum(x => x.Count()) + group2.Skip(1).Sum(x => x.Count());
                }
                else
                {
                    var ans1 = group1.Skip(1).Sum(x => x.Count()) + group2.Sum(x => x.Count()) - group2.ElementAt(1).Count();
                    var ans2 = group1.Sum(x => x.Count()) + group2.Skip(1).Sum(x => x.Count()) - group1.ElementAt(1).Count();
                    ans = ans1 < ans2 ? ans1 : ans2;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 37520
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll h = inp1;

    vector<ll> dp(100, 0);
    vector<ll> dp2(100, 0);
    dp[0] = h;
    dp2[0] = 1;
    RANGE(i, 1, 100) {
        if (dp[i] = dp[i-1] / 2) {
            dp2[i] = dp2[i-1] * 2;
        } else {
            break;
        }
    }
    // DUMPALL(dp2);
    cout << accumulate(ALL_OF(dp2), 0LL) << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int h,m,s;

        h = num/(60*60);
        num -= h*60*60;

        m = num/(60);

        s = num%60;

        System.out.println(h + ":" + m + ":" + s);

    }
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

int swap(int a, int b) {
}
int gcd(int a, int b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}

int main() {
    int n;
    int h[MAXN];

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

    ll cost[MAXN];
    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);

    for(int i=2; i<n; i++) {
        cost[i] = min(cost[i-2] + abs(h[i] - h[i-2]), cost[i-1] + abs(h[i] - h[i-1]));
//        cout << cost[i] << endl;
    }

    cout << cost[n-1] << endl;

    
}



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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



int main(){
string S;
cin >> S;
map<char, int> A;
for(int i = 'a'; i <= 'z'; i++){
A[i] = 0;

}
REP(i, S.length()){
  A[S.at(i)]++;
}
for(auto x : A){
  if(x.second == 0){
    cout << S << x.first << endl;
    return 0;
  }
}
string T = S;
string ans;
if(S =="zyxwvutsrqponmlkjihgfedcba") {
  print(-1);
  return 0;
}else{
  next_permutation(all(S));
  REP(i, S.length()){
    if(S.at(i) == T.at(i)) ans.push_back(S.at(i));
    else {
      ans.push_back(S.at(i));
      print(ans);
      return 0;
    }
  }
} 
print(-1);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;

void solve(){
    int x,y,z; cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N, S;
  while(cin >>N >>S && N){
    vector<int> v(N);
    REP(i, N) cin >>v[i];
    int ans = 0;
    REP(i, N){
      FOR(j, i + 1, N){
        if(v[i] + v[j] > S) ++ans;
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}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;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(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)...);}

class Data{
public:
	int x,y,nx,ny;
	Data()=default;
	Data(int u,int v,int nu,int nv):x(u),y(v),nx(nu),ny(nv){}
};
vector<Data> L;

int H,W;
void dfs(int u,int v,vector<vector<int>>& M,vector<vector<int>>& F){
	F[v][u] = 1;
	if(u<W-1 && !F[v][u+1]){
		if(M[v][u]%2){
			M[v][u]--;
			M[v][u+1]++;
			L.emplace_back(u,v,u+1,v);
		}
		dfs(u+1,v,M,F);
	}
	else if(u>0 && !F[v][u-1]){
		if(M[v][u]%2){
			M[v][u]--;
			M[v][u-1]++;
			L.emplace_back(u,v,u-1,v);
		}
		dfs(u-1,v,M,F);
	}
	else if(v<H-1 && !F[v+1][u]){
		if(M[v][u]%2){
			M[v][u]--;
			M[v+1][u]++;
			L.emplace_back(u,v,u,v+1);
		}
		dfs(u,v+1,M,F);
	}
}

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

	H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W)),F(H,vector<int>(W,0));
	REP(i,H){
		REP(j,W){
			M[i][j]=in();
		}
	}
	
	dfs(0,0,M,F);

	int N=L.size();
	out(N);
	REP(i,N){
		out(L[i].y+1,L[i].x+1,L[i].ny+1,L[i].nx+1);
	}
	return 0;
}


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    for(int i = 0;i < n;i ++){
        b.at(i) = a.at(i);
    }

    sort(a.begin(),a.end(),greater<int>());

    for(int i = 0;i < n;i ++){
        if(b.at(i) == a.at(0)){
            cout << a.at(1) << endl;
        }else{
            cout << a.at(0) << endl;
        }
    }

}


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

int main() {
    int n, p[110][20];
    long long f[110] = {};
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            f[i] = f[i] << 2;
            long long a, b;
            cin >> a >> b;
            f[i] += (a << 1) + b;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }
    long long ans;
    for (long long op = 1; op < (1 << 10); op++) {
        long long tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp += p[i][__builtin_popcount(op & f[i])];
        }
        ans = (op == 1) ? tmp : max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n,a,b=list(map(int,input().split(" ")))
ans=0
for i in range(1,n+1):
    l=list(map(int,str(i)))
    """"""
    #なぜできない？
    lengh=len(l)
    #print(l,lengh)
    s=0
    for j in range(lengh):
        s=+l[j]
        #print("s=",s)
    """"""
    s=sum(l)
    if a<=s and s<=b:
        #print("i=",i)
        ans+=i
print(ans)

Measured memory_bytes: 3064
import Control.Applicative

type Dice
    = (Int, Int, Int, Int, Int, Int)

type Rolling
    = [Char]

type Problem
    = (Dice, Rolling)

type Result
    = Dice

roll :: Dice -> Char -> Dice

roll (s1, s2, s3, s4, s5, s6) char
    = case char of
        'N' -> (s2, s6, s3, s4, s1, s5)
        'S' -> (s5, s1, s3, s4, s6, s2)
        'E' -> (s4, s2, s1, s6, s5, s3)
        'W' -> (s3, s2, s6, s1, s5, s4)

solve :: Problem -> Result

solve (dice, rolling)
    = foldl roll dice rolling

output :: Result -> String

output (s1, _, _, _, _, _)
    = show s1
    
input :: IO Problem

input
    = do
        [s1, s2, s3, s4, s5, s6] <- map read.words <$> getLine
        rolling <- getLine
        return ((s1, s2, s3, s4, s5, s6), rolling)

main :: IO ()

main
    = putStrLn.output =<< solve <$> input

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	ll N;
	int L[200];
	cin >> N;
	ll sum = 0;
	REP(i, 2 * N) {
		cin >> L[i];
	}
	sort(L, L + N*2);
	REP(i, N) {
		sum += L[i * 2];
	}
	cout << sum;

	return 0;
}

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

vector<int> vi;
unordered_map<int, int> m1;

int main() {
    int n;cin>>n;
    for(int i=0;i<n;i++) {
        int a;cin>>a;
        vi.push_back(a);
        m1[i+1+a]++;
    }
    long long ans=0;
    for(int i=0;i<n;i++) {
        if (i+1-vi[i]>0)
        ans+=1LL*m1[i+1-vi[i]];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12820
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    vstr a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    rep(i, n-m+1) {
        rep(j, n-m+1) {
            bool ok = true;
            rep(k, m) {
                string ai = a[i+k].substr(j, m);
                if (b[k] != ai) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                puts("Yes");
                return 0;
            }
        }
    }

    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N,D;
string S;

void solve() {

	cin >> N >> D;
	vector<vector<ll>> vec(N, vector<ll>(D));
	rep(i, N) rep(j, D) cin >> vec[i][j];

	ll ans = 0;

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			ll dist = 0;
			rep(m, D) {
				dist += pow(vec[i][m] - vec[j][m], 2);
			}
			double ddist = sqrt(dist);
			if (ddist - (int)ddist == 0) ans++;
		}
	}

	cout << ans;
}

int main() {
	solve();
	cout << endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<long long int> v(n);
  
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  
  long long int count = 0;
  for(int i = 0; i < n; i++){
    while(true){
      if(v[i] % 2 == 0){
        count++;
        v[i] /= 2;
      }
      else{
        break;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 384
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b == c || b + c == a || a + c == b ? "Yes\n" : "No\n");
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <unordered_set>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	sort(nums.begin(), nums.end());

	int res = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (nums[i] < nums[j] + nums[k] && nums[j] < nums[i] + nums[k] && nums[k] < nums[i] + nums[j]) res++;
			}
		}
	}

	cout << res;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    ll A[N+1],B[N];
    ll count = 0;
    for(int i=0;i<N+1;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin >>B[i];
    for(int i=0;i<N;i++){
      ll left = min(A[i],B[i]);
      count += left;
      B[i] -= left;
      ll right = min(A[i+1],B[i]);
      A[i+1] -= right;
      count += right;


    }
    cout << count << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int d;
	int i;
	int sum;
	
	while (scanf("%d", &d) != EOF){
		sum = 0;
		for (i = d; i < 600; i += d){
			sum += i * i * d;
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

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

int main()
{
  int64_t N, K, a, mx = 0, gc;
  cin >> N >> K;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    mx = max(mx, a);
    if (i)
      gc = __gcd(gc, a);
    else
      gc = a;
  }
  cout << ((!(K % gc) && K <= mx) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>
#include <unordered_map>

using namespace std;

//int X[100000], Y[100000];
//
//void solve() {
//    int P, Q, x, y;
//    char d;
//    cin>>P>>Q;
//    memset(X, 0, sizeof(X));
//    memset(Y, 0, sizeof(Y));
//    for (int i=0; i<P; i++) {
//        cin>>x>>y>>d;
//        if (d == 'N') for (int j= y+1; j<=Q; j++) Y[j]++;
//        if (d == 'S') for (int j= 0; j<y; j++) Y[j]++;
//        if (d == 'E') for (int j= x+1; x<=Q; j++) X[j]++;
//        if (d == 'W') for (int j= 0; j<x; j++) X[j]++;
//    }
//    int ans = 0;
//    for (int i=0; i<=Q; i++) {
//        if (X[i])
//    }
//
//}



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

    long long n, ans = 0;
    cin>>n;
    for (long long m=1; m<=sqrt(n); m++) {
        if (n % (m + 1) && n/(m+1) == n/m) ans += m;
        if (n % m) continue;
        long long mm = n / m - 1;
        //if (mm * mm < n) break;
        if (mm && n/(mm+1) == n/mm) ans += mm;
    }
    cout<<ans<<endl;

//    int T;
//    cin>>T;
//    for (int t=1; t<=T; t++) {
//        cout<<"Case #"<<t<<": ";
//        solve();
//    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())

red_x = []
red_y = []
blue_x = []
blue_y = []
for ls in [[red_x,red_y], [blue_x,blue_y]]:
    for i in range(n):
        x, y = map(int, input().split())
        ls[0].append(x)
        ls[1].append(y)
        
red_x = np.array(red_x)
red_y = np.array(red_y)
blue_x = np.array(blue_x)
blue_y = np.array(blue_y)


def abc091c(red_x, red_y, blue_x, blue_y, count):
    if len(blue_x) > 0:
        blue_min_index = np.where(blue_x == min(blue_x))[0][0] #blue_xの最小値のindexを求める
        x_threshold = blue_x[blue_min_index] #x軸のペア生成可能しきい値
        y_threshold = blue_y[blue_min_index] #y軸のペア生成可能しきい値

        enable_pair_indexes = []
        for i, (r_x, r_y) in enumerate(zip(red_x, red_y)):
            if r_x < x_threshold and r_y < y_threshold:
                enable_pair_indexes.append(i)

        if len(enable_pair_indexes) > 0:
            enable_pair_index = np.where(red_y == max(red_y[enable_pair_indexes]))[0][0]
            #赤い点削除
            red_x = np.delete(red_x, enable_pair_index)
            red_y = np.delete(red_y, enable_pair_index)
            #カウント増加
            count += 1
            
        #青い点削除
        blue_x = np.delete(blue_x, blue_min_index)
        blue_y = np.delete(blue_y, blue_min_index)
        # print(red_x, red_y, blue_x, blue_y)

        abc091c(red_x, red_y, blue_x, blue_y, count)
    else:
        print(count)

count = 0
abc091c(red_x, red_y, blue_x, blue_y, count)


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int main() {

	FAST;

	int k;
	string s;
	cin >> k >> s;
	if (s.length() <= k) {
		cout << s << '\n';
	}
	else {
		s = s.substr(0, k);
		s += "...";
		cout << s << '\n';
	}
	return 0;
}

Measured memory_bytes: 3624
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=1e6+10;
int a[N];
void solve()
{
	int n;
	cin>>n;
	cout<<n+n*n+n*n*n<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}

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

using namespace std;

typedef long long int ll;

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

  int n, m;
  cin >> n >> m;
  vector < ll > a(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];

  map < int, int > mp;

  mp[0] = 1;
  ll sum = 0, ans = 0;
  for(int i = 1; i <= n; i++){
    sum += a[i];
    sum %= m;
    ans += mp[sum];
    mp[sum]++;
  }

  cout << ans << '\n';
}


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

using namespace std;
using ll=long long;
int main(void){
    // Your code here!
    int n,K;
    cin>>n>>K;
    constexpr ll inf=1e15;
    vector<ll> a(n);
    vector<ll> dp(n+4,inf);
    for(auto &b : a)cin>>b;
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=0;i<n;++i){
        for(int k=1;k<=K;++k)
            if(i+k<n)dp[i+k] = min(dp[i+k],dp[i]+abs(a[i+k]-a[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

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

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';

///////////////////////////////////////////////////

#include <cmath>

ll sn(ll n)
{
    return (ll)n * (n+1) / 2;
}

int main()
{
    int N;
    io >> N;

    ll ans = 0;
    int sqN = (int)sqrt(N);
    for (int k = 1; k <= sqN; ++k)
        ans += (sn(N/k) - sn(k)) * k * 2 + k * k;
    io << ans << BR;
}


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

class edge {
public:
	int t, w;
	edge(int t, int w) :
			t(t), w(w) {
	}
};

#define MAX 100000
#define INF INT_MAX
int n;
int d[MAX];
vector<edge> G[MAX];

void bfs(int s) {
	for (int i = 0; i < n; i++)
		d[i] = INF;
	queue<int> Q;
	Q.push(s);
	d[s] = 0;
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (d[e.t] == INF) {
				d[e.t] = d[u] + e.w;
				Q.push(e.t);
			}
		}
	}
}

int solve() {
	int tgt = 0;
	bfs(tgt);
	int maxv = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] == INF)
			continue;
		if (d[i] > maxv) {
			maxv = d[i];
			tgt = i;
		}
	}
	bfs(tgt);
	for (int i = 0; i < n; i++) {
		if (d[i] == INF)
			continue;
		maxv = max(maxv, d[i]);
	}
	return maxv;
}

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int s, t, w;
		cin >> s >> t >> w;
		G[s].push_back(edge(t, w));
		G[t].push_back(edge(s, w));
	}
	cout << solve() << endl;
	return 0;
}



Measured memory_bytes: 9908
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+7;
int a[MAXN];
int main(){
	int n; cin>>n;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	a[n] = 1e9+7;
	int l = 0;
	int r = 1;
	int ans = 0;
	while(l<n){
		while(a[r]<=a[r-1])r++;
		ans = max(ans, r-l-1);
		//cout<<"CHECK : "<<l<<" "<<r<<endl;
		l = r; r++;
	}
	cout<<ans;
}


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

using namespace std;
typedef long long ll;
ll v[500][50],v2[500][50];
char s[100][8];
int main()
{
    ll n,m,k,i,j,l,ans=0,K,x=1,y=1;
    scanf("%lld %lld %lld",&n,&m,&K);
    for(i=1; i<=n; i++)
    {
        getchar();
        for(j=1; j<=m; j++)
        {
            scanf("%c",&s[i][j]);
        }
    }

    for( i = 0; i <(1<<n); i++)
    {
        for( j = 0; j <n; j++)
        {
            if(i & (1 << j))
            {
               // printf("%d ",j);
                v[x][j+1]=1;
            }
        }
        x++;
      //  printf("\n\n");
    }

    for(i=1; i<=n; i++)
    {

        for(j=1; j<=m; j++)
        {
           // printf("%c",s[i][j]);
        }
      //  printf("\n");
    }
    for( i = 0; i <(1<<m); i++)
    {
        for( j = 0; j <m; j++)
        {
            if(i & (1 << j))
            {
               // printf("%d ",j);
                v2[y][j+1]=1;
            }
        }
        y++;
       // printf("\n\n");
    }
    for( i=1; i<x; i++)
    {
        for( j=1; j<y; j++)
        {
            ll a=0;
            for(l=1; l<=n; l++)
            {
                if(v[i][l]!=0)
                {
                    for(k=1; k<=m; k++)
                    {
                        if(v2[j][k]!=0)
                        {
                            if(s[l][k]=='#')
                                a++;
                        }
                    }
                }
            }
           // printf("*%lld\n",a);
            if(a==K)
            {
                ans++;
            }
        }
    }

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





    return 0;

}


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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int a,b,i,j,l;
  cin>>a>>b;
  l=__gcd(a,b);
  cout<<(a*b)/l;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  //TIME
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int x, y, h, w;
	int ookisa;
	int money;
	
	while (1){
		scanf("%d", &n);
		money = 0;
		if (n == 0){
			break;
		}
		while (n != 0){
			scanf("%d %d %d %d", &x, &y, &h, &w);
			ookisa = x + y + h;
			
			if (ookisa <= 60 && w <= 2){
				money += 600;
			}
			else if (ookisa <= 80 && w <= 5){
				money += 800;
			}
			else if (ookisa <= 100 && w <= 10){
				money += 1000;
			}
			else if (ookisa <= 120 && w <= 15){
				money += 1200;
			}
			else if (ookisa <= 140 && w <= 20){
				money += 1400;
			}
			else if (ookisa <= 160 && w <= 25){
				money += 1600;
			}
			n--;
		}
		printf("%d\n", money);
	}
	
	return (0);
}

Measured memory_bytes: 596
fn main() {
    let mut r = String::new();
    let mut g = String::new();
    std::io::stdin().read_line(&mut r);
    let r: i32 = r.trim().parse().unwrap();
    std::io::stdin().read_line(&mut g).unwrap();
    let g: i32 = g.trim().parse().unwrap();
    let ans = 2 * g - r;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    int t=0, h=0;
    for(int i=0; i < n; i++){
        string a, b;
        cin >> a >> b;
        if(a == b)t++,h++;
        else if(a > b)t+=3;
        else h+=3;
    }
    cout << t << ' ' << h << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;

    std::vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> v[i];
    }

    int ret = 0;
    for (;;) {
        bool isEven = true;
        for (int i = 0; i < N; ++i) {
            if (v[i] % 2 == 0) {
                v[i] /= 2;
            } else {
                isEven = false;
                break;
            }
        }

        if (isEven) {
            ++ret;
        } else {
            break;
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256