akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,fma")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 1<<20, mod = 119<<23|1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void add(int &a, int  b) {
	a = a+b>=mod?a+b-mod:a+b;
}
int n, dp[maxn], rn[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k;
	cin >> n >> k;
	vector<array<int, 2>> a(k);
	for(auto &i : a) cin >> i[0] >> i[1];
	dp[0] = 1;
	int r = 0;
	for(int i = 0; i <= n; i++) {
		add(r, rn[i]);
		dp[i] = r+(i==0);
		for(auto [l, r] : a)
			add(rn[i+l], dp[i]), add(rn[i+r+1], mod-dp[i]);
	}
	cout << dp[n-1] << '\n';
}


Measured memory_bytes: 5964
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{int A, B, C,D, count;
 cin >> A >> B >> C;
 D = max(A, max(B, C));
 if((A+B+C)%2 == D%2){
   count = (3*D - (A + B + C))/2 ;}
 else{
   count = ((3*(D+1)) - (A + B + C))/2 ;}
 cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

void solve() {
  int n, d;
  cin >> n >> d;
  int ret = 0;
  int x = 1;
  while(x <= n) {
    ret++;
    x += 2*d+1;
  }
  cout << ret << endl;
}


void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 256
n = int(input())
w = [input() for i in range(n)]
ans = 'Yes'
if len(w)!= len(set(w)):
    ans = 'No'
else:
    for i in range(1,n):
        if w[i][0]!=w[i-1][-1]:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
  int n; cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  vector<int> a(n);
  for(int i = 0; i < n; i++) a[i] = i + 1;
  
  for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
      swap(p[i], p[j]);
      if(a == p){
        cout << "YES" << endl;
        return 0;
      }
      swap(p[i], p[j]);
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a[10000], min, max, n, i;
	long long sum = 0;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	max = min = a[0];
	for(i = 1; i < n; i++){
		if(a[i] > max){
		max = a[i];
		}
		if(a[i] < min){
			min = a[i];
			}
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 636
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n, x[101];
  ll ans=INF;
  std::cin >> n;
  REP(i,n) std::cin >> x[i];
  FOR(i,1,101) {
    int cost = 0;
    REP(j,n) {
      cost += pow((x[j]-i),2);
    }
    if (cost < ans) ans = cost;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		int n = stdIn.getValue();
		List<Integer> r = stdIn.getValueLines(n);

		int maxv = r.get(1) - r.get(0);
		;
		int minv = r.get(0);

		//		System.out.println(n);
		//		System.out.println(r);

		for (int i = 0; i < n-1; i++) {
			if (maxv < r.get(i + 1) - minv) {
				maxv = r.get(i + 1) - minv;
			}
			if (minv > r.get(i + 1)) {
				minv = r.get(i + 1);
			}
//			System.out.println("j[" + (i + 1) + "]:" + r.get(i + 1) + " i[" + i + "]:" + r.get(i) + " maxv: " + maxv
//					+ "minv:" + minv);
		}
		System.out.println(maxv);

		stdIn.close();
	}
}
class Input {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getValueLines(int n) {
		List<Integer> values = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			values.add(getValue());
		}
		return values;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 48328
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] p = new int[n];
    for(int i=0; i<n; i++){
      p[i] = sc.nextInt();
    }
    
    int cnt = 0;
    for(int i=1; i<n-1; i++){
      if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])){
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 23892
s = list(input())
k = int(input())
n = len(s)
al=[chr(ord('a') + i) for i in range(26)]

for i in range(n):
    now = ord(s[i]) - ord('a')
    if now != 0:
        if k >= 26 - now:
            s[i] = "a"
            k -= 26 - now
        
s[n-1] = al[(ord(s[n-1])-ord("a") + k) % 26]

for i in s:
    print(i,end="")

Measured memory_bytes: 5436
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
// #define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
 }
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
vector<mint> fac(MX);
vector<mint> ifac(MX);
mint comp(ll a, ll b) {
    return fac[a]/fac[b]/fac[a-b];
}
signed main() {
    int n;
    cin >>n;
    vector<int> a(n);
    mint sum = 0;
    rep(i,n) cin >> a[i];
    rep(i,n) {
        sum += a[i];
    }
    mint ans = 0;
    rep(i,n) {
        mint tmp = sum - a[i];
        tmp *=a[i];
        ans += tmp;
    }
    
    cout << ans/2 << endl;
    

    return 0;
}



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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

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

  string x;
  cin >> x;

  int n = x.size();

  set<int> rl;

  for(int i = 0; i < n - 1; i++) {
    if(x[i] == 'R' && x[i + 1] == 'L')
        rl.insert(-i);
  }

  set<int> rl2;
  for(int i = 0; i < n-1; i++) {
    if(x[i] == 'R' && x[i + 1] == 'L')
        rl2.insert(i);
  }

  vector<int> ans(n);

  for(int i = 0; i < n; i++) {
    char c = x[i];
    if(c == 'L') {
        auto it = rl.lower_bound(-i);
        if((i - (-*it)) % 2 == 0) {
            ans[(-*it)]++;
        } else 
            ans[(-*it + 1)]++;
    } else {
        auto it = rl2.lower_bound(i);
        if((*it - i) % 2 == 0) {
            ans[*it]++;
        } else {
            ans[*it + 1]++;
        }
    }
  }

  for(int y: ans) {
    cout << y << ' ';
  }
  cout << endl;

}

