akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
const long long MOD = 1e9+7, INF = 1e18;
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
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;}

int N,M;

int f(vector<vector<int>>&v,int now){
	if(now==N*N){
		/*
		rep(i,0,N){
			rep(j,0,N){
				if(j)cout<<" ";
				cout<<v[i][j];
			}
			cout<<endl;
		}
		*/
		return 1;
	}
	int tate = now / N;
	int yoko = now % N;
	int ret = 0;
	int win = 0;
	int lose = 0;
	rep(i,0,N){
		if(v[tate][i]==1)win++;
		else if(v[tate][i]==-1)lose++;
	}
	if(win>(N-1)/2) return 0;
	if(lose>(N-1)/2)return 0;
	if(tate==yoko || v[tate][yoko])ret += f(v,now+1);
	else{
		
		if(win<(N-1)/2){
			v[tate][yoko] = 1;
			v[yoko][tate] = -1;
			ret += f(v,now+1);
			v[tate][yoko] = v[yoko][tate] = 0;
		}
		if(lose<(N-1)/2){
			v[tate][yoko] = -1;
			v[yoko][tate] = 1;
			ret += f(v,now+1);
			v[tate][yoko] = v[yoko][tate] = 0;
		}
	}
	return ret;
}

signed main(){
	IOS();
	vector<int>ans;
	while(1){
		cin>>N;
		if(N==0)break;
		cin>>M;
		vector<vector<int>>v(N,vector<int>(N,0));
		rep(i,0,M){
			int a,b;
			cin>>a>>b;
			a--;
			b--;
			v[a][b] = 1;
			v[b][a] = -1;
		}
		ans.push_back(f(v,0));
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 3164
from bisect import bisect_right
def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    for i in range(n-1):
        a[i+1] += a[i]
    for i in range(m-1):
        b[i+1] += b[i]
    ans = bisect_right(b, k)
    for i in range(1, n+1):
        if k < a[i-1]:
            break
        x = k - a[i-1]
        tmp = i
        tmp += bisect_right(b, x)
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == "__main__":
    main()

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size(),m = t.size();
    int ans = n;
    for (int i = 0;i < n-m+1;++i) {
        int cnt = 0;
        for (int j = 0;j < m;++j) if (s[i+j] != t[j]) cnt++;
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a + b == 15) cout << "+" << endl;
    else if(a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

void run(void){
  int n;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a%2!=0) break;
  }
  printf("%s\n",i<n?"first":"second");
}

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

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

int mod(int val, int m) {
  int res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> s(n+1);
  s[0] = 0;
  rep(i,1,n+1) {
    int a;
    cin >> a;
    s[i] = (a + s[i-1]) % k;
  }
  map<int,ll> m;
  ll ans = 0;
  vector<int> p(n+1);
  rep(i,0,n+1) {
    p[i] = mod(s[i] - i, k);
    ans += m[p[i]];
    m[p[i]]++;
    if (i+1 >= k) {
      m[p[i-k+1]]--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 17956
<?php
fscanf(STDIN, "%s", $string);
$length = strlen($string);
$co_1 = -1;
$co_2 = -1;
for ($i = 0; $i < $length - 1; ++$i) {
    if ($string[$i] == $string[$i + 1]) {
        $co_1 = $i;
        $co_2 = $i + 1;
    }
}
for ($i = 0; $i < $length - 2; ++$i) {
    if ($string[$i] == $string[$i + 2]) {
        $co_1 = $i;
        $co_2 = $i + 2;
    }
}
if ($co_1 == -1 && $co_2 == -1) {
	echo $co_1 . " " . $co_2;
} else {
	echo ($co_1 + 1) . " " . ($co_2 + 1);
}

?>

Measured memory_bytes: 3828
import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    N = len(S)
    for i in range(N):
        if S[i] != S[N-i-1]:
            print("No")
            exit()
    for i in range((N-1)//2):
        if S[i] != S[(N-1)//2-i-1] or S[(N+3)//2+i-1] != S[N-i-1]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/* 
 * Project: AtCoder Beginners Contest 162 A - Lucky 7
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#pragma GCC optimize("Ofast")
#include <cstdio>
using namespace std;
 
char n[3];
 
void solve() {
 
    if ((n[0] ^ '7') && (n[1] ^ '7') && (n[2] ^ '7'))
        puts("No");
    else
        puts("Yes");
}
 
int main() {
 
    scanf("%s",n);
 
    solve();
 
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long w = in.nextLong();
        long h = in.nextLong();
        long x = in.nextLong();
        long y = in.nextLong();
        
        System.out.print((double)(w * h) / 2);

        if (x * 2 == w && y * 2 == h) {
            System.out.println(" 1");
        } else {
            System.out.println(" 0");
        }
    }
}


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

const int maxn=110;

char st[maxn], str[maxn];

void solve()
{
	int len=strlen(st);
	for (int i=len; i<len*2; ++i) st[i]=st[i-len];
	for (int i=0; i<len; ++i)
	{
		bool flag=true;
		for (int j=0; j<len; ++j)
			if (st[i+j]!=str[j])
			{
				flag=false;
				break;
			}
		if (flag)
		{
			puts("Yes");
			return;
		}
	}
	puts("No");
}
int main()
{
	scanf("%s", st);
	scanf("%s", str);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  vector<int> tyuo;
  int tyuoti[2];
  for(int i = 0; n > i; i++){
    cin >> a[i];
    tyuo.push_back(a[i]);
  }
  sort(tyuo.begin(),tyuo.end());
  tyuoti[0] = tyuo[tyuo.size()/2-1];
  tyuoti[1] = tyuo[tyuo.size()/2];
  for(int i = 0; n > i; i++){
    if(tyuoti[0] < a[i])cout << tyuoti[0] << endl;
    else cout << tyuoti[1] << endl;
    
  }
}

Measured memory_bytes: 3828
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for s in accumulate(a):
        x=s%m
        if x not in d:
            d[x]=1
        else:
            d[x]+=1

    if 0 in d:
        ans=d[0]
    else:
        ans=0
    for v in d.values():
        ans+=v*(v-1)//2

    print(ans)

if __name__=="__main__":
    main()

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

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			Map<String, Integer> map = new HashMap<>();
			int max = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				int val = map.containsKey(s) ? map.get(s) + 1 : 1;
				map.put(s, val);
				max = Math.max(max, val);
			}
			List<String> list = new ArrayList<>();
			for (String key : map.keySet()) if (map.get(key) == max) list.add(key);
			Collections.sort(list);
//			PrintWriter out = new PrintWriter(System.out);
//			for (String s : list) System.out.println(s);
//			out.flush();
			StringBuilder ans = new StringBuilder();
			for (String s : list) ans.append(s).append("\n");
			System.out.println(new String(ans));
		}
	}
}


Measured memory_bytes: 61172
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextStringArray() []string {
  return strings.Split(NextLine()," ")
}
func NextIntArray() []int {
  var s []string = NextStringArray()
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var nk,a []int
  var n,k,l,r int
  nk = NextIntArray()
  n,k = nk[0],nk[1]
  a = NextIntArray()
  for i:=0;i<n;i++ {
    if a[i] == 1 {
      r = i
      break
    }
  }
  l = r-k+1
  if l < 0 { l = 0 }
  if r > n-k { r = n-k }
  var s int = 1000000
  for j:=l;j<=r;j++ {
    t := ceil(j,k-1) + ceil(n-k-j,k-1) + 1
    if s > t { s = t }
  }
  fmt.Println(s)
}
func ceil(n int,m int) int {
  if n <= 0 { return 0 }
  var f float64 = float64(n)/float64(m)
  return int(math.Ceil(f))
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i = 1; i*i <= n; i++){
        if(n%i != 0) continue;
        ll j = n/i;
        ans = min(ans, i + j - 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;
#define write_to_file() freopen("output.txt" , "w" , stdout)
#define read_from_file() freopen("input.txt" , "r" , stdin)
#define GeoOutputFix(VV) cout<<fixed<<setprecision(VV)
#define MAX_V  1e9
#define MIN_V -1e9
template<class T>istream& operator>> (istream& is, complex<T>& p){T value;is >> value, p.real(value), is >> value, p.imag(value);return is;}
typedef long long lld;
typedef pair<lld, lld> dd;
typedef complex<double> point;
#define X real()
#define Y imag()
#define dist(a , b) sqrt(pow(a.X - b.X , 2) + pow(a.Y- b.Y , 2))
#define dist2(a , b) ((long double)hypot(a , b))
#define mid(a,b) (((a)+(b))/point(2,0))
#define compare(a , b) (fabs(a.X - b.X) < -1e9 && fabs(a.Y - b.Y) < -1e9)
#define all(c) c.begin() , c.end()
#define MOD (lld)(1e9+7)
#define EPS 1e-9
#define neighbours(u , e , v) for(int e = head[u] , v ; v = to[e] , ~e ; e = nxt[e])
#define watch1(x) cout<<(#x)<<" = "<<x<<"\n"
#define watch2(x , y) cout<<(#x)<<" = "<<x<<"  "<<(#y)<<" = "<<(y)<<"\n"
#define watch3(x , y , z) cout<<(#x)<<" = "<<x<<"  "<<(#y)<<" = "<<(y)<"  "<<(#z)<<" = "<<(z)<<"\n"
int dr[] = {1 , 1 , 1 , 0 , 0 , -1 , -1 , -1};
int dc[] = {-1 , 0 , 1 , -1 , 1 , -1 , 0 , 1};
int ddr[] = {1 , 0 , 0 , -1};
int ddc[] = {0 , -1 , 1 , 0};
inline int SD(){int i ;scanf("%d", &i);return i;}
inline lld SLL(){lld i;scanf("%lld", &i);return i;}
inline char SC(){char i;scanf(" %c", &i);return i;}
const int AKA = 1e6 + 6 , OO = 0x3f3f3f3f;
//----------------------------------------[TO_OO]--[To infinity and beyond]--------------------------------------------------------
int a[AKA];
int main()
{
    lld n = SLL();
    n--;
    lld ans = n * (n + 1) / 2;
    printf("%lld" , ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        StringBuilder sb = new StringBuilder(t);
        sb.setLength(t.length() - 1);

        if(s.equals(sb.toString())){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35676
#include <bits/stdc++.h>
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
using ll=long long;
using namespace std;

int main(){
  int n;
  int count = 0;
  cin >> n;
  vector<int> hoge(n);
  rep_i(i, n){
    cin >> hoge.at(i);
  }
  // vector<int> hoge = {1, 2, 3, 4, 5};
  sort(hoge.begin(), hoge.end());
  int f;
  // int count = 0;
  for (int a = 0; a < n - 2; a++){
    for(int b = a + 1; b < n - 1; b++){
      f = hoge[a] + hoge[b];
      // cout << "f: " << f << endl;
      if(f >= hoge[n - 1]){

      }
      auto it = lower_bound(hoge.begin(), hoge.end(), f);
      // if(it == hoge.end()){
      // }else{
      int dis = distance(hoge.begin(), it);
        // cout << "dis: " << dis << endl;
        // cout << "b: " << b << endl;
        count += (dis - b - 1);
      // }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import scipy as scp

# 入力の受け取り
n,l = map(int,input().split())

apple = [l+i-1 for i in range(1,n+1)]
apple = np.array(apple)
abs_apple = abs(apple)
min_idx = np.argmin(abs_apple)

ans = sum(apple) - apple[min_idx]

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 21372
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

int N;


int main()
{
	cin >> N;

	int A[N];
	REP(i,N){
		cin >> A[i];
	}
	int B[N];

	int C[N];

	B[0] = A[0];
	for (int i = 1; i < N;i++){
		
			B[i] = gcd(B[i-1],A[i]);
	}
	

	C[N - 1] = A[N - 1];
	
	for (int i = N-2; i >=0;i--){
		C[i] = gcd(C[i + 1], A[i]);
	}

	int mx = 0;

	REP(i, N){
		int g;
		if (i == 0)
		{
			g = C[i + 1];
		}
		else if(i==N){
			g = B[i - 1];
		}
		else{
			g = gcd(B[i - 1], C[i + 1]);
		}
	
		if (g > mx)
		{
			mx = g;
		}
	}

	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 1408
import static java.lang.System.out;
import static java.lang.Integer.parseInt;
import java.io.File;
import java.util.Scanner;

public class Main {

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

    public void lots() {
        try (Scanner scan = new Scanner(System.in)) {
            draw(scan);
        } catch (Exception e) {
            System.exit(0);
        }
    }

    private void draw(Scanner scan) {
        int[] lots = getLots(parseInt(scan.nextLine()));
        int crossCount = parseInt(scan.nextLine());
        for (int chageCount = 0; chageCount < crossCount; chageCount++) {
            changeLot(scan.nextLine().split(","), lots);
        }
        for (int lot : lots) {
            out.println(lot);
        }
    }

    private int[] getLots(int count) {
        int[] lots = new int[count];
        for (int lotIndex = 0; lotIndex < count; lotIndex++) {
            lots[lotIndex] = lotIndex + 1;
        }
        return lots;
    }

    private void changeLot(String[] changeNumbers, int[] lots) {
        int beforeIndex = parseInt(changeNumbers[0]) - 1;
        int afterIndex = parseInt(changeNumbers[1]) - 1;
        int tmp = lots[beforeIndex];
        lots[beforeIndex] = lots[afterIndex];
        lots[afterIndex] = tmp;
    }
}

Measured memory_bytes: 26040
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a, b;

    cin >> a >> b;

    cout << max(max(a+b, a-b), a*b);

    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n), b(n), c(n-1);
	cin >> a >> b >> c;
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		ans += b[a[i]-1];
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i+1] == a[i] + 1) {
			ans += c[a[i]-1];
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N;
	cin >> N;
	map <int, int> order;
	int a;
	rep(i, N) {
		cin >> a;
		order.insert(make_pair(a, i + 1));
	}

	for (auto it = order.begin(); it != order.end();++it) {
		print(it->second);
	}


}

Measured memory_bytes: 7040
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		char c[10];
		int sum=0,people=0,out=0;
		while(out<3){
			scanf("%s",c);
			if(c[1]=='I'){
				people++;
				if(people==4){
					sum+=1;
					people=3;}}
			if(c[1]=='O'){
				sum+=people+1;
				people=0;}
			if(c[1]=='U'){
				out++;}}
		printf("%d\n",sum);}
	return 0;}


Measured memory_bytes: 2688
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    string N;
    cin >> N;
    int tmp;
    for (auto d : N) {
        tmp += d - '0';
    }
    if (tmp % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3748
// AtCoder Beginner Contest - Problem B: Palace (https://beta.atcoder.jp/contests/abc113/tasks/abc113_b)
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 1010 };
const int oo { 2000000010 };
const int MOD { 1000000007 };

int hs[MAX];

void solve(int N, int T, int A)
{
    auto ans = -1;
    double min_dist = oo;

    REP(i, 1, N)
    {
        auto avg = T - hs[i] * 0.006;

        if (abs(avg - A) < min_dist)
        {
            min_dist = abs(avg - A);
            ans = i;
        }
    }

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, T, A;
    cin >> N >> T >> A;

    REP(i, 1, N)
        cin >> hs[i];

    solve(N, T, A);

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define chmin(x,y) x = min(x, y)
#define chmax(x,y) x = max(x, y)
#define V vector
vector<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
vector<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n, k, s; cin >> n >> k >> s;
    rep(i, k) printf("%d ", s);
    rep(i, n-k) {
        if (s == 1e9) printf("1 ");
        else printf("1000000000 ");
    }
    cout << endl;

    return 0;
}

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

int main (){
	int a,b;cin>>a>>b;
	int x,c=0,ans;
	for(int i=1;i<=a;i++){
		cin>>x;
		c+=x;
		if(c>b){
			ans=i;
			break;
		}
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(n) for(int i=0;i<n;i++)
void out(int a[],int n){
  lp(n){
    if(i!=0) cout<<" ";
      cout<<a[i];
  }
  cout<<endl;
  return;
}
int main(){
  int n,a[10];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  if(prev_permutation(a,a+n)){
    out(a,n);}
  next_permutation(a,a+n);
  out(a,n);
  if(next_permutation(a,a+n))
  out(a,n);
  return 0;
}



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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int a, b;
	cin >> a >> b;
	a = (a + 11) % 13;
	b = (b + 11) % 13;
	if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String w = scanner.nextLine();
        String t = scanner.nextLine();
        
        int cnt = 0;
        while(!t.equals("END_OF_TEXT")){
            String[] tArr = t.split(" ");
            for(String t_tmp : tArr){
                if(t_tmp.toLowerCase().equals(w)){
                    cnt++;
                }
            }
            t = scanner.nextLine();
        }
        System.out.println(cnt);
    }
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double INF{1e9};
constexpr int MAGIC_PRIME{1000000000 + 7};
constexpr array<int, 4> dy{-1, 1, 0, 0};
constexpr array<int, 4> dx{0, 0, -1, 1};
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    int n_win = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'o')
            n_win++;
    }
    if (n_win + 15 - s.size() >= 8)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
// 　　　　　　_......_
// 　　　　 , ´　 <＊y　♪
// 　　　　 i,（i ﾉﾉﾊ）_）
// 　　　　ﾉ_iﾊﾟ ヮﾟﾉﾊ
// 　　　 　 ,´i'_ｿﾉj,〈つ　))
// 　　　　〈_,ﾉ＾＾＾ヽ.´
// 　　　　 .＾＾i_ｿ_ｿ^´
// 　　　　 ￣￣ ￣　


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int INF = (int)1e9;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), m = sc.nextInt();
		
		int g[][] = new int[n+1][n+1];
		int c[][] = new int[n+1][n+1];
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				g[i][j] = INF;
			}
			g[i][i] = 0;
		}
		
		for(int i=0;i<m;i++){
			int u = sc.nextInt(), v = sc.nextInt(), w = sc.nextInt();
			g[u][v] = w;
			g[v][u] = w;
			c[u][v] = w;
			c[v][u] = w;
		}
		
		for(int k=1;k<=n;k++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j]);
				}
			}
		}
		
		int ans = 0;
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(c[i][j] > g[i][j])
					ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 25936
