akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,m;cin>>n>>m;
  vector<int> a(n+1,0);
  vector<int> sum(n+5,0);
  map<int,int> memo;
  memo[0]=1;
  rep1(i,n){
    cin>>a[i];
    sum[i]=sum[i-1]+a[i];
    sum[i]%=m;
    memo[sum[i]]+=1;
  }
  int res=0;
  for(auto it=memo.begin();it!=memo.end();++it){
      res+=it->second*(it->second-1)/2;
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 5760
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  long sum = 0;

  sc.scan(N);

  foreach (i; 1 .. N + 1) {
    if (i % 3 != 0 && i % 5 != 0)
      sum += i;
  }

  writeln(sum);
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
// #define int long long
#define pb push_back
#define INF 100000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;



int a;
int b;
int c;



signed main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if(a-b == b-c){
        printf("YES\n");
        return 0;
    }
    printf("NO\n");
    return 0;

}





Measured memory_bytes: 256
import java.io.*;
import java.lang.reflect.Array;
import java.util.Arrays;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int num = Integer.parseInt(br.readLine());         
           	for(int i = 0; i < num; i++){
           		String[] in =  br.readLine().split(" ",0);
           		int[] data  = {Integer.parseInt(in[0]),Integer.parseInt(in[1]),Integer.parseInt(in[2])};
           		Arrays.sort(data);
           		if(data[2] * data[2] == data[1] * data[1] + data[0] * data[0]){
           			System.out.println("YES");
           		}else {
           			System.out.println("NO");
				}
           	}


        }catch (Exception e) {
			// TODO: handle exception
        	System.exit(0);
		}
		
	}

}

Measured memory_bytes: 26132
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N, L;
    cin >> N >> L;
    string tmp;
    vector<string> v;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    for(int j = 0; j < N; j++){
        cout << v[j];
    }
    cout << endl;
}

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

#define MAX 256

int f(int x, int y){
	if (y == 0)return x;
	return f(y, x%y);
}

int main(void){
	
	long max[50], min[50];
	for (long i = 0; i < 50; i++){
		max[i] = 0;
		min[i] = 0;
	}

	long a, b;
	long i = 0;

	while (scanf("%ld%ld", &a, &b) != EOF){
		max[i] = f(a, b);
		long j = 1;
		while (min[i] == 0){
			if ((a*j) % b == 0)min[i] = a*j;
			j++;
		}
		i++;
	}

	for (long j = 0; j < i; j++){
		printf("%ld %ld\n", max[j], min[j]);
	}

	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pint;

const int INF=1e9;
vector<vector<int>> G,G1;
vector<int> par;

void dfs(int v)
{
    for(int u:G1[v]){
        par[u]=v;
        dfs(u);
    }
}

signed main()
{
    int N,M; cin>>N>>M;
    G.resize(N);
    M+=N-1;
    vector<int> indeg(N);
    for(int i=0;i<M;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        indeg[b]++;
    }
/*
    for(int i=0;i<N;i++) cout<<indeg[i]<<' ';
    cout<<endl;
*/
    stack<int> S;
    vector<int> dp(N,-INF);
    for(int i=0;i<N;i++){
        if(indeg[i]==0){
            S.push(i);
            dp[i]=0;
        }
    }
    while(!S.empty()){
        int v=S.top();
        S.pop();
        for(int u:G[v]){
            dp[u]=max(dp[u],dp[v]+1);
            indeg[u]--;
            if(indeg[u]==0){
                S.push(u);
            }
        }
    }
/*
    for(int i=0;i<N;i++) cout<<dp[i]<<' ';
    cout<<endl;
*/
    G1.resize(N);
    for(int v=0;v<N;v++){
        for(int u:G[v]){
            if(dp[u]==dp[v]+1){
                G1[v].push_back(u);
            }
        }
    }
    par.resize(N);
    for(int i=0;i<N;i++){
        par[i]=-1;
    }
    for(int i=0;i<N;i++){
        if(par[i]==-1){
            dfs(i);
        }
    }
    for(int i=0;i<N;i++){
        cout<<par[i]+1<<endl;
    }
}


Measured memory_bytes: 17280
N, M = map(int, input().split())
a, b = [], []

for i in range(M) :
    _a, _b = map(int, input().split())
    
    a.append(_a - 1)
    b.append(_b - 1)

zero_mask = "".join(['0' for x in range(N)])
full_mask = "".join(['1' for x in range(N)])
paths_cnt = 0
paths_set = set()

def do_mask(m, idx) :
    newmask = m[:idx] + '1' + m[idx + 1:]
    return newmask

def dfs(m, idx) :
    global paths_cnt
    
    # print("DBG, do dfs with : ", m, idx)
    # do mask for current idx
    newmask = do_mask(m, idx)
    
    if newmask == full_mask :
        paths_cnt += 1
    else :
        for i in range(N) :
            # print("DBG2 : ", idx != i, newmask[i] != '1', (idx, i) in paths_set, (idx, i))
            if idx != i and newmask[i] != '1' and (idx, i) in paths_set:
                dfs(newmask, i)
# generate map
for i in range(M) :
    paths_set.add((a[i], b[i]))
    paths_set.add((b[i], a[i]))
    
dfs(zero_mask, 0)
print(paths_cnt)

Measured memory_bytes: 3064
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := scanString()
	
	rc := 0
	gc := 0
	bc := 0

	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			rc++
		} else if s[i] == 'G' {
			gc++
		} else {
			bc++
		}
	}

	ans := rc*gc*bc
	for i := 0; i < n; i++ {
		for j := 1; j < n; j++ {
			if i+j >= n || i+2*j >= n {
				break
			}
			if s[i] != s[i+j] && s[i+j] != s[i+2*j] && s[i] != s[i+2*j] {
				ans--
			}
		}
	}

	fmt.Fprintln(wr, ans)

}


