akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        ll h1,m1,h2,m2,k;
        cin>>h1>>m1>>h2>>m2>>k;
        cout<<((h2-h1)*60 + m2-m1 -k);





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3820
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int R[1000000];
int n;
vector<int> G;

void insertionSort(int R[],int n,int g){
	int key;
	int j;
	for (int i = g; i < n; i++){
		key = R[i];
		j = i - g;
		while (j >= 0 && R[j] > key){
			R[j + g] = R[j];
			j -= g;
			cnt++;
		}
		R[j + g] = key;
	}
}

void shellSort(int R[], int n){
	for (int h = 1; ; ){
		if (h > n){
			break;
		}
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--){
		insertionSort(R, n, G[i]);
	}
}

int main(){
	cin >> n;
	int j;
	for (int i = 0; i < n; i++){
		scanf("%d",&R[i]);
	}
	int key;
	cnt = 0;
	shellSort(R, n);
	cout << G.size() << endl;
	for (int i = G.size()-1; i >= 0; i--){
		printf("%d",G[i]);
		if (i != 0)
			printf(" ");
	}
	printf("\n");
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++){
		printf("%d\n",R[i]);
	}
}

Measured memory_bytes: 7144
mod=10**9+7
n=int(input())
A=list(map(int,input().split()))
DP=[0]*(n+1)
DP[0]=3

ans=1
for i in A:
    ans *=DP[i]
    ans %=mod
    DP[i] -=1
    DP[i+1] +=1
print(ans)

Measured memory_bytes: 53300
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 302;
const int mod = 998244353;

struct mul {
	ll operator()(const ll &n1, const ll &n2) const {
		return (n1 * n2) % mod;
	}
};

ll identity_element(const mul& m) {
	return 1LL;
}

int n, tot;
int a[N];
int dp[N][N * N];
int dp2[N][N * N];

int calc(int idx, int sum) {
	if (idx == n)
		return sum * 2 >= tot;
	int &ret = dp[idx][sum];
	if (ret != -1)
		return ret;
	ret = (2LL * calc(idx + 1, sum)) % mod;
	ret += calc(idx + 1, sum + a[idx]);
	ret %= mod;
	return ret;
}

int calc2(int idx, int sum) {
	if (idx == n)
		return sum * 2 == tot;
	int &ret = dp2[idx][sum];
	if (ret != -1)
		return ret;
	ret = calc2(idx + 1, sum);
	ret += calc2(idx + 1, sum + a[idx]);
	ret %= mod;
	return ret;
}


int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		tot += a[i];
	}
	MMS(dp, -1);
	MMS(dp2, -1);
	int res = power(3LL, n, mul());
	res -= (3LL * calc(0, 0)) % mod;
	res += (3LL * calc2(0, 0)) % mod;
	res %= mod;
	if (res < 0)
		res += mod;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 215424
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val a, b, c, d = ni()

    val ok = Set(a, b, c, d) == Set(1, 9, 7, 4)
    if (ok) out.println("YES")
    else out.println("NO")
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 25516
s=input()
L=['A','T','G','C']
ans=0
M=0
for i in range(len(s)):
  if s[i] in L:
    ans += 1
  else:
      if ans > M:
          M = ans
          ans = 0
if ans > M:
    M = ans
    ans = 0
print(M)


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

H = list(map(int, input().split()))

N_addj = [[] for i in range(N)]

for i in range(M):
    AB = list(map(int, input().split()))
    N_addj[AB[0]-1].append(AB[1]-1)
    N_addj[AB[1]-1].append(AB[0]-1)


N_memo = [0] * N

num = 0


arr = []


for i in range(N):
    flag = True
    for j in N_addj[i]:
        if(H[i] <= H[j]):
            flag = False
            break
    if(flag):
        num = num + 1

print(num)


