akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
bool firstPair(pair<int, int> lhs, pair<int, int> rhs) {
    if(lhs.first > rhs.first) return true;
    else return false;
}
int main() {
    int N; cin >> N;
    vector<pair<int, int>> robots(N);
    rep(i, N) {
        int x; int l; cin >> x >> l;
        robots[i].first = x -l ;
        robots[i].second = x + l;
    }
    sort(robots.begin(), robots.end(),  firstPair);
    int ans = 1;
    pair<int, int> robot = robots[0];
    int maxX = robot.second;
    int minX = robot.first;
    for(int i = 1; i < N; i++) {
        robot = robots[i];
        if(robot.second <= minX) {
            ans++;
            maxX = robot.second;
            minX = robot.first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  	int A,B;
  	cin >> A >> B;
  	if(A <= 5) cout << 0 << endl;
  	else if(6 <= A && A <= 12) cout << B/2 << endl;
  	else cout << B << endl;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

struct item {
  int b, l, u;
  ll score;
};

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

  int n, x;
  while (scanf("%d%d", &n, &x) == 2) {
    ll target = 0;
    vector<item> v(n);
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d", &v[i].b, &v[i].l, &v[i].u);
      target += v[i].b * 1LL * v[i].l;
      v[i].score = v[i].b * 1LL * v[i].l + (x - v[i].b) * 1LL * v[i].u;
    }

    sort(v.begin(), v.end(), [](const item& a, const item& b) { return a.score > b.score;});

    auto best = [&](ll hours) {
      int full = hours / x;
      int extra = hours % x;
      ll sum = 0;
      for (int i = 0; i < full; i++) {
        sum += v[i].score;
      }
      if (extra == 0) return sum;
      sum += v[full].score;
      ll ans = 0;
      for (int i = 0; i < n; i++) {
        ll cur = sum - v[min(i, full)].score;
        int small = min(extra, v[i].b);
        int big = extra - small;
        cur += small * 1LL * v[i].l + big * 1LL * v[i].u;
        ans = max(ans, cur);
      }
      return ans;
    };

    ll lf = -1;
    ll rg = n * 1LL * x;

    while (rg - lf > 1) {
      ll mid = (lf + rg) / 2;
      if (best(mid) >= target) {
        rg = mid;
      } else {
        lf = mid;
      }
    }

    printf("%lld\n", rg);
  }

  return 0;
}


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

string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> s;
    for(int i = 0 ; i < s.size()-1 ; i++)
        if(s[i] == 'A' && s[i+1] == 'C') return cout << "Yes" << endl, 0;
    cout << "No" << endl;
    return 0;
}


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

const int N = 3005;

int dp[N][N];
int n, S;
int a[N];
int mod = 998244353;

int solve(int pos, int sum) {
    if(sum > S) return 0;
    if(pos > n) return sum == S;
    if(dp[pos][sum] != -1) return dp[pos][sum];
    int ans = solve(pos+1,sum)*2%mod;
    ans += solve(pos+1,a[pos]+sum);
    ans %= mod;
    return dp[pos][sum] = ans;
}


int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> S;
    for(int i = 1; i <= n; i++) cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << solve(1, 0) << endl;
    return 0;
}



Measured memory_bytes: 39112
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a > b)
		cout << "a > b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else
		cout << "a == b" << endl;
}



Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    long k=sc.nextLong();
    int[] a=new int[n];
    for(int i=0;i<n;i++)a[i]=sc.nextInt();
    int g=0;
    List<Integer> list=new ArrayList<>();
    Set<Integer> set=new HashSet<>();
    list.add(1);
    set.add(1);
    boolean flag=true;
    while(a[g]!=1) {
    	if(!set.add(a[g])) {
    		flag=false;
    		break;
    	}
    	list.add(a[g]);
    	g=a[g]-1;
    }
    int res=(int)(k%list.size());
    List<Integer> buff=new ArrayList<>();
    if(flag)System.out.println(list.get(res));
    else {
    	if(k<list.size()) {
    		System.out.println(list.get((int)k));
    	}else {
    		buff=list.subList(list.indexOf(a[g]), list.size());
    		int w=(int)((k-list.size())%(list.size()-list.indexOf(a[g])));
    		System.out.println(buff.get(w));
    	}
    }
    //System.out.println(buff);
  }
}


