akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s=="RRR")cout << 3 << endl;
    else if(s=="SRR") cout << 2 << endl;
    else if(s=="RRS") cout << 2 << endl;
    else if(s=="SSS") cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3228
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#define ll long long
using namespace std;
const int maxn=300005;

int n,qz[maxn],tot,ans=1<<30;
char s[maxn];

int main(){
	scanf("%d",&n),scanf("%s",s+1);
	for(int i=1;i<=n;i++) qz[i]=qz[i-1]+(s[i]=='E');
	tot=qz[n];
	for(int i=1;i<=n;i++) ans=min(ans,(i-1-qz[i-1])+(tot-qz[i]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1664
a,b,c,x = map(int, [input() for i in range(4)])

y = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == 500*i + 100*j + 50*k :
                y += 1
                # if ( x < 500*i + 100*b + 50*c ):
                #    break

print(y)


Measured memory_bytes: 2940
#include <iostream>

int main()
{
  std::string paper = "";
  std::string real = "";
  int hit = 0;
  std::cin >> paper;
  std::cin >> real;
  for(int i = 0; i < 3; ++i)
  {
    if(paper.c_str()[i] == real.c_str()[i]) ++hit;
  }
  std::cout << hit << std::endl;
  return 0;
}

Measured memory_bytes: 256
/*input
5
1 1 2 2
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;
const int maxn = 3e5;
vector<int> g[maxn];
void solve(int test ) 
{		
	int n;
	cin >> n;
	for ( int i =2; i <= n ; i++)
	{
		int x;
		cin >> x;
		g[x].push_back(i);
	}
	for ( int i =1; i <= n ; i++)
		cout<< g[i].size() << "\n";
	

}
signed main(){
	bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	
	for ( int i = 0 ; i < t; i++)
	solve(i+1 );
	
}

Measured memory_bytes: 16932
#include <iostream>

using namespace std;

int main()
{
    char vowel[] = {'a', 'e', 'i', 'o', 'u'};
    char c;
    cin >> c;
    for (int i=0 ; i<5 ; i++)
    {
        if (c == vowel[i])
        {
            cout << "vowel";
            return 0;
        }
    }
    cout << "consonant";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    p, q = map(int, s.split())
    #print('----------', p, q)
    pair_lst = []
    is_devidable = False
    cycle_start_index = None

    while True:
        quot = (10 * p) // q
        rem = (10 * p) % q
        pair = (quot, rem)

        if rem == 0:
            is_devidable = True
            pair_lst.append(pair)
            break

        if pair in pair_lst:
            cycle_start_index = pair_lst.index(pair)
            break
        else:
            pair_lst.append(pair)
            p = rem

    # answer
    for pair in pair_lst:
        print(pair[0], end='')
    print()

    if is_devidable:
        pass
    else:
        # hat
        for i, pair in enumerate(pair_lst):
            if i >= cycle_start_index:
                print('^', end='')
            else:
                print(' ', end='')
        print()

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

int main(){
	int a =0,b=0,c=0;
	int t = 0;
	int mid = 0;
	for(int i =0;i < 10; i++){
		cin >> t;
		if(t > a){
			mid = t;
			t = a; 
			a = mid;
		}
		if(t > b){
			mid = t;
			t = b; 
			b = mid;
		}
		if(t > c){
			mid = t;
			t = c; 
			c = mid;
		}
	}
	cout <<a<<endl;
	cout <<b<<endl;
	cout <<c<<endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    
    int count1 = 0, count2 = 0;
    
    int num0 = S[0] - '0';
    int num1 = S[1] - '0';
    int num2 = S[2] - '0';
    int num3 = S[3] - '0';
    
    if (1 <= 10*num0 + num1 && 10*num0 + num1 <= 12) count1++;
    if (1 <= 10*num2 + num3 && 10*num2 + num3 <= 12) count2++;
    
    if (count1 == 1 && count2 == 1) cout << "AMBIGUOUS" << endl;
    else if (count1 == 1) cout << "MMYY" << endl;
    else if (count2 == 1) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline


def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')

def main():
	a,b,c,x,y=MI()
	ans=10**10
	ans=min(a*x+b*y,c*max(x,y)*2,c*min(x,y)*2+(a*(x-min(x,y)) if x>y else b*(y-min(x,y))))
	print(ans)











if __name__ == "__main__":
	main()


Measured memory_bytes: 3188
import java.util.*;
 
public class Main{
		public static void main(String[] args){
       		Scanner ti = new Scanner(System.in);
            int d = ti.nextInt();
            int t = ti.nextInt();
            int s = ti.nextInt();
          	float c;
           	c = (float)d/(float)s;
            if(c <= t)
     			System.out.println("Yes");
            else
            	System.out.println("No");
       }	
}

Measured memory_bytes: 35816
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int res = 0;
    rep(i,s.size()) {
        if (s[0]=='1') {
            if (i%2==1 && s[i]=='1') res++;
            if (i%2==0 && s[i]=='0') res++;
        }
        if (s[0]=='0') {
            if (i%2==0 && s[i]=='1') res++;
            if (i%2==1 && s[i]=='0') res++;
        }
    }
    cout << res << "\n";

}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import java.math.*;

class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;

    public static void main(String[] args) throws Exception{
        String s = br.readLine();
        int xCount = 0;
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'x'){
                xCount++;
            } else{
                sb.append(s.charAt(i));
            }
        }

        // System.out.println(sb.reverse().toString() + " " + sb.toString());
        if(sb.toString().equals(sb.reverse().toString())){
            int i = 0;
            int j = s.length() - 1;
            int ans = 0;
            while(i < j){
                char a = s.charAt(i);
                char b = s.charAt(j);

                if(a == b){
                    i++;
                    j--;
                } else if(a == 'x'){
                    i++;
                    ans++;
                } else{
                    j--;
                    ans++;
                }
            }
            pw.print(ans + "\n");
        } else{
            pw.print("-1\n");
        }

        pw.close(); 
        br.close();
    }
}

class Pair{
    public long x, y;

    Pair(long _x, long _y){
        x = _x;
        y = _y;
    }
}
class Point implements Comparable<Point>{
    public double x, y;

    Point(double x, double y){
        this.x = x;
        this.y = y;
    }

    public int compareTo(Point p){
        if(x != p.x) return x < p.x ? -1 : 1;
        else if(y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 26836
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
string s;
  cin >> s;
  if(s[0] == 'R'){
    if(s[1] == 'R'){
      if(s[2] == 'R') cout << 3 << endl;
      else cout << 2 << endl;
    }
    else cout << 1 << endl;
  }
  else if(s[1] == 'R'){
    if(s[2] == 'R') cout << 2 << endl;
    else cout << 1 << endl;
  }
  else{
    if(s[2] == 'R') cout << 1 << endl;
    else cout << 0 << endl;
  }
    
   
  return 0;
}

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

int main() {
    int A,B;
    cin >> A >> B;
    if(A <=8 && B<=8){
      cout << "Yay!" << endl;
    } else {
      cout << ":(" << endl;
    }
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

vec<ll> temp;

ll dfs(ll N, ll Q, ll M, vec<ll>& a, vec<ll>& b, vec<ll>& c, vec<ll>& d, int ind){
    if(ind == N){
        // きめおわった
        ll res = 0;
        for(int i=0; i < Q; i++){
            if(temp.at(b.at(i)-1) - temp.at(a.at(i)-1) == c.at(i)){
                res += d.at(i);
            }
        }
        return res;
    }

    ll currentMax = 0;
    for(int i=(ind == 0 ? 1 : temp.at(ind-1)); i <= M; i++){
        temp.at(ind) = i;
        currentMax = max(currentMax, dfs(N, Q, M, a, b, c, d, ind+1));
    }

    return currentMax;

}

void solve(long long N, long long M, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
    temp = vec<ll>(N, 0);
    ll res = dfs(N, Q, M, a, b, c, d, 0);
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(Q);
    std::vector<long long> b(Q);
    std::vector<long long> c(Q);
    std::vector<long long> d(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    solve(N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


Measured memory_bytes: 3676
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


SIZE = 51
table = [[None]*SIZE for _ in range(SIZE)]

while True:
    N = int(input())
    if N == 0:
        break

    for row in range(N+1):
        for col in range(N+1):
            table[row][col] = 0

    sum = 0

    for row in range(N):
        input_array = list(map(int,input().split()))
        for col in range(N):
            table[row][col] += input_array[col]
            table[N][col] += input_array[col]
            table[row][N] += input_array[col]
            sum += input_array[col]

    table[N][N] = sum

    for row in range(N+1):
        for col in range(N+1):
            print("%5d"%(table[row][col]),end="")
        print()


Measured memory_bytes: 13888
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)


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

const string YES = "Yes";
const string NO = "No";

bool check(string S){
    auto T = S;
    reverse(T.begin(), T.end());
    return T == S;
}

void solve(std::string S){
    auto N = S.length();
    auto res = check(S) && check(S.substr(0, (N-1)/2)) && check(S.substr((N+3)/2 - 1, (N-1)/2));
    cout << (res ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 3e2+3;
double dp[N][N][N];
int arr[4], n;
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i){
		int num;
		cin >> num;
		++arr[num];
	}
	for(int three = 0; three <= arr[3]; ++three){
		for(int two = 0; two <= (arr[2]+ arr[3]); ++two){
			for(int one = 0; one <= (arr[1] + arr[2] + arr[3]); ++one){
				int take = one + two + three;
				if(take)
					dp[one][two][three] += ((double)n) / ((double)take);
				if(one)
					dp[one][two][three] += dp[one-1][two][three] * ((double)one) / ((double)take);
				if(two)
					dp[one][two][three] += dp[one+1][two-1][three] * ((double)two) / ((double)take);;
				if(three)
					dp[one][two][three] += dp[one][two+1][three-1] * ((double)three) / ((double)take);;
			}
		}
	}
	cout << setprecision(20) << dp[arr[1]][arr[2]][arr[3]];
	return 0;
}


Measured memory_bytes: 217344
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>

using namespace std;
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;

    vector<pair<int, int> > t(n);
    int as = 0, bm = 0;
    for(int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;
        t[i] = make_pair(a, b);
        as += a;
        bm = max(bm, b);
    }

    sort(t.begin(), t.end(), compare_by_b);

    int c = 0;
    for(int i=0; i<n; i++) {
        c += t[i].first;
        if (c>t[i].second) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n, k;
int a[20];
signed main() {
	cin >> n >> k;
	rep(i, k)cin >> a[i];
	rep(i, (1 << n)) {
		bool ok = 1;
		rep(j, k)if (!((i >> a[j]) & 1))ok = 0;
		if (!ok)continue;
		vector<int>v;
		rep(j, n) {
			if ((i >> j) & 1)v.push_back(j);
		}
		if (i == 0)puts("0:");
		else {
			cout << i << ":";
			for (int x : v)cout << " " << x;
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3128
def getlist():
	return list(map(int, input().split()))

N, M = getlist()
l = 0
r = float("inf")
for i in range(M):
	L, R = getlist()
	if L > l:
		l = L
	if R < r:
		r = R

if r - l < 0:
	print(0)
else:
	print(r - l + 1)

Measured memory_bytes: 3060
from fractions import gcd
 
N,M = map(int,input().split())
a = list(map(int,input().split()))
 
if len(set([i&-i for i in a])) != 1:
  print(0)
else:
  x = 1
  for i in range(N):
    x = x*(a[i]//2//gcd(x,a[i]//2))
 
  print(M//x-M//(2*x))

Measured memory_bytes: 89580
#include<stdio.h>

int main(){
  char s[3];
  scanf("%s",s);
  
  if(s[0]=='S' && s[1]=='S' && s[2]=='S')printf("0");
  if(s[0]=='S' && s[1]=='S' && s[2]=='R')printf("1");
  if(s[0]=='S' && s[1]=='R' && s[2]=='S')printf("1");
  if(s[0]=='R' && s[1]=='S' && s[2]=='S')printf("1");
  if(s[0]=='S' && s[1]=='R' && s[2]=='R')printf("2");
  if(s[0]=='R' && s[1]=='S' && s[2]=='R')printf("1");
  if(s[0]=='R' && s[1]=='R' && s[2]=='S')printf("2");
  if(s[0]=='R' && s[1]=='R' && s[2]=='R')printf("3");
  
  return 0;
}

Measured memory_bytes: 2064
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

const lli maxN = 27;

lli n;
lli cache[maxN][3000000];
lli a[maxN][maxN];

lli dp(lli idx, lli mask) {

//    if(idx == n ) {
//        cout<<mask<<endl;
//    }

    if(idx == n and mask == (1 << n) - 1) {
        return 1;
    }

    lli &ans = cache[idx][mask];

    if(ans != -1)
        return ans;

    ans = 0;
    for(int i = 0; i < n; i ++) {
        if(mask & (1 << i)) {
            ;
        }
        else if(a[idx][i] == 1){
            ans += dp(idx + 1, (mask | (1 << i)));
            ans %= mod;
        }
    }
    return ans ;
}

void solve()
{

    memset(cache, -1, sizeof cache);
    cin>>n;
    for(int i = 0; i < n; i ++)  {
        for(int j = 0; j < n; j ++) {
            cin>>a[i][j];
        }
    }
    lli ans = dp(0, 0);
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

int a, b, k;

int main(){
    scanf("%d%d%d", &a, &b, &k);
    for(int i=1; i<=k; i++){
        if (i%2==1){
            if (a%2==1) a--;
            if (a%2==0) {
                b += a/2;
                a/=2;
            }
        }
        else {
            if (b%2==1) b--;
            if (b%2==0) {
                a += b/2;
                b/=2;
            }
        }
    }
    printf("%d %d", a, b);
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long k = sc.nextInt();

		if(k == 0) {
			System.out.println(n * n);
			System.exit(0);
		}

		if(n == 1) {
			System.out.println("0");
			System.exit(0);
		}

		long ans = 0;
		for(long i = 1;i <= n;i++) {
			long a = n / i;
			long b = n % i;

			if(i >= k) {
				ans += (i - k) * a;
			}
			if(b - k >= 0 ) {
				ans += b - k + 1;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n];For(i,0,n) cin>>a[i];
	For(i,0,n){
		a[i]=a[i]-i-1;
	}
	sort(a,a+n);
	ll b = a[n/2];
	ll ans=0;
	For(i,0,n) ans+=(abs(a[i]-b));
	cout<<ans<<endl;











	
}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc160/tasks/abc160_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, X, Y;
  cin >> N >> X >> Y;

  VVL edge_list(N, VL(0));

  rep(i, N - 1) {
    edge_list[i].emplace_back(i + 1);
    edge_list[i + 1].emplace_back(i);
  }

  edge_list[X - 1].emplace_back(Y - 1);
  edge_list[Y - 1].emplace_back(X - 1);

  VVL dist(N, VL(N, INF));
  rep(i, N) dist[i][i] = 0;

  // ダイクストラ
  rep(i, N) {
    priority_queue<PL, V<PL>, greater<PL>> q;
    q.emplace(0, i);

    while (!q.empty()) {
      PL pa = q.top();
      q.pop();
      ll cost = pa.fi;
      ll p = pa.se;

      if (cost > dist[i][p]) continue;

      for (auto np : edge_list[p]) {
        ll nc = cost + 1;
        if (chmin(dist[i][np], nc)) {
          q.emplace(nc, np);
        }
      }
    }
  }

  VL dist_ct(N + 1);

  rep(j, N) rep(i, j) { ++dist_ct[dist[i][j]]; }
  rep1(i, N - 1) { cout << dist_ct[i] << endl; }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define ll long long

using namespace std;

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

ll count = 0;
sort(a.begin(),a.end());
if (n <= k){
    cout << "0";
}
else{
    for (int i=0; i<n-k; i++){
        count += a.at(i);
    }
    cout << count;
    }

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int size = 1e5;
////////////////////////////////////////////////
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res*a%mod;
    a = a * a % mod;
    n>>=1;
  }
  return res;
}
////////////////////////////////////////////////
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}
////////////////////////////////////////////////
int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  if(n == 2){
    cout << '0' << endl;
    return 0;
  }
  //////////
  ll ans = modpow(2, n, MOD);
  ans = ((ans + MOD) - 1)%MOD;
  //////////
  ll na = 1;
  ll af = 1;
  REP(i, a){
    na *= (n - i);
    na %= MOD;

    af *= (i + 1);
    af %= MOD;
  }
  ll nca = na*modinv(af, MOD)%MOD;
  //////////
  ll nb = 1;
  ll bf = 1;
  REP(i, b){
    nb *= (n - i);
    nb %= MOD;

    bf *= (i + 1);
    bf %= MOD;
  }
  ll ncb = nb*modinv(bf, MOD)%MOD;
  //////////
  ans = (ans + MOD) - (nca + ncb)%MOD;
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if ((c >= a) && (c <= b)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,ans10000,ans50000,ans1000,cha=0;
	cin>>a>>b;
	if(b%1000!=0)
		{
			cout<<"-1 -1 -1";
			return 0;
		}
	ans1000=b/1000;
	cha=ans1000-a;
	if(cha<0)
	{
		cout<<"-1 -1 -1";
		return 0;
	}
	for(int i=0;i<=cha/4;i++)
	{
		if((cha-i*4)%9==0&&((cha-i*4)/9)>=0&&i>=0&&(a-(cha-i*4)/9-i)>=0)
		{
			cout<<(cha-i*4)/9<<" "<<i<<" "<<a-(cha-i*4)/9-i;
			return 0;
		}
	}
	cout<<"-1 -1 -1";
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
long int dp[100005][4]={-1},a[100005][4];
long int max2(long int a,long int b)
{
    if(a>=b)
        return a;
    else
        return b;
}
long int max3(long int a,long int b,long int c)
{
    if(a>=b && a>=c)
        return a;
    else if(b>=a && b>=c)
        return b;
    else
        return c;
}
void f(long int n)
{
    if(n==1)
    {
        dp[1][1]=a[1][1];
        dp[1][2]=a[1][2];
        dp[1][3]=a[1][3];
    }
    else if(n==2)
    {
        dp[2][1]=max2(a[1][2]+a[2][1],a[1][3]+a[2][1]);
        dp[2][2]=max2(a[1][1]+a[2][2],a[1][3]+a[2][2]);
        dp[2][3]=max2(a[1][1]+a[2][3],a[1][2]+a[2][3]);
    }
    else
    {
        if(dp[n-1][1]!=-1)
            f(n-1);
        dp[n][1]=max2(dp[n-1][2]+a[n][1],dp[n-1][3]+a[n][1]);
        dp[n][2]=max2(dp[n-1][1]+a[n][2],dp[n-1][3]+a[n][2]);
        dp[n][3]=max2(dp[n-1][1]+a[n][3],dp[n-1][2]+a[n][3]);
    }
}
int main()
{
    long int n;
    scanf("%ld",&n);
    for(long int i=1;i<=n;i++)
    {
        for(long int j=1;j<=3;j++)
            scanf("%ld",&a[i][j]);
    }
    f(n);
    long int ans;
    ans= max3(dp[n][1],dp[n][2],dp[n][3]);
    printf("%ld\n",ans);
    return 0;
}


Measured memory_bytes: 9472
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
int w;
string s;

int main(){
	cin>>s>>w;
	for(int i=0;i<s.size();i+=w)cout<<s[i];
	cout<<endl;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int fai[200010],miu[200010];
int check[200010],prime[200010],top;
long long ans,p=1000000007,n,k;
long long ksm(long long a,long long b)
{
     long long x=1;
     for(;b>0;a=(a*a)%p,b/=2) if(b%2==1) x=(x*a)%p;
     return x;
}
int main()
{
    int i,j;
    cin>>k>>n;
    fai[1]=miu[1]=1;
    for(i=2;i<=n;i++)
    {
        if(check[i]==0)
        {
            prime[++top]=i;
            fai[i]=i-1;
            miu[i]=-1;
        }
        for(j=1;j<=top&&i*prime[j]<=n;j++)
        {
            check[i*prime[j]]=1;
            if(i%prime[j]==0)
            {
                miu[i*prime[j]]=0;
                fai[i*prime[j]]=fai[i]*prime[j];
                break;
            }
            else
            {
                fai[i*prime[j]]=fai[i]*(prime[j]-1);
                miu[i*prime[j]]=miu[i]*(-1);
            }
        }
    }
    for(i=1;i<=n;i++) ans=(ans+fai[i]*ksm(n/i,k))%p;
    cout<<ans;
    //system("pause");
    return 0;
}


Measured memory_bytes: 4848
#include <stdio.h>

int f(int n) {
  int t = 0;
  while (n) {
    t = t*10 + n%10;
    n /= 10;
  }
  return t;
}

int main() {
  int n;
  scanf("%d", &n);
  if (n == f(n))
    printf("Yes");
  else
    printf("No");
  
  return 0;
  
}



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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll r,g,b,n,cnt=0; cin>>r>>g>>b>>n;
    rep(i,n+1)rep(j,n+1){
        ll x=r*i+g*j;
        if((n-x)%b==0 && x<=n) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

int main() {

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

    constexpr int A_MAX = 1000000;

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    sort(all(A));

    vector<bool> is_divisible(A_MAX + 1, false);
    map<int, int> cnt;
    REP(i, N) {
        ++cnt[A[i]];
        if (cnt[A[i]] == 1) {
            for (int n = 2 * A[i]; n <= A_MAX; n += A[i]) {
                is_divisible[n] = true;
            }
        }
    }
    REP(i, N) {
        if (cnt[A[i]] > 1) {
            is_divisible[A[i]] = true;
        }
    }

    int result = 0;
    REP(i, N) {
        if (!is_divisible[A[i]]) {
            ++result;
        }
    }
    
    cout << result << endl;

    return 0;
}


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

int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  
  for (int i = 0; i < N; i++) {    
    int l, r;
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const int mod = (int)1e9 + 7;
const int maxN = 2e5+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s, t;
	cin >> s;
	cin >> t;
	int ans = maxN;
	for(int i=0; i+t.size()-1<s.size(); i++){
		int c = 0;
		for(int j=0; j<t.size(); j++){
			if(t[j]!=s[i+j]) c++;
		}
		ans = min(ans, c);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int p, m, c; scanf("%d%d%d", &p, &m, &c);
	
	printf("%d\n", p + m + c);
	return 0;
}



Measured memory_bytes: 3216
import java.util.Scanner

object Main {
  def solve(S: String) = {
    (S.indices map { i =>
      val (x, y) = S.splitAt(i)
      (x.toCharArray.distinct intersect y.toCharArray.distinct).size
    }).max
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    println(solve(sc.next()))
  }
}


Measured memory_bytes: 27836
from collections import defaultdict

def bellman_ford(V, E, s):
    '''
    Input:
        V = list(range(N))
        E = {i: defaultdict(int) for i in range(N)}
        s (in V) : start vertex
    Output:
        dist: the list of the minimum cost from s to arbitrary vertex v in the given graph
    '''
    INF = float('inf')
    N = len(V)
    dist = [INF]*N
    dist[s] = 0
    for n_iterations in range(N):
        updated = [False]*N
        for v in V:
            d = dist[v]
            if d != INF:
                for u, c in E[v].items():
                    temp = d + c
                    if dist[u] > temp:
                        updated[u] = True
                        dist[u] = temp
        if sum(updated) == 0: # the minimum costs are already stored in dist
            break
    else: # the above loop is not broken if and only if there exists a negative cycle
        if updated[N-1]: return None
        else: return dist
    return dist

N, M = map(int, input().split())
E = {i: defaultdict(int) for i in range(N)}
for _ in range(M):
    a, b, c = map(int, input().split())
    E[a-1][b-1] = -c
V = list(range(N))
dist = bellman_ford(V, E, 0)
if dist is None:
    print('inf')
else:
    print(-dist[N-1])

Measured memory_bytes: 3828
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void b_polygon(void) {
	int n;
	cin >> n;
	int* l;
	l = (int*)calloc(n, sizeof(int));
	for (int i = 0; i < n; i++)cin >> l[i];

	sort(l, l + n, greater<int>());

	int sum = 0;
	for (int i = 1; i < n; i++) sum += l[i];

	if (l[0] < sum) cout << "Yes" << endl;
	else            cout << "No" << endl;
}

int main()
{
    b_polygon();

    return 0;
}

Measured memory_bytes: 3640
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;*/
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
typedef long long ll;
typedef pair<ll, ll> Pa;

/*
template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

typedef modint<MOD> m;
m func[400001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}*/

string s;
int main() {
	cin >> s;
	if (s != "AAA" && s != "BBB") cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	int s=0;
	for (int i = 0; i < n-1; ++i)
	{
		for (int j = i+1; j<n;++j)
		{
			s+=arr[i]*arr[j];
		}
	}
	cout<<s<<endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N;
  M = 0;
  int l, r;
  for (int i = 0; i < N; i++){
    cin >> l >> r;
    M += r - l + 1;
  }
  cout << M << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(ii, n) for (int ii = 0; ii < (int)(n); ii++)
int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> T(H, vector<int>(W, 1));
  rep(ii, N){
    int a, x, y;
    cin >> x >> y >> a;
    int i, j;
    if(a == 1){
      // drow x << xi
      for(i=0; i<H; i++){
        for(j=0; j<x; j++){
          T[i][j] = 0;
        }
      }
    }else if(a == 2){
      // drow x > xi
      for(i=0; i<H; i++){
        for(j=x; j<W; j++){
          T[i][j] = 0;
        }
      }
    }else if(a == 3){
      //drow y < yi
      for(i = 0; i < y; i++){
        for(j = 0; j < W; j++){
          T[i][j] = 0;
        }
      }
    }else{
      //drow y > yi
      for(i = y; i < H; i++){
        for(j = 0; j < W; j++){
          T[i][j] = 0;
        }
      }
    }
  }
  int cnt = 0;
  rep(i, H){
    rep(j, W){
      cnt += T[i][j];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
a = gets.split(" ").map(&:to_i)

for i in 0..a.length do
    a[i]=a[i].to_i
end
x=0
y=0
z=0
for i in 1..a[0] do
    if a[1]>=10000 then
        a[1]-=10000
        x+=1
    elsif a[1]>=5000
        a[1]-=5000
        y+=1
    elsif a[1]>=1000
        a[1]-=1000
        z+=1
    end
end
if a[1]>0 then
    x=-1
    y=-1
    z=-1
end
temp=a[0]-(x+y+z)
while temp!=0
    if temp>0 then
        if temp>=4 then
            if y>0 then
                y-=1
                z+=5
                temp-=4
            elsif x>0 then
                x-=1
                y+=2
                temp-=1
            else 
                x=-1
                y=-1
                z=-1
                break
            end
        elsif x>0 then
            x-=1
            y+=2
            temp-=1
        else 
            x=-1
            y=-1
            z=-1
            break
        end
    else 
        x=-1
        y=-1
        z=-1
        break
    end
end
puts ("#{x} #{y} #{z}")

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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    vi a(n);
    ull comfy = 0; int c=2;
    forl(i,0,n) cin>>a[i];// comfy += (ull)a[i];
    sort(a.rbegin(), a.rend());
    comfy = a[0];
    forl(i,1,n) {
        if(c==n) break;
        comfy += (ull)a[i]; c++;
        if(c==n) break;
        comfy += (ull)a[i]; c++;
        if(c==n) break;
    }
    //comfy = (ull)a[0] + (ull)(n-2)*(ull)a[1];
    cout<<comfy<<"\n";
}

Measured memory_bytes: 3940
#include<iostream>
#include<algorithm>
using namespace std;
int cnt;
int SelectionSort(int A[], int N){
  cnt = 0;
  for(int i = 0; i < N; i++){
    int minj = i;

    for(int j = i; j < N; j++){
      if(A[j] < A[minj]){
        minj = j;
      }
    }

    swap(A[i],A[minj]);
    if(i != minj) cnt++;
  }
  return cnt;
}
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++)
    cin >> A[i];

  cnt = SelectionSort(A,N);

  for(int i = 0; i < N; i++){
    cout << A[i];
    if(i == N-1) cout << endl;
    else cout << " ";
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

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

    stack<char> st;

    ll ans = 0;
    rep(i, X.length()) {
        // cout << i << endl;
        if (X[i] == 'S') {
            st.push(X[i]);
        } else if (X[i] == 'T') {
            if (st.empty()) continue;
            char c = st.top();
            if (c == 'S') {
                st.pop();
                ans++;
            }
        }
    }

    cout << X.length() - ans * 2 << endl;

    return 0;
}

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

using namespace std;

int main(){
	int N, L;
	scanf("%d%d", &N, &L);
	
	int min1 = 1e9;
	int sum = 0;
	int temp = false;
	for(int i = 0; i < N; i ++){
		sum += L+i;
		
		if(abs(L+i) < min1){
			min1 = abs(L+i);
			temp = 2*((L+i) >= 0)-1;
		}
	}
	printf("%d", sum-temp*min1);
	
	return 0;
}


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

using namespace std;

int mod = 2019;
long long ans;
string s;

long long dp[2][2020];

int main()
{
  cin >> s;
  int n = s.length();

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < mod; j++)
    {
      dp[(i+1)%2][(j * 10 + (s[i] - '0')) % mod] += dp[i%2][j];
      dp[i%2][j] = 0;
    }
    dp[(i+1)%2][s[i]-'0']++;
    ans += dp[(i+1)%2][0];
  }

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

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int M = 1e6 + 7;
const int INF = 1e9 + 7;
typedef long long ll;
int main()
{
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, abs(n % k - k)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define o(s) cout<< s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    char c; 
    rep(i,3){
        cin>>c;
        if(c=='1') cout<<9;
        else if(c=='9') cout<<1;
        else cout<<c;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<char> S(110);
  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }
  for(int i=0;i<N;i++){
    if(S.at(i)=='Y'){
      cout << "Four" << endl;
      goto as;
    }
  }
  cout << "Three" << endl;
  as:
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

b = input()

at = ["A", "T"]
gc = ["G", "C"]

if b == "A" or b == "T":
	at.remove(b)
	print(at.pop())
else:
	gc.remove(b)
	print(gc.pop())

Measured memory_bytes: 3880
#include <stdio.h>
int main(void){
    int num[5],i,j,temp;
    for(i=0;i<5;i++) scanf("%d",&num[i]);
    for(i=0;i<5;i++){
        for(j=0;j<4-i;j++){
            if(num[j]<num[j+1]){
                temp=num[j];
                num[j]=num[j+1];
                num[j+1]=temp;
            }
        }
    }
    for(i=0;i<5;i++) {
        if((i+1)%5==0) {
            printf("%d\n",num[i]);
        } else{
            printf("%d ",num[i]);
        }
    }
    return 0;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int H, W; cin >> H >> W;
   char a[2*H+1][W+1];
   for(int i = 1; i <= H; i++)
   {
      for(int j = 1; j <= W; j++)
      {
         cin >> a[i][j];
      }
   }
   for(int i =1; i <= 2*H; i++)
   {
      for(int j = 1; j <= W; j++)
      {
         int k = floor((i+1)/2.0);
          cout <<  a[k][j];
      }
      cout << nl;
   }

	return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> p(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    int ans=0;
    bool flag=1;
    rep(i,n){
        ans+=p[i].second;
        if(ans>p[i].first) flag=0;
    }
    cout << (flag ? "Yes" : "No") <<endl;

    return 0;
}


Measured memory_bytes: 1792