Measured memory_bytes: 1776
#include<stdio.h>

#define MAX 2000000
#define INFTY (1<<30)

int n,A[MAX+1];

void maxHeapify(int i){
  
  int l,r,largest,a;
  l = 2 * i;
  r = 2 * i +1;

  if(l<=n && A[l] > A[i]) largest = l;
  else largest = i;

  if(r<=n && A[r] > A[largest]) largest = r;

  if(largest != i){
    a=A[i];
    A[i]=A[largest];
    A[largest]=a;
      maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(n<1) return -INFTY;
  maxv = A[1];
  A[1] = A[n--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){

  int m;
  if(key<A[i]) return;
  A[i] = key;
  while(i>1 && A[i/2]<A[i]){
       m=A[i];
    A[i]=A[i/2];
    A[i/2]=m;
    i=i/2;
  }
}

void insert(int key){
  n++;
  A[n] = -INFTY;
  increaseKey(n,key);
}

int main(){
  int key;
  char com[10];
  while(1) {
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n') break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extract());
  }
  return 0;
}
/*
#include<stdio.h>
 
#define MAX 2000000
#define INFTY (1<<30)
 
int n,A[MAX+1];
 
void maxHeapify(int i){
   
  int l,r,largest,a;
  l = 2 * i;
  r = 2 * i +1;
 
  if(l<=n && A[l] > A[i]) largest = l;
  else largest = i;
 
  if(r<=n && A[r] > A[largest]) largest = r;
 
  if(largest != i){
    a=A[i];
    A[i]=A[largest];
    A[largest]=a;
      maxHeapify(largest);
  }
}
 
int extract(){
  int maxv;
  if(n<1) return -INFTY;
  maxv = A[1];
  A[1] = A[n--];
  maxHeapify(1);
  return maxv;
}
 
void increaseKey(int i,int key){
 
  int m;
  if(key<A[i]) return;
  A[i] = key;
  while(i>1 && A[i/2]<A[i]){
       m=A[i];
    A[i]=A[i/2];
    A[i/2]=m;
    i=i/2;
  }
}
 
void insert(int key){
  n++;
  A[n] = -INFTY;
  increaseKey(n,key);
}
 
int main(){
  int key;
  char com[10];
  while(1) {
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n') break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extract());
  }
  return 0;
  }*/



Measured memory_bytes: 5700
#include<cstdio>
int n;
int main(){
	scanf("%d",&n); if(n<=2||!(n&(n-1))){puts("No");return 0;}puts("Yes");
	printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n",n+1,n+1,n+2,n+2,n+3); 
	for(int i=4;i<n;i+=2)printf("%d %d\n%d %d\n%d %d\n%d %d\n",i,i+1,i,n+1,n+1,n+i+1,n+i+1,n+i);
	if(!(n&1))printf("%d %d\n%d %d\n",n,n-(n&-n),n+n,((n&-n)==2?0:n)+(n&-n)+1);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
	int w,h,n,x[1000],y[1000],e[1000];
	cin>>w>>h>>n;
	int a=0,b=w,c=0,d=h;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>e[i];
		if(e[i]==1)a=max(a,x[i]);
        if(e[i]==2)b=min(b,x[i]);
        if(e[i]==3)c=max(c,y[i]);
        if(e[i]==4)d=min(d,y[i]);
	}
	cout<<max(0,b-a)*max(0,d-c)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<boost/format.hpp>

using namespace std;

int main(){
  int N;
  int n, r;

  cin >> N ;

  int sum=0;
  for(int c=0; c<N; c++){
    cin >> n >> r;
    sum+=(r-n+1);
  }

  cout << sum;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, a, b, c, maxn, num;
int main() {
	while (true) {
		cin >> n; maxn = 0; num = 0;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			if (maxn < b + c) {
				maxn = b + c;
				num = a;
			}
		}
		cout << num << ' ' << maxn << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int h, a;
    cin >> h >> a;

    cout << (h + a - 1) / a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N, K;
int A[1000000];

int main(void) {
	int i;
	int asumisu, mizuhasu;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	asumisu = N - K;
	mizuhasu = K - 1;
	printf("%d\n", (asumisu + mizuhasu - 1) / mizuhasu + 1); /* +1 : 最初 */
	return 0;
}

/*
すべて等しく→最小値にする
最小値を拠点に左右に広げる
最初の一発→K
その後→最大K-1
*/


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
ll mod = 1e9+7;


int main(){
    int n,k; cin >> n >> k;
  	vector<int> h(n);
  	for(int i=0;i<n;i++){
      cin >> h[i];
    }
  	int ans=0;
  	for(int i=0;i<n;i++){
      if(h[i]>=k){
        ans++;
      }
    }
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] l = new int[Q];
		int[] r = new int[Q];
		for (int i=0;i<Q;i++) {
			l[i]=sc.nextInt();
			r[i]=sc.nextInt();
		}
		int[] SUM = new int[N];
		for (int i=0;i<N-1;i++) {
			if (S.charAt(i)=='A') {
				if (i!=S.length()-1 && S.charAt(i+1)=='C') {
					SUM[i+1]=SUM[i]+1;
				}else {
					SUM[i+1]=SUM[i];
				}
			}else {
					SUM[i+1]=SUM[i];
			}
		}

		for (int i=0;i<Q;i++) {
			System.out.println(SUM[r[i]-1]-SUM[l[i]-1]);
		}
	}
}

Measured memory_bytes: 81316
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, m;
ll a[1000005];

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < m; i++)
    {
        scanf("%lld", &a[i]);
        n -= a[i];
    }
    printf("%lld\n", max(n, -1ll));
    return 0;
}