Measured memory_bytes: 5968
#include <stdio.h>

int main(){
	long long int X,Y,num,count=1;
	scanf("%lld%lld",&X,&Y);
	num=X;
	while(1){
		num = num*2;
		if(num>Y)break;
		count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<algorithm>
#include<string>

using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)
#define scan(a) scanf("%d",&a)
#define scanll(a) scanf("%lld",&a)
#define print(a) printf("%d\n",a)
#define printll(a) printf("%lld\n",a)
#define stll(a) stoll(a,nullptr,10)
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)

typedef long long ll;
typedef unsigned long long ull;

vector<ll>ar[200050];
ll cost[200050];
int visit[200050];
//ll par[200000];

void dfs(ll s)
{
    visit[s]=1;
    //cost[s]+=cost[par[s]];
    for(int i=0;i<ar[s].size();i++)
        if(visit[ar[s][i]]==0)
        {
            cost[ar[s][i]] +=cost[s];
            dfs(ar[s][i]);
        }

}


int main()
{
    ll n,q,a,b;
    cin>>n>>q;
    //par[1]=0;
    for(int i=1;i<n;i++)
    {
        cin>>a>>b;
        ar[a].push_back(b);
        //par[b]=a;
    }
    for(int i=1;i<=q;i++)
    {
        cin>>a>>b;
        cost[a]+=b;
    }
    dfs(1);
    cout<<cost[1];
    for(int i=2;i<=n;i++)
        cout<<" "<<cost[i];
    cout<<endl;



}







