akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int N = 1e5 + 5;
int dp[N];

int main()
{
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); // no scientific output
    int n; cin>>n;
    vi v;
    rep(i, n)
    {
        int x; cin>>x;
        v.pb(x);
    }
    dp[0] = 0;
    dp[1] = abs(v[1]-v[0]);
    REP(i, 2, n-1)
    {
        dp[i] = min(dp[i-1]+abs(v[i-1]-v[i]), dp[i-2]+abs(v[i-2]-v[i]));
    }
    cout<<dp[n-1];
}



/*before sub
loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
*/

Measured memory_bytes: 1144
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

//#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <time.h>
#include <random>
#include <chrono>
#include <memory>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

#define plus dfghjk
#define minus tyughj
#define y1 tyjnm

using namespace std;

inline void setmin(int &x, int y) { if (y < x) x = y; }
inline void setmax(int &x, int y) { if (y > x) x = y; }
inline void setmin(ll &x, ll y) { if (y < x) x = y; }
inline void setmax(ll &x, ll y) { if (y > x) x = y; }

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = 998244353;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;


int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b / a) << "\n";
    return 0;
}

Measured memory_bytes: 256
import Data.Fixed
main = do
  line <- getLine
  let 
    [a,b] = map read $ words line :: [Int]
    in do 
      putStrLn $ (show $ div a b) ++ " " ++ (show $ mod a b) ++ " " ++ (show $ (read $ show a :: Micro) / (read $ show b :: Micro))



Measured memory_bytes: 4092
#include<iostream>
#include<cmath>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<iomanip>
#include<string>
#include<map>
#define PI 3.14159265
#define mod 998244353  
#define mod1 1e9 + 7  
using namespace std;

double prob(vector<vector<vector<double>>> &vec, double c1 , double c2 , double c3 , double c4 , double n){
  
    double sum = 0;
    if(c4 != n){
        sum += (n / (n - c4));
    }
   
    if(c1 > 0 ){
        if(vec[c1 - 1][c2][c3] == -1)
            vec[c1 - 1][c2][c3] = prob(vec,c1 - 1,c2,c3,c4 + 1,n);
        sum += (c1 / (c1 + c2 + c3)) * vec[c1 - 1][c2][c3];
    }
    if(c2 > 0){
        if(vec[c1 + 1][c2 - 1][c3] == -1)
         vec[c1 + 1][c2 - 1][c3] = prob(vec,c1 + 1,c2 - 1,c3,c4,n);
        sum += (c2 / (c1 + c2 + c3)) * vec[c1 + 1][c2 - 1][c3];
    }
    if(c3 > 0){
    if(vec[c1][c2 + 1][c3 - 1] == -1)
        vec[c1][c2 + 1][c3 - 1] = prob(vec,c1,c2 + 1,c3 - 1,c4,n);

        sum += (c3 / (c1 + c2 + c3)) * vec[c1][c2 + 1][c3 - 1];
    }
   
    vec[c1][c2][c3] = sum;

    return sum;
 }
void func(){
    int n ;
    cin >> n ;
    double count1 = 0 , count2 = 0 , count3 = 0,c4 = 0;

   
    for(int i = 0 ; i < n ; ++i){
        int inp;
        cin >> inp;
        if(inp == 1){
            ++count1;
        }
        else if(inp == 2){
            ++count2;
        }
        else{
            ++count3;
        }
    }
   // cout << count1 << " " << count2 << " " << count3 << "\n";
    vector<vector<vector<double>>> vec(n + 1, vector<vector<double>> (n + 1, vector<double>(n + 1 , -1)));
    //cout << vec[1][2][3];
    double ans = prob(vec,count1,count2,count3 ,c4 , n);
    cout << setprecision(10) << ans << "\n";

}

int main(){
    int t = 1 , cnt = 0 ;
   // cin >> t;
    
    while(t--){
        
        func();
    }
}