Measured memory_bytes: 3864
#include <stdio.h>
main(){
    
  int a,b,c,x,y,z;
    
  scanf("%d%d%d",&a,&b,&c);
    
  if(a > b){ 
    x = a;
    a = b;
    b = x;
  }
    
  if(b > c){
    y = b;
    b = c;
    c = y;
  }
    
  if(a > b){
    z = a;
    a = b;
    b = z;
  }
    
  printf("%d %d %d\n",a,b,c);
    
  return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
/**
 * @author penguin_410
 *         Date: 2014/03/06
 */
public class Main {
    public static void main(String... args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        while (true) {
            final String line = br.readLine();
            final int index = line.indexOf(" ");
            final int x = Integer.parseInt(line.substring(0, index));
            final int y = Integer.parseInt(line.substring(index+1));
            if (x == 0 && y == 0) break;
            sb.append(x < y ? x + " " + y : y + " " + x).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 22804
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int p = Integer.parseInt(sa[1]);
		char[] s = br.readLine().toCharArray();
		br.close();

		long ans = 0;
		if (10 % p == 0) {
			for (int i = n - 1; i >= 0; i--) {
				long x = s[i] - '0';
				if (x % p == 0) {
					ans += i + 1;
				}
			}

		} else {
			int now = 0;
			int base = 1;
			int[] cnt = new int[p];
			cnt[0] = 1;
			for (int i = n - 1; i >= 0; i--) {
				int x = s[i] - '0';
				x *= base;
				x %= p;
				now += x;
				now %= p;
				ans += cnt[now];
				cnt[now]++;
				base *= 10;
				base %= p;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26068
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int s = 0;
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
            s^=a[i];
        }
        for (int i=0;i<n;i++)System.out.print((s^a[i])+" ");
        System.out.println();
    }
}


Measured memory_bytes: 61496
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	n = int(input().strip())
	res = []
	for i in range(n):
		S, P = input().strip().split()
		res.append((S, int(P), i+1))
	res_sed = sorted(res, key=lambda tup: tup[1], reverse=True)
	res_ans = sorted(res_sed, key=lambda tup: tup[0])
	for tup in res_ans:
		print(tup[2])

if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else if (r < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int ans[100001]={};
    ans[0]=0;
    int a[n];
    for(int i=0;i<n;++i)
        cin>>a[i];
    for(int i=1;i<=k;++i)
    {
        int f=0;
        for(int j=0;j<n;++j)
        {
            if(i-a[j]>=0&&ans[i-a[j]]==0)
                f=1;
        }
        ans[i]=f;
    }
    if(ans[k])
    {
        cout<<"First";
    }
    else
        cout<<"Second";
}

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

int main() {
  int N, count = 1;
  

  cin >> N;
  
  vector<int>d(N);

  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(),d.end());

	for(int i=1;i<N;i++) {
    if(d.at(i-1) < d.at(i)){
      count++;
    }
  }

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{

  public static int squareInt(int x){ 
    return x * x;
  }

  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int n =  s.nextInt();
    int[] lengths = new int[3];
    for (int i = 0; i < n; i++) {
      // 3辺の配列への入力
      for (int j = 0; j < 3; j++){
        lengths[j] = s.nextInt();
      }   
      // 直角三角形かどうかの判定
      Arrays.sort(lengths);
      if (squareInt(lengths[0]) + squareInt(lengths[1]) == squareInt(lengths[2])){
        System.out.println("YES");
      } else{
        System.out.println("NO");
      }   
    }   
  }

}

Measured memory_bytes: 23380
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
long long chk[200000+1];
long long sm[200000+1];
int getnext(long long A, long long M){
  return (A*A) % M;
}
int main(){
  long long N;
  rd(N);
  long long X;
  rd(X);
  long long M;
  rd(M);
  long long ad;
  long long res = 0;
  long long i;
  long long j;
  long long k;
  long long r;
  long long d;
  for(i=(0);i<(200000+1);i++){
    chk[i] = -1;
  }
  for(i=(0);i<(N);i++){
    res += X;
    if(i <= 200000){
      sm[i] = res;
    }
    if(chk[X] != -1){
      k = i - chk[X];
      r = (N-1) - i;
      d = r / k;
      if(d > 0){
        res += d * (sm[i] - sm[chk[X]]);
        i += d * k;
      }
    }
    else{
      chk[X] = i;
    }
    X = getnext(X, M);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200916-1

// --- original code ---
// ll chk[2d5+1];
// ll sm[2d5+1];
// 
// int getnext(ll A, ll M){
//   return (A*A) % M;
// }
// 
// {
//   ll @N, @X, @M, ad, res = 0;
//   ll i, j, k, r, d;
//   rep(i,2d5+1) chk[i] = -1;
// 
//   rep(i,N){
//     res += X;
//     if(i <= 2d5) sm[i] = res;
//     if(chk[X] != -1){
//       k = i - chk[X];
//       r = (N-1) - i;
//       d = r / k;
//       if(d > 0){
//         res += d * (sm[i] - sm[chk[X]]);
//         i += d * k;
//       }
//     } else {
//       chk[X] = i;
//     }
//     X = getnext(X, M);
//   }
// 
//   wt(res);
// }


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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

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


	int N = getint();

	int A[1000001] = {};
	rep(i, N) A[getint()]++;

	if (A[1]) {
		if (A[1] == 1) co(1);
		else co(0);
		return 0;
	}
	if (A[2]) {
		int kotae = (A[2] == 1);
		for (int i = 3; i <= 500000; i += 2) {
			if (A[i]) {
				kotae += (A[i] == 1);
				for (int j = i + i; j <= 1000000; j += i) {
					A[j] = 0;
				}
			}
		}
		for (int i = 500001; i <= 1000000; i += 2) kotae += (A[i] == 1);
		co(kotae);
		return 0;
	}

	int kotae = 0;
	for (int i = 2; i <= 500000; i++) {
		if (A[i]) {
			kotae += (A[i] == 1);
			for (int j = i + i; j <= 1000000; j += i) {
				A[j] = 0;
			}
		}
	}
	for (int i = 500001; i <= 1000000; i++) kotae += (A[i] == 1);
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 7224
def main(n: int, a: list):
    a_max, a_second = sorted(a, reverse=True)[:2]

    for i in range(n):
        if a[i] != a_max:
            print(a_max)
        else:
            print(a_second)


if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]

    main(n, a)


Measured memory_bytes: 13316
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool isstr(string str){
    string ls,rs;
    for(int i=0;i<str.length()/2;i++){
        ls.push_back(str[i]);
        rs.push_back(str[i+str.length()/2]);
    }
//    cout << ls << endl;
//    cout << rs << endl;
    if(ls==rs)return true;
    else return false;
}

int main(){
    string str;
    cin >> str;
    str.erase(str.end()-1,str.end());
    while(true){
        if(isstr(str))break;
        str.erase(str.end()-1,str.end());
//        cout << endl;
    }
    cout << str.length()-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int, int>
#define F first
#define S second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define REP(n) for(int i = 0; i < n; i++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 987654321;
template <typename 	X = int> inline X min(X a, X b, X c) { return min(min(a, b), c); }
template <typename 	X = int> inline X max(X a, X b, X c) { return max(max(a, b), c); }
template <typename 	X = int> inline X mid(X s, X e) { return (s + (e-s)/2); }
template <typename 	X = int> inline X len(X s, X e) { return (e - s + 1); }

void solve()
{
	string s,t;
	cin >> s >> t;
	int ct = 0, n = s.size();
	REP(n)
	{
		if(s[i] != t[i])
			ct++;
	}
	cout << ct << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int T = 1;
	while(T--)
		solve();
	return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll a, b, c, d;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    if(k <= a) {
        cout << k << endl;
    } else if(k <= a + b) {
        cout << a << endl;
        return 0;
    } else {
        cout << a - min(c, (k - (a + b))) << endl;
    }
    return 0;
}

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

// @@ !! LIM()

ll solve() {
  ll N, M; cin >> N >> M;
  vector<ll> cc(N, -1);
  for (ll i = 0; i < M; i++) {
    ll s, c; cin >> s >> c; 
    s = N - s;
    if (cc.at(s) >= 0 && cc.at(s) != c) return -1;
    cc.at(s) = c;
  }
  if (N > 1 && cc.at(N-1) == 0) return -1;
  if (cc.at(N-1) == -1) {
    if (N > 1) cc.at(N-1) = 1;
    else       cc.at(N-1) = 0;
  }
  for (ll i = N-2; i >= 0; i--) {
    if (cc.at(i) == -1) cc.at(i) = 0;
  }
  if (N == 3) return cc.at(2) * 100 + cc.at(1) * 10 + cc.at(0);
  if (N == 2) return cc.at(1) * 10 + cc.at(0);
  return cc.at(0);
  
}  


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans1=sum(b)
ans2=0
for i in range(n-1):
    if a[i+1]-a[i]==1:
        ans2+=c[a[i]-1]
print(ans1+ans2)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
using namespace std;

typedef long long int ll;

int main() {

	ll ans = 0;


	ll head[5] = { 0 };
	ll dis[2][5] = { 0 };                //head[2以上か3以上か][]
	ll sum = 0;
	ll sdis = 0;
	int N = 0;
	int cou = 0;
	cin >> N;

	for (int i = 0; i < N; i++) {
		char w[11];
		cin >> w;
		if (w[0] == 'M') {
			head[0] += 1;
		}
		else if (w[0] == 'A') {
			head[1] += 1;
		}
		else if (w[0] == 'R') {
			head[2] += 1;
		}
		else if (w[0] == 'C') {
			head[3] += 1;
		}
		else if (w[0] == 'H') {
			head[4] += 1;
		}

	}

	sum = head[0] + head[1] + head[2] + head[3] + head[4];

	
	for (int i = 0; i < 5; i++) {
		if (head[i] > 0) {
			cou += 1;
		}
	}

	
	for (int i = 0; i < 5; i++) {
		if (head[i] >= 2) {
			dis[0][i] = head[i] * (head[i] - 1) / 2*(sum-head[i]);
		}
	}

	for (int i = 0; i < 5; i++) {
		if (head[i] >= 3) {
			dis[1][i] = head[i] * (head[i] - 1)*(head[i] - 2) / 6;
		}
	}

	for (int i = 0; i < 2; i++) {
		for (int k = 0; k < 5; k++) {
			sdis += dis[i][k];
		}
	}


	cout << sum * (sum - 1)*(sum - 2) / 6 - sdis << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define vvi         vector<vector<ll>>
#define mpi         map<pi,ll>
#define pipi        pair<ll,pair<ll,ll> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define ef          else if
#define yes       cout<<"YES"<<'\n';
#define no        cout<<"NO"<<'\n';
#define C         continue;
#define wa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define debugp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>     
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>     
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll N = 350;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); } 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) 
    { 
        if (y & 1) 
        res = res*x; 
        y = y>>1; 
        x = x*x;  
    } 
    return res; 
}

signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n,i;
		ll ans=0;
		cin>>n;
		n--;
		fo(i,1,n+1)
		{
			ans+=(n/i);
		}
		cout<<ans<<u;
	}
	return 0;
} 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int mx = 0, smx = 0;
  rep(i, n){
    if(a.at(i) > mx){
      smx = mx;
      mx = a.at(i);
    }else if(a.at(i) > smx){
      smx = a.at(i);
    }
  }
  rep(i, n){
    if(a.at(i) == mx) cout << smx << endl;
    else cout << mx << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
 
const ll MOD = 1000000007;
const ll INF = 1000000000;
 

using namespace std;
int main(void){
    int n;
    int dp[100010],h[100010];
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i+1];
        dp[i+1] = INF;
    }
    
    dp[1] = 0;

    for(int i = 1; i < n; i++){
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
        if(i > 1){
            dp[i+1] = min(dp[i+1], dp[i-1]+abs(h[i+1]-h[i-1]));
        }
    }
    
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
s = input()