Measured memory_bytes: 25088
fn main() {
    let mut x = read::<usize>();
    let x500 = x / 500;
    x = x % 500;
    let x5 = x / 5;
    println!("{}", x500 * 1000 + x5 * 5);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Control.Monad.State

main :: IO ()
main = do
  n <- getl toInt
  es <- lines <$> getContents
  mapM_ print . take n . solve $ es

solve :: [String] -> [Int]
solve es = evalState (bbsim es) ([],0,0,0,0,0)

bbsim :: [String] -> State ([Int],Int,Int,Int,Int,Int) [Int]
bbsim [] = do
  (ps,_,_,_,_,_) <- get
  return . reverse $ ps

bbsim (s:ss)
  | s == "HIT" = do
      (ps,p,o,fb,sb,tb) <- get
      put (ps,p + tb,o,1,fb,sb)
      bbsim ss
  | s == "HOMERUN" = do
      (ps,p,o,fb,sb,tb) <- get
      put (ps,p + tb + sb + fb + 1,o,0,0,0)
      bbsim ss
  | s == "OUT" = do
      (ps,p,o,fb,sb,tb) <- get
      if o == 2 then put (p:ps,0,0,0,0,0)
        else put (ps,p,o+1,fb,sb,tb)
      bbsim ss

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

int main() {
    string s;
    cin >> s;
    int ans = 1000;
    for (int i = 0; i < s.size() - 2; i++) {
        int num = stoi(s.substr(i, 3));
        int diff = abs(753 - num);
        ans = min(diff, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let mut a = read_as_vec::<usize>();

    let mut v: Vec<i64> = vec![0;n+1];
    for elem in &a{
        v[*elem] += 1;
    }

    let mut default_ans = 0;
    for i in 0..n+1{
        default_ans += v[i]*(v[i]-1)/2;
    }

    for removed_n in &a{
        println!("{}", cmp::min(
            default_ans - (v[*removed_n] -1),
                 default_ans
        ));
    }

}


Measured memory_bytes: 11248
import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;
import java.util.Scanner;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        
        String[] card = {"S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13"
                        ,"H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13"
                        ,"C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13"
                        ,"D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"};
        List<String> list = new ArrayList<String>(Arrays.asList(card));

        for(int i = 0; i<n;i++){
            String s = sc.nextLine();
            list.remove(s);
        }
        for(int i = 0; i<list.size();i++){
            System.out.println(list.get(i));
        }
        sc.close();

    }
}




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

using ll=long long; 

void solve(){
	int n,m;
	cin>>n>>m;
	int a[100];
	memset(a, 0, sizeof a);
	int x,y;
	for(int i=0; i<m; i++){
		cin>>x>>y;
		a[x]++;
		a[y]++;
	}
	for(int i=1; i<=n; i++){
		cout<<a[i]<<endl;
	}
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;

int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    
    int ans=1;
    for(int i=0; i<k; i++){
        if(s[i]!='1'){
            ans=s[i]-'0';
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

template< class Abel > class BIT {
public:
  BIT(int _n) : N(_n) { init(); }

  void init() {
    // [1, N]の範囲なので、+1する必要がある
    bit.clear();
    bit.resize(N + 1, 0);
  }

  void add(int i, Abel x) {
    while (i <= N) {
      bit[i] += x;
      i += i & -i;
    }
  }

  Abel sum(int i) {
    Abel sm = 0;
    while (i > 0) {
      sm += bit[i];
      i -= i & -i;
    }
    return sm;
  }

  Abel getSum(int _x, int _y) {
    return sum(_y) - sum(_x - 1);
  }

private:
  int N;
  vector< Abel > bit;
};



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

  CIN(N, M, Q);
  vector< BIT< int > > bit(N + 1, BIT< int >(N + 1));

  REP(i, M) {
    CIN(L, R);
    REP(j, L + 1) {
      bit[j].add(R, 1);
    }
  }

  REP(qi, Q) {
    CIN(p, q);
    cout << bit[p].sum(q) << endl;
  }
  
  return 0;
}



Measured memory_bytes: 1920
// ABC071
// A - Meal Delivery
#include<bits/stdc++.h>

using namespace std;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a) > abs(x-b)) cout << "B" << endl;
    else cout << "A" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int,input().split())) for _ in range(2)]

ans = 0
for i in range(n):
    tmp = 0
    for j in range(i+1):
        tmp += a[0][j]
    for j in range(i,n):
        tmp += a[1][j]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<list>
#include<vector>
using namespace std;

