akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		
		int dx = x2 - x1;
		int dy = y2 - y1;
		
		System.out.println((x2 - dy) + " " + (y2 + dx) + " " + (x1 - dy) + " " + (y1 + dx));
	}
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	repp(i,0,N){int A; cin >> A;}
	cout << (N-1+K-2)/(K-1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

const int INF = 100000000;
int dist[101][101];

void calc(int c, int d, int e) {
    for (int i=0; i<101; ++i) {
        for (int j=0; j<101; ++j) {
            dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][c] + e + dist[d][j]);
        }
    }
}

int main() {
    int n, k;
    while (cin >> n >> k, n) {
        // prepare
        for (int i=0; i<101; ++i) {
            for (int j=0; j<101; ++j) {
                dist[i][j] = i == j ? 0 : INF;
            }
        }
        int type, a, b, c, d, e;
        for (int i=0; i<k; ++i) {
            cin >> type;
            if (type == 0) {
                cin >> a >> b;
                if (dist[a][b] == INF) {
                    cout << -1 << endl;
                } else {
                    cout << dist[a][b] << endl;
                }
            } else {
                cin >> c >> d >> e;
                calc(c, d, e);
            }
        }
    }
    return 0;
}

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

int main(void){
    char t[1001],w[11];
    int len,i,count=0;
    
    scanf("%s",&w);
    while(scanf("%s",&t)){
        if(strcmp(t,"END_OF_TEXT")==0){
            break;
        }
        len=strlen(t);
        for(i=0;i<len;i++){
            if(t[i]<91 &&t[i]>64){//??§???????????¨??????65???90  (?°???????91???115)
                t[i]+=32;  //+32
            }
        }
        if(strcmp(t,w)==0)count++;
    }
    
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 1760
#include <stdio.h>

int main(void){
	
	int a, b, c, max, min, total;
	
	scanf("%d %d %d", &a, &b, &c);
	
	total=a+b+c;
	
	if(a > b && a > c)
    {
    	max=a;
	}
 	else if(b > a && b > c)
	{
		max=b;
	}
    else
    {
    	max=c;
	}
    if(a < b && a < c)
    {
    	min=a;
	}
    else if(b < a && b < c)
    {
    	min=b;
	}
    else
    {
    	min=c;
	}

    printf("%d %d %d\n",min ,total-max-min ,max);
    
    return 0;

}



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

pair<pair<string, int>, int> p[110];
int main () {
    int N;
    scanf("%d", &N);
    for ( int i = 0; i < N; i++ ) {
        char c[15];
        int t;
        scanf("%s%d", c, &t);
        string city = c;
        p[i] = make_pair(make_pair(city, -t), i);
    }
    sort(p, p+N);
    for ( int i = 0; i < N; i++ ) printf("%d\n", p[i].second+1);
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
// ll mod=998244353;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ve<ll>ar(n+1);
	lr(n){
		cin>>ar[i+1];
	}
	ll dp[n+1]={0};
	dp[n-1]=abs(ar[n]-ar[n-1]);
	for(ll i=n-2;i>=1;i--){
		dp[i]=min(abs(ar[i+1]-ar[i])+dp[i+1], abs(ar[i+2]-ar[i])+dp[i+2]);
	}
	cout << dp[1] << "\n";
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main
{
  public static Scanner sc = new Scanner(System.in);

  public static long n;

  public static int dfs(String s) {
    if (Long.parseLong(s) > n) {
      return 0;
    }

    int ans = 0;
    if (s.contains("7") && s.contains("5") && s.contains("3")) {
      ans = 1;
    }

    ans += dfs(s + "7");
    ans += dfs(s + "5");
    ans += dfs(s + "3");

    return ans;
  }

  public static void main(String args[])
  {
    n = Long.parseLong(sc.next());

    System.out.println(dfs("0"));
  }
}

Measured memory_bytes: 35284
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int N, D;
    long long X, Y;
    int num = 0;

    scanf("%d %d", &N, &D );
    
    for(int i = 0; i < N; i++) {
        scanf("%lld %lld", &X, &Y );
        if( D >= sqrt( ( X * X ) + ( Y * Y ) ) ) {
            num++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 2148
n = int(input())
cnt4 = 0
cnt2 = 0
a = list(map(int, input().split()))
for num in a:
    if num % 4 == 0:
        cnt4 += 1
    elif num % 2 == 0:
        cnt2 += 1

if cnt4 >= n // 2:
    print("Yes")
    exit()
elif cnt4 >= (n - cnt2 + 1) // 2:
    print("Yes")
    exit()
print("No")

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

using namespace std;

int main() {
    
    int n;
    cin >> n;
    vector<pair<int,int> > v;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back({x, i + 1});
    }
    
    sort(v.begin(), v.end());

    for (auto p: v)
        cout << p.second << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1780
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

vector <pii> Vl[35];
int del[100050];
int main() {
	int N, C, i, j;
	scanf("%d %d", &N, &C);
	for (i = 1; i <= N; i++) {
		int t1, t2, t3;
		scanf("%d %d %d", &t1, &t2, &t3);
		Vl[t3].emplace_back(t1, t2);
	}
	for (i = 1; i <= C; i++) {
		sort(all(Vl[i]));
		if (Vl[i].empty()) continue;

		int st = Vl[i][0].first, en = Vl[i][0].second;
		for (j = 1; j < Vl[i].size(); j++) {
			if (en != Vl[i][j].first) {
				del[st]++;
				del[en + 1]--;
				st = Vl[i][j].first, en = Vl[i][j].second;
			}
			else en = Vl[i][j].second;
		}
		del[st]++;
		del[en + 1]--;
	}

	int ans = 0;
	for (i = 1; i <= 100000; i++) {
		del[i] += del[i - 1];
		ans = max(ans, del[i]);
	}
	return !printf("%d\n", ans);
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll B[100005];
ll S[100005];
bool U[100005];

int main()
{
    int N;
    cin >> N;
    ll asum = 0;
    REP(i, N)
    {
        cin >> A[i];
        asum += A[i];
    }
    ll bsum = 0;
    REP(i, N)
    {
        cin >> B[i];
        S[i] = A[i] - B[i];
        bsum += B[i];
    }
    if (asum < bsum)
    {
        cout << -1 << endl;
        return 0;
    }
    sort(S, S + N, [](ll a, ll b) { return a > b; });
    int si = 0;
    int sum = 0;
    ll cost = 0;
    REP(i, N)
    {
        ll d = B[i] - A[i];
        if (d <= 0)
        {
            continue;
        }
        sum++;
        while (d > 0)
        {
            if (!U[si])
            {
                sum++;
                U[si] = true;
            }
            ll e = std::min(d, S[si]);
            d -= e;
            S[si] -= e;
            if (d > 0)
            {
                si++;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
//const int md = 998244353;
//const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/

int dp[20000];

signed main()
{
    showoff;
    int n,ans = 0,a[maxn],pgcd[maxn];
    cin >> n;
    FOR(i,1,n+1){
        cin >> a[i];
        pgcd[i] = __gcd(pgcd[i-1],a[i]);
    }
    int g = 0;
    RFOR(i,n,0){
        ans = max(ans,__gcd(pgcd[i-1],g));
        g = __gcd(g,a[i]);
    }
    cout << ans;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...    

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

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

    int n;
    scanf("%d", &n);
    int last = n % 10;
    if (last == 2 || last == 4 || last == 5 || last == 7 || last == 9) {
        printf("hon\n");
    } else if (last == 3) {
        printf("bon\n");
    } else {
        printf("pon\n");
    }

    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,aa[3][3];
signed main(){
	rep(i,3){
		rep(j,3){
			cin>>aa[i][j];
		}
	}
	rep(i,2){
		rep(j,2){
			if(aa[i][j]-aa[i][j+1]!=aa[i+1][j]-aa[i+1][j+1]||aa[i][j]-aa[i+1][j]!=aa[i][j+1]-aa[i+1][j+1]){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x));

        var set = new HashSet<int>();
        foreach (var a in seqA)
        {
            if (!set.Add(a))
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");
    }
}


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

using namespace std;


int main() {
  int n;
  cin >> n;
  vector<double> v(n);

  for(int i =0; i <n; i++){
    cin >> v[i];
  }

  sort(v.begin(),v.end());

  double ans =v[0];
  for(int i=1; i <n;i++){
    double a = (ans + v[i])/2.0;
    ans = a;
  }

  cout <<setprecision(10)<< ans << 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;
typedef long long ll;
typedef pair<int,int>P;

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  rep(i,n){
    cin >> h[i];
  }
  int key = 0;
  int res = 0;
  int ans = 100100100;
  vector<P> p(n);
  rep(i,n) {
    res = 1000*t-h[i]*6;
    p[i].second = abs(res-1000*a);
    p[i].first = i;
    if(ans >= p[i].second) {
      ans = p[i].second;
      key = p[i].first;
    }
  }
  cout << key+1 << endl;
}

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

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


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int l,r,ll,rr;
    cin>>l>>r>>ll>>rr;
    int ans=0;
    for(int i=0;i<100;i++)if(l<=i&&i<r&&ll<=i&&i<rr)ans++;
        cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	R := make([]int, N)
	for i := 0; i < M; i++ {
		a, b := sc.nextInt()-1, sc.nextInt()-1
		R[a]++
		R[b]++
	}

	for _, to := range R {
		fmt.Fprintln(wtr, to)
	}
	wtr.Flush()
}


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

int main() {
    int a, b, c, d, e, k ;
    cin >> a >> b >>c >> d >> e >> k;
    if(e - a <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<array<ll, 2>> vp(n);

  for (auto &p : vp) {
    ll x, y;
    cin >> x >> y;
    p[0] = x - y;
    p[1] = x + y;
  }

  ll ans = 0;
  for (int d = 0; d < 2; ++d) {
    ll max_n, min_n;
    max_n = min_n = vp.front()[d];
    for (auto &p : vp) {
      max_n = max(p[d], max_n);
      min_n = min(p[d], min_n);
    }

    ans = max(ans, max_n - min_n);
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6368
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

const int dx[] = {1, 0, -1, 0, 0};
const int dy[] = {0, 1, 0, -1, 0};

const int Maxn = 300 * 300 + 10;

int dp[Maxn];
P a[Maxn];

int h, w, d, m;

int cost(P &p1, P &p2) {
    return abs(p1.first - p2.first) + abs(p1.second - p2.second);
}

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
     */
    scanf("%d%d%d", &h, &w, &d);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int x;
            scanf("%d", &x);
            a[x] = P(i, j);
        }
    }

    for (int i = h * w; i >= 1; --i) {
        if (i + d <= h * w) {
            dp[i] = dp[i + d] + cost(a[i], a[i + d]);
        }
    }

    scanf("%d", &m);
    while (m--) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", dp[l] - dp[r]);
    }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main(){
std::ios::sync_with_stdio(false);std::cin.tie(0);
	ll n,a,b;
	cin>>n>>a>>b;
	if(a+b<=n)
	cout<<n/(a+b)*a+((n%(a+b))>=a?a:(n%(a+b)))<<'\n';
	else{
		if(a>=n) cout<<n<<'\n';
		else cout<<a<<'\n';
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll P, Q, R;
  cin >> P >> Q >> R;
  cout << min(min(P + Q, P + R), Q + R) << endl;
  return 0;
}


Measured memory_bytes: 256
// Marcin Knapik
// before you read it
// make sure it's a good idea
#include<bits/stdc++.h>
using namespace std;

typedef long long         ll;
typedef unsigned long long      ull;
typedef pair< ll, ll >        pll;
typedef pair< int, int  >       ii;
typedef vector< int  >       vi;
typedef vector< ii >        vii;
typedef vector< vi >        vvi;
typedef vector< vector < ii > >   vvii;
typedef vector< ll >        vll;
typedef vector< pll >       vpll;
typedef long double         ld;

#define boost   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define szy     first
#define gi      second
#define sz(a)   (int)(a).size()
#define pb      push_back
#define all(c)    (c).begin(), (c).end()
#define rall(c)   (c).rbegin(), (c).rend()


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

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template<class T> inline T sub(T a, T b, T mod) {return ((a - b)+mod)%mod;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

ld e = 2.7182818284590452353602874713526624;
ld PI = acos(-1);
ld eps = 1e-11;

const ll T = 1 << 19;
const ll INF = 1e9 + 7;
const ll BIG_INF = 1e18 + 5;
const long long  N = 1e6 + 7;
ll n, m, k;
int s,t;
vvi G(N);

int odw[N][3];

void BFS(){
	queue<pair<int, int > > kolejka;
	odw[s][0] = 3;
	kolejka.push({s,0});

	while(sz(kolejka)){
		ii akt = kolejka.front();
		kolejka.pop();
		int v = akt.first;
		int val = akt.second;
		int nast = (val+1)%3;
		for(auto&u:G[v]){
			// cout << v << ' ' << val << ' ' << u << ' ' << nast << endl;
			if(!odw[u][nast]){
				odw[u][nast] = odw[v][val] + 1;
				kolejka.push({u,nast});
			}
		}
	}
}

int main(){
	boost;
	cin >> n >> m;
	for( int i = 0 ; i < m ; i++){
		int a, b;
		cin >> a >> b;

		G[a].pb(b);
		// G[b].pb(a);
	}

	cin >> s >> t;
	odw[s][0] = 3;
	BFS();
	cout << odw[t][0]/3 - 1 << '\n';

	for(int i = 1 ; i <= 3 ; i++){
		for( int j = 0 ; j < 3; j++){
			// cout << odw[i][j] << ' ';
		}
		// cout << endl;
	}
}		

Measured memory_bytes: 28032
#include <bits/stdc++.h>
using namespace std;
#define INF 9223372036854775807

int64_t rf(vector<vector<int64_t> > &dp, vector<int64_t> &a, int i, int j) {
    if (dp.at(i).at(j) != INF) {
        return dp.at(i).at(j);
    }
    if (i == j) {
        return a.at(i);
    }
    dp.at(i).at(j) = max(a.at(i) - rf(dp, a, i+1, j), a.at(j) - rf(dp, a, i, j-1));
    return dp.at(i).at(j);
}

int main() {
    int n; cin >> n;
    vector<int64_t> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    vector<vector<int64_t> > dp(n, vector<int64_t>(n, INF));
    cout << rf(dp, a, 0, n-1) << endl;
}

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

typedef long long ll;

main()
{
    ll n, i, s = 0;
    cin >> n;
    ll arr[n];
    for(i = 0; i < n; i++){
        cin >> arr[i];
    }
    for(i = 1; i < n; i++){
        if(arr[i] < arr[i-1]){
            s = s + arr[i-1] - arr[i];
            arr[i] = arr[i-1];
        }
    }
    cout << s;


}





///promy_pompom
//hello world


Measured memory_bytes: 5200
from collections import defaultdict, deque

N, u, v = map(int, input().split())
u -= 1
v -= 1
adj = defaultdict(list)
for i in range(N - 1):
    Ai, Bi = map(lambda x: int(x) - 1, input().split())
    adj[Ai].append(Bi)
    adj[Bi].append(Ai)

A = [0] * N
stack = deque()
stack.append(v)
while len(stack) > 0:
    e = stack.popleft()
    for a in adj[e]:
        if a == v or A[a] != 0:
            continue
        A[a] = A[e] + 1
        stack.append(a)

T = [0] * N
stack = deque()
stack.append(u)
while len(stack) > 0:
    e = stack.popleft()
    for a in adj[e]:
        if a == u or T[a] != 0 or A[a] < T[e] + 1:
            continue
        T[a] = T[e] + 1
        stack.append(a)

print(max([A[i] for i in range(N) if T[i] != 0 or i == u]) - 1)


Measured memory_bytes: 34780
import java.util.ArrayDeque;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FS fs = new FS();
        int n = fs.nextInt();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int m = fs.nextInt();
            if (test(m)) sum++;
        }
        System.out.println(sum);
    }

    private static boolean test(int m) {
        if (m == 2) return true;
        else if (m == 3) return true;
        else {
            if (m%2==0)return false;
            if (m%3==0)return false;
            for (int i = 5; i < Math.sqrt(m)+1; i += 2) {
                if (m % i == 0) return false;
            }
            return true;
        }
    }

}


 class FS {
    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() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        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 int nextInt() {
        return (int) nextLong();
    }

    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();
        }
    }
}



Measured memory_bytes: 26160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LL long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double t, x;
    cin >> t >> x;
    printf("%lf\n", t / x);
    return 0;
}

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

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

  vector<tuple<string, int, int>> vt(N);

  for (int i = 0; i < N; i++) {
    cin >> get<0> (vt.at(i));

    int p;
    cin >> p;

    get<1> (vt.at(i)) = - p;
    get<2> (vt.at(i)) = i + 1;
  }

  sort(vt.begin(), vt.end());

  for (auto t : vt) {
    //cout << get<0> (t) << " : " << - get<1> (t) << " : " << get<2> (t) << endl;
    cout << get<2> (t) << endl;
  }
}


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

class Main{
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final ArrayList<vec> mat = new ArrayList<vec>();
        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            for(int j = 0; j<i; j++){
                final int len = Integer.parseInt(st.nextToken());
                if(len!=-1) mat.add(new vec(len, j, i));
            }
        }
        mat.sort(null);
        final int[] group = new int[n];
        int cost = 0;
        for(int i = 0; i<n; i++)
            group[i] = i;
        for(int i = 0, m = mat.size(); i<m; i++){
            if(group[mat.get(i).f]==group[mat.get(i).t]) continue;
            cost += mat.get(i).l;
            final int f = group[mat.get(i).f];
            final int t = group[mat.get(i).t];
            for(int j = 0; j<n; j++)
                if(group[j]==t) group[j] = f;
        }
        System.out.println(cost);
    }
}

class vec implements Comparable<vec>{
    final int l;
    final int f;
    final int t;
    vec(int len, int from, int to){
        l = len;
        f = from;
        t = to;
    }
    @Override
    public int compareTo(vec other){
        return l-other.l;
    }

}

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

int main()
{
    string s;
    string x;

    cin >> s >> x;

    int n = 0;
    n = s.size();
    bool ans = true;

    if (n != x.size() - 1)
    {
        ans = false;
    }

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != x[i])
        {
            ans = false;
        }
    }

    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
import java.util.*;

public class Main{
  public static void main(String[] args){
    int ans = 0;
    Scanner sc = new Scanner(System.in);
    String pm = sc.next();
    char[] c = pm.toCharArray();
    for(int i=0; i<4; i++){
      if(c[i]=='+'){
        ans++;
      }else{
        ans--;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <chrono>
#include <set>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;
typedef long long int64;
typedef unsigned long long ll;
#define fi first
#define se second

#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vec vector<int> 
#define lvec vector<ll>
#define dvec vector<double>
#define Mem(x) memset(x,0,sizeof(x));

#define rFor(i,a,b) for(int i=(a);i>(b);--i)
#define For(...)  GET_MACRO(_0,##__VA_ARGS__,For3,For2,For1,For0)(__VA_ARGS__)
#define foronce for(static int __ = 0; __ < 1;++__)
#define forall(i, s) foreach(i,begin(s),end(s))
#define foreach(i, a, b) for(auto i = (a);i!=(b) ;++i)
#define foreachn(i, a, n) for(auto i = (a),_=next(a,n);i!=_;++i)
#define For3(i,a,b) for(int i=(a);i<(b);++i)
#define For2(i,a) for(int i=0;i<(a);++i)
#define For1(a) For2(_,a)
#define For0()	

#define in(x) scanf("%d",&(x));
#define put(x) cout<<(x)<<endl;
#define GET_MACRO(_0,_1,_2,_3,_NAME,...) _NAME
#ifndef ONLINE_JUDGE
	#define out0()
	#define out1(x) {cout<<" ";cout.width(5);cout<<(x);}
	#define out2(x,y) {out1(x)out1(y)}
	#define out3(x,y,z) {out2(x,y)out1(z)}
	#define outset(x) for(auto i : x) out1(i) //std::size()
	#define outarr1(x,fir) foreachn(_iter,begin(x),fir) out1(*_iter)
	#define outarr2(x,fir,sec) for(auto iter2=begin(x);iter2!=begin(x)+fir;++iter2){ outarr1((*iter2),sec)out()}
	#define out(...) {cout<<#__VA_ARGS__<<" ";GET_MACRO(_0,##__VA_ARGS__,out3,out2,out1,out0)(__VA_ARGS__);cout<<endl;}
	#define outa(...)  {cout<<#__VA_ARGS__;out()GET_MACRO(""##__VA_ARGS__,UNUSED,outarr2,outarr1,outset)(__VA_ARGS__)out()}
#endif // ONLINE_JUDGE

const double eps = 1e9;
int mod = 222;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
#define lcm(a,b) ((ll)(a)/gcd(a,b)*(b))
inline ll powmod(ll a,ll b) {ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

#include<unordered_set>

int R;

int main(){
in(R)
if(R<1200)put("ABC")
else if(R<2800)put("ARC")
else put("AGC")
    
}


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

ll divisor=1e9+7;
int main(){
	int n;
	cin>>n;
	int a[n];
	ll sum=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	ll sum2=0;
	ll ans=sum;
	rep(i,n){
		ans=min(ans,abs(sum-sum2*2));
		sum2+=a[i];
	}
	ans=min(ans,abs(sum-sum2*2));
	puts(ans);
}

Measured memory_bytes: 1024
N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]

stc.sort()
counter = 0
array = []

for i in stc:
    s, t, c =  i
    flag = True
    for j in range(len(array)):
        if array[j][0] == s and array[j][2] == c or array[j][0] < s:
            array[j] = [t, s, c]
            flag = False
            array.sort(reverse = True)
            break

    if flag:
        array.append([t, s, c])
        array.sort(reverse = True)
        counter += 1

print(counter)

Measured memory_bytes: 27944
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  vector<string> vec;
  rep(i,0,3){
    cin >> s;
    vec.pb(s);
  }
  t = toupper(vec[1][0]);
  cout << "A" << t << "C" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))

res = [0] * N
allrain = sum(As)
elselast = sum(As[:-1:2]) * 2
res[-1] = allrain - elselast

for idx in range(0, N-1)[::-1]:
    res[idx] = As[idx] * 2 - res[idx + 1]

print(*res)

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

int main(){
    int N;
    cin >> N;
    bool flag = true;
    rep(i,N){
        int A;
        cin >> A;
        if(A % 2 == 0 && !(A % 3 == 0 || A % 5 == 0)) flag = false;
    }
    if(flag){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }


    return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long []l = new long [n+1];
		
		l[0] = 2;
		l[1] = 1;
		
		for(int i = 2; i <= n ;i++) {
			l[i] = l[i-1] + l[i-2];
		}
		System.out.println(l[n]);

	}

}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N, K;
    cin >> N >> K;

    vs32 V(N);
    rep (i, N) cin >> V[i];

    s64 ans = 0;
    s64 temp = 0;
    for (int l = 0; l <= MIN(N, K); ++l)
    {
        for (int r = 0; l + r <= MIN(N, K); ++r)
        {
            temp = 0;
            priority_queue<int> pq;
            rep (i, l)
            {
                if (V[i] < 0) pq.push(-V[i]);
                temp += V[i];
            }
            rep (i, r)
            {
                if (V[N - i - 1] < 0) pq.push(-V[N - i - 1]);
                temp += V[N - i - 1];
            }
            for (int i = 0; i < K - l - r && !pq.empty(); ++i)
            {
                temp += pq.top();
                pq.pop();
            }
            ans = MAX(ans, temp);
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
#道がない場合、infで初期化したい
inf = 10 ** 13 + 1
#input
n, m, l = list(map(int, input().split()))
way = [[inf for i in range(n)] for j in range(n)]
oil = [[400 for i in range(n)] for j in range(n)]

for i in range(m):
    a, b, c, = list(map(int, input().split()))
    way[a - 1][b - 1] = c
    way[b - 1][a - 1] = c

q = int(input())

query = []

for i in range(q):
    query.append(list(map(int, input().split())))

#ワーシャルフロイド法を使い、各道への最短経路を調べる。計算量はO(N**3)
for k in range(n):
    for i in range(n):
        for j in range(n):
            if i == j:
                way[i][j] = 0
                continue
            way[i][j] = min(way[i][j],way[i][k] + way[k][j])
            
#oilの補給できる回数もワーシャルフロイドで求める。まず、一補給でいけるところに辺を張る
for i in range(n):
    for j in range(n):
        if i == j:
            oil[i][j] = 0
        if way[i][j] <= l:
            oil[i][j] = oil[j][i] = 1
#の後でワーシャルフロイド
for k in range(n):
    for i in range(n):
        for j in range(n):
            if i == j:
                oil[i][j] = 0
                continue
            oil[i][j] = min(oil[i][j],oil[i][k] + oil[k][j])

for i in range(q):
    ans = oil[query[i][0] - 1][query[i][1] - 1] - 1
    if way[query[i][0] - 1][query[i][1] - 1] == inf or oil[query[i][0] - 1][query[i][1] - 1] == 400:
        ans = -1
    print(ans)


Measured memory_bytes: 68700
#include <iostream>
using namespace std;
int main() {
    string x;
    cin >> x;

    int diff = 753;
    for (int i=0; i<x.length()-2; i++)
    {
        int y = static_cast<int>(stoi(x.substr(i,3)));
        diff = min(diff, abs(753 - y));
    }
    
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
lst = list(map(int,input().split()))

p = sum(lst)/n
p1 = int(p)
p2 = math.floor(p)
p3 = math.ceil(p)

res = []
tmp = 0
for i in range(n):
    tmp += (lst[i] - p1)**2
res.append(tmp)
tmp = 0
for i in range(n):
    tmp += (lst[i] - p2)**2
res.append(tmp)
tmp = 0
for i in range(n):
    tmp += (lst[i] - p3)**2
res.append(tmp)
print(min(res))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////

int main() {
    int n;
    I(n);
    int ans = -1;
    int ko = 0;
    for(int i = 1; i<= 50000000;i++){
        ko = (ko * 10 + 7) % n;
        if(ko == 0){
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
A, B, K = map(int, input().split())
k = 0
max_val = min(A,B) + 1
L = list(reversed((range(1, min(A,B) + 1))))

for div in L:
	if A%div == 0 and B%div == 0:
		k = k + 1
		if k == K:
			print(div)
			exit()

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

fn main() {
    let n: usize = read();
    let a: Vec<char> = read::<String>().chars().collect();
    let b: Vec<char> = read::<String>().chars().collect();
    let c: Vec<char> = read::<String>().chars().collect();
    
    let mut ans = 0;
    for i in 0..n {
        if a[i] != b[i] {
            if a[i] == c[i] || b[i] == c[i] {
                ans += 1;
            } else {
                ans += 2;
            }
        } else if b[i] != c[i] {
            if a[i] == b[i] || a[i] == c[i] {
                ans += 1;
            } else {
                ans += 2;
            }
        } else if a[i] != c[i] {
            if a[i] == b[i] || b[i] == c[i] {
                ans += 1;
            } else {
                ans += 2;
            }
        }
    }
    println!("{}", ans);
}

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")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  ll a,b,c=0,d=0,e,n,m,ans=0;
  string s,t;
  bool f=false;
  cin>>a>>b;
  a%=b;
  co(min(a,abs(a-b)));
  
  return 0;
}

Measured memory_bytes: 256
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------- fast io --------------------
 
d, t, s = map(int, input().split())
print("Yes" if d / s <= t else "No")


Measured memory_bytes: 62556
r, g, b, n = map(int, input().split())
# r, g, b, n = 13, 1, 4, 3000
# r, g, b, n = 1, 2, 3, 4
counter = 0
for i in range(0,n+1):
    j = 0
    if (n-i) % b == 0:
        while i >= r * j:
            if (i - r * j) % g == 0:
                counter += 1 
                # print(r*j, (i - r*j)/g,(n-i)/b)
            j += 1
print(counter)

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

int main(){
  int x,a=0;
  char s[200];
  signed long long stack[200];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a--;
      stack[a-1]+=stack[a];
    }else if(s[0]=='-'){
      a--;
      stack[a-1]-=stack[a];
    }else if(s[0]=='*'){
      a--;
      stack[a-1]*=stack[a];
    }else{
      x=atoi(s);
      stack[a]=x;
      a++;
    }            
  }
  printf("%lld\n",stack[0]);
  return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>
#include<algorithm>
using namespace std;
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)%2==0)
		printf("%d\n",(a+b)/2);
	else
		printf("%d\n",((a+b)/2)+1);
	return 0;
}

Measured memory_bytes: 128