N, M = map(int, input().split())

cl = [0 for i in range(N+1)]
for i in range(M):
    L, R = map(int, input().split())
    cl[L-1] += 1
    cl[R] -= 1

ans = 0
cnt = 0
for i, c in enumerate(cl):
    cnt += c
    if cnt == M:
        ans += 1

#print(cl)
print(ans)


Measured memory_bytes: 45740
#include<stdio.h>
int main(void)
{
	int i,m,f,r;
	for(i=0;i<100;i++){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1){
			break;
		}else if(m==-1||f==-1||m+f<30){
			printf("F\n");
		}else if(m+f>=80){
			printf("A\n");
		}else if(m+f>=65&&m+f<80){
			printf("B\n");
		}else if(m+f>=50&&m+f<65){
			printf("C\n");
		}else if(m+f>=30&&m+f<50){
			if(r>=50){
				printf("C\n");
			}else{
				printf("D\n");
			}
		}
	}
	return 0;
}

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

#define int long long
const int mod = 1e9 + 7;
int memo[10005][105];

int rec(int n, int su, int rem){
    if(memo[n][su] != -1) return memo[n][su];
    int ans = 0;
    if(not n){
        ans = 1;
        if(su % rem) ans = 0;
    }
    else{
        for(int j = 0;j < 10;++j)
            ans = (ans + rec(n - 1, (su + j) % rem, rem)) % mod;
    }
    memo[n][su] = ans % mod;
    return ans % mod;
}