a = s[:2]
b = s[-2:]

mm = ["01","02","03","04","05","06","07","08","09","10","11","12"]

if a in mm and b in mm:
    print("AMBIGUOUS")
elif a in mm:
    print("MMYY")
elif b in mm:
    print("YYMM")
else:
    print("NA")










Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
			continue;
		}
		while (x) {
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3096
from collections import deque

H, W = list(map(int,input().split()))
A = [input() for _ in range(H)]

from collections import deque

dx = [0, 1, -1, 0]
dy = [1, 0, 0, -1]  

def bfs(q, a):
  
    ret = deque([])
    while(q):
        pop = q.popleft()
        x, y = pop[0], pop[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx and nx < W and ny >= 0 and ny < H:
                if a[ny][nx] == -1:
                    ret.append([nx, ny])
                    a[ny][nx] = 0
    return ret, a
  
q = deque([])

a = [[0 for _ in range(W)] for _ in range(H)]
for i in range(W):
    for j in range(H):
        if A[j][i] == ".":
            a[j][i] = -1  

ans = 0
for i in range(W):
    for j in range(H):
        if a[j][i] == 0:
            q.append([i, j])

ans = -1
while q:
    ans += 1
    q, a = bfs(q, a)
            
print(ans)

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

int main() {
  int N,K;
  cin  >> N >> K;
  
  vector<int> p(N);
  for (int i=0;i<N;i++)
    cin >> p.at(i);
  
  sort(p.begin(), p.end());
  
  int answer = 0;
  for (int i=0; i<K; i++)
    answer += p.at(i);
  
  cout << answer << endl;
}

Measured memory_bytes: 3596
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    x, y = map(int, input().split())
    if y & 1:
        print("No")
    else:
        if 2*x <= y <= 4*x:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


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

n, a, b = map(int, readline().split())
if n <= a + b:
    print(min(n, a))
else:
    ans = n // (a + b) * a
    if n % (a + b) < a:
        ans += n % (a + b)
    else:
        ans += a
    print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
int Len;
char s[ 1005 ];
int main() {
	scanf ("%s", s);
	Len = strlen(s);
	printf ("%c%d%c\n", s[ 0 ], Len - 2, s[ Len - 1 ]);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int a, b;
  cin >> a >> b;

  if (a <= 5)
    cout << 0 << endl;
  else if (a <= 12) {
    cout << b / 2 << endl;
  } else {
    cout << b << endl;
  }

  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a;
	while(scanf("%d",&a),a){
		a/=100;
		int ret=99999999;
		for(int i=0;i<=25;i++){
			for(int j=0;j<=16;j++){
				for(int k=0;k<=10;k++){
					if(i*2+j*3+k*5==a){
						int col=0;
						col+=((i/5)*380*4);
						col+=((i%5)*380);
						col+=((j/4)*550*4*17/20);
						col+=((j%4)*550);
						col+=((k/3)*850*3*22/25);
						col+=((k%3)*850);
						ret=min(ret,col);
					}
				}
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif
 
void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
 
const int N = 2e5+34;
 
int a[N];
int h[N];
 
void solve() {
    int n; scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", h+i);
        a[i] = i+1-h[i];
    }
    sort(a, a+n);
    long long ans = 0;
    for (int i = 0; i < n-1; ++i) {
        int x = i+1+h[i];
        const auto p = equal_range(a, a+n, x);
        ans += p.second-p.first;
    }
    printf("%lld", ans);
}
 
int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5424
import java.math.BigDecimal;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] a = new int[n];
		
		for (int i = 0; i < n; i++)
			a[i] = scanner.nextInt();
		
		int min = a[0];
		int max = a[0];
		long sum = 0l;
		
		for (int i = 0; i < n; i++) {
			if (a[i] < min)
				min = a[i];
			
			if (a[i] > max)
				max = a[i];
			
			sum += a[i];
		}

		System.out.println(min + " " + max + " " + BigDecimal.valueOf(sum).toPlainString());
	}

}



Measured memory_bytes: 42328
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n    = inputs(0).toInt
  val nums    = inputs(1).split(" ").map(_.toInt)

  println(solve(n, nums))

  def solve(n: Int, nums: Seq[Int]): Int = {
    var ans = 0
    (1 to n).foreach { i =>
      val index = i - 1
      if (i % 2 == 1 && nums(index) % 2 ==1) {
        ans = ans + 1
      }
    }
    ans
  }
}

Measured memory_bytes: 54972
import itertools
N = int(input())
P = list(map(int, input().split())) 
Q = list(map(int, input().split())) 

l = []
for i in range(1, N + 1): 
        l.append(i)

p = list(itertools.permutations(l, N)) 

print(abs((p.index(tuple(P)) + 1) - (p.index(tuple(Q)) + 1 ))) 

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e16;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const ll N = 2e5 + 10; 
ll n, x[N], y[N];
char c[N];
map<ll, set<ll>> l, r, u, d;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    cin >> n;
    zep(i, 0, n)cin >> x[i] >> y[i] >> c[i];

    ll ans1 = INF;

    zep(i, 0, n){
        if(c[i] == 'L')l[y[i]].insert(x[i]);
        if(c[i] == 'D')u[x[i]].insert(y[i]);
    }

    zep(i, 0, n){
        if(c[i] == 'R' && l.find(y[i]) != l.end()){
            if(l[y[i]].lower_bound(x[i]) != l[y[i]].end()){
                ans1 = min(ans1, (*l[y[i]].lower_bound(x[i])) - x[i]);
            }
        }
        if(c[i] == 'U' && u.find(x[i]) != u.end()){
            if(u[x[i]].lower_bound(y[i]) != u[x[i]].end()){
                ans1 = min(ans1, (*u[x[i]].lower_bound(y[i])) - y[i]);
            }
        }
    }

    ans1 *= 5;
    
    while(!l.empty())l.erase(l.begin());
    while(!u.empty())u.erase(u.begin());
    
    ll ans2 = INF;

    zep(i, 0, n){
        if(c[i] == 'L')l[x[i] - y[i]].insert(y[i]);
        if(c[i] == 'D')d[x[i] - y[i]].insert(y[i]);
    }

    zep(i, 0, n){
        if(c[i] == 'U' && l.find(x[i] - y[i]) != l.end()){
            if(l[x[i] - y[i]].lower_bound(y[i]) != l[x[i] - y[i]].end()){
                ans2 = min(ans2, (*l[x[i] - y[i]].lower_bound(y[i])) - y[i]);
            }
        }
    }

    zep(i, 0, n){
        if(c[i] == 'R' && d.find(x[i] - y[i]) != d.end()){
            if(d[x[i] - y[i]].lower_bound(y[i]) != d[x[i] - y[i]].end()){
                ans2 = min(ans2, (*d[x[i] - y[i]].lower_bound(y[i])) - y[i]);
            }
        }
    }

    while(!l.empty())l.erase(l.begin());
    while(!d.empty())d.erase(d.begin());

    zep(i, 0, n){
        if(c[i] == 'R')r[x[i] + y[i]].insert(y[i]);
        if(c[i] == 'D')d[x[i] + y[i]].insert(y[i]);
    }

    zep(i, 0, n){
        if(c[i] == 'U' && r.find(x[i] + y[i]) != r.end()){
            if(r[x[i] + y[i]].lower_bound(y[i]) != r[x[i] + y[i]].end()){
                ans2 = min(ans2, (*r[x[i] + y[i]].lower_bound(y[i])) - y[i]);
            }
        }
    }

    zep(i, 0, n){
        if(c[i] == 'L' && d.find(x[i] + y[i]) != d.end()){
            if(d[x[i] + y[i]].lower_bound(y[i]) != d[x[i] + y[i]].end()){
                ans2 = min(ans2, (*d[x[i] + y[i]].lower_bound(y[i])) - y[i]);
            }
        }
    }

    ans2 *= 10;

    ll ans = min(min(ans1, ans2), INF);
    if(ans == INF){
        print("SAFE")
    }else{
        print(ans)
    }

    return 0;
}