int main(){
    list<int> li;
    int n;  cin >> n;

    for(int i=0;i<n;i++){
        char c[20];
        cin >> c;

        if(c[0]=='i'){
            int x;  cin >> x;
            li.push_front(x);
        }else if(c[6]=='F'){
            li.pop_front();
        }else if(c[6]=='L'){
            li.pop_back();
        }else{
            int x;  cin >> x;
            for(list<int>::iterator it=li.begin();it!=li.end();it++){
                if(*it==x){
                    li.erase(it);
                    break;
                }
            }
        }
    }

    vector<int> ans;

    for(list<int>::iterator it=li.begin();it!=li.end();it++){
        ans.push_back(*it);
    }

    for(int i=0;i<ans.size();i++){
        cout << ans[i];
        if(i==ans.size()-1){
            cout << endl;
        }else{
            cout << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 33976
#include<stdio.h>
#define abs(a) (((a)<0)?-(a):(a))

int main(int argc, char const *argv[]){
	int n,m,i,id,j;
	long a[50],b[50],c[50],d[50],min;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%ld %ld",&a[i],&b[i]);
	}
	for(i=0;i<m;i++){
		scanf("%ld %ld",&c[i],&d[i]);
	}
	for(i=0;i<n;i++){
		min=abs(a[i]-c[0])+abs(b[i]-d[0]);
		id=0;
		for(j=1;j<m;j++){
			if(min>(abs(a[i]-c[j])+abs(b[i]-d[j]))){
				id=j;
				min=abs(a[i]-c[j])+abs(b[i]-d[j]);
			}
		}
		printf("%d\n",id+1);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
    int n,x;
    map<int,int>mp;
    vector<int>v;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>x;
        v.pb(x);
        mp[x]++;
    }
    int cnt=0;
    for(int i=0; i<v.size(); i++)
    {
        x=v[i];
        if(mp[x]>1)
            continue;
        if(x==1)
            cnt++;
        else
        {
            int ok=0;
            for(int i=1; i<=sqrt(x); i++)
            {

                if(x%i==0)
                {
                    if(mp[i]!=0)
                    {
                        ok=1;
                        break;
                    }
                    else if(mp[x/i]!=0&&i!=1)
                    {
                        ok=1;
                         break;
                    }
                }
            }
            if(ok==0)
                cnt++;
        }


    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 32936
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int X,t,s;
	cin >> X >> t;
	if(X-t<=0){
		printf("0");
	}else{
		s=X-t;
		cout<<s;	
	}
	
	
	
	
	return 0;
 } 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int x;
	cin >> x;
	cout << x * x * x << endl;
	return 0;
}

Measured memory_bytes: 3088
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7


N, M = MAP()
A = LIST()
if sum(A)>N:
    print(-1)
else:
    print(N-sum(A))

Measured memory_bytes: 72988
using System;
using System.Collections.Generic;
using System.Linq;

namespace DPL2_B
{
    class Program
    {
        const int INF = 1 << 30;
        const int MAX = 15;
        //???????????°
        static int n;
        //??¨??????????????????
        static int[,] d = new int[MAX,MAX];
        //??????????¬???°
        static int[] deg = new int[MAX];
        //?????????
        static int weight;
        //?\??????????????????????
        static List<int> odds = new List<int>();

        static void floyd()
        {
            var a = scan;
            n = a[0];
            int e = a[1];
            for (int i = 0; i < n; i++)            
                for (int j = 0; j < n; j++)           
                    d[i, j] = i == j ? 0 : INF;
                         
            for (int i = 0; i < e; i++)
            {
                var f = scan;
                weight += f[2];
                deg[f[0]]++;
                deg[f[1]]++;
                if (f[2] < d[f[0],f[1]])
                {
                    d[f[0], f[1]] = f[2];
                    d[f[1], f[0]] = f[2];
                }
            }
            for (int k = 0; k < n; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    if (d[i, k] == INF) continue;
                    for (int j = 0; j < n; j++)
                    {
                        if (d[k, j] == INF) continue;
                        d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
                    }
                }
            }
            for (int i = 0; i < n; i++) if ((deg[i] & 1) == 1) odds.Add(i);    
        }
        static void Main(string[] args)
        {
            floyd();
            int cnt = odds.Count;
            int N = 1 << cnt;
            var dp = Enumerable.Repeat(INF, N).ToArray();
            dp[0] = 0;

            //???????????????S???1????????????
            for (int S = 0; S < N; S++)
            {
                for (int i = 0; i < cnt; i++)
                {
                    if ((S & 1 << i) != 0) continue;
                    for (int j = i+1; j < cnt; j++)
                    {
                        if ((S & 1 << j) != 0) continue;
                        dp[S | 1 << i | 1 << j] = Math.Min(dp[S | 1 << i | 1 << j], dp[S] + d[odds[i], odds[j]]);                     
                    }
                }
            }
            Console.WriteLine(weight + dp[N - 1]);
        }

        static int[] scan
        {
            get { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
        }
    }
}

Measured memory_bytes: 9816
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int n , k;
ll dp[100005][3];
ll a[100005] , b[100005] , c[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i=1;i<=n;i++)cin >> a[i] >> b[i] >> c[i];
    for (int i=1;i<=n;i++)
    {
        dp[i][0] = max(dp[i-1][1] + a[i] , dp[i - 1][2] + a[i]);
        dp[i][1] = max(dp[i-1][0] + b[i] , dp[i - 1][2] + b[i]);
        dp[i][2] = max(dp[i-1][1] + c[i] , dp[i - 1][0] + c[i]);
    }
    cout << max(dp[n][0] , max(dp[n][1] , dp[n][2])) << endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
 
int main() {
    string s;
    cin >> s;
    ll n[26] = {};
    for(int i=0;i<s.size();i++) {
        n[s[i]-'a']++;
    }
 
    vector<ll> v;
    for(int i=0;i<26;i++) {
        if(n[i] != 0)
            v.push_back(n[i]);
    }
    ll ans = 0;
    if(v.size() <= 1) {
        ans = 1;
    } else {
        for(int i=0;i<v.size()-1;i++) {
            for(int j=i+1;j<v.size();j++) {
                ans += v[i] * v[j];
            }
        }
        ans++;
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

typedef pair<int,int> P;
const int MAX_N = 112345;
P p[MAX_N];


int main2() {
  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int a = nextInt();
    int b = nextInt();
    p[i] = {a, b};
  }
  sort(p, p+M, [](const P& a, const P& b) -> bool {
    if (a.second != b.second) return a.second < b.second;
    if (a.first != b.first) return a.first < b.first;
    return false;
  });
  int ans = 0;
  int prev = -1;
  REP(i, M) {
    const int a = p[i].first;
    const int b = p[i].second;
    if (prev >= a) {
    } else {
      ans++;
      prev = b-1;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=1e5+7;
vi G[maxn];
int dp[maxn];
int len;
void dfs(int u,int fa=-1)
{
    dp[u]=1;
    for(auto v:G[u])if(v!=fa)
    {
        dfs(v,u);
        dp[u]=max(dp[u],dp[v]+1);
    }
}
void dfs2(int u,int fa=-1)
{
    multiset<int> son;
    for(auto v:G[u])
        son.insert(dp[v]);
    if(son.size()>2)
    {
        //dbg(u,son);
        auto it=son.rbegin();
        vi all;
        for(int i=0;i<3;i++)
        {
            all.push_back(*it);
            it++;
        }
        if(all[0]!=all[2])
            len=max(len,all[0]+all[2]+1);
        else len=max(len,all[0]+all[2]);
    }
    for(auto v:G[u])if(v!=fa)
    {
        son.erase(son.find(dp[v]));
        int tmp=dp[u];
        if(son.empty()) dp[u]=1;
        else dp[u]=(*son.rbegin())+1;
        int tmpv=dp[v];
        dp[v]=max(dp[v],dp[u]+1);
        dfs2(v,u);
        dp[u]=tmp;
        dp[v]=tmpv;
        son.insert(dp[v]);
    }
}
int main()
{
    int n;
    cin>>n;
    len=2;
    string ans;
    for(int i=0;i<n;i++) ans+='1';
    bool ac=1;
    for(int i=1,u,v;i<n;i++)
    {
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1);
    dfs2(1);
    for(int i=2;i<len-1;i++) ans[i]='0';
    cout<<ans<<'\n';
}


Measured memory_bytes: 30672
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;

string s;
int N;



int main(){
  cin >> N;
  int A[N],B[N-1];
  rep(i, N) {
    A[i] = 0;
  }
  rep(i, N-1) {
    cin >> B[i];
  }
  A[0] = B[0];
  REP(i, 1, N-1) {
    if ( B[i-1] < B[i] ) {
      A[i] = B[i-1];
    } else {
      A[i] = B[i];
    }
  }
  A[N-1] = B[N-2];
  int ans = 0;
  rep(i,N) {
    ans += A[i];
  }
  cout << ans << endl;
}


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

char w[105];

int a[30];

int main() {

	int i;

	scanf("%s",w);

	for (i = 0; i < strlen(w); i++) {
		a[w[i] - 'a']++;
	}
	for (i = 0; i < 26; i++) {
		if (a[i] % 2 == 1) {
			printf("No\n");
			break;
		}
	}
	if (i == 26) {
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	int N;
	cin >> N;
	string A, B, C;
	cin >> A >> B >> C;

	int ans = 0;

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

		char a = A[i];
		char b = B[i];
		char c = C[i];

		if (a == b && b != c)
		{
			ans++;
		}
		else if (a != b && b == c)
		{
			ans++;
		}
		else if (a == c && a != b)
		{
			ans++;
		}
		else if (a != b && b != c && c != a)
		{
			ans += 2;
		}

	}

	cout << ans << endl;


}





Measured memory_bytes: 256
import itertools
import numpy as np

n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(n)]
ans = -1
for bool_list in range(2 ** n):
    bool_list = bin(bool_list)[2:].zfill(n)
    cost = 0
    exp = np.array([0] * m)
    for i, b in enumerate(books):
        if bool_list[i] == '1': continue
        cost += b[0]
        tmp = np.array(b[1:])
        exp = exp + tmp
    for y in exp:
        if y < x: break
    else:
        if ans == -1:
            ans = cost
        else:
            ans = min(cost, ans)
print(ans)

Measured memory_bytes: 27232
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
const int mod=1e9+7;

ll a[N],b[N];

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m,k,x,ans=0;
    cin>>n>>m>>k;
    ll sum=0;
    for(int i=1;i<=n;i++){
    	cin>>x;
    	sum+=x;
    	a[i]=sum;
    }
    sum=0;
    for(int i=1;i<=m;i++){
    	cin>>x;
    	sum+=x;
    	b[i]=sum;
    }
    ans=0;
    for(int i=0;i<=n;i++){
    	ll c=k;
    	if(a[i]>c)continue;
    	c-=a[i];
    	ll l=0,r=m,ok;
    	while(l<=r){
    		int mid=(l+r)/2;
    		if(b[mid]<=c){
    			ok=mid;
    			l=mid+1;
    		}
    		else {
    			r=mid-1;
    		}
    	}
    	ans=max(ans,i+ok);
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 6776
X=int(input())
def divisors(n):
	a=[]
	for i in range(1,int(n**(1/2))+1):
		if n%i==0:
			if n==i**2:
				a.append(i)
			else:
				a.append(i)
				a.append(n//i)
	return a
ans=0
while X>0:
	if len(divisors(X))==2:
		ans=X
		break
	X+=1
print(ans)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<Integer> pList;

	static final long DIVIDE_NUMBER = 1000000007;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();
		int n = scan.nextInt();

		pList = new ArrayList<Integer>();

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

			pList.add(scan.nextInt());
		}

		int answer = check(x);

		println(answer);
	}

	public static int check(int x) {

		if (!pList.contains(x)) {
			return x;
		}

		int upper = x + 1;
		int lower = x - 1;

		while (true) {

			if (!pList.contains(lower)) {
				return lower;
			}

			if (!pList.contains(upper)) {
				return upper;
			}

			upper++;
			lower--;
		}
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    string s;
    cin >> s;
    if(s.back()=='s') s+="es";
    else s.push_back('s');

    cout << s;
}

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

int main(){
	int n;
	double x[4],y[4];
	cin>>n;
	for(;n--;){
		for(int i=0;i<4;i++){
			cin>>x[i];
			cin>>y[i];
		}
		if((x[0]-x[1])*(y[2]-y[3])==(x[2]-x[3])*(y[0]-y[1])){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}
  

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
using namespace std;
   
int main(){
 int n;
 vector<int> x(10010);
 int i;
 for(i=0;i<10010;i++){
  cin >> x.at(i);
 }
 for(int j=0;x.at(j)!=0;j++){
  cout << "Case " << j+1 << ": " << x.at(j)  << endl;
 }
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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 int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int ans = 0;
	int N,D; cin >> N >> D;

	while(N>0)
	{
		N -= 2*D + 1;
		ans ++;
	}
	cout << ans << endl;
}


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

int main() {
    int n,k;
    int count=0;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec.at(i);
    }
    for(int j=0;j<n;j++){
        if(vec.at(j)>= k){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main() {
    int h,w;
    cin >> h >> w;
    int cost[10][10];
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> cost[i][j];
        }
    }
    for(int k = 0; k < 10; k++) {
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
            }
        }
    }
    int a[h][w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    int sum = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] == -1) continue;
            sum += cost[a[i][j]][1];
        }
    }
    cout << sum << endl;


}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int x_dis = x2-x1;
		int y_dis = y2-y1;
		int y3 = y2+x_dis;
		int x3 = x2-y_dis;
		int y4 = y1+x_dis;
		int x4 = x1-y_dis;
		System.out.println(x3+" "+y3+" "+x4+" "+y4);
	}
}