signed main(){

    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);



    memset(memo, -1, sizeof(memo));
    
    
    string l;
    int d, n, curr = 0;
    cin >> l >> d;
    n = l.length();

    int ans = 0;
    for(int i = 0;i < n;++i){
        for(int j = 0;j < l[i] - '0';++j){
            ans = (ans + rec(n - i - 1, (curr + j) % d, d)) % mod;
        }

        curr = (curr + (l[i] - '0')) % d;
    }
    
    ans -= 1;
    if(curr % d == 0) ans += 1;

    cout << (ans + mod) % mod << endl;


}

Measured memory_bytes: 12612
#include <iostream>

using namespace std;

int main(){
    int t ;
    cin>>t;
    int n,m;
    cin>>n>>m;
    int result = 0;
    for (int i = 0;i <t;i++ ){
        int p;
        cin>>p;
        int k = 1;
        while(k*p+1<=n){
            result++;
            k++;
        }
        result++;
    }
    cout<<result+m<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int a,b;
    cin>>a>>b;
    if((a+b)%2==0)fin((a+b)/2);
    else fin("IMPOSSIBLE");
}

Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
vector<pair<int,int> >g[100005];
int n,m;
int c[3];
vector<int>vec;
bool vis[100005];
int col[100005],can;
void dfs(int x){
	vis[x]=1;vec.push_back(x);
	c[col[x]]++;
	for(auto p:g[x]){
		int to=p.first,cost=p.second;
		if(vis[to]){
			if((col[x]+cost+3)%3!=col[to]){
				can=0;
			}
		}else{
			col[to]=(col[x]+cost+3)%3;dfs(to);
		}
	}
}
signed main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;cin>>a>>b;
		g[a].push_back(make_pair(b,1));
		g[b].push_back(make_pair(a,-1));
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			memset(c,0,sizeof c);
			can=1;vec.clear();col[i]=0;dfs(i);
			if(can){
				if(c[0]&&c[1]&&c[2]){
					ans+=c[0]*c[1]+c[1]*c[2]+c[2]*c[0];
				}else{
					int tot=0;
					for(auto vv:vec)tot+=g[vv].size();
					ans+=tot/2; 
				}
			}else{
				ans+=(int)vec.size()*vec.size();
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13812
n = int(input())
L =[]
for i in range(n):
    x = int(input())
    L.append(x)

ma = L[1]-L[0]
mi = L[0]
for x in range(n-1):
    ma = max([ma,L[x+1]-mi])
    mi = min(mi,L[x+1])


print (ma)

Measured memory_bytes: 15628
N = int(input())
W = input().split()
W = [int(n) for n in W]
min = 0
for i in range(N):
  left = sum(W[:i])
  right = sum(W[i:])
  zettaiti = left-right
  if zettaiti < 0:
    zettaiti = zettaiti * -1
  if i == 0:
    min = zettaiti
  if min > zettaiti:
    min = zettaiti
    
    
print(min)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long n,k,i,t,tt;
	scanf("%lld %lld",&n,&k);
	if(n>=k)
	{
		t=n%k;
		printf("%lld",min(t,k-t));
	}
	else printf("%lld",min(n,k-n));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 2e5 + 100;
 
ll n, k;
int val[N];
 
int Check(int len) {
	ll res = 0;
	for(int i = 1;i <= n; ++i)
		res += (val[i] - 1) / len;
	return res <= k;
}
 
int main() {
	cin >> n >> k; int L = 0, R = 1;
	for(int i = 1;i <= n; ++i) cin >> val[i], R = max(R, val[i]);
	while(R - L > 1) {
		int mid = (L + R) >> 1;
		if(Check(mid)) R = mid;
		else L = mid;
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
int main() {
int R;
cin >> R;
if (R < 1200){
	cout << "ABC" << endl;
}else if (1200<= R && R < 2800) {
	cout << "ARC" << endl;
}else {
	cout << "AGC" << endl;	
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

struct edge{int to;ll cap;int rev;};

int MAX_V=20050;
int tmp1,tmp2;

vector<vector<edge>> g(MAX_V);//グラフの隣接リスト表現
vin level(MAX_V);//distance form s
vin iter(MAX_V);//どこまで調べたか

void add_edge(int from,int to,ll cap=(ll)inf){
    tmp1=g[to].size();tmp2=g[from].size();
    g[from].push_back((edge){to,cap,tmp1});//g[to]のg[to].size()番目にfromが入っている
    g[to].push_back((edge){from,0,tmp2});//g[from]のg[from].size()-1番目にtoが入っている
}

void bfs(int s){
    fill(all(level),-1);
    queue<int> q;
    q.push(s);
    level[s]=0;
    while(q.size()){
        int v=q.front();q.pop();
        for(auto& e:g[v]){
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                q.push(e.to);
            }
        }
    }
}

//増加パスをdfsで探す
//v:今見てる頂点 t:終点 f:流量
int dfs(int v,int t,ll f){
    if(v==t)return f;
    for(int& i=iter[v];i<(int)g[v].size();i++){
        edge& e=g[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s,int t){
    ll flow=(ll)0;
    ll f;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        fill(all(iter),0);
        while((f=dfs(s,t,inf))>0)flow+=f;
    }
}

int main(){
    int h,w;cin>>h>>w;
    vstr S(h);
    rep(i,h)cin>>S[i];
    //各マスinとoutを2つ用意
    //(i,j)のinは2(i*w+j)で, outは2(i*w+j)+1で表される
    int s=2*h*w;//s→ヤギ
    int t=s+1;//追加したグリッドのマス(ゴール)→t
    int tmp;
    rep(i,h)rep(j,w){
        tmp=2*(i*w+j);
        if(S[i][j]=='X'){
            if(i==0||i==h-1||j==0||j==w-1){
                cout<<-1<<endl;
                return 0;
            }
            add_edge(tmp,tmp+1);
            add_edge(s,tmp);
        }
        else add_edge(tmp,tmp+1,(ll)1);
        if(i>0)add_edge(tmp+1,tmp-2*w);
        if(i<h-1)add_edge(tmp+1,tmp+2*w);
        if(j>0)add_edge(tmp+1,tmp-2);
        if(j<w-1)add_edge(tmp+1,tmp+2);
        if(i==0||i==h-1||j==0||j==w-1)add_edge(tmp+1,t);
    }
    cout<<max_flow(s,t)<<endl;
}

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

using namespace std;

#define N 1000
#define M 50

void init();

int point[M][N];

int main(){
    int student,subject,sum;
    vector<int> total;
    vector<int> res;

    init();
    total.clear();

    while(1){
        cin>>student>>subject;
        if((student==0) && (subject==0)) break;
        
        init();
        for(int i=0;i<subject;i++){
            for(int j=0;j<student;j++){
                cin>>point[i][j];
            }
        } 

        for(int i=0;i<student;i++){
            sum = 0;
            for(int j=0;j<subject;j++){
                sum+= point[j][i];
            }
            total.push_back(sum);
        }

        sort(total.begin(),total.end());
        res.push_back(total[student-1]);
        total.clear();
    }

    for(int i=0;i!=res.size();i++){
        cout<<res[i]<<endl;
    }

    return 0;
}

void init(){
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++){
            point[i][j] = 0;
        }
    }
}


Measured memory_bytes: 3368
def div(n):
    l = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            l.append(i)
            if i != n // i:
                l.append(n // i)
    return l
n = int(input())
l = div(n)
ans = 0
for i in l:
    if i - 1 != 0 and n // (i - 1) == n % (i - 1):
        ans += i - 1
print(ans)

Measured memory_bytes: 3272
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#define int long long
using namespace std;
string s;
int len,sum,tt=1,maxx,ans;
signed main(){
	cin>>s;len=s.length() ;
	s+=".";
	for(register int i=1;i<s.length() ;i++){
		if(s[i]==s[i-1]){
			tt++;
		}
		else{
			if(s[i-1]=='>'){
				if(maxx>=tt) ans+=(tt-1)*tt/2;
				else ans+=(1+tt)*tt/2,ans-=maxx;
			}
			else{
				ans+=(1+tt)*tt/2;maxx=tt;
			}
			tt=1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 900
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let a: Vec<u32> = parse_line().unwrap();
    let mut color = [false; 8];
    let mut free = 0;

    for &ai in &a {
        match ai {
            1..=399 => color[0] = true,
            400..=799 => color[1] = true,
            800..=1199 => color[2] = true,
            1200..=1599 => color[3] = true,
            1600..=1999 => color[4] = true,
            2000..=2399 => color[5] = true,
            2400..=2799 => color[6] = true,
            2800..=3199 => color[7] = true,
            _ => free += 1,
        }
    }
    let cnt = color.iter().filter(|&x| *x).count();
    println!("{} {}", cnt.max(1), cnt + free);
}


Measured memory_bytes: 2092
N = int(input())
A = list(map(int,input().split()))
A_abs = []
cnt = 0
ans = 0

for a in A:
    if a < 0:
        cnt += 1
    A_abs.append(abs(a))

if A_abs.count(0) > 0:
    print(sum(A_abs))
elif cnt % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs)- 2 * min(A_abs))

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

bool include_fig(int fig, std::vector<int> S){
	for (int i = 0; i < S.size(); ++i){
		if(S[i]==fig) return true;
	}
	return false;
}

int main(int argc, char const *argv[]){

	int N,fig;
	int cnt = 0;

	std::vector<int> S;
	std::cin >> N;
	for (int i = 0; i < N; ++i){
		std::cin >> fig;
		S.push_back(fig);
	}

	std::cin >> N;
	for (int i = 0; i < N; ++i){
		std::cin >> fig;
		if(include_fig(fig,S)) cnt++;
	}

	std::cout << cnt << std::endl;

	return 0;
}


Measured memory_bytes: 3152
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int X[][] = new int[n][d];
		for(int y=0;y<n;y++){
			for(int x=0;x<d;x++){
				X[y][x] = sc.nextInt();
			}
		}
		int dis[] = new int[1000];
		int count=0;
		for(int ya=0;ya<n;ya++){
			for(int yb=ya+1;yb<n;yb++){
				for(int x=0;x<d;x++){
					int tmp = X[ya][x] - X[yb][x];
					dis[count] += (int)Math.pow(tmp,2);
				}
				count++;
			}
		}
		int number=0;
		for(int i=0;i<count;i++){
			for(int j=1;j<200;j++){
				if(dis[i]==j*j){
					number++;	
				}
				
			}
		}
		System.out.println(number);

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x;
   string s,a,b;

   cin>>n>>s;
   if(n%2){
    cout<<"No"<<endl;
    return 0;
   }
    a= s.substr(0,n/2);
    b= s.substr(n/2,n/2);
   cout<<(a==b?"Yes":"No")<<endl;
   return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = 0;
        for (int i = a ; i <= b ; i++){
          if (c % i == 0){
            k = k + 1;
          }
        }
        System.out.println(k);
      }
    }


Measured memory_bytes: 26168
#include <iostream>
#include <string>

int main()
{
        std::string str1,str2;
        std::cin >> str1 >> str2;

        str1 += str1;

        bool flag = false;
        for(int i=0;i<str1.size();i++)
        {
                if(str2 == str1.substr(i,str2.size()))
                        flag = true;
        }

        if(flag)
                std::cout << "Yes" << std::endl;
        else
                std::cout << "No" << std::endl;
}


Measured memory_bytes: 3216
//D knapsack approach 2
#include<bits/stdc++.h>
#define int long long
using namespace std;
class event{
public:
  int wt,val;  
};
int32_t main(){
    int n,w;
    cin>>n>>w;
    event arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i].wt;
        cin>>arr[i].val;
    }
    int dp[n+1][w+1];
    memset(dp,0,sizeof dp);
    for(int j=0;j<=w;j++){
        dp[1][j]=0;
    }
    dp[1][arr[1].wt]=arr[1].val;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=w;j++){
            dp[i][j]=dp[i-1][j];
            if(arr[i].wt<=j){
                dp[i][j]=max(dp[i][j],arr[i].val+dp[i-1][j-arr[i].wt]);
            }
        }
    }
    cout<<*max_element(dp[n],dp[n]+w+1)<<endl;
    //cout<<dp[n][w]<<endl;
	return 0;
}

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

