akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

void solve() {
    int n, m;
    std::cin >> n >> m;

    Graph<> graph(n * 2);
    while (m--) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;

        graph[u].emplace_back(u, v + n);
        graph[v].emplace_back(v, u + n);
        graph[u + n].emplace_back(u + n, v);
        graph[v + n].emplace_back(v + n, u);
    }

    std::vector<int> dist(n * 2, -1);
    std::queue<int> que;
    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto e : graph[v]) {
            int u = e.dst;
            if (dist[u] != -1) continue;

            dist[u] = dist[v] + 1;
            que.push(u);
        }
    }

    if (*std::min_element(dist.begin(), dist.end()) == -1) {
        std::cout << -1 << std::endl;
        return;
    }

    int ans = std::min(*std::max_element(dist.begin(), dist.begin() + n),
                       *std::max_element(dist.begin() + n, dist.end()));
    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 17240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    bool ok = false;
    if(s[2]==s[3]&&s[4]==s[5]) ok = true;
    if(ok) Yes();
    else No();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define MAXN (1<<16)
lli val[MAXN];
lli dp[MAXN];
int used[MAXN];
int a[17][17];
int n;

lli solve(int msk){
	if(msk == (1<<n)-1){
		return 0ll;
	}

	if(used[msk]) return dp[msk];
	used[msk] = 1;
	lli ans = -1ll;
	int ini = msk ^ ((1<<n)-1);
	for(int i=ini; i >=1; i--){
		int andi = msk & i;
		if(andi == 0){
			ans = max(ans, solve(msk | i) + val[i]);
		}
	}
	return dp[msk] = ans;
}

int main(){__
	cin >> n;
	for(int i=0; i < n; i++){
		for(int j=0; j < n; j++){
			cin >> a[i][j];
		}
	}

	for(int i=1; i < (1<<n);i++){
		int msk = i;
		lli res = 0ll;
		for(int j =0; j < n; j++){
			if(msk & (1<<j)){
				for(int k =j; k < n; k++){
					if(msk & (1<<k)){
						res+= a[j][k];
					}
				}
			}
		}
		val[i] = res;
	}
	cout << solve(0) << endl;
	return 0;
}


Measured memory_bytes: 1536
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
a, b, c = map(int, input().split())
i = 1
ok = False
while i<b+1:
    if (a*i-c)%b != 0: i+=1
    else:
        ok = True
        break
if ok: print("YES")
else: print("NO")

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

using namespace std;

#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


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

int main()
{
	int n, i, j, l,k;
	int A[101];
	int q[101][101];
	cin >> n;
	for (i = 1; i < n+1; i++) {
		cin >> A[i - 1] >> A[i];
	}
	for (i = 0; i < n + 1; i++) q[i][i] = 0;

	for (l = 2; l < n + 1; l++) {
		for (i = 1; i < n - l + 2; i++) {
			j = i + l - 1;
			q[i][j] = (1<<21);
			for (k = i; k < j; k++) {
				q[i][j] = min(q[i][j], q[i][k] + q[k + 1][j] + A[i - 1] * A[k] * A[j]);
			}
		}
	}
	cout << q[1][n] << endl;

}

Measured memory_bytes: 3132
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define f first
#define s second
#define inf 1000000007

ll A,B,C,D,E,F;

int main() {
    cin >> A >> B >> C >> D >> E >> F;
    double ctl = 0;
    ll ans1;
    ll ans2;
    rep(i,31){
        rep(j,31){
            rep(k,3001){
            ll re = F-(100*A*i+100*B*j+C*k);
            ll resalt = E*(A*i+B*j) -(C*k);
            if (re < 0 || resalt < 0) continue;
            ll b = min(re/D,resalt/D);
            double salt = C*k+D*b;
            double water = 100*A*i+100*B*j;
            double d = salt/(salt+water);
            if (d >= ctl){
                ctl = d;
                ans1 = salt;
                ans2 = water;
            }
            }
    }
    }
    cout << ans1+ans2 << " " << ans1 << endl;
   
    return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<int, int>();
        var d2 = new Dictionary<int, int>();
        Console.ReadLine();
        string[] line = Console.ReadLine().Trim().Split(' ');
        setDict(d, line);
        Console.ReadLine();
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        setDict(d2, line2);
        Console.WriteLine(compDict(d, d2) ? "YES" : "NO");
    }
    public static bool compDict(Dictionary<int, int> d, Dictionary<int, int> d2)
    {
        foreach (var x in d2)
            if (!d.ContainsKey(x.Key)) return false;
            else if (d[x.Key] < x.Value) return false;
        return true;
    }
    public static void setDict(Dictionary<int, int> d, string[] a)
    {
        for (int i = 0; i < a.Length; i++)
        {
            var w = int.Parse(a[i]);
            if (d.ContainsKey(w)) d[w]++;
            else d[w] = 1;
        }
    }
}