Measured memory_bytes: 34780
N = int(input())
*A, = map(int,input().split())

S = [0]*(N+1)
X = [0]*(N+1)
for i,a in enumerate(A,1):
    S[i] = S[i-1] + a
    X[i] = X[i-1] ^ a

l = 0
r = 0
ans = 0
while r<N:
    s = S[r+1]-S[l]
    x = X[r+1]^X[l]
    if s==x:
        r+=1
    else:
        ans += r-l
        l+=1
while l<N:
    ans += r-l
    l+=1
print(ans)

Measured memory_bytes: 29320
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;
}


void solve() {
    int n; cin >> n;
    string up, low; cin >> up >> low;
    int x = 0;
    ll ans = 1;
    int pre = -1;
    while(x < n){
        // printf("x: %d, ans: %lld\n", x, ans);
        if(x == 0){
            if(up[x] == low[x]){
                ans *= 3;
                ans %= MOD;
                x++;
                pre = 1;
            } else {
                ans *= 3 * 2;
                ans %= MOD;
                x += 2;
                pre = 2;
            }
        } else {
            if(up[x] == low[x] && pre == 2){
                ans *= 1;
                ans %= MOD;
                x++;
                pre = 1;
            } else if(up[x] == low[x] && pre == 1){
                ans *= 2;
                ans %= MOD;
                x++;
                pre = 1;
            } else if(pre == 1){
                ans *= 2;
                ans %= MOD;
                x += 2;
                pre = 2;
            } else {
                ans *= 3;
                ans %= MOD;
                x += 2;
                pre = 2;
            }
        }
    }
    cout << ans << endl;
}