Measured memory_bytes: 72184
N = int(input())
ST = []
for _ in range(N):
    x, l = map(int, input().split())
    ST.append((x - l, x + l))
ST.sort(key=lambda x: x[1])
# print(ST)
cur = float('-inf')
cnt = 0
for i in range(N):
    if cur <= ST[i][0]:
        cnt += 1
        cur = ST[i][1]
print(cnt)

Measured memory_bytes: 18260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	string X, Y;
	cin >> X >> Y;
	if (X < Y) puts("<");
	else if (X > Y) puts(">");
	else puts("=");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static readonly long Mod = 1000000007;
    static void Main()
    {
        int N = RInt();
        var a = RLongs();
        var d = new long[N + 1];
        for (int i = 0; i < N; i++)
        {
            d[i + 1] = d[i] + a[i];
        }
        long ans = 0;
        for (int i = 0; i < N-1; i++)
        {
            ans += a[i] * ((d[N] - d[i + 1])%Mod);
            ans %= Mod;
        }
        WriteLine(ans);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 48572
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x,y;
  int b;
  cin>>x>>y;
  if(y>=(2*x))
  {
     if((y-(2*x))%2==0)
     {
       b=(y-(2*x))/2;
       if(b<=x)
       {
         cout<<"Yes";
       }
       else
         cout<<"No";
     }
    else
         cout<<"No";
  }
  else
         cout<<"No";
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 200000 + 10;
const int INF = 1000000000;

int N;
char S[MAXN];
int cnt[3];

void Work()
{
	scanf("%s", S);
	N = strlen(S);
	for (int i = 0; i < N; i ++)
		cnt[S[i] - 'a'] ++;
	
	sort(cnt, cnt + 3);
	printf((cnt[2] - cnt[0] <= 1) ? "YES\n" : "NO\n");
}

int main()
{
	Work();

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    int d = b - a;
    if(d&1) cout << "IMPOSSIBLE" << endl;
    else cout << a + d/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {vector<int> par; // uf(x,y)->y
    UnionFind(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); }
    void reset() { rep(i, 0, par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) {x = operator[](x); y = operator[](y);if (x != y) par[x] = y;}};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int N, M, A[101010];
min_priority_queue<int> buf[101010];
//---------------------------------------------------------------------------------------------------
ll solve() {
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];

    UnionFind uf(N);
    int group = N;
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        if (uf[a] != uf[b]) {
            uf(a, b);
            group--;
        }
    }

    ll ans = 0;
    rep(i, 0, N) buf[uf[i]].push(A[i]);
    min_priority_queue<int> rest;
    rep(i, 0, N) if (uf[i] == i) {
        ans += buf[i].top(); buf[i].pop();
        while (!buf[i].empty()) {
            rest.push(buf[i].top());
            buf[i].pop();
        }
    }

    if (group == 1) return 0;

    int need = (group - 1) * 2 - group;
    while (0 < need) {
        if (rest.empty()) return -1;

        ans += rest.top();
        rest.pop();
        need--;
    }

    return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    ll res = solve();
    if (res < 0) printf("Impossible\n");
    else printf("%lld\n", res);
}

Measured memory_bytes: 7288
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), m = in(), c = in();
	vector<ll>b(m); REP(i, m)b[i] = in();

	ll cnt = 0;
	REP(i, n) {
		ll sum = 0;
		REP(j, m) {
			ll a = in();
			sum += a * b[j];
		}
		sum += c;
		if (sum > 0)++cnt;
	}

	cout << cnt;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Calendar cal = Calendar.getInstance();
    String[] weekName = {"Sunday","Monday","Tuesday","Wednesday",
                         "Thursday","Friday","Saturday"};
    while (true) {
      int month = sc.nextInt();
      if (month == 0) {
        break;
      }
      int day = sc.nextInt();
      cal.set(2004, month - 1, day);
      int week = cal.get(Calendar.DAY_OF_WEEK) - 1;
      System.out.println(weekName[week]);
    }
  }
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <math.h>
int main()
{
  int i,j,N,a,count1=0,count2=0;
  double x;
  scanf("%d",&N);

  
  for(i=0;i<N;i++)
    {
      scanf("%d",&a);
      count1 = 0;
      /*if(a == 2)
	{
	  count1++;
	  continue;
	  }*/
      for(j=1;j<=sqrt(a);j++)
	{
	  if((a % j) == 0) count1++;
	}
      if(count1 == 1) count2++;
    }
 
  printf("%d\n",count2);

  return 0;
}