Measured memory_bytes: 216960
package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	table := make(map[int]bool)
	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			table[i*j] = true
		}
	}
	ans := "No"
	if table[n] {
		ans = "Yes"
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
s = gets
h = s[0..1].to_i
t = s[2..3].to_i
m = 1..12
case
  when m.include?(t) && m.include?(h)
    puts 'AMBIGUOUS'
  when h >= 0 && m.include?(t)
    puts 'YYMM'
  when t >= 0 && m.include?(h)
    puts 'MMYY'
  else
    puts 'NA'
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD          1000000007
#define PI           3.14159265358979
#define rep(i, n)    for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)   for (auto i : v)
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define pb(x)       push_back(x)
#define mp(x, y)     make_pair((x), (y))
#define fi           first
#define se           second
#define setp(x)      setprecision(x)
#define mset(m, v)   memset(m, v, sizeof(m))
#define OUT(x) cerr << #x << " = " << x << endl
//#define int          long long
//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
static const int INF =        0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long             ll;
typedef vector<int>           vi;
typedef vector<double>        vd;
typedef vector<long long>     vll;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef pair<int, int>        pii;
typedef pair<long, long>      pll;
typedef vector<pii>           vpii;
typedef vector<pll>           vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int main() { 
        int n, m;
        cin >> n >> m;
        int a, b;
        vi cnt(101010, 0);
        rep(i, m) {
                cin >> a >> b;
                cnt[a] ++;
                cnt[b] ++;
        }
        bool f = true;
        rep(i, 101010) if (cnt[i] % 2 == 1) f = false;
        puts(f ? "YES" : "NO");
        return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (double i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    double N, K;
    cin >> N >> K;

    double ans = 0.0;
    repd(i, 1, N + 1) {
        ll tmp = i;
        double cnt = 1;
        while (tmp * cnt < K) cnt *= 2;
        ans += 1.0 / cnt;
    }
    ans /= N;
    printf("%.9lf", ans);
    return 0;
}

Measured memory_bytes: 256
# diverta 2019 Programming Contest
# https://atcoder.jp/contests/diverta2019
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    divisors = make_divisors(N)
    #print(divisors)
    c = 0
    for x in divisors:
        m = int(N / x) - 1
        if m <= x:
            continue
        c += m
    print(c)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

main()


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n);
  vector<int> c(m),d(m);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> c[i] >> d[i];
  }

  for (int i = 0; i < n; i++)
  {
    int mind = 500000000;
    int ans = 0;
    for (int j = 0; j < m; j++)
    {
      int dis = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(dis<mind){
        mind = dis;
        ans=j;
      }
    }
    cout << ans+1 << endl;    
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int field[10][5];

int howManySameColorRight(int i, int j,int color) {
	if (j >= 5) return 0;
	if (field[i][j] == 0) return 0;
	if (color != field[i][j]) return 0;
	if (j == 4 && color == field[i][j]) return 1;
	return howManySameColorRight(i, j + 1, color) + 1;
}

void banishRightN(int i, int j, int n) {
	for (int k = 0; k < n; k++) {
		field[i][j + k] = 0;
	}
}

void moveBlocks(int h) {
	for (int i = 0; i < h - 1; i++) {
		for (int j = 0; j < 5; j++) {
			if (field[i + 1][j] == 0) {
				field[i + 1][j] = field[i][j];
				field[i][j] = 0;
			}
		}
	}
}

int main()
{
	int h;
	cin >> h;
	while (h != 0) {
		rep(i, h) {
			rep(j, 5) cin >> field[i][j];
		}
		ll ans = 0;
		rep(k, 20) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < 5; j++) {
					int blocks = howManySameColorRight(i, j, field[i][j]);
					if (blocks >= 3) {
						ans += blocks * field[i][j];
						banishRightN(i, j, blocks);
					}
				}
			}
			rep(l,100)moveBlocks(h);
			/*cout << "------------" << endl;
			rep(i, h) {
				rep(j, 5) cout << field[i][j] << " ";
				cout << endl;
			}*/
		}
		cout << ans << endl;
		cin >> h;
	}
	


	return 0;
}


Measured memory_bytes: 3080
import java.util.*;

//update 2020/1/1 23:01

public class Main{

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