int main(void){
  solve();
  return 0; 
}


Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        System.out.println(N-K+1);
        sc.close();
    }
}

Measured memory_bytes: 21716
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    if(a>=k)cout<<k<<endl;
    else {
        ans+=a;
        k-=a;
        k-=b;
        if(k>0)ans-=min(c,k);
        cout<<ans<<endl;
    }
}
    


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

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

	void run(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		if(!(A+B-1<=N&&N<=(long)A*B)){
			System.out.println(-1);
			return;
		}
		PrintWriter pw=new PrintWriter(System.out);
		int cur=N;
		int cnt=0;
		for(int i=0;i<B;++i){
			int tmp=Math.min(cur-(B-1-i),A);
			for(int j=0;j<tmp;++j){
				pw.print(cur-(tmp-1)+j);
				++cnt;
				if(cnt==N){
				    pw.println("\n");
				}else{
				    pw.print(" ");
				}
			}
			cur-=tmp;
		}
		pw.close();	
	}
}

Measured memory_bytes: 41364
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin>>n; vector<int> a(n,0);
    for (int i = 0; i < n; i++) cin>>a[i];
    int sum=0;
    for (int i = 0; i < n; i++) sum+=a[i];
    if(!(sum%10)){
        sort(a.begin(), a.end());
        int key=sum;
        for (int i = 0; i < n; i++){
            if(a[i]%10){
                key=a[i]; break;
            }
        }
        cout<<sum-key<<'\n';
    }else cout<<sum<<'\n';
}

Measured memory_bytes: 256