akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int dp[2000001] = {};
int main() {
	int n;
	scanf("%d", &n);
	int sum = 0;
	dp[0] = 1;
	for (int i = 0;i < n;++i) {
		int a;
scanf("%d",&a);
		sum += a;
		for (int q = min(2000000 - a,2000*i);q >= 0;--q) {
			dp[q + a] |= dp[q];
		}
	}
	for (int i = sum / 2;i >= 0;--i) {
		if (dp[i]) {
			cout << max(i, sum - i) << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define ll long long

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

	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		arr[i] -= i + 1;
	}

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

	ll b = arr[n / 2];
	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		res += abs(arr[i] - b);
	}

	cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,c=0;
    string s[300];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    
    for(int i=0;i<n;i++){
        bool f=true;
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(s[(i+j)%n][k]!=s[(i+k)%n][j]){
                    f=false;
                    j=k=n;
                }
            }
        }
        if(f)c++;
    }
    cout<<c*n<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//solve

//FUNCTION
//solve

void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  sort(ALL(vec));
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = i+1; j < N; j++)
    {
      int L = vec[i] + vec[j];
      auto itr = lower_bound(ALL(vec),L);
      int D = distance(vec.begin(),itr);
      ANS += D - j -1;
    }
  }
  cout<<ANS<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
l=[str(x) for x in range(100000)]
n,k=map(int,input().split())
l2=list(map(str,input().split()))
ind=l.index(str(n))
while True:
  a=l[ind]
  f=False
  for x in l2:
    if x in a:
      f=True
  if not f:
    break
  ind+=1
print(a)