Measured memory_bytes: 22100
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7


def conv(n,a,b):
    return a*(2*n-a-1)//2+b-a-1

def main(): 
    N = II()
    # A = [[] for _ in range(N)]
    # for i in range(N):
    #     A[i] = LI()

    # print(A)
    # return

    from collections import defaultdict
    outs = defaultdict(list)
    ins = defaultdict(int)
    for i in range(N):
        # prev_v = (i+1, A[i][0]) if i+1 < A[i][0] else (A[i][0], i+1)
        a = LI()
        for j in range(1,N-1):
            # prev_v = (i+1, A[i][j-1]) if i+1 < A[i][j-1] else (A[i][j-1], i+1)
            # next_v = (i+1, A[i][j]) if (i+1 < A[i][j]) else (A[i][j] , i+1)
            # prev_v = conv(N, prev_v[0], prev_v[1])
            # next_v = conv(N, next_v[0], next_v[1])
            prev_v = (min(i+1, a[j-1]), max(i+1, a[j-1]))
            next_v = (min(i+1, a[j]), max(i+1, a[j]))
            prev_v = conv(N, prev_v[0]-1, prev_v[1]-1)
            next_v = conv(N, next_v[0]-1, next_v[1]-1)
            outs[prev_v].append(next_v)
            ins[next_v] += 1

    # print(outs, ins)
    # return

    from collections import deque
    q = deque()
    for i in range(1, N+1):
        for j in range(1, N+1):
        # j = A[i-1][0]
            if i < j and ins[conv(N, i-1, j-1)] == 0:
                q.append([conv(N, i-1, j-1), 0])

    if not q:
        print(-1)
        return

    # q = deque(v1 for v1 in range(1, N+1) if ins[v1] == 0)
    res = []
    depth_max = 0
    while q:
        v1, depth = q.popleft()
        res.append(v1)
        for v2 in outs[v1]:
            ins[v2] -= 1
            if ins[v2] == 0:
                q.append([v2, depth+1])
                depth_max = max(depth_max, depth+1)
    if len(res)!=N*(N-1)//2:
        print(-1)
        return
    else:
        print(depth_max+1)
        return