Measured memory_bytes: 596
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

s = input()
x, y = map(int, input().split())

dpx = {0}
dpy = {0}

f = s.split("T")

fx = []
fy = []

for i, fi in enumerate(f):
    if i % 2:
        fy.append(len(fi))
    else:
        fx.append(len(fi))

for i, fxi in enumerate(fx):
    nex = set([])
    for j in dpx:
        nex.add(j+fxi)
        if i > 0:
            nex.add(j-fxi)
    dpx = nex

for fyi in fy:
    nex = set([])
    for j in dpy:
        nex.add(j+fyi)
        nex.add(j-fyi)
    dpy = nex

if x in dpx and y in dpy:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 93488
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool comp1(pair<int,int> &a,pair<int,int> &b)
{
    return a.second>b.second;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll> m;
    ll s=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
        m[a[i]]++;
    }
    ll q;
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        //cout<<m[b]<<" "<<m[c]<<" ";
        s+=m[b]*(c-b);
        m[c]+=m[b];
        m[b]=0;
        cout<<s<<"\n";
    }

}

Measured memory_bytes: 10348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int arr[111];
int main(){
    int n;
    while(cin>>n){
        bool t=0;
        int su=0;
        for(int i=0;i<n;i++){
            cin>>arr[i];
            su+=arr[i];
            if(arr[i]%10){
                t=1;//break;
            }
        }
        //cout<<"n:"<<n<<endl;
        if(!t){
            cout<<0<<endl;
            continue;
        }
        if(su%10){
            cout<<su<<endl;
            continue;
        }
        sort(arr,arr+n);
        for(int i=0;i<n;i++){
            if(arr[i]%10!=0){
                su-=arr[i];break;
            }
        }
        cout<<su<<endl;
    }
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  n %= 10;
  if (n == 3) puts("bon");
  else if (n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
  else puts("hon");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

using int64 = long long;

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

    const int MAXM = 200005;

    vector<int> a(n);
    static vector<int> dest[MAXM];

    int64 sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;

        if (i == 0) continue;
        if (a[i - 1] > a[i]) dest[a[i] + m].push_back(a[i - 1]);
        else dest[a[i] + m].push_back(a[i - 1] + m);

        sum += (a[i] - a[i - 1] + m) % m;
    }

    vector<int64> prize(2 * m, 0);
    priority_queue<int> Q;

    int64 score = 0;
    for (int i = 2 * m - 1; i >= 0; i--) {
        score -= Q.size();
        while (!Q.empty() and Q.top() > i) Q.pop();

        while (!dest[i].empty()) {
            int d = dest[i].back(); dest[i].pop_back();

            if (i >= d + 2) {
                Q.push(d + 2);
                score += i - d - 1;
            }
        }
        prize[i] += score;
    }

    int64 ans = sum;
    for (int i = 0; i < m; i++) {
        ans = min(ans, sum - prize[i] - prize[i + m]);
    } 
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int a, b, k;

int main() {
	cin >> k >> a >> b;
	for (int i = 0; i < 3000; i += k) {
		if (i >= a && i <= b) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3636
////////////////////////////////////////BatTle rOweL ///////////////////////////////////////
#include <bits/stdc++.h>
#include <deque>
#include <vector>
using namespace std;
#define smackie ios_base::sync_with_stdio(0); cin.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
typedef long long ll;
#define mset(a,k) memset(a,k,sizeof(a));
#define rep(i,l,h) for(ll i=l;i<h;i++)
#define ds1(i,x) for(int  i=0;i<x.size();i++)
#define ds2(i,x) for(auto i:x)
typedef vector<ll>  vit;
typedef pair<int,int> pii;
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
typedef map<ll,ll >   mps;
//-------------------------------------------<dec>-------------------------------
 bool isPrime(int n) 
{ 
    if (n <= 1) return false; 
    rep(i,2,n)  if (n % i == 0) return false;  
    return true; 
}
 
 
 
//------------------------------------------<Assumes>----------------------------
int main()
{
    smackie
    string s;
    cin>>s;
    int n=s.length();
    string f=s.substr(0,(n-1)/2);
    string d=f;
    reverse(f.begin(),f.end());
    if(f!=d){
        cout<<"No"<<endl;
        return 0;
        
    }
    f=s.substr((n+3)/2-1,n-(n+3)/2+1);
    d=f;
    reverse(f.begin(),f.end());
    //cout<<d<<' '<<f<<endl;
    string h=s;
    reverse(h.begin(),h.end());
    if(f!=d or h!=s){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
s = set(a)
if len(s)>=3:
    print('No')
elif len(s)==2:
    #頑張る
    mx = max(a)
    mn = min(a)
    y = a.count(mx)
    x = a.count(mn)
    if mx-mn>1:
        print('No')
    elif x < mx and 2*(mx-x)<=y:
        print('Yes')
    else:
        print('No')
else:
    if a[0]==n-1:
        print('Yes')
    elif a[0]*2<=n:
        print('Yes')
    else:
        print('No')

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

int main() {
  int n,m,x;
    cin>>n>>m>>x;
  
  vector<int>vec(m);
  int sum=0;
  
  for(int i=0;i<m;i++){
    cin>>vec[i];
  }
  for(int j=0;j<m;j++){
    if(x<vec[j]){
      sum+=1;
    }
  }
  
    cout<<min(sum,m-sum)<<endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
#define ent '\n'
ll fac[100007];
ll power(ll x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % mod;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % mod; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll n) 
{ 
    return power(n, mod-2); 
} 
  

ll nCrModPFermat(ll n, ll r) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    return (fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod) % mod; 
} 
bool sortbyfirst(const tuple<int, int, int>& a,  
               const tuple<int, int, int>& b) 
{ 
    return (get<0>(a) < get<0>(b)); 
} 
//ll power2[100005];

int main(){
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r;
    }
    else{
        cout<<r+100*(10-n);
    }
}


Measured memory_bytes: 256
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int32_t main()
{
   // shuru_krte_hai_bina_kisi_bakchodi_ke();
    int n;
    cin >> n;
    int a, b, c;
    
    int dp[n + 1][3] = {0};
    cin >> a >> b >> c;
    dp[1][0] = a;
    dp[1][1] = b;
    dp[1][2] = c;
    for (int i = 2; i <= n; i++)
    {
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c;
    }
    cout << max(dp[n][1], max(dp[n][2], dp[n][0]));

    return 0;
}

Measured memory_bytes: 5940
a,b,k = map(int,input().split())
if abs(a-b) + 1 <= 2*k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=k;i>=j;i--)
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return  x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
ll n,a[1000001],ans=1e17,sum,now;
int main()
{
	n=read();
	For(i,1,n)	a[i]=read(),sum+=a[i];
	now=0;
	For(i,1,n-1)
		now+=a[i],ans=min(ans,abs((sum-now)-now));
	writeln(ans);
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

bool check(string& T)
{
  for (auto& c : T) {
    if (c != 'A' && c != 'T' && c != 'C' && c != 'G') return false;
  }
  return true;
}

int main()
{
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    for (int j = i; j < S.size(); j++) {
      string tmp = S.substr(i, j - i + 1);
      if (check(tmp)) ans = max(ans, j - i + 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll get(ll A,ll B){
    int i,a,b;ll t;
    if(A==B) return 1;
    for(a=0;A>=(1ll<<a);a++);
    for(b=0;B>=(1ll<<b);b++);
    if(a>b){
        for(i=a-2;i>=0;i--)
            if(A&(1ll<<i)) break;
        t=i==-1?0:(1ll<<(i+1))-1;
        if(B<=t+1) return (1ll<<a)-B;
        return ((1ll<<(a-1))|t)-B+1+(1ll<<(a-1))-B;
    }
    else return get(A^(1ll<<(a-1)),B^(1ll<<(b-1)));
}
int main()
{
    ll A,B;
    cin>>B>>A;
    cout<<get(A,B);
    return 0;
}

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

int main(){
  double N, D;
  cin >> N >> D;
  
  int count = 0;
  for(int i=0; i<N; i++){
    double X, Y;
    cin >> X >> Y;
    if (sqrt(X*X+Y*Y) <= D) count++;
  }
  
  cout << count;
}

Measured memory_bytes: 3816
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    sc.useDelimiter("\\n");

    while(true) {
      String input = sc.next();
      if(input.equals(".")) {
        break;
      }

      char[] stack = new char[100];
      int position = 0;
      for(int i = 0; i < input.length(); i++) {
        char c = input.charAt(i);
        if(c == '(') {
          stack[position] = '(';
          position++;
        }
        if(c == '[') {
          stack[position] = '[';
          position++;
        }
        if(c == ')') {
          if(position > 0 && stack[position - 1] == '(') {
            position--;
          } else {
            position = -1;
            break;
          }
        }
        if(c == ']') {
          if(position > 0 && stack[position - 1] == '[') {
            position--;
          } else {
            position = -1;
            break;
          }
        }
      }

      if(position == 0) {
        System.out.println("yes");
      } else {
        System.out.println("no");
      }
    }
  }
}

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

using namespace std;
using ll = long long;

int main() {

    int H, W;
    cin >> H >> W;

    string grid = string(W + 2, 'X');
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        grid += 'X' + s + 'X';
    }
    grid += string(W + 2, 'X');

    vector<int> black;
    for (int i = 0; i < grid.length(); ++i)
        if (grid[i] == '#')
            black.push_back(i);

    int INF = 1000;
    int move[] = {1, -1, W + 2, -(W + 2), INF};
    bool ans = true;

    for (int x : black) {
        for (int dx : move) {
            if (dx == INF) {
                cout << "No" << endl;
                exit(0);
            }
            int y = x + dx;
            if (grid[y] == '#')
                break;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int cnt=0;
		for(int i=0;i<=9;i++) {
			for(int j=0;j<=9;j++) {
				if(N==i*j) {
					cnt = 1;
					break;
				}
			}
		}
		if(cnt == 1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

const int N=1100005;
const ll inf=1000000000000000ll;

int n,sz,ans;
int a[N],mx1[N][21],mx2[N][21];

void add(int s,int p,int w){
	if (w>mx2[s][p]) mx2[s][p]=w;
	if (mx2[s][p]>mx1[s][p]) swap(mx1[s][p],mx2[s][p]);
}

int main(){
	int i,j;
	scanf("%d",&n); sz=(1<<n)-1;
	for (i=0;i<=sz;i++) scanf("%d",&a[i]);
	for (i=0;i<=sz;i++) mx1[i][0]=a[i],mx2[i][0]=-1;
	for (i=0;i<=sz;i++){
		for (j=0;j<=n;j++){
			add(i,j+1,mx1[i][j]);
			add(i,j+1,mx2[i][j]);
			if (!((i>>j)&1)){
				add(i|(1<<j),j+1,mx1[i][j]);
				add(i|(1<<j),j+1,mx2[i][j]);
			}
		}
	}
	for (i=1;i<=sz;i++){
		ans=max(ans,mx1[i][n+1]+mx2[i][n+1]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 95232
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);i++)

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 10000000000;

const int M = 100010;
long long h[M];

long long dp[M];

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

    rep(i, N) cin >> h[i];
    rep(i, M) dp[i] = INF;

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    cout << dp[N - 1] << endl;
}


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

int main() {
    
    string S;
    long long sum = 0;
    
    cin >> S;
    
    for ( int i = 0; i < S.length(); i++ ) {
        for ( int j = i; j < S.length(); j++ ) {
            
            int length = S.length();
            
            int x = max(0, i-1) + max(0,(length-j-2) );
            
            long long temp = std::stoll( S.substr( i, j-i+1 ) );
            
            sum += temp * pow( 2, x );
            
            cout << endl;
        }
        
    }
    
    cout << sum << endl;
    
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void print(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void print(H head, T ...tail) { cout << head << " "; print(tail...); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	map<ll, ll> freq;

	int n; ll k; read(n, k);
	rep(i, 0, n) { int a, b; read(a, b); freq[a] += b; }
	
	ll ctl = 0;
	for (auto p : freq) {
		ctl += p.second;
		if (ctl >= k) {
			print(p.first);
			return 0;
		}
	}
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 5e3 + 5;
int x, pw[2 * M];
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	for(int i = -M; i < M; i++)
		pw[i + M] = pow(i, 5);
	cin >> x;
	for(int i = -M; i < M; i++)
	{
		int a = pw[i + M];
		for(int j = -M; j < M; j++)
		{
			int b = pw[j + M];
			if(a - b == x)
				return cout << i << " " << j, 0;
		}
	}
    	return 0;
}

Measured memory_bytes: 4296
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
ll root(ll x,ll par[]){
    if(par[x]==x) return x;
    else return par[x]=root(par[x],par);
}

void unite(ll x,ll y,ll par[],ll size[]){
    x=root(x,par);
    y=root(y,par);
    if(x==y) return;
    par[y]=x;
    size[x]=size[x]+size[y];
}
int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    ll par[N],size[N],fr[N];
    ll A,B,C,D;
    ll i;
    for(i=0;i<N;i++)par[i]=i,size[i]=1,fr[i]=1;
    for(i=0;i<M;i++){
        cin >> A >> B;
        unite(A-1,B-1,par,size);
        ++fr[A-1],++fr[B-1];
    }
    ll ans[N];
    for(i=0;i<N;i++){
        ans[i]=size[root(i,par)]-fr[i];
    }
    for(i=0;i<K;i++){
        cin >> C >> D;
        if(root(C-1,par)==root(D-1,par))--ans[C-1],--ans[D-1];
    }
    for(i=0;i<N;i++){
        cout << ans[i] <<" ";
    }
    return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 500000
#define INF 1000000000

int L[N], R[N];
long long count = 0;

void merge(int A[], int left, int mid, int right)
{
  int n1, n2, i, j, k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++) L[i] = A[left + i];
  for(i = 0; i < n2; i++) R[i] = A[mid + i];

  L[n1] = INF;
  R[n2] = INF;

  i = 0;
  j = 0;

  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
      count += n1 - i;
    }
  }
}

void mergeSort(int A[], int left, int right)
{
  int mid;

  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void)
{
  int i, n, A[N];

  scanf("%d", &n);

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

  mergeSort(A, 0, n);

  printf("%lld\n", count);            //%lldとすることでlong long int型の数値をprint文で表示

  return 0;
}



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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    vector<pair<int, int>> m(n + 1);
    int w, v;
    for (int i = 1; i <= n; i++) {
        cin >> w >> v;
        m[i] = make_pair(w, v);
    }

    vector<vector<int>> dp(n + 1, vector<int>(100001, 1000100100));
    dp[0][0] = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 100001; j++) {
            if (j - m[i].second >= 0) {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - m[i].second] + m[i].first);
            } else {
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
        }
    }

    for (int j = 100000; j >= 0; j--) {
        if (dp[n][j] <= lw) {
            cout << j << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 40192
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  int cnt = 0;
  for (int i = A; i <= B; i++) {
    string i_s = to_string(i);
    if (i_s[0] == i_s[4] && i_s[1] == i_s[3]) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
  int n, m;
  int a[101][101];
  int b[101];
  int c[101] = {0};
  cin >> n >> m;
  
  rep(i, n){
    rep(j, m){
      cin >> a[i][j];
    }
  }
  
  rep(i, m){
    cin >> b[i];
  }
  
  rep(i, n){
    rep(j, m){
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3132
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

tgt = 1
cnt = 0
flg = False
for j in range(n):
    tgt = a[tgt-1]
    cnt += 1
    if tgt == 2:
        flg = True
        break
print(cnt if flg == True else "-1")

Measured memory_bytes: 7084
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N;
	scanf("%d", &N);
	int32_t p[100000];
	for (int32_t i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		p[i]--;
	}

	int32_t res = 0;
	for (int32_t i = 0; i < N; i++) {
		if (p[i] != i)
			continue;
		res++;
		if (i == N - 1)
			continue;

		int32_t temp = p[i];
		p[i] = p[i + 1];
		p[i + 1] = temp;
	}

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

	return 0;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))



int main(){
  int k, t;
  std::cin >> k >> t;
  vi a(t);
  rep(i,t) std::cin >> a[i];
  sort(all(a));
  if(k-a[a.size()-1]>=a[a.size()-1]-1) std::cout << '0' << std::endl;
  else std::cout << a[a.size()-1] - (k-a[a.size()-1])-1 << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x, y; cin >> x >> y;
  cout << x + y/2 << endl;
  return 0;
}

Measured memory_bytes: 3196
//---------------laziness is poison-------------------
#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inf 1e18
int main()
{
	ios_base:: sync_with_stdio(false); cin.tie(0);
	// freopen ("inp","r",stdin);
	// freopen ("out","w",stdout);
	ll a[4],n;
	for(int i=0;i<4;i++)
	{
		cin>>a[i];
	}
	cin>>n;
	ll ans=inf;
	ans=n*4*a[0];
	ans=min(ans,n*2*a[1]);
	ans=min(ans,n*a[2]);
	ll val = (n/2)*a[3];
	ll extra = n%2;
	ll extra_val = min(extra*4*a[0],min(extra*2*a[1],extra*a[2]));
	ans=min(ans,val+extra_val);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
while 1:
	n=input()
	if n==0:break
	y=input()
	mx=0
	for i in range(n):
		b,r,t=map(int,raw_input().split())
		m=(1+y*float(r)/100) if t==1 else (1+float(r)/100)**y
		if m>mx:mx,a=m,b
	print a

Measured memory_bytes: 4316
#include<iostream>
using namespace std;
int main()
{
int h,w,i,j;
char c;
cin>>h>>w;
bool p[h][w];
for(i=0;i<h;i++)
{
for(j=0;j<w;j++)
{
cin>>c;
if(c=='.')p[i][j]=false;
else p[i][j]=true;
}}
for(i=0;i<h;i++)
{
for(j=0;j<w;j++)
{
if(p[i][j]==false)continue;
if((i!=0)&&(p[i-1][j]==true))continue;
if((i!=h)&&(p[i+1][j]==true))continue;
if((j!=0)&&(p[i][j-1]==true))continue;
if((j!=w)&&(p[i][j+1]==true))continue;
cout<<"No";
return 0;
}}
cout<<"Yes";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int nxt[26][2<<17];
int dp[26][2<<17];
bool ap[26];
main()
{
	cin>>s;
	for(int i=0;i<26;i++)nxt[i][s.size()]=s.size();
	for(int i=s.size();i--;)
	{
		for(int j=0;j<26;j++)dp[j][i]=dp[j][i+1],nxt[j][i]=nxt[j][i+1];
		int tmp=s[i]-'a';
		int mi=0;
		for(int j=0;j<26;j++)
		{
			if(dp[mi][nxt[mi][i]]>dp[j][nxt[j][i]])mi=j;
			//if(nxt[mi][i]>nxt[j][i])mi=j;
		}
		dp[tmp][i]=dp[mi][nxt[mi][i]]+1;
		nxt[tmp][i]=i;
	}
	string ans="";
	int id=0;
	while(id<s.size())
	{
		int mi=0;
		for(int i=0;i<26;i++)
		{
			if(dp[mi][nxt[mi][id]]>dp[i][nxt[i][id]])mi=i;
		}
		ans+=mi+'a';
		id=nxt[mi][id]+1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 53380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0619
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] science = new int[4];
            int[] socialStudies = new int[2];

            for (int i = 0 ; i < science.Length ; i++)
            {
                science[i] = ReadInt();
            }
            for (int i = 0 ; i < socialStudies.Length ; i++)
            {
                socialStudies[i] = ReadInt();
            }
            Console.WriteLine(science.Sum()-science.Min() + socialStudies.Max());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 18312
import bisect#bisection search 
#二分探索のためのライブラリ
#ソート済みリストに対して二分探索法を行う関数を提供
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

count=0
for b in B:
    a=bisect.bisect_left(A,b)
    c_=bisect.bisect_right(C,b)
    c=N-c_
    count+=a*c
print(count)


Measured memory_bytes: 23232
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    nt, nx, ny = map(int, input().split())
    km = abs(nx-x) + abs(ny-y)
    if km > (nt-t) or (km - (nt-t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y = nt, nx, ny
print("Yes")


Measured memory_bytes: 8964
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val a, b = sc.nextInt()
  var cnt = 0
  for (i <- a to b) {
    val s = i.toString
    if (s(0) == s(4) && s(1) == s(3)) {
      cnt += 1
    }
  }
  println(cnt)
}

Measured memory_bytes: 56764
#include<stdio.h>

int n, i;
int a;
double s;

int main(void){
	scanf("%d", &n);
	s=0;
	for(i=0; i<n; i++){
		scanf("%d", &a);
		s += (double)1/a;
	}
	printf("%lf\n", 1/s);
}


Measured memory_bytes: 128