Measured memory_bytes: 9496
//abc071_b.cpp
//Wed Oct 31 23:05:01 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;

	int flag = 0;
	for (char i='a';i<='z';i++){
		if (s.find(i) == -1){
			cout << i << endl;
			flag = 1;
			break;
		}
	}
	if(flag == 0){
		cout << "None" << endl;
	}
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b){
		if (b < c)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
		printf("No\n");
		return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int mod = 1e9 + 7;
int binomialCoeff(int n, int r) {
    int res = 1;
    if(r > n - r)r = n - r;
    for(int i = 0; i < r; i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}


int power(int x, int n, int mod) {
    //(x^n)%mod
    int result = 1;
    while(n) {
        if(n % 2)
            result = (result * x) % mod;
        x = (x * x) % mod;
        n /= 2;
    }
    return result;
}

int inverseMod(int x, int mod) {
    return power(x, mod - 2, mod);
}

int32_t main() {

    fast
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int maxi = max({a * c, a * d, b * c, b * d});
    cout << maxi;


    return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

ll N;
VI A(100100);
VI B;

bool solve(int mid){
  VI C(N);
  rep(i,N){
    if(A[i]>=B[mid]) C[i]=1;
    else C[i]=-1;
  }
  VI D(N+1);
  rep(i,N) D[i+1]=D[i]+C[i];
  rep(i,N+1) D[i]+=N;
  int size=2*N;
  VI BIT(size);
  ll cnt=0;
  rep(i,N+1){
    int tmp=D[i];
    if(i) while(tmp>0){
      cnt+=BIT[tmp];
      tmp-=tmp&(-tmp);
    }
    tmp=D[i];
    while(tmp<size){
      BIT[tmp]++;
      tmp+=tmp&(-tmp);
    }
  }
  ll Z=(N+1)*N/2;
  if(cnt>=(Z+1)/2) return true;
  return false;
}

int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  rep(i,N) B.pb(A[i]);
  sort(all(B));
  int ng=N;
  int ok=0;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(solve(mid)) ok=mid;
    else ng=mid;
  }
  cout<<B[ok]<<endl;
}

Measured memory_bytes: 2680
{-# LANGUAGE BangPatterns #-}
import Prelude hiding (getLine, getContents, words, lines)
import Data.ByteString.Char8 as BC hiding (sort, map, length, head, tail)
import Data.List hiding (words)
import Data.Maybe

modulo :: Int
modulo = 1000000007

powModM :: Int -> Int -> Int
powModM base power = pmm' power 1
    where
        base' = base `mod` modulo
        pmm' 0 acc = acc
        pmm' !p !acc = pmm' (p-1) ((base' * acc) `mod` modulo)

isSane :: [Int] -> Bool
isSane [] = True
isSane l = if head l == 0
              then isSane' 2 (tail l)
              else isSane' 1 l
    where
        isSane' :: Int -> [Int] -> Bool
        isSane' _ [] = True
        isSane' _ [_] = False
        isSane' n (h0:h1:r) = (h0 == n && h1 == n) && isSane' (n+2) r
 
readReport :: IO [Int]
readReport = sort . parse <$> getLine
    where
        parse = map unsafeReadInt . words

unsafeReadInt :: ByteString -> Int
unsafeReadInt = fst . fromJust . readInt

solve ::  [Int] -> Int
solve v = if isSane v
             then powModM 2 $ length v `div` 2
             else 0

main = do
    _ <- getLine
    readReport >>= print . solve

Measured memory_bytes: 16764
H,W=map(int,input().split())

ans=float('inf')
for h in range(1,H+1):
  div1,div2=h*W,(H-h)*(W//2)
  div3=H*W - (div1+div2)
  divs=[div1,div2,div3]
  ans=min(ans,max(divs)-min(divs))
  div1,div2=h*W,((H-h)//2)*W
  div3=H*W - (div1+div2)
  divs=[div1,div2,div3]
  ans=min(ans,max(divs)-min(divs))
H,W=W,H
for h in range(1,H+1):
  div1,div2=h*W,(H-h)*(W//2)
  div3=H*W - (div1+div2)
  divs=[div1,div2,div3]
  ans=min(ans,max(divs)-min(divs))
  div1,div2=h*W,((H-h)//2)*W
  div3=H*W - (div1+div2)
  divs=[div1,div2,div3]
  ans=min(ans,max(divs)-min(divs))
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>

#define X first
#define Y second
#define PB push_back

using namespace std;

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

const int N = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;

inline int add(int A, int B){
	if(A + B >= MOD)
		return A + B - MOD;
	return A + B;
}

inline int sub(int A, int B){
	if(A - B < 0) 
		return A - B + MOD;
	return A - B;
}

inline int mul(int A, int B){
	return (ll)A * B % MOD;
}

inline int pot(int A, int B){
	int bs = A, ret = 1;
	for(;B;B >>= 1){
		if(B & 1) ret = mul(ret, bs);
		bs = mul(bs, bs);
	}
	return ret;
}

inline int divv(int A, int B){
	return mul(A, pot(B, MOD - 2));
}

int gcd[N], A[N], n, sol = 0;

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d", A + i);
		gcd[A[i]] = add(gcd[A[i]], A[i]);
		sol = sub(sol, A[i]);
	}
	for(int i = 1;i < N;i++){
		for(int j = 2 * i;j < N;j += i)
			gcd[i] = add(gcd[i], gcd[j]);
		gcd[i] = mul(gcd[i], gcd[i]);
	}
	for(int i = N - 1;i >= 1;i--){
		for(int j = 2 * i;j < N;j += i)
			gcd[i] = sub(gcd[i], gcd[j]);
		sol = add(sol, divv(gcd[i], i));
	}
	printf("%d\n", divv(sol, 2));
	return 0;
}

Measured memory_bytes: 6784
n, q = map(int, input().split())
s = input()
c = [0] * (n + 1)
for i in range(2, n + 1):
  if s[i - 1] == 'C' and s[i - 2] == 'A':
    c[i] = c[i - 1] + 1
  else:
    c[i] = c[i - 1]
for _ in range(q):
  l, r = map(int, input().split())
  t = c[r] - c[l - 1]
  if l > 1 and s[l - 2: l] == 'AC':
    t -= 1
  print(t)


Measured memory_bytes: 6164
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return a;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

const int MAX_N = 100000;
const int MAX_V = 1000000000;

int main() {
  int N; cin >>N;
  vector<int> X(N), L(N);
  rep(i, N) cin >>X.at(i) >>L.at(i);
  vector<pair<int,int>> ps(N);
  rep(i, N) ps.at(i) = make_pair(X.at(i)+L.at(i), X.at(i)-L.at(i));
  sort(all(ps));

  int comp = -MAX_V;
  int ans = 0;
  rep(i, N){
    if (comp <= ps.at(i).second){
      comp = ps.at(i).first;
      ans++;
    }
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,b;
    cin>>n;
    int a[n+1][2];
    int coun=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=2;j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=1;i<=n-2;i++)
    {
        if(a[i][1]==a[i][2]&&a[i+1][1]==a[i+1][2]&&a[i+2][1]==a[i+2][2])
        {
            coun++;
        }
    }
    if(coun>=1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N;
int v[100005];
LL s[100005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++) scanf("%d", &v[i]);
    sort(v + 1, v + N + 1);
    for(int i = 1; i <= N; i++) s[i] = s[i - 1] + v[i];
    int ans = 0;
    for(int i = N; i >= 1; i--)
        if(2 * s[i] >= v[i + 1])
            ans++;
        else
            break;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if (a * b % 2 == 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();
		for(int i = 0 ; i <= n ; i++) {
			for(int j = 0 ; i + j <= n ; j++) {
				int k = n - i - j;
				if(i * 10000 + j * 5000 + k * 1000 == y) {
					System.out.println(i + " " + j + " " + k);
					return;
				}
			}
		}
		System.out.println(-1 + " " + -1 + " " + -1);
	}
}


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

int main(){
  int n;
  cin >> n;
  vector<double>v(n);
  for(int i=0; i<n; i++)cin >> v[i];
  sort(v.begin(), v.end());
  double ret=v[0];
  for(int i=1; i<n; i++){
    ret = (ret+v[i])/2;
  }
  cout << ret;
  return 0;
}


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


signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin>>n;
    if (n%1000==0) cout<<0<<endl;
    else {
        int mul = n/1000;
        cout<<(mul+1)*1000-n<<endl;

    }

    return 0 ;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;

long long n;
long long aa;
long long bb;
long long ans;
long long now_a;
long long now_b;
long long now_wa;
int main()
{
	long long a,b;
	cin>>n;
	ans=1;
	aa=1;
	bb=1;
	rep(i,n)
	{
		cin>>a>>b;
		now_a=a;
		now_b=b;
		now_wa=a+b;
		if(aa%a!=0)
		{
			now_a=max(now_a,(long long)((aa/a)+1)*a);
			now_b=max(now_b,(long long)((aa/a)+1)*b);
		}
		else
		{
			now_a=max(now_a,(long long)(aa/a)*a);
			now_b=max(now_b,(long long)(aa/a)*b);
		}
		if(bb%b!=0)
		{
			now_a=max(now_a,(long long)((bb/b)+1)*a);
			now_b=max(now_b,(long long)((bb/b)+1)*b);
		}
		else
		{
			now_a=max(now_a,(long long)(bb/b)*a);
			now_b=max(now_b,(long long)(bb/b)*b);
		}
		if((aa+bb)%(a+b)!=0)
		{
			now_a=max(now_a,(long long)(((aa+bb)/(a+b))+1)*a);
			now_b=max(now_b,(long long)(((aa+bb)/(a+b))+1)*b);
		}
		aa=now_a;
		bb=now_b;
		//cout<<aa<<" "<<bb<<endl;
	}
	cout<<aa+bb<<endl;
	return 0;
}

Measured memory_bytes: 256
module A = Array
module C = Char
module I = Int64
module L = List
module Q = Queue

let pf = Printf.printf
let sf = Scanf.scanf
let ssf = Scanf.sscanf

let read_int () = sf "%d " (fun x -> x)
let read_float () = sf "%f " (fun x -> x)
let read_str () = sf "%s " (fun x -> x)
let read_array read n = A.init n (fun _ -> read ())
let err s = raise (Failure s)

let range s t = A.init (t - s) @@ (+) s
let foreach fold_f init s t map_f =
  range s t |> A.map map_f |> A.fold_left fold_f init

let inf = int_of_float 1e18
let eps = 1e-11

module S = struct
  include String
  let of_array a = String.init (A.length a) (A.get a)
  let to_array s = A.init (String.length s) (String.get s)
end;;

let rec search vals str sum goal =
  match vals with
  | [] ->
     if sum = goal
     then Some str
     else None
  | x :: xs ->
     (* case + *)
     let case_plus = search xs (str ^ "+" ^ string_of_int x) (sum + x) goal in
     ( match case_plus with
       | None -> search xs (str ^ "-" ^ string_of_int x) (sum - x) goal
       | _ -> case_plus )

let () =
  let s = read_str () in
  let vals = S.to_array s |> A.map int_of_char |> A.to_list in
  let vals = L.map (fun x -> x - int_of_char '0') vals in
  let head = L.hd vals in
  let tail = L.tl vals in
  let res = search tail (string_of_int head) head 7 in
  match res with
  | None -> ()
  | Some x -> pf "%s=7\n" x
  


Measured memory_bytes: 384
import java.util.*;

class MathUtil {
	public static void swap(int[] obj, int a, int b) {
		int tmp = obj[a];
		obj[a] = obj[b];
		obj[b] = tmp;
	}
}

class Dice {
	int N=6;
	int ten[] = new int[N+1];

	public Dice(int[] tenkaizu) {
		for(int i=1;i<=N;i++) {
			this.ten[i] = tenkaizu[i-1];
		}
	}

	@Override
	public boolean equals(Object obj) {
		return this.toNumberStr().equals(((Dice)obj).toNumberStr());
	}

	@Override
	public int hashCode() {
		return (int)Long.parseLong(toNumberStr());
	}

	public int showDice(int number) {
		return ten[number];
	}

	public void printDice() {
	    for(int i=1;i<=N;i++) {
            System.out.print(ten[i] + "\t");
        }
        System.out.println("");
    }

	public void rotate(String meirei) {
		switch (meirei) {
			case "N":
				rotate(1, 2, 6, 5);
				break;
			case "S":
				rotate(5,6, 2, 1);
				break;
			case "E":
				rotate(4, 6, 3, 1);
				break;
			case "W":
				rotate(1, 3, 6, 4);
				break;
		}
	}

	public void rotate(int a, int b, int c, int d) {
		MathUtil.swap(ten, a, b);
		MathUtil.swap(ten, b, c);
		MathUtil.swap(ten, c, d);
	}

	public void rotate(int a, int b, int c) {
		MathUtil.swap(ten, a, b);
		MathUtil.swap(ten, b, c);
	}

	/**
	 * ????????????????????¢??????d?????????
	 * @param d
	 */
	public void topTo(int d) {
		for(int i=0;i<4;i++) {
			rotate("W");
			if(showDice(1) == d) break;
		}
		for(int i=0;i<4;i++) {
			rotate("N");
			if(showDice(1) == d) break;
		}
	}

	public int findRight(int frontD) {
		int[] pos = {4,2,3,5};
		for(int i=0;i<4;i++) {
			if(ten[pos[i]] == frontD) {
				return ten[pos[(i+1)%4]];
			}
		}
		return -1;
	}

	public String toNumberStr() {
		String str = "";
		for(int i=1;i<=N;i++) {
			str += ""+ten[i];
		}
		return str;
	}
}

class DiceUtil {
	static Set<String> diceSet;
	public static boolean isSame(Dice d1, Dice d2) {
		diceSet = new HashSet<>();
		return dfs(d1, d2);
	}

	public static boolean dfs(Dice d1, Dice d2) {
		int n = diceSet.size();
		if(diceSet.contains(d1)) return false;
		if(d1.equals(d2)) return true;
		diceSet.add(d1.toNumberStr());
		if(n == diceSet.size()) return false;
		for(int i=0;i<4;i++) {
			d1.rotate("N");
			if(dfs(d1, d2)) return true;
		}
		for(int i=0;i<4;i++) {
			d1.rotate("E");
			if(dfs(d1, d2)) return true;
		}
		return false;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		in.nextLine();
		List<Dice> dices = new ArrayList<>();
		for(int k=0;k<n;k++) {
			String[] men_str = in.nextLine().split(" ");
			int[] men_int = new int[6];
			for (int i = 0; i < 6; i++) {
				men_int[i] = Integer.parseInt(men_str[i]);
			}
			Dice dice = new Dice(men_int);
			dices.add(dice);
		}
		boolean answer = true;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				if(DiceUtil.isSame(dices.get(i), dices.get(j))) {
					answer = false;
					break;
				}
			}
			if(!answer) break;
		}
		if(answer) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 304800
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()

	for i := 9; i >= 1; i-- {
		if N%i == 0 && N/i < 10 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string S; cin >> S;
  int N = S.size();
  string ans{};
  ans += S[0];
  ans += std::to_string(N-2);
  ans += S[N-1];
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n,sum=0;
        cin>>n;
        ll arr[n];
        for(ll i=0;i<n;i++){
            cin>>arr[i];
            sum=sum^arr[i];
        }
        for(ll i=0;i<n;i++){
            arr[i]=sum^arr[i];
        }
        for(auto it:arr)cout<<it<<" ";
}


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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef long double ld;

const int N = 500200;
const int mod = 1e9 + 7;
int n, k, q, a[N], bad[N];

inline bool check(int id, int sub) {
    int up = a[id] + sub;
    int last = 0, ops = 0;
    for(int i = 1; i <= n; ++i) {
        if(bad[i]) {
            int len = i - last - 1;
            if(len >= k) {
                int tmp = 0;
                for(int j = last + 1; j < i; ++j)
                    if(a[j] <= up) ++tmp;
                ops += min(tmp, len - k + 1);
            }
            last = i;
        }
    }
    if(n - last >= k) {
        int tmp = 0;
        for(int j = last + 1; j <= n; ++j) {
            if(a[j] <= up) ++tmp;
        }
        ops += min(tmp, n - last - k + 1);
    }
    return ops >= q;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k >> q;
    fo(i, n) cin >> a[i];
    if(q == 1) return cout << 0, 0;
    vector<int> v;
    int ans = 2e9;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j)
            if(a[j] < a[i]) bad[j] = 1;
            else bad[j] = 0;
        v.clear();
        for(int j = 1; j <= n; ++j)
            if(a[j] >= a[i]) v.pb(a[j] - a[i]);
        sort(v.begin(), v.end());
        v.resize(unique(v.begin(), v.end()) - v.begin());
        int l = -1, r = (int)v.size() - 1;
        while(l + 1 < r) {
            int m = (l + r) >> 1;
            if(check(i, v[m])) r = m;
            else l = m;
        }
        if(check(i, v[r])) ans = min(ans, v[r]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

// h1 = max(H - |x1-Cx| - |y1-Cy|,0)
// h2 = H - |x2-Cx| - |y2-Cy|
// h3 = H - |x3-Cx| - |y3-Cy|

string solve(){
  ll N; cin>>N;
  ll x[N];
  ll y[N];
  ll h[N];
  REP(i,N){
    cin>>x[i]>>y[i]>>h[i];
  }
  string ans;
  for(ll cx=0; cx<=100;++cx){
    bool ok;
    for(ll cy=0; cy<=100; ++cy){
      ll H;
      REP(i,N){
        if(h[i]>0){
          H = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
        }
      }
      ok = true;
      REP(i,N){
        if(h[i]!=max(H- abs(x[i]-cx) -abs(y[i]-cy), (ll)0) ){ ok = false; break;}
      }
      if(ok){ ans = to_string(cx) + " " + to_string(cy) + " " + to_string(H); break;}
    }
    if(ok){break;}
  }
  return ans;
}

int main(){
  cout << solve()<<"\n";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int a[1000000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n;
	int h1, h2;
	scanf("%d%d", &n,&h1);

	int ans = 0;
	REP(i, n - 1) {
		scanf("%d", &h2);
		if (h1 <= h2) {
			h1 = h2;
		}
		else {
			ans += h1 - h2;
			h1 = h2;
		}
	}
	ans += h1;
	PRINTD(ans);
}

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

int main(){
    ll N;
    std::string str;

    std::cin >> N;
    std::cin >> str;

    vector<int> A(N, 0);

    for(int i=1;i<str.size();i++)
    {

        if(str[i-1] == 'W')
        {
            A[i] = A[i-1] + 1;
        }else
        {
            A[i] = A[i-1];
        }
        
    }

    ll tmpValue = 0;
    for(int i=(str.size()-2);i>=0;i--)
    {
        if(str[i+1] == 'E')
        {
            tmpValue++;
        }        
        A[i] += tmpValue;
    }

    std::sort(A.begin(), A.end());
    std::cout << A[0];

    return 0;
}




Measured memory_bytes: 1796
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
ll mod = 1000000007;
int m[100][100];
bool flag[100][100];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	int num;
	scanf("%d", &num);
	vector<int>v;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	int r = 0;
	for (int i = 0; i < num; i++)
	{
		if (i % 2 == 0)r += v[i];
		else r -= v[i];
	}
	cout << r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char s[100005];
    int n=0, check[2], ans;
    scanf("%s", s);
    while(strncmp(&s[n], "\0", 1)!=0) n++;
    
    if(n%2==0) check[0]=1;
    else check[0]=0;

    if(strncmp(&s[0], &s[n-1], 1)==0) check[1]=1;
    else check[1]=0;

    if(check[0]!=check[1]) printf("Second");
    else printf("First");

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
      //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] score = new int[100010];
        int q = sc.nextInt();
        for (int i=0;i<n;i++) {
           score[i] = k-q;
        }
        //int[] array = new int[100010];
        for (int i=0;i<q;i++) {
           score[sc.nextInt()-1] ++;
        }
      //ラウンド
      //  for (int i=0;i<q;i++) {
       //   for (int j=0;j<n;j++) {
         //   if(j==array[i]-1) score[j] = score[j];
           // else score[j] --;
          //}
        //}
      
      //発表
        for (int i=0;i<n;i++) {
          if(score[i]>0) System.out.println("Yes");
          else System.out.println("No");
        }
    }
}



Measured memory_bytes: 66700
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> m(1001,0);

int main(){

    ll n; cin >> n;
    ll pos = 1;
    vector<ll> a(n);
    vector<ll> ans(n+1,0);
    vector<ll> d(n+1);
    ll sum = 0;

    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }

    rep(i,n-1){
        d[i+1] = a[i+1]-a[i];
    }
    d[n] = a[n-1]-a[0];

    for(int i = 1; i <= n; i ++){
        d[i] *= 2;
    }

    ans[1] = 0;

    for(int i = 1; i < n-1; i += 2){
        ans[i+2] = ans[i] + d[i];
    }

    ans[2] = ans[n]-d[n];

    for(int i = 2; i <= n-2; i += 2){
        ans[i+2] = ans[i] + d[i];
    }

    for(int i = 1; i <= n; i ++){
        sum -= ans[i];
    }

    ans[1] = sum/n;
    cout << ans[1] << " ";

    for(int i = 2; i <= n; i ++){
        cout << ans[i] + ans[1] << " ";
    }



    return 0;
}

Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	int n,m; cin>>n>>m;
	long long x[n],y[n],z[n]; rep(i,n) cin>>x[i]>>y[i]>>z[i];

	//最終結果の符号(8通り)を決めて最適なm個を取り出す
	long long ans=0;
	rep(i,8){
		long long a[n]={};
		rep(j,n){
			long long p=x[j],q=y[j],r=z[j];
			a[j]+=(i&1?p:-p);
			a[j]+=(i>>1&1?q:-q);
			a[j]+=(i>>2&1?r:-r);
		}
		sort(a,a+n); reverse(a,a+n);
		long long tmp=0;
		rep(k,m) tmp+=a[k];
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;

	return 0;
}


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

// (5-(6/2/2+50*3/2/3*6/4)/9*2-(6/2/2+50*3/2/3*6)-36)*2-1=

class Main{
	static Pattern addsub = Pattern.compile("^(.*?)(-?\\d+)([+Z])(-?\\d+)(.*)$");
	static Pattern muldiv = Pattern.compile("^(.*?)(-?\\d+)([*/])(-?\\d+)(.*)$");

	static String process(String s){
	//System.out.println("---"+s);
		//analyze parens
		int bidx=s.indexOf("(");
		while(bidx!=-1){
			int count=1,eidx=bidx+1;
			for(;count!=0;eidx++){
				if(s.charAt(eidx)=='(')count++;
				if(s.charAt(eidx)==')')count--;
			}
			s=s.substring(0,bidx)+process(s.substring(bidx+1,eidx-1))+s.substring(eidx);
	//System.out.println("+++"+s);
			bidx=s.indexOf("(");
		}

		//calc without parens
		Matcher m=muldiv.matcher(s);
		while(m.find()){
			if(m.group(3).equals("*"))
				s=m.group(1)+(Integer.parseInt(m.group(2))*Integer.parseInt(m.group(4)))+m.group(5);
			else
				s=m.group(1)+(Integer.parseInt(m.group(2))/Integer.parseInt(m.group(4)))+m.group(5);
			m=muldiv.matcher(s);
		}

		m=addsub.matcher(s);
		while(m.find()){
			if(m.group(3).equals("+"))
				s=m.group(1)+(Integer.parseInt(m.group(2))+Integer.parseInt(m.group(4)))+m.group(5);
			else
				s=m.group(1)+(Integer.parseInt(m.group(2))-Integer.parseInt(m.group(4)))+m.group(5);
			m=addsub.matcher(s);
		}
		return s;
	}

	public static void main(String[]z){
		Scanner x=new Scanner(System.in);
		int n=x.nextInt();for(;n>0;n--){
			String s=x.next().replaceAll("-","Z");
			System.out.println(process(s.substring(0,s.length()-1)));
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int main() {
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool pass = c > d;

    bool canChange = false;
    for (int i = b; i <= d; i++) {
        if (s[i - 2] != '#' && s[i - 1] != '#' && s[i] != '#')canChange = true;
    }

    bool ret = true;
    for (int i = a; i <= c; i++) {
        if (s[i - 1] == '#' && s[i] == '#')ret = false;
    }
    for (int i = b; i <= d; i++) {
        if (s[i - 1] == '#' && s[i] == '#')ret = false;
    }

    cout << (ret && (!pass || canChange) ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;
//#define int long long
const int INF = 1000000007;


int a[500001];
signed main(){
    int  n,t;
    cin>>n>>t;
    int l,m,lmax,mmin;
    cin>>l>>m;
    lmax=l;mmin=m;
    for(int i=1;i<t;i++){
        cin>>l>>m;
        lmax=max(lmax,l);
        mmin=min(m,mmin);
    }
    cout<<max(0,mmin-lmax+1);
    
   
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N  = sc.nextInt();

		String S = sc.next();

		int R = 0;

		int B = 0;

		for(int i=0;i<N;i++) {

			if(S.charAt(i)=='R' ) R++;

			else B++;
		}

		if(R>B) System.out.println("Yes");
		else System.out.println("No");
	}

}


Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


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

tuple<int,int,int>calc(int N,int Y,int x,int y,int z){
    for(x=0;x<=N;x++){
        for(y=0;y<=N-x;y++){
            z=N-x-y;
            if(10000*x+5000*y+1000*z==Y){
                return forward_as_tuple(x,y,z);
            }
        }
    }
    return forward_as_tuple(-1,-1,-1);
}

int main(){
    int N,Y;
    cin>>N>>Y;
    int x,y,z;
    tie(x,y,z)=calc(N,Y,x,y,z);
    cout<<x<<' '<<y<<' '<<z;
}

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

const int MAX_N = 1e5 + 100;

vector<bool> PrimeTable(MAX_N + 1, true);

void PrimeTableInit() {
    PrimeTable[0] = false;
    PrimeTable[1] = false;
    for (int i = 2; i < sqrt(MAX_N) + 1; i++) {
        if (PrimeTable[i]) {
            int j = 2;
            while(i * j <= MAX_N) {
                PrimeTable[i * j] = false;
                j++;
            }
        }
    }
}

int main() {
    PrimeTableInit();
    int X; cin >> X;
    for (int i = X; i <= MAX_N; i++) {
        if (PrimeTable[i]) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 
  long a;
  scanf("%ld", &a);
  long b;
  scanf("%ld", &b);
  long c;
  scanf("%ld", &c);

  if(a+b-c>=0){
      printf("No");
  }else if((a+b-c)*(a+b-c)>4*a*b){
      printf("Yes");
  }else{
      printf("No");
  }
 
  return 0;
}

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

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


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int>T;
T line[200001];
bool flg[200001]={false};
int main(void){
	int n,m,q;
	int a[200000];
	int x[1001];
	int i,j,k,l;
	cin>>n>>m>>q;
	for(i=0;i<n;i++){
		if(i==0){			get<0>(line[i])=n-1;	get<1>(line[i])=i;	get<2>(line[i])=i+1;}
		else if(i==n-1){	get<0>(line[i])=i-1;	get<1>(line[i])=i;	get<2>(line[i])=0;}
		else{				get<0>(line[i])=i-1;	get<1>(line[i])=i;	get<2>(line[i])=i+1;}
	}
	for(i=0;i<m;i++)	cin>>a[i];
	for(i=0;i<q;i++)	cin>>x[i];
/* 	for(i=0;i<n;i++)	cout<<get<0>(line[i])<<" "<<get<1>(line[i])<<" "<<get<2>(line[i])<<endl;
	cout<<endl;
 */	
	k=0;
	for(i=0;i<m;i++){
		//cout<<"K="<<k<<endl;
		if(a[i]%2==0){
			j=0;
			while(j!=a[i]){
				k=get<2>(line[k]);
			//	cout<<"K2="<<k<<endl;
				j++;
			}
			get<2>(line[get<0>(line[k])])=get<2>(line[k]);
			get<0>(line[get<2>(line[k])])=get<0>(line[k]);
			k=get<2>(line[k]);
		}
		else{//a[i]%2!=0
			j=0;
			while(j!=a[i]){
				k=get<0>(line[k]);
			//	cout<<"K1="<<k<<endl;
				j++;
			}
			get<2>(line[get<0>(line[k])])=get<2>(line[k]);
			get<0>(line[get<2>(line[k])])=get<0>(line[k]);
			k=get<2>(line[k]);
		}
		/* for(j=0;j<n;j++)	cout<<get<0>(line[j])<<" "<<get<1>(line[j])<<" "<<get<2>(line[j])<<endl;
		cout<<endl; */
	}
	l=k;
	while(1){
		k=get<2>(line[k]);
		flg[k]=true;
		if(k==l)	break;
	}
	for(i=0;i<q;i++)	cout<<flg[x[i]]<<endl;
	
	return 0;
}
	


Measured memory_bytes: 6228
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX (400)

using namespace std;

typedef long long ll;

int n, m, s[MAX], l[MAX], p[MAX], w[MAX];
int dp[MAX];

int main() {
    /* 入力 */
    cin >> n;
    REP(i, n) {
        cin >> s[i] >> l[i] >> p[i];
    }
    
    cin >> m;
    REP(i, m) {
        cin >> w[i];
    }
    
    fill(dp, dp + MAX, -1);
    dp[0] = 0;
    
    /* メロディの長さの最大点数を作って行く */
    REP(i, MAX) {
        REP(j, n) {
            FOR(k, s[j], l[j] + 1) {
                if (i - k >= 0) {
                    dp[i] = max(dp[i], dp[i - k] + p[j]);
                }
            }
        }
    }
    
    /* 初期値のままだったら-1 */
    REP(i, m) {
        if (dp[w[i]] < 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    /* 答えの出力 */
    REP(i, m) {
        cout << dp[w[i]] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3124
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>; 

vl A;
bool dfs(ll now, ll sum){
    if(sum == 0) return true;
    else if(now == A.size() || sum < 0) return false;
    return dfs(now+1, sum-A[now]) || dfs(now+1, sum);
}

int main() {
    ll n;
    cin >> n;
    A.resize(n);
    rep(i, n) cin >> A[i];
    ll q;
    cin >> q;
    rep(i, q){
        ll m;
        cin >> m;
        cout << ( dfs(0, m) ? "yes" : "no" ) << endl;
    }
}



Measured memory_bytes: 3136
#include <iostream>

using namespace std;

int main()
{
    int x, y, z, r1, r2, r3;
    cin >> x >> y >> z;

    r1 = x + y;
    r2 = x + z;
    r3 = y + z;

    if (r1 == z)
        cout << "Yes";
    else if (r2 == y)
        cout << "Yes";
    else if (r3 == x)
        cout << "Yes";

    else cout << "No";
    return 0;
}



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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 2e5 + 41;

int n;
int a[MAX];
int b;
ll ans;

void solve() {
	vi v;
	fi(1, n) {
		v.pb(a[i] - i);
	}
	sort(v.begin(), v.end());
	b = v[n / 2];
	//
	err("b = %d\n", b);
	//
	fi(1, n) {
		ans += abs(a[i] - i - b);		
	}
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  fi(1, n) {
  	scanf("%d", &a[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
// #define int long long
void read(int &x)
{
    int r = 0, ne = 1;
    char c;
    while (c < '0' || c > '9')
    {
        if (c == '-')
            ne = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        r = r * 10 + c - '0';
        c = getchar();
    }
    x = r * ne;
}
struct  Edge
{
    /* data */
    int i,nxt;
};
/* 链表 */
int h[100002],tot;
Edge e[200002];
inline void _add(int x,int y){
    e[++tot].i=y;
    e[tot].nxt=h[x];
    h[x]=tot;
    e[++tot].i=x;
    e[tot].nxt=h[y];
    h[y]=tot;
}
/* 输入 */
int n,m,x,y;
/* 偶环-求解 */
int s[100002],top,mid;
/* dfs */
bool odd;/* 奇环 */
int A,B;/* 环两个连接点 */
int w[100002];/* 点绿色权值(1,-1) */ /* 第二遍扫时存的是子树总权值 */
int k[100002];/* 偶环时标记多余边到LCA的点 */
int sum;/* 权值总和 */
long long ans;/* 答案 */
void dfs(int x,int fa){/* 染色 */
    for(int i=h[x];i;i=e[i].nxt){      
        int o=e[i].i;
        if(o==fa)continue;
        if(w[o]){
            if(w[o]==w[x])
                odd=true;
            A=x,B=o;
        }else{
            w[o]=-w[x];
            // sum+=w[o];
            dfs(o,x);
        }
    }
}
void Dfs(int x,int fa){/* 求解 */
    for(int i=h[x];i!=0;i=e[i].nxt){
        int o=e[i].i;
        if(o==fa||(o==A&&x==B)||(o==B&&x==A))continue;/* 排除基环树的干扰 */
        Dfs(o,x);
        w[x]+=w[o];
        k[x]+=k[o];
    }
}
signed main(){
    read(n),read(m);
    for(register int i=0;i<m;++i){
        read(x),read(y);
        _add(x,y);
    }
    // if(n%2){
    //     puts("-1");
    //     return 0;
    // }
    w[1]=1;
    // sum=1;
    dfs(1,0);
    for(int i=1;i<=n;++i)sum+=w[i];    
    if(m+1==n)/* 树 */{
        if(sum){
            puts("-1");
           return 0;
        }
    }else{
        if(odd)/* 奇环 */{
            if(sum&1){
                puts("-1");
                return 0;
            }
            ans+=abs(sum>>1);
            w[A]-=sum>>1,w[B]-=sum>>1;
        }else/* 偶环 */{
            if(sum){
                puts("-1");
                return 0;
            }else 
                k[A]=1,k[B]=-1;
        }
    }
    Dfs(1,0);
    for(register int i=1;i<=n;++i){
        if(k[i])
            s[++top]=k[i]*w[i];
        else
            ans+=abs(w[i]);
    }
    s[++top]=0;
    sort(s+1,s+top+1);
    mid=s[(top+1)>>1];
    for(register int i=1;i<=top;++i)
        ans+=abs(s[i]-mid);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 14636
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n, *v, *c, sum = 0;

	scanf("%d", &n);

	v = (int*)malloc(sizeof(int)* n);
	c = (int*)malloc(sizeof(int)* n);

	for (int i = 0; i < n; i++)
		scanf("%d", &v[i]);

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

		if (v[i] - c[i] > 0)
			sum += v[i] - c[i];
	}

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

	return 0;
}

Measured memory_bytes: 128
import math
num = int(input())
arr = input().split()
arr = sorted([int(i) for i in arr])

lis1 = [0]*(arr[-1]+1)

for num in arr:
  for j in range(0, len(lis1), num):
    lis1[j] += 1

cnt = 0
for num in arr:
  if lis1[num]==1: cnt+=1
    
print(cnt)

Measured memory_bytes: 34556
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <set>
#include <algorithm>
#include <cstring>

using namespace std;

bool g_schedule[50][31];
set<int> g_map[50][31]; // DP

int g_n;

int solution() {
	for (int i = 1; i <= 30; ++i) {
		vector<int> ables; // i日目に予定が空いている人達
		for (int j = 0; j < g_n; ++j) {
			if (g_schedule[j][i]) ables.push_back(j);
			else g_map[j][i] = g_map[j][i - 1];
		}

		set<int> gathers; // i日目に集めることができる地図の断片
		for (auto able = ables.begin(); able != ables.end(); ++able) {
			for (auto it = g_map[*able][i - 1].begin(); it != g_map[*able][i - 1].end(); ++it) {
				gathers.insert(*it);
			}
		}
		for (auto it = ables.begin(); it != ables.end(); ++it) {
			g_map[*it][i] = gathers;
		}

		// 終了条件
		for (int j = 0; j < g_n; ++j) {
			if (g_map[j][i].size() == g_n) return i;
		}
	}

	return -1;
}

int main() {
	while (true) {
		cin >> g_n;
		if (g_n == 0) break;

		// 初期化
		for (int i = 0; i < g_n; ++i) {
			g_map[i][0].clear();
			g_map[i][0].insert(i);
		}
		memset(g_schedule, false, sizeof(g_schedule));

		// 入力
		for (int i = 0; i < g_n; ++i) {
			int f;
			cin >> f;
			for (int j = 0; j < f; ++j) {
				int day;
				cin >> day;
				g_schedule[i][day] = true;
			}
		}

		cout << solution() << endl;
	}

}

Measured memory_bytes: 4672