main()

Measured memory_bytes: 177380
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n, r;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
int n;
int A[maxn];
vector<int> pos[maxn];
ll k;
int has[maxn];
vector<int> tmp;
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&A[i]);
		pos[A[i]].emplace_back(i);
	}
	int cur=1,p;
	while(true)
	{
		p=lower_bound(pos[A[cur]].begin(),pos[A[cur]].end(),cur)-pos[A[cur]].begin();
		p++;
		if(p>=pos[A[cur]].size())
		{
			tmp.emplace_back(cur);
	//		cout<<cur<<endl;
			p-=pos[A[cur]].size();
			cur=pos[A[cur]][p]+1;
		}
		else
		{
			cur=pos[A[cur]][p]+1;
		}
		if(cur==n+1)break;
	}
	int m=tmp.size();
	k=k%(1ll*(m+1))-1;
	if(k<0)return 0;
	p=tmp[k];
	tmp.clear();
//	cout<<k<<" "<<p<<endl;
	for(int i=p;i<=n;i++)
	{
		if(!has[A[i]])tmp.emplace_back(A[i]),has[A[i]]++;
		else
		{
			while(has[A[i]])
			{
				has[tmp.back()]--;
				tmp.pop_back();
			}
		}
	}
	for(int i=0;i<tmp.size();i++)
		printf("%d ",tmp[i]);
}