Measured memory_bytes: 47928
N = int(input())
h = list(map(int,input().split(" ")))

def rec(H,acc,l,r):
    if r - l == 1:
        return (H[l] - acc) 
    mn = min(H[l:r])
    mx = max(H[l:r])
    if mn == mx:
        return mn - acc
    flg = False
    ans = (mn - acc)
    L = 0
    for i in range(l,r):
        if H[i] != mn:
            if not flg:
                L = i
                flg = True

            if i == r-1:
                ans += rec(H,mn,L,r)
        else:
            if flg:
                ans += rec(H,mn,L,i)
            flg = False
    
    return ans
print(rec(h,0,0,N))

Measured memory_bytes: 38512
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,m = li()

if 2*n >= m:
    print(m//2)
    
else:
    print(n + (m-2*n)//4)

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

int main(){
    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    for(int i=0;i<3;i++) s[i][0]-=32;
    cout<<s[0][0]<<s[1][0]<<s[2][0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
int main () {
    int n, x, t;
    scan3(n, x, t);
    int q = (n%x==0)?n/x:n/x + 1;
    print1(t*q);
}

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

int main(){
    int H,W,i,j;

    while(1){
        cin >> H >> W;
        if(H==0 && W==0)break;

        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                if(i==1 || i==H || j==1 || j==W){
                    cout << '#';
                }else{
                    cout << ".";
                }
            }
            cout << '\n';
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKi solver = new DKi();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKi {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            long value[] = new long[n + 1];
            ArrayList<ArrayList<Integer>> a = new ArrayList<>();
            for (int i = 0; i < n + 1; i++) {
                a.add(new ArrayList<>());
            }
            for (int i = 0; i < n - 1; i++) {
                int x = in.nextInt();
                int y = in.nextInt();
                a.get(x).add(y);
            }
            while (q-- > 0) {
                int p = in.nextInt();
                int x = in.nextInt();
                value[p] += x;
            }
            for (int i = 1; i <= n; i++) {
                for (int t : a.get(i)) {
                    value[t] += value[i];
                }
            }
            for (int i = 1; i <= n; i++) {
                out.print(value[i] + " ");
            }
        }

    }
}



Measured memory_bytes: 195880
#include<stdio.h>

int main(void){
    char x[1003];
    int sum,i;

    while(1){
        scanf("%s",x);
        if(x[0] ==  '0' && x[1] == '\0')
            break;
        sum = 0;i = 0;
        while(x[i] != '\0')
            sum += x[i++] - '0';
        printf("%d\n",sum);
    }
    return 0;
}



Measured memory_bytes: 2044
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x = read::<usize>();
    let a = read::<usize>();
    println!("{}", if x < a { 0 } else { 10 });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
bool myComp(pair<string,int> a, pair<string,int> b){
       return a.first < b.first ||
       ((a.first == b.first) && a.second > b.second);
}

int main() {
   int t; cin >> t;
   map<pair<string, int> , int> m;
   vector<pair<string, int>> ans;
   for(int i =1; i <=t; i++){
      string s; int p;
      cin >> s >> p;
      pair<string,int> k = make_pair(s,p);
      m[k] = i;
      ans.push_back(k);
      
   }
   
   // we need to write a custom comparator,.
   // 1. We need to sort in lexicograohic order.
   // 2. and if city is same , sort in descending order of score.
   // also, we need to push all thse pairs into a vetor.
   sort(ans.begin(), ans.end(), myComp);
   for(auto i:ans){
          cout << m[i] << endl;
   }
   
   
return 0;
}









  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n,k;
    cin>>n>>k;
    int cnt = 0;
    // vector<int> a(n);
    rep(i,0,n)
    {
        int x;
        cin>>x;
        if ( x >= k )
        {
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	double w, h, x, y;
	double pos_x, pos_y;

	cin >> w >> h >> x >> y;

	pos_x = w / 2;
	pos_y = h / 2;

	double tan;

	if (x == 0 || x == w || y == 0 || y == h) {
		cout << fixed << setprecision(9) << h*w/2 << " " << 0 << endl;
	}
	else if (x == pos_x && y == pos_y) {
		cout << fixed << setprecision(9) << h*w/2 << " " << 1 << endl;
	}
	else {
		cout << fixed << setprecision(9) << h*w / 2 << " " << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int a[26];
int main(){
 string s;
 cin >>s;
 for(int i=0;i<s.size();i++) a[s[i]-'0'-49]++;
 for(int i=0;i<26;i++) {
   if(a[i]==0) {
     s+=(i+49+'0');
     cout <<s<<endl;
     return 0;
   }
 }
 int l=s.size();
 char t=s[l-1];
 string k;
 for(int i=l-1;i>0;i--){
   if(s[i]>s[i-1]){
     for(int j=0;j<i-1;j++) k+=s[j];
     char p=s[i-1],q;
     int c=1000;
     for(int j=i;j<l;j++) {
       int a=s[j]-p;
       if(c>a&&a>0) {
         q=s[j];
         c=a;
       }
     }
     t=q;
     k+=t;
     cout <<k<<endl;
     return 0;
   }
 }
 cout <<-1<<endl;
 return 0;
}


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

int main() {
	int x[4], a=0, b=0, c=0, d=0;
	for (int i=0; i<4; i++) cin >> x[i];
	for (int i=0; i<4; i++) {
		switch (x[i]) {
			case 1: a = 1; break;
			case 9: b = 1; break;
			case 7: c = 1; break;
			case 4: d = 1; break;
		}
	}

	cout << ((a & b & c & d) ? "YES" : "NO") << endl;
	return 0;
}


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

const int A = 1000005;

int gcd(int a, int b) {
    int x = max(a,b);
    int y = min(a,b);
    int r = x % y;

    while(r!=0){
        x = y;
        y = r;
        r = x % y;
    }

    return y;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);

  rep(i,n){
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for(int i = 2; i < A; i++){
    int cnt = 0;
    for(int j = i; j < A; j += i){
      cnt += c[j];
    }
    if(cnt > 1) pairwise = false;
  }
  if(pairwise){
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = a[0];
  rep(i,n){
    g = gcd(g,a[i]);
    if(g==1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }

  cout << "not coprime" << endl;

  return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 int n,m,K;
 cin>>n>>m>>K;
 vector<string>  v(n);
 for(int i =0; i<n; i++)
	cin>>v[i];
 int ans =0, cnt = 0;
 for(int i =0; i<(1<<n); i++){
	 for(int j =0; j<(1<<m); j++){
		 cnt=0;
		 for(int k=0; k<n; k++){
			 for(int l=0; l<m; l++){
				 if(((i>>k)&1) || ((j>>l)&1)) continue;
				 if(v[k][l]=='#') cnt++;
				 }
			 }
			 if(cnt==K) ans++;
		 }
	 }
	 cout<<ans;
	 return 0;
}


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

using namespace std;

int main()
{
    string str;
    cin >> str;
    for(int i=0; i<(int)str.size(); ++i) {
        if(i%2==0) {
            cout << str[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long int N,K;
int main(){
    cin>>N>>K;
    if(N<K){
        cout << min(N,K-N) << endl;
    }else{
        long int r = N%K;
        if(r!=0){
            cout << min(r,K-r) << endl;
        }else{
            cout << r << endl;
        }
    }
}

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


int ASC(const void *a, const void *b) {
	return *(int *)b - *(int *)a;//降順
}
	
int main(void)
{
	int n, m, a[1001], vote = 0, ans = 0;
	double keep;
	scanf("%d%d",&n,&m);
	for (int i = 0; i < n; i++) {
		scanf("%d",&a[i]);
		vote += a[i];
	}
	keep = (double) vote / (4 * m);
	//printf("%f",keep);
	for (int i = 0; i < n; i++) {
		if ((double)a[i] >= keep)
			ans++;
	}
	if (ans >= m)
		printf("Yes");
	else
		printf("No");

	return 0;
} 

Measured memory_bytes: 128
#include <iostream>

using namespace std;

class Vector3{
public:
	double x,y;

	Vector3(){}
	Vector3( double dx, double dy ){
		x = dx;
		y = dy;
	}

	double operator*( Vector3 hoge ){
		return ( x * hoge.y - ( y * hoge.x ) );
	}

	void operator-=( Vector3 hoge ){
		x -= hoge.x;
		y -= hoge.y;
	}
};

double crossProduct( Vector3 a, Vector3 b, Vector3 p )
{
	b -= a;
	p -= a;

	return b * p;
}

int main(int argc, char const* argv[])
{
	Vector3 p[3];
	Vector3 point;
	double answer[3];

	while( cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y >> p[2].x >> p[2].y >> point.x >> point.y ){
		answer[0] = crossProduct( p[0], p[1], point );
		answer[1] = crossProduct( p[1], p[2], point );
		answer[2] = crossProduct( p[2], p[0], point );
		if( ( ( answer[0] < 0 ) && (answer[1] < 0 ) && ( answer[2] < 0 ) ) || ( ( answer[0] > 0 ) && ( answer[1] > 0 ) && ( answer[2] > 0 ) ) )
			cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
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; }
//ここから始めよう
signed main(){
    int n;cin>>n;
    int a[111];rep(i,0,n)cin>>a[i];
    int ans=0;
    rep(i,1,111){
        int cnt=0;bool ok=true;
        rep(j,0,n){
            if(ok&&a[j]>=i){
                cnt++;ok=false;
            }else if(a[j]<i)ok=true;
        }
        ans+=cnt;
    }cout<<ans<<endl;return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(new InputStreamReader(System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		
		System.out.println(((a+b)*h)/2);
		
	}
}


Measured memory_bytes: 21716
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(vector<int>& A, int K) {
        int n = A.size();
        
        map<int,vector<int>> M;
        M[0].push_back(-1);
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += A[i] - 1;
            M[sum % K].push_back(i);
        }

        long long res = 0;
        for (auto& P : M) {
            auto& V = P.second;
            int n = V.size();
            for (int i = 0, j = 0; i < n; ++i) {
                while (j < n && V[j] - V[i] < K) {
                    ++j;
                }
                res += max(0, j - i - 1);
            }
        }

        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Solution sol;

    cout << sol.solve(A, k) << "\n";

    return 0;
}

Measured memory_bytes: 22912
#include<bits/stdc++.h>
#define taskname ""
#define int long long
using namespace std;

const int maxn = 1e6;
const int lim = 1e9 + 7;

int n;
int a[maxn + 10];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        sum -= a[i];
        ans += ((a[i] % lim) * (sum % lim)) % lim;
        ans %= lim;
    }
    cout << ans;
}


Measured memory_bytes: 5176
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	cin >> n;
	int ans = (n - 1) / 2;
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string a,b;
    cin>>a>>b;
    ll res = 0;
    for( string::size_type i = 0;i<a.size();++i)
    {
	if(a[i] != b[i]){res = res+1;}
    }
    cout<<res<<"\n";
    return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  double a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    double det = a * e - b * d;
    double x = e * c / det - b * f / det;
    double y = a * f / det - d * c / det;
    cout << fixed;
    cout << setprecision(3) << x << " " << setprecision(3) << y << endl;
  }
}


Measured memory_bytes: 3248
#include<stdio.h>

int main(){
  int num;
  
  scanf("%d",&num);
  switch(num % 10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon");
      break;
    case 3:
      printf("bon");
    default:
      break;
  }
  return 0;
}

Measured memory_bytes: 1732
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if i == 0 or i == H-1  or j == 0 or j == W-1 :
                    print('#', end='')
                else:
                    print('.', end='')
            print()
        print()


Measured memory_bytes: 7000
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


N = 10 ** 5
P = set(prime_numbers(N))
P = [n for n in P if (n + 1) // 2 in P]
a = [0] * (N + 1)
for n in P:
    a[n] = 1
a = list(accumulate(a))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(a[r] - a[l - 1])


Measured memory_bytes: 52640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>

using namespace std;

int n;

double a, x, ans;

int main() {
	scanf("%d", &n);
	scanf("%lf%lf", &a, &x);
	for(int i = n; i; i--) {
		double m = 2*i;
		double v = (a+(a+(m-1)*x))/m*i;
		ans += v;
		a = ((m+2)*a+5*x)/m;
		x = (m+4)/m*x;
	}
	printf("%.15lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    int paper[][] = new int[20][20];
    for(int i=0; i<20; i++) {
      for(int j=0; j<20; j++) {
        paper[i][j] = 0;
      }
    }
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      String line = sc.nextLine();
      String[] a = line.split(",");
      int x = Integer.parseInt(a[0])+2;
      int y = Integer.parseInt(a[1])+2;
      int s = Integer.parseInt(a[2]);
      if(s == 1) {
        paper[y][x]   += 1;
	paper[y+1][x] += 1;
	paper[y-1][x] += 1;
	paper[y][x+1] += 1;
	paper[y][x-1] += 1;
      }
      else if(s == 2) {
	for(int i=-1;i<=1;i++) {
          for(int j=-1;j<=1;j++) {
            paper[y+i][x+j] += 1;
	  }
	}
      }
      else if(s == 3) {
	for(int i=-1;i<=1;i++) {
          for(int j=-1;j<=1;j++) {
            paper[y+i][x+j] += 1;
	  }
	}
	paper[y+2][x] += 1;
	paper[y-2][x] += 1;
	paper[y][x+2] += 1;
	paper[y][x-2] += 1;
      }
    }
    int count=0;
    int max=0;
    for(int i=2; i<12; i++) {
      for(int j=2; j<12; j++) {
	if(paper[i][j] == 0) {
          count++;
	}
	if(max < paper[i][j]) {
          max = paper[i][j];
	}
      }
    }
    System.out.println(count);
    System.out.println(max);
  }
}

Measured memory_bytes: 26096
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
//int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int i,ans=0;
  char S[5];
  scanf("%s",S);
  if(S[0]==S[1]&&S[2]==S[3])ans=1;
  if(S[0]==S[2]&&S[1]==S[3])ans=1;
  if(S[0]==S[3]&&S[1]==S[2])ans=1;
  if(S[0]==S[1]&&S[1]==S[2])ans=0;
  if(ans==1)printf("Yes");
  else printf("No");

  //printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 105;

int n;
int a[N], b[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n - 1; i++)
		cin >> b[i];
	a[1] = b[1];
	a[n] = b[n - 1];
	for(int i = 2; i <= n - 1; i++)
		a[i] = min(b[i - 1], b[i]);
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans += a[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 55
#define X first
#define Y second
using namespace std;

int n, c, mn = 1e9;
bool v[N];
pair<int, int> a[N];

void f(int p, int q, int r) {
	int i, tp = a[r].X, tq = a[r].Y;
	for (i = r; i < n; i++) {
		if (a[i].X == tp && a[i].Y == tq) {
			v[i] = 1;
			tp += p;
			tq += q;
		}
	}
}

int main()
{
	int i, j, k;
	cin >> n;
	if (n == 1) {puts("1"); return 0;}
	for (i = 0; i < n; i++) {
		scanf("%d %d", &a[i].X, &a[i].Y);
	}
	sort(a, a + n);
    for (i = 0; i < n; i++) {
		for (j = 0; j < i; j++) {
			c = 0;
			for (k = 0; k < n; k++) v[k] = 0;
			for (k = 0; k < n; k++) {
				if (!v[k]) c++, f(a[i].X - a[j].X, a[i].Y - a[j].Y, k);
			}
			mn = min(mn, c);
		}
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val result = getResult(in)
    print(result)
  }
  def getResult(in:java.util.Scanner):String = {
    val n = in.nextInt()
    val x = in.nextInt()
    if(n == 0 && x ==0){
      return ""
    }
    var count = 0
    for(i <- 1 to n){
      for(j <- i to n){
        for(k <- j to n){
          if(i+j+k == x && i != j &&j!= k){
            count += 1
          }
        }
      }
    }
    return count + "\n" + getResult(in)
  }
}

Measured memory_bytes: 47744
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ClassNotFoundException, IOException {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		List<Integer> d = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			d.add(sc.nextInt());
		}
		Collections.sort(d);
		System.out.println(d.get(N/2) - d.get(N/2 - 1));
	}


}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 28628
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll inf = 1e18;
struct Edge{
  	ll to, cost;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

vll dijkstra(const Graph &g, int s){
  	vll d(g.size(), inf);
  	d[s] = 0;
  	priority_queue<P, vector<P>, greater<P>> que;
  	que.push(P(0, s));
  	while(!que.empty()){
    	ll dist = que.top().first;
    	int v = que.top().second;
    	que.pop();
    	if(d[v] < dist) continue;
    	for(const auto &e: g[v]){
      		if(d[e.to] <= d[v] + e.cost) continue;
      		d[e.to] = d[v] + e.cost;
      		que.push(P(d[e.to], e.to));
    	}
  	}
  	return d;
}


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

    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    ll v1, v2, a, b;
    Graph yen(n), snk(n);
    REP(i, m){
        cin >> v1 >> v2 >> a >> b;
        v1--, v2--;
        yen[v1].push_back(Edge{v2, a});
        yen[v2].push_back(Edge{v1, a});
        snk[v1].push_back(Edge{v2, b});
        snk[v2].push_back(Edge{v1, b});
    }
    vll d1 = dijkstra(yen, s), d2 = dijkstra(snk, t);
    vll ans(n, inf);
    REPR(i, n){
        ans[i] = min(ans[i], d1[i] + d2[i]);
        if(i != n - 1) ans[i] = min(ans[i], ans[i + 1]);
    }
    ll res = 1e15;
    REP(i, n) cout << res - ans[i] << endl;
    return 0;
}

Measured memory_bytes: 19016
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val items = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()

    val sum = items.sum().toDouble()
    val result = items[m - 1].toDouble() >= (sum / (4.0 * m.toDouble()))
    if (result) {
        println("Yes")
    } else {
        println("No")
    }
}

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

int main()
{
  ll n;
  cin >> n;
  ll ans = 1e12;

  ll k = 0;

  for (ll i = 1; i <= sqrt(n); i++)
  {
    if (n % i == 0)
    {
      ll yaku = n / i;
      ll dx = yaku - 1;
      ll dy = i - 1;
      ans = min(ans, dx + dy);
    }
  }

  cout << ans;
}


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

#define int long long
#define pb emplace_back
#define f(i,n) for(int i=0 ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;
	int n;  cin >> n;
	int l;  cin >> l;
	
	int a[n+1];
	int tot = 0;
	for(int i=1 ; i<=n ; i++)   a[i] = l + i - 1 , tot+= a[i];
	
	int cmp = INT_MAX;
	int ans;
	for(int i=1 ; i<=n ; i++)
	{
		if(abs(a[i]) < cmp)
		{
			ans = tot- a[i];
			cmp = abs(a[i]);
		}
	}
	cout << ans;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int> p(n*n);
	for(int& i:p) cin >> i;
	vector<vector<int>> m(n, vector<int>(n, 0));
	vector<vector<int>> used(n, vector<int>(n, 1));
	for(int i=0; i<n; ++i){
		for(int j=0; j<n; ++j) m[i][j]=min({i, j, n-1-i, n-1-j});
	}
	int ans = 0;
	for(int _:p){
		--_;
		int i=_/n, j=_%n;
		ans += m[i][j];
		used[i][j]=0;
		queue<pii> q;
		q.push({i, j});
		while(!q.empty()){
			int i=q.front().first, j=q.front().second;
			q.pop();
			pii dir[] = {{0,1}, {1,0}, {0,-1}, {-1,0}};
			for(int _=0; _<4; ++_){
				int x=i + dir[_].first;
				int y=j + dir[_].second;
				if(x>=0 && x<n && y>=0 && y<n && m[x][y]>m[i][j]+used[i][j]){
					m[x][y]=m[i][j]+used[i][j];
					q.push({x, y});
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8956
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	char a[5],b[5];
	scanf("%s",a);
	scanf("%s",b);
	if(a[0]==b[2]&&a[2]==b[0]&&a[1]==b[1])
	printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

#define F first
#define S second
#define x1 privet1
#define x2 privet2
#define y1 privet3
#define y2 privet4
#define left privet6

using namespace std;
typedef long long ll;

const int max_n = 200011, log_n = 32, max_m = 111, mod = 1000000007, inf = 1000111222;

int n, m;
vector<int> v[max_n];

int main() {
    // freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i =0 ; i < m; ++i) {
        int f, g;
        scanf("%d%d", &f, &g);
        f--; g--;
        v[f].push_back(g);
        v[g].push_back(f);
    }
    for (int i = 0; i < v[0].size(); ++i) {
        for (int q = 0; q < v[v[0][i]].size(); ++q) {
            if (v[v[0][i]][q] == n - 1) {
                cout << "POSSIBLE\n";
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE\n";
    return 0;
}


Measured memory_bytes: 12016
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long i, j, k, x, n, ans, v;
	priority_queue<long long> pq;
	vector<long long> a;
	for (i = 1; i <= 9; i++) pq.push(-i);

	cin >> k;
	while (a.size() < k) {
		x = -pq.top();
		pq.pop();
		a.push_back(x);

		v = x % 10;
		x *= 10;
		for (i = max(0LL, v - 1); i <= min(9LL, v + 1); i++) pq.push(-(x + i));
	}

	cout << a[k - 1] << "\n";

	return 0;
}



Measured memory_bytes: 3012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;

public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next().trim();
        char arr[] = new char[27];
        for (int i = 0; i < s.length(); i++) {
            arr[s.charAt(i) - 'a']++;
        }
        Solver solver = new Solver();
        solver.solve(arr);
        System.out.println(output);
    }

}

class Solver {
    public void solve(char arr[]) {
        String ans = "Yes";
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 != 0) {
                ans = "No";
                break;
            }
        }
        Main.output.append(ans);
    }
}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,l,r,sum;
  sum=0;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

map<ll, int> dp;

ll fn(ll h){
	if(h == 0)
		return 0;
	if(h == 1)
		return 1;
	return 1 + 2LL * fn(h/2);
}

int main(){
    fastio();

    ll h;
    cin >> h;

    cout << fn(h);
    

    return 0;
}

/*

*/

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#define LL long long
LL ans = 10000000000000;
int main() {
	LL H, W;
	std::cin >> H >> W;
	ans = std::min(H, W);
	if (H % 3 == 0 || W % 3 == 0) {
		ans = 0;
	}
	for (LL i = 0; i < H; i++) {
		LL M = std::max({ W*i,(W / 2)*(H - i),(W - (W / 2))*(H - i) });
		LL m = std::min({ W*i,(W / 2)*(H - i),(W - (W / 2))*(H - i) });
		ans = std::min(ans, M - m);
	}
	for (LL i = 0; i < W; i++) {
		LL M = std::max({ H*i,(H / 2)*(W - i),(H - (H / 2))*(W - i) });
		LL m = std::min({ H*i,(H / 2)*(W - i),(H - (H / 2))*(W - i) });
		ans = std::min(ans, M - m);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 
  
 

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


  int p,a;
  cin>>p>>a;

  int sum=0;
  for(int i=0;i<a;i++)
  {
    int x;
    cin>>x;
    sum+=x;
  }
  if(sum>=p)
  {
    cout<<"Yes\n";
  }
  else cout<<"No\n";
   
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<string>s(n);
    rep(i,n)cin>>s[i];
    ll ans=0;
    vector<string>t=s;
    rep(i,n){
      bool flag=true;
      rep(h,n){
        rep(w,n){
          t[h][w]=s[(h+i)%n][w];
        }
      }
      rep(h,n){
        rep(w,n){
          if(t[h][w]!=t[w][h])flag=false;
        }
      }
      if(flag)++ans;
    }
    cout<<ans*n<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int a[N];
int main() {
    int n; scanf("%d",&n);
    for(int i=0;i<n*2;i++) scanf("%d",&a[i]);
    sort(a,a+n*2);
    int sum=0;
    for(int i=0;i<n*2;i+=2) sum+=a[i];
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 256