  public static void main(String[] args) {

    int n = nextInt();
    int k = nextInt();

    int[] num = new int[n];

    int[] a = new int[n];
    for(int i=0;i<k;i++){
      int d = nextInt();
      for(int j=0;j<d;j++){
        num[nextInt()-1]++;
      }
    }

    int ans = 0;


    for(int i=0;i<n;i++){
      if(num[i]==0){
        ans++;
      }
    }

    System.out.println(ans);

    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 41284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int base[100010];
ll sa[100010];
vector<int> mem[100010];
int n, m;

int main()
{
	read(n, m);
	for(int i=1; i<=m; ++i){
		int a, b, d; read(a, b, d);
		if(!base[b]){
			if(!base[a]){
				base[a] = a; sa[a] = 0;
				base[b] = a; sa[b] = d;
				mem[a].pb(a);
				mem[a].pb(b);
			} else {
				base[b] = base[a]; sa[b] = sa[a] + d;
				mem[base[a]].pb(b);
			}
		} else {
			if(base[a]){
				if(base[a] == base[b]){
					if(sa[b]-sa[a] != d){
						puts("No");
						return 0;
					}
				} else {
					if(mem[base[b]].size() > mem[base[a]].size()) swap(a, b), d=-d;
					ll diff = sa[a]+d-sa[b];
					auto& v=mem[base[b]];
					for(int x:v){
						base[x] = base[a];
						sa[x] = sa[x] + diff;
					}
					mem[base[a]].insert(mem[base[a]].end(), all(v));
					v.clear();
				}
			} else {
				base[a] = base[b]; sa[a] = sa[b] - d;
				mem[base[b]].pb(a);
			}
		}
	}
	for(int i=1; i<=n; ++i){
		ll Mx=-2e9, mx=2e9;
		for(int m:mem[i]){
			Mx=max(Mx, sa[m]);
			mx=min(mx, sa[m]);
		}
		if(Mx-mx > ll(1e9)){
			puts("No"); return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 8416
n=int(input())
a = [int(_) for _ in input().split()]
if 0 in a:print(0);exit()
ans=1
for i in a:
    if ans > 10 ** 18:
        print(-1)
        exit()
    ans*=i
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

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

int main() {
	ll K;
	cin >> K;
    if (K%7==0){
      K= K/7;
    }
	if (7 % K == 0) {
		cout << 1 << endl;
	} else {
		ll sum = 0, d = 1, y = 1;
		rep(i, 10*K) {
			sum = (sum+d)%K;
			d = 10 * d % K;
			if (sum == 0) {
				cout << i+1 << endl;
                y=0;
				break;
			}
		}
		if (y == 1) { cout << -1 << endl; }
	}
}


Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main(){
  char a[3],b[3];
  cin>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
  int i=0,k=1;
  for(i;i<3;i++){
    if(a[i]!=b[2-i])k=0;
  }
  if(k>0)cout<<"YES";
  else cout<<"NO";
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if((a + b) % 2 == 0)
    {
        cout << (a + b) / 2;
    }
    else
    {
        cout << "IMPOSSIBLE";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 998244353;
const int N = 1e6 + 5;
const int M = 1e6 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
ll a[N];
bool ok(ll x){
    ll cnt=0;
    rep(i,1,n){
        cnt+=(a[i]+x-1)/x-1;
    }
    return cnt<=k;
}

int main(){
    cin>>n>>k;
    ll r=0;
    rep(i,1,n) cin>>a[i], r=max(r,a[i]);
    ll l=1, ans;
    while(l<=r){
        ll mid=l+r>>1;
        if(ok(mid)) ans=mid, r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}
/*
2
1 5 10
2 15 5
3
2 93 78
1 71 59
3 57 96
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 5208
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
// stores smallest prime factor for every number 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;
vector <ll> v[5001];
int n;
ll k;
int perm[5001]; ll val[5001];
void find_cycles(){
    
    for(int i=0;i<n;i++){
        v[i].push_back(val[perm[i]-1]);
        ll sum=val[perm[i]-1];
        int j=perm[i]-1;
        while(j!=i){
            sum+=val[perm[j]-1];
            v[i].push_back(sum);
            j=perm[j]-1;
        }
    }
    ll ans=-1e15;
    for(int i=0;i<n;i++){
        ll sum=-1e15;
        if(k<v[i].size() || v[i][v[i].size()-1]<=0){
            for(int j=0;j<min(k,(ll)v[i].size());j++){
                sum=max(sum,v[i][j]);
            }
        }else{
            
            ll val=(k)/(ll)v[i].size();
            if(k%(ll)v[i].size()==0){
                val--;
            }
            sum=max((v[i][v[i].size()-1])*val,sum);
            ll rem=(k)-(ll)v[i].size()*val;
            for(int j=0;j<rem;j++){
                sum=max(sum,v[i][j]+(v[i][v[i].size()-1])*(val));
            }
            
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
}
int main(){
    fastio();
        //write code here
        cin>>n;
        cin>>k;
        for(int i=0;i<n;i++) cin>>perm[i];
        for(int i=0;i<n;i++) cin>>val[i];
        find_cycles();
    return 0;
}

 

Measured memory_bytes: 218652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 4e5 + 123, MOD = 1e9 + 7;
int n, X, Y, mn[N], cnt[N], fact[N], rev[N], inv[N], used[N], P[N], S[N], w[N];
array <int, 2> p[N];
vector <int> g[N];

void dfs(int v) {
	if (v < n) cnt[p[v][1]]++;
	used[v] = 1;
	for (int to : g[v]) {
		if (used[to]) continue;
		dfs(to);
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	fact[0] = rev[0] = inv[1] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = (ll)fact[i - 1] * i % MOD;
		if (i > 1) {
			int x = (i - MOD % i) % i;
			inv[i] = (ll)inv[x] * ((MOD + x) / i) % MOD;
		}
		rev[i] = (ll)rev[i - 1] * inv[i] % MOD;
	}
	memset(& mn, 0x3f, sizeof(mn));
	cin >> n >> X >> Y;
	for (int i = 0; i < n; i++) {
		cin >> p[i][1] >> p[i][0];
		mn[p[i][1]] = min(mn[p[i][1]], p[i][0]);
	}
	P[0] = mn[0] = S[n + 1] = mn[n + 1];
	for (int i = 1; i <= n; i++)
		P[i] = min(P[i - 1], mn[i]);
	for (int i = n; i >= 1; i--)
		S[i] = min(S[i + 1], mn[i]);
	for (int i = 1; i <= n; i++)
		w[i] = min(P[i - 1], S[i + 1]);
	for (int i = 0; i < n; i++) {
		if (p[i][0] <= Y - w[p[i][1]])
			g[n].pb(i), g[i].pb(n);
		if (p[i][0] <= X - mn[p[i][1]])
			g[n + p[i][1]].pb(i), g[i].pb(n + p[i][1]);
	}
	dfs(n);
	int res = 1, s = 0;
	for (int i = 1; i <= n; i++) {
		res = (ll)res * rev[cnt[i]] % MOD;
		s += cnt[i];
	}
	res = (ll)res * fact[s] % MOD;
	cout << res;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i=0;i<n;i++){
            int num = input.nextInt();
            list.add(num);
        }
        iSort(list,n);
    }

    private static void iSort(List<Integer> list, int n){
        int count=0;
        List<Integer> sbList = new ArrayList<>(list);
        for(int num : list){
            for(int i = count-1; i >= 0 && sbList.get(i)>num; i--){
                sbList.set(i+1,sbList.get(i));
                sbList.set(i,num);
            }
            count++;

            for(int i = 0; i < list.size(); i ++){
                if(i == n-1)System.out.println(sbList.get(i));
                else System.out.print(sbList.get(i) + " ");
            }
        }
    }

}



Measured memory_bytes: 32612
N=int(input())
xy = [0]*N

for i in range(N):
    xy[i]=list(map(int, input().split()))


ans = N

for i in range(N):
    x0 = xy[i][0]
    y0 = xy[i][1]
    # print(x0,y0)
    for j in range(i+1,N):
        ans_sub = N
        vecx = xy[j][0]-x0
        vecy = xy[j][1]-y0
        # print(vecx,vecy)
        for z in range(N):
            if [xy[z][0]+vecx,xy[z][1]+vecy] in xy:
                ans_sub -= 1
        
        if ans_sub < ans:
            ans = ans_sub

print(ans)




Measured memory_bytes: 42076
#include <cstdio>
#include <algorithm>
using namespace std;

int W, H;

struct X {
    int t;
    int v;

    bool operator < (const X& x) const {
        return v < x.v;
    }
};

X cost[200000];


int main() {
    scanf("%d%d", &W, &H);
    int n = 0;
    for (int  i = 0; i < W; i++) {
        int p;
        scanf("%d", &p);
        cost[n].t = 0, cost[n].v = p;
        n++;
    }
    for (int i = 0; i < H; i++) {
        int q;
        scanf("%d", &q);
        cost[n].t = 1, cost[n].v = q;
        n++;
    }
    sort(cost, cost + n);

    typedef long long ll_t;
    ll_t res = 0;
    int x[2] = {0, 0};
    for (int i = 0; i < n; i++) {
        if (cost[i].t == 0) {
            res += (ll_t) cost[i].v * (H + 1 - x[1]);
            x[0]++;
        } else {
            res += (ll_t) cost[i].v * (W + 1 - x[0]);
            x[1]++;
        }
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1664
n,k=map(int,input().split())
l =[]
cnt =0
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        l.append(j)

for i in range(1,n+1):
    if i not in l:
        cnt+=1

print(cnt)

Measured memory_bytes: 9188
#include<iostream>
#include<vector>
using namespace std;
int main(){
 int n;
 long long t;
 cin>>n>>t;
 long long  t0;
 long long  sum = 0;
cin>>t0;
 for(int i=1;i<n;i++){
  long long tn;cin>>tn;
  if(tn - t0 < t){
      sum += tn -t0;
  }else{
       sum += t;
 }
 t0 = tn;
} 
cout<<sum+t<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this


void solve(){
    ll n; cin>>n;

    vector<ll> graph[n+1];
    ll to_be_made = n;

    if(n%2 == 0) to_be_made++;

    vector<pair<ll,ll>> pairs;
    for(ll i=1;i<=n/2;i++){
        pairs.push_back({i,to_be_made-i});
    }

    for(ll i=0;i<pairs.size();i++){
        for(ll j=i+1;j<pairs.size();j++){
            graph[pairs[i].first].push_back(pairs[j].first);
            graph[pairs[i].first].push_back(pairs[j].second);
            graph[pairs[i].second].push_back(pairs[j].first);
            graph[pairs[i].second].push_back(pairs[j].second);
        }
        if(n%2 == 1){
            graph[n].push_back(pairs[i].first);
            graph[n].push_back(pairs[i].second);
        }
    }

    vector<pair<ll,ll>> edges;

    for(ll i=1;i<=n;i++){
        for(ll v:graph[i]){
            edges.push_back({i,v});
        }
    }

    cout<<edges.size()<<endl;

    for(auto x:edges){
        cout<<x.first<<" "<<x.second<<endl;
    }
}

signed main(){


    FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    while(t--) solve();
    
}

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

#define fi first
#define se second
#define MAX 40000000000000001

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

int N,M;
pii A[100],B[100];

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < N; i++)scanf("%d%d",&A[i].fi ,&A[i].se);
    for(int i = 0; i < M; i++)scanf("%d%d",&B[i].fi ,&B[i].se);

    for(int i = 0; i < N; i++)
    {
        ll MIN = MAX;int ans = 0;
        for(int j = 0; j < M; j++)
        {
            if(abs(A[i].fi - B[j].fi) + abs(A[i].se - B[j].se) < MIN)
            {
                MIN = abs(A[i].fi - B[j].fi) + abs(A[i].se - B[j].se);
                ans = j + 1;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		int count = 1;
		while(true){
			 int i = sc.nextInt();
			 if(i == 0){
				 break;
			 }
		
		System.out.println("Case" + " " + count + ":" + " " + i);
		count++;
		}
		}
	}

Measured memory_bytes: 41672
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){

    string s,t;
    cin >> s >> t;
    int ans = 1000000;
    rep(i,0,s.size()-t.size()+1){
        int match = 0;
        rep(j,0,t.size()){
            if(s[i+j]==t[j]){
                match++;
            }
        }
        int Size = t.size();
        ans = min(ans,Size-match);
    }
    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 3624
SDResult = []
index = 0
dataSetNum = 0
while True:
    dataNum = int(input())
    if dataNum == 0:
        break
    else:
        dataSetNum += 1
        dataSet = [int(i) for i in input().split()]
        dataSetAvg = sum(dataSet)/len(dataSet)
        SDPow2 = 0
        for index in range(len(dataSet)):
            SDPow2 += ((dataSet[index] - dataSetAvg)**2) / dataNum
        SD = SDPow2 ** (1/2)
        SDResult.append(SD)

for index in range(dataSetNum):
    print(SDResult[index])


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

int main()
{
    int n, m, sum = 0;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    int ans = n - sum;

    if (ans < 0)
        ans = -1;

    cout << ans;
}

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

using namespace std;

const int MAXN=1024;
const int MOD=1e9+7;
int f[MAXN][MAXN];
char m[MAXN][MAXN];
int h,w;

int main(){
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>m[i][j];
		}
	}
	f[0][1]=1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(m[i][j]!='#'){
				f[i][j]=f[i-1][j]+f[i][j-1];
				f[i][j]%=MOD;
			}
		}
	}
	cout<<f[h][w]<<endl;
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <map>
#include <queue>
#include <algorithm> 
#include <cstring>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pb push_back
int fa[3000005];
int sum[3000005];
int find(int x)
{
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
vector<int>ty[3000005];
int main(int argc, char** argv) {
	int n,m,k;
	cin>>n>>m>>k;
	rep(i,0,n+1)fa[i]=i,sum[i]=1;
	rep(i,1,m)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		int x=find(l),y=find(r);
		ty[l].pb(r);
		ty[r].pb(l);
		if(x!=y)
		{
			fa[x]=y;
			sum[y]+=sum[x];
		}
	}
	rep(i,1,k)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		ty[l].pb(r);
		ty[r].pb(l);
	} 
	rep(i,1,n)
	{
		int ans=sum[find(i)]-1;
	//	cout<<ans<<"?";
		if(ty[i].size())
		rep(j,0,ty[i].size()-1)
		{
			if(find(i)==find(ty[i][j])){
				ans--;
			}
		}
		printf("%d ",ans);
	}
	return 0;
}

Measured memory_bytes: 79224
import sys
lines = [l.rstrip() for l in sys.stdin.readlines()]
n = int(lines[0])
s = lines[1]

r = 0
for c in range(len(s) - 2):
    if s[c] == "A" and s[c+1] == "B" and s[c+2] == "C":
        r += 1
        c += 2

print(r) 



Measured memory_bytes: 3060
#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>;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x) {
        return Size[root(x)];
    }
};

int main()
{
    int N, M, K; cin >> N >> M >> K;

    UnionFind uf(N);
    vector<vector<int>> nears(N);
    int a = 0, b = 0;

    rep(i, M) {
        cin >> a >> b;
        a--; b--;
        nears[a].push_back(b);
        nears[b].push_back(a);
        uf.merge(a, b);
    }

    vector<int> ans(N);
    rep(i, N) {
        ans[i] = uf.size(i) - nears[i].size() - 1;
    }

    int c = 0, d = 0;
    rep(i, K) {
        cin >> c >> d;
        c--; d--;

        if (uf.issame(c, d)) {
            ans[c]--;
            ans[d]--;
        }
    }
    
    rep(i, N) {
        cout << ans[i];
        if (i < N - 1)
            cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 8696
n,k=map(int,input().split())
s=input()
s_dimlist=[s[i+1]==s[i] for i in range(n-1)]
s_seqcnt=[]
if s[0]=='0':
    s_seqcnt.append(0)
pre=-1
for i in range(n-1):
    if not s_dimlist[i]:
        s_seqcnt.append(i-pre)
        pre=i
s_seqcnt.append(n-1-pre)
if s[n-1]=='0':
    s_seqcnt.append(0)
# print(s_dimlist)
# print(s_seqcnt)
width=2*k+1
length=len(s_seqcnt)
s_sum=[0 for i in range(length//2+length%2)]
s_ruiseki=[0 for i in range(length+1)]
s_ruiseki[0]=0
s_ruiseki[1]=s_seqcnt[0]
for i in range(1,length):
    s_ruiseki[i+1]=s_seqcnt[i]+s_ruiseki[i]
# print(s_ruiseki)
for i in range(length//2+length%2):
    num=0
    if 2*i+width-1>=length:
        s_sum[i]=s_ruiseki[length]-s_ruiseki[2*i]
        break
    else:
        s_sum[i]=s_ruiseki[2*i+width]-s_ruiseki[2*i]
# print(s_sum)
print(max(s_sum))


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

int main() {
  int A, B,sum,c1,c2,c3,c4,c5,LA;
  cin>>A>>B;
  
  for(int i=A;i<=B;i++){
    for(int j=4;j>-1;j--){
      sum=1;
    	for(int k=0;k<j;k++){
        sum *=10;
        }
     	if(j==4){
        c1 = i/sum;
        }
        if(j==3){
        c2 = i%(10000)/sum;
        }
        if(j==2){
        c3 = i%(1000)/sum;
        }
        if(j==1){
        c4 = i%(100)/sum;
        }
        if(j==0){
        c5 = i%(10)/sum;
        }
    }  
    if (c1==c5&&c2==c4){
  		LA +=1;
    
    }
  

    }
  cout<<LA<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#define LONG 100005

typedef struct po
{
  char name[100];
  int time;
}P;

P Que[LONG];
int head,tail,n;

P deque()
{
  P x =Que[head];
  head=(head+1)%LONG;
  return x;
}

void enqu(P x)
{
  Que[tail]=x;
  tail = (tail + 1)%LONG;
}

int min(int a,int b)
{
  return a<b ?a:b;
}

int main()
{
  int lap=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++)
    {
      scanf("%s",Que[i].name);
      scanf("%d",&Que[i].time);
    }
  head=1;tail = n+1;
  while(head!=tail)
    {
      u = deque();
      c = min(q,u.time);
      u.time-=c;
      lap +=c;
      if(u.time>0)enqu(u);
      else
	{
	  printf("%s %d\n",u.name,lap);
	}
    }
  return 0;
}

Measured memory_bytes: 10756
import heapq

N,T = map(int,input().split())
A = list(map(int,input().split()))

h = []
B = [0]*N

for i in range(N):
    heapq.heappush(h,A[i])
    B[i] = h[0]

j = []
C = [0]*N

for i in range(N-1,-1,-1):
    heapq.heappush(j,-A[i])
    C[i] = -j[0]

B = B[:-1]
C = C[1:]
D = list(map(lambda x:C[x]-B[x],range(N-1)))
t = max(D)

s = 0
D.append(0)
for i in range(N-1):
    if D[i] == t and D[i] > D[i+1]:
        s += 1

print(s)


Measured memory_bytes: 21860
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5+5;
int N;
int f[maxN][3];
int a[3][maxN];
int main() {
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> a[0][i] >> a[1][i] >> a[2][i];
    for(int i = 1; i <= N; ++i) {
        f[i][0] = max(f[i-1][1], f[i-1][2]) + a[0][i];
        f[i][1] = max(f[i-1][0], f[i-1][2]) + a[1][i];
        f[i][2] = max(f[i-1][0], f[i-1][1]) + a[2][i];
    }
    cout << max(f[N][0], max(f[N][1], f[N][2])) << endl;
}


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

void d(vector<vector<int>> v,int h){
	for(int i=0;i<h;i++){
		for(int j=0;j<v[i].size();j++){
			cout<<v[i][j]<<" ";
		}
		cout<<"\n";
	}
	cout<<"\n";
}

int main (){
	int h;
	while(cin>>h && h){
		vector<vector<int>> v(h,vector<int>(5));
		for(int i=0;i<h;i++)for(int j=0;j<5;j++)cin>>v[i][j];
		int ans=0;
		while(1){
			int flag=true;
			for(int i=0;i<h;i++){
				int chain;
				for(int j=0;j<5;j++){
					chain=1;
					while(j+1<5 && v[i][j]!=-1 && v[i][j]==v[i][j+1]){
						chain++;
						j++;
					}
					if(chain>=3){
						flag=false;
						ans+=chain*v[i][j];
						for(int k=0;k<chain;k++){
							v[i][j-chain+k+1]=-1;
						}
						break;
					}
				}
			}
			//d(v,h);
			for(int p=0;p<h;p++){
				for(int i=0;i<5;i++){
					for(int j=h-1;j>=1;j--){
						if(v[j][i]==-1){
							for(int k=j;k>=1;k--)swap(v[k][i],v[k-1][i]);
						}
					}
				}
			}

			//d(v,h);
			if(flag)break;
		}
		cout<<ans<<endl;
	}


}

/*
5 8 105
8 5 105
1 2 24
99 98 24
12 13 26
1 22 23
1 13 201
13 16 112
2 24 50
1 82 61
1 84 125
1 99 999
99 1 999
98 99 999
1 99 11
99 1 12
0 0 0
*/


Measured memory_bytes: 3136
# 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 ll long long
# define ld long double
# define pb push_back
# define ppb pop_back

const ll N = 1e5 + 10;
const ll M = 1e7 + 1000;
const ll mod = 998244353;
const ll INF = 1e18;
const ll inf = -1e18;

///typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> void_set;

bool isprime(ll x) {
    if(x == 1) return false;
    ll y = sqrt(x);
    for(int i = 2;i <= y;i++) {
        if(x % i == 0) {
            return false;
        }
    }
    return true;
}

ll bin_pow(ll a, ll b) {
    if(b == 0) return 1;
    if(b == 1) return a;
    if(a == 0) return 0;
    if(a == 1) return a;
    if(b % 2 == 0) {
        ll pw = bin_pow(a, b / 2);
        return pw * pw;
    } else {
        return bin_pow(a, b - 1) * a;
    }
}

const ld pi = acos(-1);

ll a, b, k, ans;
ll us[N];
vector <ll> v;

int main() {
    ///ios_base::sync_with_stdio(false);
    ///cin.tie(NULL), cout.tie(NULL);
    ///setlocale(0,"RUS");
    ///ifstream cin("input.txt");
    ///ofstream cout("output.txt");
    cin >> a >> b;
    for(ll i = 1;i * i <= a;i++) {
        if(a % i == 0) {
            if(a % i == 0 && b % i == 0) v.pb(i);
            if(a / i > i && b % (a / i) == 0) v.pb(a / i);
        }
    }
    for(int i = 0;i < v.size();i++) {
        if(isprime(v[i]) == true) {
            ans++;
        }
    }
    cout << ans + 1;
}
/**
**/



Measured memory_bytes: 384
#include <stdio.h>

int main(){

    unsigned long int a,b,k,answer;

    scanf("%lu%lu%lu",&a,&b,&k);
    if(a<=k){
        
        if(b<=k-a){
            b=0;
        }
        
        else{
            b=b-(k-a);
        }
        a=0;
    }
    else{
        a=a-k;
    }

    printf("%lu %lu",a,b);
   
    return 0;
}


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

using namespace std;

const int   N   = 3e3 + 1;
const int   inf = 1e9 + 7;

vector<int> g[N];

int n, a[N];

int dfs(int u,int p)   {
	bool win = 0;
	for(int v : g[u])
		if(v != p && a[v] < a[u])
			win |= (dfs(v,u) ^ 1);
	return win;
}

int main()  {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	
	for(int i = 1 ; i <= n ; ++i)
		cin >> a[i];
	
	for(int i = 1 ; i < n ; ++i)    {
		int x, y;   cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	for(int i = 1 ; i <= n ; ++i)
		if(dfs(i,0))    cout << i << " ";
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if (b%a==0) cout<<a+b<<endl;
    else cout<<b-a<<endl;
    
}

Measured memory_bytes: 256
use proconio::input;


fn main() {

let mut _a : i128 ;
let mut _b : i128 ;
let mut _c : i128 ;


    input! {

       a : i128 ,
       b : i128 ,
       c : i128 ,

    }
    

if a == b && b == c  {
    println!("No");
}else if a != b && b != c && c != a {
    println!("No");
}else {
    println!("Yes");
}


}


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

int main() {
    int N;
    cin >> N;
    int a;
    vector <int> rate(10);
    for(int i=0;i<N;i++){
        cin >> a;
        if(a<3200) rate[a/400]++;
        else rate[8]++;
    }
    int sum=0;
    for(int i=0;i<=7;i++){
        if(rate[i]) sum++;
    }
    cout << max(1,sum) << " " << sum+rate[8] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
    string a={};
    cin>>a;
    bool determinate = true;
    int count[26]={};
    for (int i=0; i<a.size(); i++)
    {
        count[a[i]-'a']+=1;
    }
    
    for (int i=0; i<a.size(); i++)
    {
        if(count[i] >1)
        {
            determinate =false;
        }
    }
    
    if (determinate==true)
    {
        cout<<"yes";
    }
    else if(determinate==false)
    {
        cout<<"no";
    }
    return 0;
}

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

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int ans = 1;
  for (ll i = 2; i * i <= g; i++) {
    if (g % i) {
      continue;
    }
    ans++;
    while (g % i == 0) {
      g /= i;
    }
  }
  if (g != 1) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> t(n), x(n), y(n);
    rep(i, n) cin >> t[i] >> x[i] >> y[i];
    rep(i, n)
    {
        if (x[i] + y[i] > t[i] || (x[i] + y[i]) % 2 != t[i] % 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

bool P[31623];

int main() {

    int n;
    cin >> n;

    fill(P, P + 31623, true);
    P[0] = P[1] = false;

    for (int i = 2; i <= sqrt(n); i++) {
        if (P[i]) {
            for (int j = i * 2; j <= sqrt(n); j += i) {
                P[j] = false;
            }
        }
    }

    cout << n << ":";

    for (int i = 2; i <= sqrt(n); i++) {
        if (P[i] && n % i == 0) {
            do {
                cout << " " << i;
                n /= i;
            } while (n % i == 0);
        }
    }

    if (n != 1) cout << " " << n;

    cout << endl;
}


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

int main()
{
    int x[5];
    int geras = 0;
    for(int i = 0; i < 5; i++)
    {
        cin >> x[i];
        if(x[i]==0)geras = i;
    }
    cout << geras+1;

}


Measured memory_bytes: 3192
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
 
class Main
{
	static class Pair implements Comparable
	{
		int first;
		double second;
		
		public Pair(int f, double s)
		{
			first = f;
			second = s;
		}
		
		public String toString()
		{
			return first + " " + second;
		}
		
		public int compareTo(Object o)
		{
			Pair p2 = (Pair)o;
			if(this.first < p2.first)
				return -1;
			if(this.first > p2.first)
				return 1;
			if(this.second < p2.second)
				return -1;
			if(this.second > p2.second)
				return 1;
			return 0;
		}
	}
	
	static int log2(double a)
	{
		return (int)(Math.log(a) / Math.log(2));
	}
	
	static long gcd(long a, long b)
	{
		long r;
		while((r = a % b) > 0)
		{
			a = b;
			b = r;
		}
		return b;
	}
	
	static long boundary(double x1, double y1, double x2, double y2)
	{
		if((long)x1 == (long)x2)
			return (long)Math.abs(y1 - y2) + 1;
		if((long)y1 == (long)y2)
			return (long)Math.abs(x1 - x2) + 1;
		long a = (long)Math.abs(y1 - y2);
		long b = (long)Math.abs(x1 - x2);
		long d = gcd((long)a, (long)b);
		a /= d;
		b /= d;
		return Math.min((long)Math.abs(x1 - x2) / b + 1, (long)Math.abs(y1 - y2) / a + 1);
	}

	static long square(long x)
	{
	    return x * x;
	}

	
	public static void main(String[] args) throws IOException
	{
		String s = in.next();
		if(s.length() < 4)
		{
			sop("No");
			return;
		}
		if(s.substring(0, 4).equals("YAKI"))
			sop("Yes");
		else
			sop("No");
	}
    
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	
    static FastReader in = new FastReader();
  
    public static void sop(Object o)
    {
    	System.out.print(o);
    }
}

Measured memory_bytes: 23124