Measured memory_bytes: 30240
#include<iostream>
#include<vector>
std::vector<int>count(100010,0);
int main(){
  int N,ans=0;
  std::cin>>N;
  std::vector<int>a(N);
  for(int i=0;i<N;i++){
    std::cin>>a.at(i);
    count[a.at(i)+1]++;
    count[a.at(i)]++;
    if(a.at(i)==0)continue;
    count[a.at(i)-1]++;
  }
  for(int i=0;i<count.size();i++){
  	ans=std::max(count[i],ans);
  }
  std::cout<<ans<<std::endl;
  return 0;
}
  

Measured memory_bytes: 3936
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

char affine(char s, int a, int b) {
	auto c = s - 'a';
	return ((a * c + b) % 26 + 'a').to!char;
}

void main()
{
	auto n = readln.chomp.to!int;
	while (n--) {
		auto str = readln.chomp.map!(to!char).array.split;
		auto target = str.filter!(a=> a.length == 4).array;
		int a, b;
		ll:while (1) {
			foreach (bb; 0..26) {
				foreach (e; target) {
					auto sub = e.map!(x=> affine(x.to!char, a, bb)).array;
					if (sub == "this" || sub == "that") {
						b = bb;
						break ll;
					}
				}
			}
			a++;
		}
		foreach (ref e; str) {
			e = e.map!(x => affine(x.to!char, a, b)).array;
		}
		str.join(" ").writeln;
	}
}

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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename H> void print(H head) { std::cout << head << std::endl; }
template <typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll cnt = 0LL;
  for (ll i = 0; i < N; i++) {
    while (va[i] % 2 == 0) {
      va[i] /= 2;
      cnt++;
    }
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 384
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    x, n = 6, 5
    P = [4, 7, 10, 6, 5]

  else:
    ##INPUT 
    #n = input()
    x, n = map(int, input().split())
    if n == 0:
      P = []
    else: 
      P = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  for i in range(1, 100):
    if x - i not in P:
        dif_mis = x-i
        break

  for i in range(0, 100):
    if x + i not in P:
        dif_pls = x+i
        break

  if (x-dif_mis)**2 > (x-dif_pls)**2:
    print(dif_pls)
  else:
    print(dif_mis)

main()

Measured memory_bytes: 8984
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

template <class T> void read(T &x) {
	int f = 1;
	char c = getchar();
	x = 0;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	x *= f;
}

template <class T> void write(T x) {
	int len = 0;
	char s[30];
	if(x < 0) putchar('-'), x = -x;
	do {
		s[++len] = x % 10;
		x /= 10;
	}while(x);
	while(len) putchar(s[len--] + '0');
}

template <class T> inline bool gmin(T &a, T b) { return a > b ? a = b, true : false; }
template <class T> inline bool gmax(T &a, T b) { return a < b ? a = b, true : false; }

typedef long long LL;

int n, a, b;
LL min, max;

int main() {
		read(n); read(a); read(b);
		if((a > b) || (n == 1 && a < b)) puts("0");
		else {
			min = (LL)a * (n - 1) + b;
			max = (LL)b * (n - 1) + a;
			write(max - min + 1); putchar('\n');
		}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (B/A <= C) cout << B/A << endl;
  else cout << C << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		String[] tokens = in.nextLine().split(" ");
		List<Integer> nums = new ArrayList<>(n);
		for (int i = 0; i < n; ++i) {
			nums.add(Integer.parseInt(tokens[i]));
		}
		Collections.sort(nums);
		System.out.println(Math.abs(nums.get(nums.size() - 1) - nums.get(0)));

		in.close();
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa;
	cin>>sa;
	sa[1]=(char)((int)'B'+(int)'R'-(int)sa[1]);
	cout<<sa<<endl;
}


Measured memory_bytes: 3592
import bisect      
    
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:
    
    c_num = len(C)-bisect.bisect_left(C,b+1)
    a_num = bisect.bisect_right(A,b-1)
    count+=c_num*a_num

print(count)  

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

using namespace std;

int main(void){

  int n,q;

  while(cin >> n >> q, n|q){
    vector<int>v(101,0);
    int m,d;
    for(int i=0;i<n;i++){
      cin >> m;
      while(m--)cin >> d, v[d]++;
    }

    int ans=0;
    for(int i=0;i<101;i++){
      if(v[i]>=q && v[i]>v[ans])ans = i; 
    }
    
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2972
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
	string s;
	cin >> s;
	if(s[3] == '8'){
		cout << s;
	}else{
		string date;
		date += "2018/01/";
		date += s[8];
		date += s[9];
		cout << date << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val c = Array(3) { Array(3) { sc.nextInt() } }

  var ok = true
  if (c[0][0] - c[1][0] != c[0][1] - c[1][1] ) {
    ok = false
  }
  if (c[0][0] - c[1][0] != c[0][2] - c[1][2] ) {
    ok = false
  }

  if (c[0][0] - c[2][0] != c[0][1] - c[2][1] ) {
    ok = false
  }
  if (c[0][0] - c[2][0] != c[0][2] - c[2][2] ) {
    ok = false
  }

  if (c[1][0] - c[2][0] != c[1][1] - c[2][1] ) {
    ok = false
  }
  if (c[1][0] - c[2][0] != c[1][2] - c[2][2] ) {
    ok = false
  }

  if (ok) {
    println("Yes")
    return
  }
  println("No")
}


Measured memory_bytes: 36364
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define fo(i,l,r,d) for(int i=(l);i<=(r);i+=(d))
using namespace std;
const int maxn=3e5+10;
int a[maxn],n;
int main(){
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d",&a[i]);
        if((i^a[i])&1) return puts("No"),0;
    }
    for(int i=1;i<=n;++i){
        if(a[i]==i) continue;
        int p;
        for(p=i;p<=n-2;p+=2)
            if(a[p+2]==p+2||a[p+1]!=p+1) break;
        int mx=0,mn=n+1;
        rep(j,i,p) mx=max(mx,a[j]),mn=min(mn,a[j]);
        if(mx!=p||mn!=i) return puts("No"),0;
        int f1=0,f2=0;
        fo(j,i,p,2)
            if(a[j]>f1) f1=a[j];
            else if(a[j]>f2) f2=a[j];
            else return puts("No"),0;
        i=p;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
	int S,h,m,s,x;
	scanf("%d",&S);
	h=S/3600;
	S=S%3600;
	m=S/60;
	s=S%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1804
n = int(input())
a = list(map(int, input().split()))
ma = -100000000
mi = 100000000
for i in range(n):
    if a[i] > ma:
        ma = a[i]
        ma_index = i
    if a[i] < mi:
        mi = a[i]
        mi_index = i
ans = []
if ma >= -mi:
    for i in range(n):
        ans.append((ma_index,i))
    for i in range(n-1):
        ans.append((i,i+1))
else:
    for i in range(n):
        ans.append((mi_index,i))
    for i in range(n-1):
        ans.append((n-1-i,n-2-i))
print(len(ans))
for x in ans:
    print(x[0]+1,x[1]+1)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

int main()
{
    string s;
    int k;
    cin >> s >> k;
    int neednum[100001];
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'a') neednum[i] = 0;
        else neednum[i] = 'z' - s[i] + 1;
    }
    int charnum = 0;
    while(charnum < s.length()){
        // cout << s[charnum] << " " << k << endl;
        if(k >= neednum[charnum]){
            k -= neednum[charnum];
            s[charnum] = 'a';
        }
        charnum++;
    }
    char lastchar = (s[s.length() - 1] + k - 'a') % 26;
    s[s.length() - 1] = 'a' + lastchar;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int l,i,j,f[300]={};
	char s[30];
	chin(s);
	l=strlen(s);
	if(strcmp("zyxwvutsrqponmlkjihgfedcba",s)==0)
		print(-1);
	else if(l<26){
		rep(i,l)f[s[i]]++;
		for(i='a';i<='z';i++)if(!f[i])break;
		printf("%s%c\n",s,i);
	}
	else{
		rev(i,l)if(s[i-1]<=s[i])break;
		for(j=i;j<l;j++)f[s[j]]++;
		for(j='a';j<'z';j++)if(f[j]&&s[i-1]<j)break;
		s[i]=0;
		s[i-1]=j;
		puts(s);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
 
int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    rep(i,n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y,y+n);
    int lit = y[n/2-1];
    int dec = y[n/2];
    rep(i,n){
        if(x[i] >= dec){
            cout << lit << endl;
        }else{
            cout << dec << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cout<<#x<<" "<<endl;
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
//-------------------------------------------------------------------------------




int n;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	cin>>n;
	int h[100005];
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	int dp[100005]={};
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;++i){
		dp[i]=min((dp[i-1]+abs(h[i-1]-h[i])),(dp[i-2]+abs(h[i-2]-h[i])));

	}
	cout<<dp[n]<<endl;


}
 


Measured memory_bytes: 1024
//In The Name of Beauty
//...So here I go is my shot
//Feet fail me not 'cause maybe the only opportunity that I got...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e5 + 8;
ll const INF  = 1e12 + 8;
ll const delta = 1000000007;
vll G[MAXN];
ll dp[MAXN][2];
void dfs(ll v,ll par)
{
    ll bl = 1;
    ll sum = 1;
    ll c = 0;
    for(ll i = 0;i < G[v].size();i++)
    {
        ll u = G[v][i];
        if(u == par)continue;
        dfs(u,v);
        bl = (bl * dp[u][1]) % delta;
        sum = (sum * ((dp[u][0] + dp[u][1]) % delta)) % delta;
        c++;
    }
    if(!c)
    {
        dp[v][0] = dp[v][1] = 1;
    }
    else
    {
        dp[v][1] = sum;
        dp[v][0] = bl;
    }
}
int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll f , s;
    for(ll i = 0;i < n - 1;i++)
    {
        cin >> f >> s;
        G[f].pb(s);
        G[s].pb(f);
    }
    dfs(1,-1);
    cout << (dp[1][0] + dp[1][1]) % delta << endl;
    return 0;
}
//Written by M_H_H_7


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 2; i <= n; i++){
        int tmp = i;
        for(int j = 2; tmp != 1; j++){
            while(tmp%j == 0){
                tmp /= j;
                mp[j]++;
            }
        }
    }

    ll ans = 1;
    for(auto x: mp){
        ans *= (x.second+1);
        ans %= mod;
    }
    
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;


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

#define int long long

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

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


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


signed main(void) {
	int N;
	cin >> N;
	vector<int>a(N);
	int ans = 0;
	int lower = 0;
	rep(i, N) {
		cin >> a[i];
	}
	rep1(i, N) {
		if (a[i - 1] >= a[i]) {
			lower++;
			ans = max(lower, ans);
		}else lower = 0;
	}
	print(ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    String s = sc.next();
	    String a = "aiueo";
	    
	    if(a.contains(s)) {
	    	System.out.println("vowel");
	    }else {
	    	System.out.println("consonant");
	    }
	    
	}
}

Measured memory_bytes: 22100
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

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

const ll A = 210;

ll n;
ll a[A];

int main() {
	cin >> n;
	for (ll i = 1; i <= n; i++) cin >> a[i];

	ll res = 1000;
	for (ll i = 1; i <= n - 1; i++) {
		if (a[i + 1] > a[i]) {
			res += res / a[i] * (a[i + 1] - a[i]);
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3620
//Bismillahir rahmanir rahim
#include<bits/stdc++.h>
#define ll long long

using namespace std;
int main()
{   //freopen("in.txt","r",stdin);

    std::ios_base::sync_with_stdio(0);cin.tie(NULL);
    ll n;
    cin>>n;
    vector <ll> v(1),pre(1),suf(1);
    ll g = 0;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        g = __gcd(g,x);
        pre.push_back(g);
        v.push_back(x);
    }
    g =0;
       for(int i=n;i>=1;i--){
        g = __gcd(g,v[i]);
        suf.push_back(g);
    }
     suf.push_back(0);
     reverse(suf.begin(),suf.end());
    // for(auto u : pre)cout<<u;
    // for(auto u : suf)cout<<u;
    g = -1;
         for(int i=1;i<=n;i++){
       g = max(__gcd(pre[i-1],suf[i+1]),g);
    }
    cout<<g<<endl;
}


Measured memory_bytes: 3308
def main():
    m_MAX = 0.0
    m_MIN = 9999999999999.0
    while True:
        try:
            m = float(input())
            if m > m_MAX :
                m_MAX = m
            elif m < m_MIN :
                m_MIN = m
        except EOFError:
            break
    print(m_MAX - m_MIN)
if __name__ == '__main__':
    main()


Measured memory_bytes: 5580
// inputに入力データ全体が入る
function Main(input) {

     input = input.split("\n");
    var n= parseInt(input[0], 10);

  var tmp = input[1].split(" ");
     var i = 0;
   var a = [];
for (var i = 0; i < n ; i++){
  var r= parseInt(tmp[i], 10);
  var r = r - 1;
  a[i] = r;}
  
   var tmp = input[2].split(" ");
     var i = 0;
   var b = [];
for (var i = 0; i < n ; i++){
  var r= parseInt(tmp[i], 10);
  b[i] = r;}
  
   var tmp = input[3].split(" ");
     var i = 0;
   var c = [];
for (var i = 0; i < n-1 ; i++){
  var r= parseInt(tmp[i], 10);
  
  c[i] = r;}
  
 //   console.log(n);
    var p = a[0];
    var T = b[p];
      for (i =1;i < n;i++){var q = a[i];
                            T = T +b[q];
                           var r = a[i] - a[i-1];
                           if (r == 1 ){T = T + c[q-1];}
               //    console.log(T);
      }
      
   console.log(T);
 
  	   }    //    1    
     
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll dp[111][4][4][4];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    dp[0][3][3][3] = 1;
    REP(idx, N){
        REP(i,4) REP(j,4) REP(k,4){
            for(int c=0;c<4;c++){
                if(i == 1 && j == 0 && c == 2) continue;
                if(i == 0 && j == 1 && c == 2) continue;
                if(i == 2 && j == 0 && c == 1) continue;
                if(i == 1 && k == 0 && c == 2) continue;
                if(j == 1 && k == 0 && c == 2) continue;

                dp[idx+1][c][i][j] += dp[idx][i][j][k];
                dp[idx+1][c][i][j] %= MOD;
            }
        }
    }
    ll ans = 0;
    REP(i,4) REP(j,4) REP(k,4){
        ans += dp[N][i][j][k];
        ans %= MOD;
    }
    cout << ans << endl;
}


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

#define MAX 80


int main()
{
	int i,j=97;
	char str[MAX];
	char str1[MAX];
	char arr[26];

	for (i = 0; i < 26; i++)
	{
		arr[i] = j;
		++j;
	}

	i = 1;
	while (fgets(str1,81,stdin)!=NULL)   
	{
		//printf("%s",str);
		//printf("%s",str1);
		while (1)
		{
			int j = 0;
			strcpy(str, str1);
			int len = strlen(str);
			while (len)
			{
				if (str[j] >= 'a'&&str[j] <= 'z')
				{
					str[j] = arr[(str[j]-'a'+i)%26];
				}
				++j;
				--len;
			}
			if (strstr(str, "the") || strstr(str, "this") || strstr(str, "that"))
			{
				break;
			}
			++i;
		}
		printf("%s",str);
	}

	
	return 0;
}


Measured memory_bytes: 532
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    
    int n,k;
    cin>>n>>k;

    int now=1;
    int count_double=0;
    int count_k=0;

    if(k==1){
        cout<<1+n<<endl;
        return 0;
    }

    if(n==1){
        cout<<2<<endl;
        return 0;
    }
    REP(i,10){

        int now=1;

        // cout<<pow(2,i)<<endl;
        if(pow(2,i)<k){
            count_double++;
        }else{
            break;
        }

        count_k=n-count_double;
    }

    // cout<<count_double<<" "<<count_k<<endl;

    REP(i,count_double){
        now=2*now;
    }
    REP(i,count_k){
        now+=k;
    }
    cout<<now<<endl;



    return 0;

}

Measured memory_bytes: 512
object Main {
  def main(args: Array[String]): Unit ={
    val sc = new java.util.Scanner(System.in)
    val s = sc.nextLine()
    val t = sc.nextLine()

    var cnt = 0
    for(i <- 0 to 2){
      if(s.charAt(i) == t.charAt(i)) cnt+=1
    }

    println(cnt)
  }
}

Measured memory_bytes: 26008
import fractions
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def k(x):
    return x - (x//c + x//d - x//lcm(c, d))

print(k(b)-k(a-1))

Measured memory_bytes: 5048
PROGRAM-ID.                      ABC_048_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP     PIC X(302).
    01 a       PIC X(100).
    01 x       PIC X(100).
    01 c       PIC X(100).
    01 ans     PIC X(3).

PROCEDURE                        DIVISION.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO a x c.

    DISPLAY a(1:1) x(1:1) c(1:1)

    STOP RUN.


Measured memory_bytes: 888
<?php

$n = trim(fgets(STDIN));

$w = trim(fgets(STDIN));
$r = $w[strlen($w)-1];
$ws = [$w];

$ans = 'Yes';
for($i=1; $i<$n; $i++){
  $w = trim(fgets(STDIN));
  $l = $w[0];
  if ($l !== $r){
    $ans = 'No';
    break;
  } else if (in_array($w,$ws)){
    $ans = 'No';
    break;
  }
  $r = $w[strlen($w)-1];
  array_push($ws,$w);
}


echo $ans;
  
?>

Measured memory_bytes: 4604
N=int(input())
ls1=[]
for i in range(N):
    si,pi=input().split()
    pi2=int(pi)
    ls2=[si,pi2,i+1]
    ls1.append(ls2)
ls1.sort(key=lambda x:-x[1])   
ls1.sort(key=lambda x:x[0])
for i in range(N):
    print(ls1[i][2])

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

void insertionSort(int *,int,int);
void shellSort(int *,int);

int cnt;

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

  int num;
  int i;
  int line[1000000];

  scanf("%d",&num);

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

  shellSort(line,num);

  for( i = 0 ; i < num ; i++ ){
    printf("%d\n",line[i]);
  }


  return 0;
}

void insertionSort(int *A, int n, int g){

  int i,j;
  int v;

  for( i = g ; i < n ; i++ ){

    v = A[i];
    j = i - g;

    while( j >= 0 && A[j] > v ){

      A[j+g] = A[j];
      j -= g;
      cnt++;

    }

    A[j+g] = v;

  }

}

void shellSort(int *A, int n){

  int i;
  int G[14] = {1,4,13,40,121,364,1093,3280,9841,29524,88573,265720,797161,2391584};
  int m = 14;
  int count = 0;

  for( i = m-1 ; i >= 0 ; i-- ){
    insertionSort(A,n,G[i]);
  }

  for( i = m-1 ; i >= 0 ; i-- ){
    if( n >= G[i] ){
      count++;
    }
  }

  m = count;

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

  for( i = m-1 ; i >= 0 ; i-- ){
    if( n >= G[i] ){
      printf("%d",G[i]);
      if( i ){
        printf(" ");
      }
    }
  }

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

}

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

int main(){
  int n;
  cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  
  long long res1=0, res2=0, sum=0;
  
  for(int i=0;i<n;i++){
    sum+=a[i];
    if(i%2==0 && sum>=0){//奇数番目までの和を負に
      res1+= sum+1;
      sum=-1;
    }
    if(i%2==1 && sum<=0){//偶数番目までの和を正に
      res1+= 1-sum;
      sum=1;
    }
  }
  
  sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
    if(i%2==0 && sum<=0){//奇数番目までの和を正に
      res2+= 1-sum;
      sum=1;
    }
    if(i%2==1 && sum>=0){//偶数番目までの和を負に
      res2+= sum+1;
      sum=-1;
    }
  }
  
  cout<<min(res1, res2)<<endl;
  return 0;
}

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

int main()
{

  int N;
  int even_count = 0, odd_count = 0;
  cin >> N;
  long long a[N];

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

    cin >> a[i];
    if (a[i] % 2 == 0)
    {
      //even_count++;
    }
    else
    {
      odd_count++;
    }
    if (odd_count != 0)
    {
      break;
    }
  }
  if (odd_count != 0)
  {
    cout << "first" << endl;
  }
  else
  {
    cout << "second" << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    vector<int> v(5);
    rep(i,5) cin>>v[i];
    sort(v.begin(),v.end());
    int ans = inf;
    do{
        int now = 0;
        for(int i = 0;i<5;i++){
            now += v[i];
            if(i==4) break;
            while(now%10!=0){
                now++;
            }
        }
        ans = min(ans,now);
    }while(next_permutation(v.begin(),v.end()));
    cout<< ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int N,Y;
int x[9];
int a[3] = { 0 }, b[3] = {0};
bool flag = false;
int main(void) {
	FOR(i, 0, 9){
		cin >> x[i];
	}
	FOR(i, 0, 101)FOR(k,0,101) {
		int cnt = 0;
		a[0] = i; b[0] = k;
		a[1] = a[0] + x[3] - x[0];
		a[2] = a[0] + x[6] - x[0];
		b[1] = b[0] + x[1] - x[0];
		b[2] = b[0] + x[2] - x[0];
		if (x[4] == a[1] + b[1])cnt++;
		if (x[5] == a[1] + b[2])cnt++;
		if (x[7] == a[2] + b[1])cnt++;
		if (x[8] == a[2] + b[2])cnt++;
		if (cnt == 4)flag = true;
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W;
int main() {
	ios::sync_with_stdio(false);
	cin >> W >> H;
	vector<int> p(W), q(H); vector<pair<int, int> > r;
	for (int i = 0; i < W; i++) cin >> p[i], r.push_back(make_pair(p[i], 0));
	for (int i = 0; i < H; i++) cin >> q[i], r.push_back(make_pair(q[i], 1));
	long long ret = 0;
	sort(r.begin(), r.end());
	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < W + H; i++) {
		if (r[i].second == 0) cnt0++, ret += 1LL * (H - cnt1 + 1) * r[i].first;
		else cnt1++, ret += 1LL * (W - cnt0 + 1) * r[i].first;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
ll n, a, b, s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ll mi = linf;
  FOR(i, 0, n){
    cin >> a >> b;
    s += a;
    if(a > b) mins(mi, b);
  }
  cout << max(0ll, s-mi) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{

ll k;
cin>>k;
bool hbe=false;

ll cnt=0,ans=7;
for(ll i=0;i<=k;i++)
{
    cnt++;
 if(ans%k==0)
 {
     cout<<cnt<<endl;
    
     hbe=true;
      break;
 }
 ans=(ans*10+7)%k;
}
if(!hbe)
cout<<-1<<endl;


}



   
      
    
        



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    set<pair<int, int>> es;
    for (int i = 0; i < 3; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        es.insert({min(a, b), max(a, b)});
    }

    vi hoge = {0, 1, 2, 3};
    do {
        int ok = 1;
        for (int i = 0; i < 3; i++) {
            int a = hoge[i], b = hoge[i + 1];
            if (es.count({min(a, b), max(a, b)}) == 0) ok = 0;
        }
        if (ok) {
            cout << "YES" << endl;
            return 0;
        }
    } while (next_permutation(hoge.begin(), hoge.end()));
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;

int main(){
    ll a,b,q;cin >> a >> b >> q;
    vector<ll> s(a),t(b),x(q);
    for(int i=0;i<a;i++){
        cin >> s[i];
    }
    s.push_back((ll)-1e12);
    s.push_back((ll)1e12);
    sort(s.begin(),s.end());
    for(int i=0;i<b;i++){
        cin >> t[i];
    }
    t.push_back((ll)-1e12);
    t.push_back((ll)1e12);
    sort(t.begin(),t.end());
    for(int i=0;i<q;i++){
        cin >> x[i];
    }
    for(int i=0;i<q;i++){
        ll tmps1,tmps2,tmpt1,tmpt2;
        if(upper_bound(s.begin(),s.end(),x[i])-lower_bound(s.begin(),s.end(),x[i])>0){
            tmps1 = 0;
            tmps2 = 0;
        }
        else{
            tmps1 = abs(s[upper_bound(s.begin(),s.end(),x[i])-s.begin()-1]-x[i]);
            tmps2 = abs(s[upper_bound(s.begin(),s.end(),x[i])-s.begin()]-x[i]);
            
        }

        if(upper_bound(t.begin(),t.end(),x[i])-lower_bound(t.begin(),t.end(),x[i])>0){
            tmpt1 = 0;
            tmpt2 = 0;
        }
        else{
            tmpt1 = abs(t[upper_bound(t.begin(),t.end(),x[i])-t.begin()-1]-x[i]);
            tmpt2 = abs(t[upper_bound(t.begin(),t.end(),x[i])-t.begin()]-x[i]);
        }
        ll ans = min(max(tmps1,tmpt1),
        min(max(tmps2,tmpt2),
        min(2*min(tmps1,tmpt2)+max(tmps1,tmpt2),
        2*min(tmps2,tmpt1)+max(tmps2,tmpt1))));
        //cout << tmps1<< " " << tmps2 << " " << tmpt1 << " " << tmpt2 << " ";
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=2e5;
int dp[N],a[101];
signed main()
{
    
    CHAL_BAAP_KO_MT_SIKHA
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            if(i>=a[j])
            dp[i]|=(!dp[i-a[j]]);
        }
    }
    if(dp[k]){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
typedef struct {
    ll to;
    ll cap;
    ll rev;
} edge;
vector<edge> G[210];
bool used[210];

ll dfs(ll v, ll t, ll f){
    if(v == t) return f;
    used[v] = true;
    rep(i,0,G[v].size()){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            ll d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X,Y,E;
    cin >> X >> Y >> E;
    ll x[10010], y[10010];
    rep(i,0,E){
        cin >> x[i] >> y[i];
        x[i]++; y[i] += X+1;
        G[x[i]].push_back((edge){y[i], 1, G[y[i]].size()});
        G[y[i]].push_back((edge){x[i], 0, G[x[i]].size()-1});
    }
    rep(i,1,X+1){
        G[0].push_back((edge){i, 1, G[i].size()});
        G[i].push_back((edge){0, 0, G[0].size()-1});        
    }
    rep(i,X+1,X+Y+1){
        G[i].push_back((edge){X+Y+1, 1, G[X+Y+1].size()});
        G[X+Y+1].push_back((edge){i, 0, G[i].size()-1});
    }

    ll ans = 0;
    while(1){
        memset(used, 0, sizeof(used));
        ll f = dfs(0, X+Y+1, INF);
        if(f == 0) break;
        ans += f;
    }
    print(ans);
    
}


Measured memory_bytes: 3596
import numpy as np

n = int(input())
a = int(round(np.sqrt(n)))
b = int(a-1)
c = int(a+1)

if c**2 < n+1:
    print(c**2)
elif a**2 < n+1:
    print(a**2)
elif b**2 < n+1:
    print(b**2)


Measured memory_bytes: 12420