Measured memory_bytes: 14968
n = int(input())
B = list(map(int, input().split()))
A = []
C = []
flag = True
j = 0
if max(B) > n:
  flag = False
if flag:
  while j < n:
    A = []
    for i in range(n-j):
      if B[i] == i+1:
        A.append(i+1)
    if A ==[]:
      flag = False
      break
    else:
      C.append(B[max(A)-1])
      del B[max(A)-1]
      j += 1
if flag:
  for k in range(1, n+1):
    print(C[-k])
else:
  print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<int> h(n);
	for (int i = 0; i < n; i++){
		cin>>h[i];
	}
	int now = h[n-1];
	for (int i = n-2; i >= 0; i--){
		if(h[i]>h[i+1]+1){
			cout<<"No"<<endl;
			return 0;
		}else if(h[i] == h[i+1]+1){
			h[i]--;
		}
		now = h[i];
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
   map<string,int> m;
   int n;
   cin>>n;
   int maxc=0;
   string s;
   int cnt=0;
   rep(i,n){
      cin>>s;
      if(m.count(s)==0){
         m[s]=1;
         if(cnt==0)cnt=1;
      }
      else
      {
         m[s]++;
//         cout<<s<<" "<<m[s]<<" "<<cnt<<endl;
         cnt=max(cnt,m[s]);
//         cout<<s<<" "<<m[s]<<" "<<cnt<<endl;
      }      
   }
//   cout<<cnt<<endl;
   for(auto itr=m.begin();itr!=m.end();itr++){
      if(itr->second==cnt) cout<<itr->first<<endl;
   }
   return 0;
}


Measured memory_bytes: 25216
using System;

namespace ABC087_B
{
    class Program
    {
        static int Solve()
        {
            int coin500 = int.Parse(Console.ReadLine());
            int coin100 = int.Parse(Console.ReadLine());
            int coin50 = int.Parse(Console.ReadLine());
            int coinAll = int.Parse(Console.ReadLine());
            int count = 0;
            for (int i = 0; i <= coin500; i++)
            {
                for (int j = 0; j <= coin100; j++)
                {
                    for (int k = 0; k <= coin50; k++)
                    {
                        if (coinAll == (500*i)+(100*j)+(50*k))
                        {
                            count++;
                        }
                    }
                }
            }

            return count;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Solve());
        }
    }
}


Measured memory_bytes: 11092