int main(){
	int r,d;
	vector<int> x(15);
	cin >> r >> d >> x[0];
	for(int i = 1;i <= 10;i++){
		x[i] = r * x[i - 1] - d;
		cout << x[i] << endl;
	}

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main() {
	ll N, M;
    cin >> N >> M;

	vector<vector<ll>> goodness(8);

	for(ll i=0; i<N; i++) {
		ll x, y, z;
		cin >> x >> y >> z;
		goodness[0].push_back(x+y+z);
		goodness[1].push_back(x+y-z);
		goodness[2].push_back(x-y+z);
		goodness[3].push_back(x-y-z);
		goodness[4].push_back(-x+y+z);
		goodness[5].push_back(-x+y-z);
		goodness[6].push_back(-x-y+z);
		goodness[7].push_back(-x-y-z);
	}

	ll ans = numeric_limits<ll>::min();
	for(int i=0; i<8; i++) {
		sort(goodness[i].begin(), goodness[i].end());
		reverse(goodness[i].begin(), goodness[i].end());

		ll x = 0;

		for(ll j=0; j<M; j++) {
			x += goodness[i][j];
		}
		ans = max(ans, x);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1016
import functools
def gcd(a,b):
    m=max(a,b)
    n=min(a,b)
    return n if m%n==0 else gcd(n,m%n)

def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    print(functools.reduce(gcd,a))

resolve()

Measured memory_bytes: 62832
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


int main(){
	int x;
	scanf("%d", &x);
	int ro, count, i=x;
	if(x == 2) printf("%d\n", 2);
	else{
		if(x%2 == 0) x++;
		for(i=x; i<100005; i=i+2){
			//printf("%d\n", i);100005
			count = 0;
			ro = pow(i, 0.5); //printf("%d\n", ro);
			for(int j=2; j<=ro; j++){
				if(i%j == 0) break;
				else count++;
			}
			if(count == ro-1) break;
		}
		printf("%d\n", i);

	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n'
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n'
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size]

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)
#define IN(a) for (auto &it : a) cin >> it

void solve() {
    ints(x, y);
    for (int i = 0; i <= y; i++) {
        if (y >= 4 * i && (y - 4 * i) % 2 == 0 && ((y - 4 * i) / 2 + i) == x) {
            show("Yes");
            return;
        }
    }
    show("No");
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3612