akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S, &T)
	can := true

	chMap := make(map[rune][]int)

	for i, c := range T {
		chMap[c] = append(chMap[c], i)
	}

	for _, arr := range chMap {
		if len(arr) == 0 {
			continue
		}

		po := S[arr[0]]
		for _, r := range arr[1:] {
			if po != S[r] {
				can = false
			}
		}
	}

	chMap = make(map[rune][]int)
	for i, c := range S {
		chMap[c] = append(chMap[c], i)
	}

	for _, arr := range chMap {
		if len(arr) == 0 {
			continue
		}

		po := T[arr[0]]
		for _, r := range arr[1:] {
			if po != T[r] {
				can = false
			}
		}
	}

	if can {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  double ave = 0;
  REP(i, n) ave += a[i];
  ave /= n;

  ll idx = 0;
  double mi = INF;
  REP(i, n) {
    if(abs(ave - a[i]) < mi) {
      mi = abs(ave - a[i]);
      idx = i;
    }
  }
  cout << idx << endl;

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules! dbg { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; }

#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        m: usize,
    }
    let mut r = x;
    let mut l = vec![x];
    let mut set = BTreeSet::new();
    set.insert(x);
    loop {
        r = (r * r) % m;
        l.push(r);
        if set.contains(&r) {
            break;
        }
        set.insert(r);
    }
    let l_len = l.len();
    let mut ans = 0;
    let mut k1 = 0;
    for i in 0..l_len {
        if l[i] == l[l_len - 1] {
            k1 = i;
            break;
        }
        ans += l[i];
    }
    l.pop();
    let k2 = l_len - k1 - 1;
    let mut ll = l[k1..]
        .iter()
        .scan(0, |arr, a| {
            *arr += a;
            Some(*arr)
        })
        .collect::<Vec<_>>();
    ll.insert(0, 0);
    if n > k1 {
        ans += ll[k2] * ((n - k1) / k2) + ll[(n - k1) % k2];
    }
    println!("{}", ans);
}


Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int main(void)
{
	int k,s,i,j,x,y,z,sum,cnt=0;
	cin>>k>>s;
	for(j=0;j<=k;j++){
		for(i=0;i<=k;i++){
			x=i;
			y=j;
			z=s-x-y;
			if(z>=0 && z<=k) cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

const int b[7] = {0,9,12,15,18,21,30};
inline bool check(const vector<int> &c){
  for(int x=0;x<6;x++){
    for(int i=b[x];i<b[x+1]-1;i++)if(c[i]!=c[i+1])return false;
  }
  return true;
}

inline void rot(vector<int> &c, int d){
  if(d==0){
    swap(c[0],c[23]); swap(c[3],c[26]); swap(c[6],c[29]);
    swap(c[15],c[17]); swap(c[9],c[20]);
  }else if(d==1){
    swap(c[6],c[21]); swap(c[7],c[22]); swap(c[8],c[23]);
    swap(c[9],c[11]); swap(c[12],c[17]);
  }else if(d==2){
    swap(c[2],c[21]); swap(c[5],c[24]); swap(c[8],c[27]);
    swap(c[12],c[14]); swap(c[11],c[18]);
  }else{
    swap(c[0],c[27]); swap(c[1],c[28]); swap(c[2],c[29]);
    swap(c[18],c[20]); swap(c[14],c[15]);
  }
}

int rec(int d, vector<int> &c, int prv){
  if(check(c))return d;
  if(d>=8)return 8;

  int res = 8;
  for(int i=0;i<4;i++){
    if(i==prv)continue;
    rot(c,i);
    res = min(res,rec(d+1,c,i));
    if(res==d)break;
    rot(c,i);
  }
  return res;
}

int main(){
  int t;
  scanf("%d",&t);
  while(t--){
    vector<int> p(30);
    for(int i=0;i<30;i++)scanf("%d\n",&p[i]);
    printf("%d\n",rec(0,p,-1));
  }
}

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

int main()
{
    int N, W;
    cin >> N >> W;
    vector<int> w(N, 0), v(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j - w[i - 1] >= 0)
            {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << *max_element(dp[N].begin(), dp[N].end()) << endl;

    return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll n;
    string s;
    cin >> n >> s;
    if(sz(s)>n)
        cout << s.substr(0,n) << "..." << endl;
    else 
        cout << s << endl;

}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 3616
num = input().split()
 
a = int(num[0])
b = int(num[1])
c = int(num[2])
 
if a <= b <= c :
  print(a,b,c);
elif a <= c <= b :
  print(a,c,b);
elif b <= a <= c:
  print(b,a,c)
elif b <= c <= a:
  print(b,c,a)
elif c <= a <= b:
  print(c,a,b)
else:
  print(c,b,a)

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

int N,I,J,K;
vector< vector< vector<double> > > dp;

double exp(int i, int j, int k) {
  if (dp[i][j][k] >= 0) return dp[i][j][k];
  double ret = (double)N / (i+j+k);
  if (i > 0) {
    ret += exp(i-1,j,k) * (double)i / (i+j+k);
  }
  if (j > 0) {
    ret += exp(i+1,j-1,k) * (double)j / (i+j+k);
  }
  if (k > 0) {
    ret += exp(i,j+1,k-1) * (double)k / (i+j+k);
  }
  dp[i][j][k] = ret;
  return ret;
}

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int a;
    cin >> a;
    switch(a){
      case 1: I++; break;
      case 2: J++; break;
      case 3: K++; break;
    }
  }
  dp = vector<vector<vector<double> > >(N+1, vector<vector<double> >(N+1, vector<double>(N+1, -1.0)));
  dp[0][0][0] = 0;
  cout << setprecision(12) << exp(I,J,K) << endl;
}

Measured memory_bytes: 216960
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int c,a,n;
    cin >> c >> a >> n;
    
    int sum = 0;

    
    while(c > 0 && a > 0 && n > 0){
      c--;
      a--;
      n--;
      sum++;
    }
    
    while(c >= 2 && a >= 1){
      c-=2;
      a--;
      sum++;
    }
    
    while(c >= 3){
      c-=3;
      sum++;
    }

    cout << sum << endl;
    //cout << c << ' ' << a << ' ' << n << endl;
  }

  return 0;
}



Measured memory_bytes: 3196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

void solve(vi& rs,vi& es,vi& as)
{
	int rsize=rs.size();
	int n=es.size()-1;
	int m=0;
	rep(i,n+1) if(es[i]==2) m+=as[i];
	
	vvd dp(n+1,vd(m+1)); // [現在のマス][所持金の最大値] => その状態にある確率
	dp[0][0]=1;
	rep(i,n) rep(j,m+1) rep(k,rsize){
		int next=min(i+rs[k],n);
		int money=j;
		if(es[next]==0)
			;
		else if(es[next]==1)
			next=min(next+as[next],n);
		else if(es[next]==2)
			money+=as[next];
		else if(es[next]==3)
			money=max(money-as[next],0);
		dp[next][money]+=dp[i][j]/rsize;
	}
	
	double res=0;
	rep(i,m+1)
		res+=i*dp[n][i];
	cout<<floor(res+EPS)<<endl;
}

int main()
{
	for(int x,y,z;cin>>x>>y>>z,x|y|z;){
		vi rs(x);
		rep(i,x) cin>>rs[i];
		vi es(y+1),as(y+1);
		rep(i,z){
			int n,e,a; cin>>n>>e>>a;
			es[n]=e; as[n]=a;
		}
		solve(rs,es,as);
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
int main()
{
  int A[100], N, i, j, key;
  scanf("%d", &N);
  for(i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  for(i = 0; i < N; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j + 1] = A[j];
      j--;
      A[j + 1] = key;
    }
    for(j = 0; j < N; j++){
      printf("%d", A[j]);
      if(j != N - 1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int pizzaA = inpt[0];
        int pizzaB = inpt[1];
        int pizzaAB = inpt[2];

        long mustA = inpt[3];
        long mustB = inpt[4];

        List<long> price = new List<long>();
        price.Add(pizzaA * mustA + pizzaB * mustB);

        long tmpAB = mustA * 2;
        long tmpB = Math.Max(0, mustB - mustA);
        price.Add(tmpAB * pizzaAB + tmpB * pizzaB);

        tmpAB = mustB * 2;
        long tmpA = Math.Max(0, mustA - mustB);
        price.Add(tmpAB * pizzaAB + tmpA * pizzaA);

        tmpAB = Math.Max(mustA, mustB) * 2;
        price.Add(tmpAB * pizzaAB);
        Console.WriteLine(price.Min());


    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


1500 2000 1900 3 2


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
n = gets.to_i
a1 = gets.split(" ").map(&:to_i)
a2 = gets.split(" ").map(&:to_i)

max = -1
n.times do |i|
  sum = a1[0..i].inject(:+) + a2[i..n].inject(:+)
  max = sum if sum > max
end

puts max

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	int pos = S.find("ABC");

	while(pos != string::npos) {
		ans++;
		pos = S.find("ABC", pos+3);
	}
	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
A,B,C = [int(i) for i in input().split()]

if A%2+B%2+C%2 != 0:
    print(0)
    exit()


p = [set([A,B,C])]
cnt = 1
while True:
    a = B//2+C//2
    b = A//2+C//2
    c = A//2+B//2
    if a%2+b%2+c%2 != 0:
        print(cnt)
        exit()
    if set([a,b,c]) in p:
        print(-1)
        exit()
    else:
        p.append(set([a,b,c]))
        A = a
        B = b
        C = c
        cnt += 1


Measured memory_bytes: 9136
#include <stdio.h>

#define MAX_N 100000

int main(void) {
    int n;
    int h[MAX_N];
    int score[MAX_N];
    int largest = 0;

    scanf("%d\n", &n);

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        h[i] = x;
    }

    score[n-1] = 0;

    for (int i = n-2; i >= 0; i--) {
        if (h[i] >= h[i+1]) {
            score[i] = score[i+1] + 1;
        } else {
            score[i] = 0;
        }

        if (score[i] > largest) {
            largest = score[i];
        }
    }

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

    return 0;
}


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

long long solve(long long n)
{
  long long a = n / 4 * 4;
  long long mask = 0;
  for(long long i = a; i < n; i++)
    mask ^= i;
  return mask;
}
int main()
{
  long long a, b;
  scanf("%lld%lld", &a, &b);
  printf("%lld\n", solve(b + 1) ^ solve(a));
  return 0;
}

Measured memory_bytes: 384
def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        count = 0
        if i % 2 == 0:
            continue
        for j in range(1, i+1):
            count += 1 if i % j == 0 else 0
        if count == 8:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
          long long int n,m,i=1;
          cin >> n >> m;
          long int x = max(n,m);
          long int y = min(n,m);
          while(1)
          {
                    if((x * i) % y == 0)
                              break;
                              i++;
          }
          cout << x * i << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    char[] cs;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        cs = sc.nextLine().toCharArray();
    }

    private void solve() {
        boolean flg = false;
        for (int i = 0; i < cs.length-1; i++) {
            if (cs[i] == 'A' && cs[i+1] == 'C')
                flg = true;
        }
        if (flg)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 20688
"use strict";
function main(input) {
    let line = input.split("\n");
    const K = parseInt(line[0]);
    let arr = line[1].split(" ");
    const A = parseInt(arr[0]);
    const B = parseInt(arr[1]);
    if (A <= (B % K ? (B / K | 0) * K : B)) {
        console.log("OK");
    } else {
        console.log("NG");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29584
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n, k;
  cin >> n >> k;
  vector <int> p(n);
  rep(i,n) cin >> p.at(i);

  sort(all(p));

  int ans = 0;
  rep(i,k) ans += p.at(i);
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}

//radian → degree
long double chg_RadDeg(long double rad) {
	return rad * 180.0 / PI;
}
 
//桁数
ll CountDigit(ll n) {
	ll digit = 1;
	while ((n /= 10) != 0) digit++;
	return digit;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//abs()平均
//pow(,)累乗


//提出コード↓


ll n, m, ans;


int main() {
	cin >> n >> m;
	while (n >= 2) {
		ans += n - 1;
		n--;
	}
	while (m >= 2) {
		ans += m - 1;
		m--;
	}
	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	String S = sc.next();
	String day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	boolean bl = true;

	for (int i = 1; i < 7; i++) {
	    if (S.equals(day[i])) {
		System.out.println(7 - i);
		bl = false;
	    }
	}

	if (bl)
	    System.out.println(7);
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;

int main(){
	ll tot = 1LL, x, lim = 1e18;
	int n;
	bool io = true;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lld", &x);
		if(x == 0) return !printf("0");
		if(!io) continue;
		if(x > lim / tot) io = false;
		tot *= x;
	}
	if(!io) return !printf("-1");
	printf("%lld", tot);


}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int m,d;
  cin >> m >> d;
  int res = 0;
  rep(i,1,m+1)rep(j,1,d+1){
    if(j/10 == 1 or j%10 == 1)continue;
    if(i == (j/10)*(j%10))res++;
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length()-1;++i){
        if(s[i]=='A' && s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  if(s[0]==s[1] && s[0]==s[2] && s[0]==s[3]){
    cout << "No" << endl;
  }
  else if(s[0]==s[1] && s[2]==s[3]){
    cout << "Yes" << endl;
  }
  else if(s[0]==s[2] && s[1]==s[3]){
    cout << "Yes" << endl;
  }
  else if(s[0]==s[3] && s[1]==s[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define nl "\n"
#define ump unordered_map<ll , ll>

void doit(){
	char ch ;
	cin >> ch;
	if(ch>='A' && ch <='Z')cout <<'A' <<nl;
	else cout << 'a' <<nl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	// cin >> t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


Measured memory_bytes: 3616
#include<stdio.h>

int main(){
  int a, b;
  int x, y;

  scanf("%d %d",&a,&b);
  if(a>b){
    x=a;
    a=b;
    b=x;
  }
  x=a;
  y=b;
  while(1){
    a=y%x;
    if(a==0)break;
    y=x;
    x=a;
    if(x==0)break;
  }
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 592
n, m = map(int, input().split())

P = [[0] * n for i in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    P[a-1][b-1] = 1
    P[b-1][a-1] = 1

#dp[S][v] := 頂点０から出発し、集合Sに含まれる頂点を全て訪れるpathのうち、頂点vが最後になるようなpathの総数
dp = [[0] * n for _ in range(1 << n)]

#dpの初期化 dp({0}, 0) = 1
dp[1][0] = 1

for S in range(1 << n):
    for v in range(n):
        #vがSに含まれていないときはパスする
        if S & (1 << v) == 0:
            continue
        
        #sub = S - {v}
        sub = S ^ (1 << v)
        
        for u in range(n):
            #subにuが含まれており、かつuとvが辺で結ばれている
            if sub & (1 << u) and P[u][v]:
                dp[S][v] += dp[sub][u]

ans = sum(dp[(1 << n) - 1][u] for u in range(1, n))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >>n;
  set<string> st;
  rep(i,n){
    string t; cin >> t;
    st.insert(t);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19224
# https://atcoder.jp/contests/abc113/tasks/abc113_b


def temp(T, x, A):
    return abs(A - (T - 0.006 * x))

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

min_diff = temp(T, H[0], A)
answer = 0
for i in range(1, N):
    diff = temp(T, H[i], A)
    if diff < min_diff:
        answer = i
        min_diff = diff
print(answer + 1)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int dp[100005][4];
int arr[100005][4];

int y;
 
int knap(int n,int a){
	if(n==y)
		return 0;
	if(dp[n][a]!= -1)
		return dp[n][a];
     int m = 0;
	 if(a == 0){
		m = max(m, arr[n][1] + knap(n+1,1));
		m = max(m,arr[n][2] + knap(n+1,2));
		m = max(m,arr[n][3] + knap(n+1,3));
	}
	else if(a == 1){
		
		m =max(m, arr[n][2] + knap(n+1,2));
		m =max(m, arr[n][3] + knap(n+1,3));
	}
	else if(a == 2){
		
		m =max(m, arr[n][1] + knap(n+1,1));
		m = max(m,arr[n][3] + knap(n+1,3));
	}
	else {
		
		m = max(m,arr[n][1] + knap(n+1,1));
		m = max(m,arr[n][2] + knap(n+1,2));		
	}
	return dp[n][a] = m;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE    
    freopen("input.txt", "r", stdin);     
    freopen("output.txt", "w", stdout);
#endif

cin>>y;


	rep(i,y){
		cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
	}
	// rep(i,n){
	// 	cout<<arr[i][0]<<arr[i][1]<<arr[i][2]<<endl;
	// }
	memset(dp,-1,sizeof(dp));
	cout<<knap(0,0);
 
 
 
 
 
 
 
 

 
return 0;
}

Measured memory_bytes: 14524
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int A, B, X;
  cin >> A >> B >> X;

  X = X-A;

  if(X == 0) {
    cout << "YES" << endl;
  } else if(X < 0) {
    cout << "NO" << endl;
  } else if(B >= X) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    REP(i,N){
        cin>>A[i];
        B[i]=A[i]-i-1;
    }
    //入力部
    sort(ALL(B));
    int size=A.size();
    int b;
    if(size%2==0){
        b=B[size/2-1];
    }else{
        b=B[(size-1)/2];
    }
    ll ans=0;
    REP(i,N){
        ans+=abs(A[i]-(b+i+1));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int N=5e6+10;
const int mod=998244353;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,fac[N],inv[N],ifac[N];

int C(int n,int m) {
	if(m<0||n<m) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main() {
	cin>>n>>m;
	fac[0]=1;for(int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[1]=1;for(int i=2;i<N;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	ifac[0]=1;for(int i=1;i<N;i++) ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	int ans=0;
	for(int i=0;i<=m;i++) if(!((3*m-i)&1)) ans=(ans+1ll*C(n,i)*C((3*m-i)/2+n-1,n-1))%mod;
	for(int i=2*m+1;i<=3*m;i++) ans=(ans-1ll*n*C(3*m-i+n-2,n-2))%mod;
	cout<<(ans%mod+mod)%mod;
	return 0;
}


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

int main(void) {
    int a, b;
    char op;

    while(true) {
        cin >> a >> op >> b;
        if(op == '?')
            break;
        if(op == '+')
            cout << a + b << endl;
        if(op == '-')
            cout << a - b << endl;
        if(op == '*')
            cout << a * b << endl;
        if(op == '/')
            cout << a / b << endl;
    }

    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}
long long int n, m;

int main() {
  cin >> n >> m;

  long long int ans;
  for(long long int i=1; i<=sqrt(m)+10; i++){
    if(m%i != 0) continue;
    if(i * n <= m) ans = max(i, ans);
    if(n <= i) ans = max(m/i, ans);
  }
  cout << ans << endl;

  return 0;
}



//


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
 
  private static void solve() {
    int n = nextInt();
    int q = nextInt();
    
    Map<Integer, List<Integer>> map = new HashMap<>();
    
    for (int i = 0; i < n - 1; i++) {
      int a = nextInt() - 1;
      int b = nextInt() - 1;
      
      map.computeIfAbsent(a, (k) -> new ArrayList<>()).add(b);
      map.computeIfAbsent(b, (k) -> new ArrayList<>()).add(a);
    }
    
    long[] value = new long[n];
    long[] ans = new long[n];
    
    for (int i = 0; i < q; i++) {
      int p = nextInt() - 1;
      int x = nextInt();
      
      value[p] += x;
    }
    
    
    preOrder(0, -1, map, value, ans, 0);
    
    for (int i = 0; i < n; i++) {
      out.print(ans[i] + " ");
    }
    out.println();
  }
  
  private static void preOrder(int root, 
                               int parent, 
                               Map<Integer, List<Integer>> map, 
                               long[] value,
                               long[] ans, long curValue) {
    ans[root] = curValue + value[root];
    
    List<Integer> ch = map.get(root);
    
    if (ch == null || ch.isEmpty()) return;
    
    for (int chId : ch) {
      if (chId != parent) {
        preOrder(chId, root, map, value, ans, ans[root]);
      }
    }   
  }
                               
  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);
 
    solve();
 
    out.close();
  }
 
  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;
 
  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }
 
  private static int nextInt() {
    return Integer.parseInt(next());
  }
 
  private static long nextLong() {
    return Long.parseLong(next());
  }
 
  public static void main(String[] args) {
    run();
  }
}


Measured memory_bytes: 165736
h,w=map(int,input().split())
A=[]
ans=[]
for i in range(h):
    A.append(list(input()))
for a in A:
    if a != ['.']*w:
        ans.append(a)
counter=[]
for i in range(w):
    flag=0
    for j in range(len(ans)):
        if ans[j][i]=='#':
            flag=1
            break
    if flag==1:
        counter.append(i)
        
for a in ans:
    temp=''
    for i in counter:
        temp+=a[i]
    print(temp)

Measured memory_bytes: 9264
#c
n=int(input())
a=[int(i) for i in input().split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
l=[1]*n
r=[1]*n
l[0]=a[0]
r[0]=a[n-1]
for i in range(1,n):
    l[i] = gcd(l[i-1],a[i])
    r[i] = gcd(r[i-1],a[n-i-1])
if n>=3:
    ans = max(l[-2],r[-2],max(gcd(l[i-1],r[n-i-2]) for i in range(1,n-1)))
    print(ans)
else:
    print(max(a))

Measured memory_bytes: 63984
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
ans = 0
for n in range(1, N+1, 2):
    yaku = 0
    for i in range(1, n+1):
        if n%i==0:
            yaku += 1
    if yaku == 8:
        ans += 1
print(ans)


Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
LL qread(){
	LL w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}
const int MAXN =1e3+3;
LL ans,n,m,P[MAXN],A[MAXN],B[MAXN],C[MAXN];
void calc(){
	LL tmp=0; sort(P+1,P+1+n);
	dn(n,n-m+1,i) tmp+=P[i];
	ans=max(ans,tmp);
}
int main(){
	n=qread(),m=qread();
	up(1,n,i) A[i]=qread(),B[i]=qread(),C[i]=qread();
	up(0,1,k1) up(0,1,k2) up(0,1,k3){
		up(1,n,i) P[i]=A[i]*(k1?1:-1)+B[i]*(k2?1:-1)+C[i]*(k3?1:-1);
		calc();
	} 
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll n;
  cin >> n;
  vector<ll>x(n),y(n),h(n);
  rep(i,n)cin >> x[i] >> y[i] >> h[i];
  rep(X,101)rep(Y,101){
    vector<int>tmp;
    rep(i,n){
      int dist = abs(X - x[i]) + abs(Y - y[i]);
      tmp.push_back(h[i] + dist);
    }
    for(auto H : tmp){
      bool ok = true;
      rep(j,n){
        int dist = abs(X - x[j]) + abs(Y - y[j]);
        if(max(H - dist,0) != h[j])ok = false; 
      }
      if(ok){
        cout << X << " " << Y << " " << H << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while (A > 0 || C > 0){
    C -= B;
    if(A <= 0){
      cout << "No" <<endl;
      return 0;
    }
    A -= D;
    if(C <= 0){
      cout << "Yes" <<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    string a[t];
    map<string,int> m;
    //map<string,int,greater<int>> m1;
    while(t--){
        string s;
        cin>>s;
        m[s]++;
       
    }
    auto it=m.begin();
    int mx=-12;
    for(it;it!=m.end();it++){
        if(mx<m[it->first]) mx=m[it->first];
    }
    //cout<<mx<<endl;
    it=m.begin();
    int i=0;
    for(it;it!=m.end();it++){
        if(it->second==mx){
            a[i]=it->first;
            i++;
        }
    }
    int j=i;
    sort(a,a+i);
    
   for(int x=0;x<j;x++) {
       cout<<a[x]<<endl;
   }


}

Measured memory_bytes: 25472
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

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

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c;
  cin>>a>>b>>c;
  bool can=false;
  if(a<=c && b>=c)can=true;
  if(b<=c && a>=c)can=true;
  YN(can);
  
  
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int a, b; cin >> a >> b;
  int N = b - a;
  cout << (1 + N) * N / 2 - b << endl;
}


Measured memory_bytes: 3568
def q(s)
[?+,?-].each{|i|[?+,?-].each{|j|[?+,?-].each{|k|
  s[1]=i
  s[3]=j
  s[5]=k
  return s+"=7".to_s if eval(s)==7
}}}
end
puts q(gets.chop.chars*" ")


Measured memory_bytes: 1788
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			BigInteger a = new BigInteger(sc.nextLine());
			BigInteger b = new BigInteger(sc.nextLine());

			if (a.compareTo(b) > 0) {
				System.out.println("GREATER");
			} else if (a.compareTo(b) == 0) {
				System.out.println("EQUAL");
			} else {
				System.out.println("LESS");
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#define MOD 1000000007
#define pb push_back
using namespace std;

double dp[3030][3030];
double p[3030];

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

	for (int i = 1; i <= n; i++) cin >> p[i];

	dp[0][0] = 1;

	for (int i = 1; i <= n; i++)
		dp[i][0] = dp[i - 1][0] * (1 - p[i]);

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
		}
	}

	double sol = 0;
	for (int i = 1; i <= n; i++)
		if (i > n - i) sol += dp[n][i];

	cout << fixed << setprecision(12) << sol;
	return 0;
}

Measured memory_bytes: 70272
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
	KAKA
	vector<ll> ar(n);
	map<ll,ll> mp;
	ll sum = 0;
	pragi(0,n)
	{
		cin>>ar[i];
		if(i >= ar[i]) sum += mp[i - ar[i]];
		mp[i + ar[i]]++; 
	}
	cout<<sum<<"\n";
}
int main()
{
	KAKA
	ll n;
	cin>>n;
	Compute(n);
}

Measured memory_bytes: 18328
h, w = map(int, input().split())
arr = [input() for j in range(h)]
tarr = []
counter = 0
for i in range(h):
    buf = arr[i]
    if buf.count("#") != 0:
        counter += 1
        tarr.append(buf)
tans = [["" for i in range(counter)] for j in range(w)]
for i in range(counter):
    for j in range(w):
        tans[j][i] = tarr[i][j]
counter2 = 0
ttans = []
for i in range(w):
    buf = tans[i]
    if buf.count("#") != 0:
        counter2 += 1
        ttans.append(buf)
for i in range(counter):
    for j in range(counter2):
        print(ttans[j][i], end="")
        if j == counter2-1:
            print("")

Measured memory_bytes: 4596
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, a, b;
    
    scanf("%d %d %d", &n, &a, &b);
    
    printf("%d %d\n", min(a, b), max(0, a + b - n));
    
    return 0;
}


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

using namespace std;

bool dfs(
    const int now,
    const vector<vector<int>> &adj,
    vector<bool> &subset,
    vector<int> &subset_num,
    vector<bool> &visited,
    vector<int> &can_go
) {
    subset[now] = true;
    subset_num.push_back(now);
    visited[now] = true;
    for (int next : adj[now]) {
        can_go[next] += 1;
    }

    int max_depth = -1;
    for (int next : adj[now]) {
        can_go[next] -= 1;
        if (can_go[next] == 0 && subset[next]) {
            for (int j = 0; j < subset_num.size(); j++) {
                if (subset_num[j] == next) {
                    max_depth = max(max_depth, j);
                    break;
                }
            }
        }
        can_go[next] += 1;
    }

    if (max_depth != -1) {
        while (max_depth > 0) {
            subset_num.erase(subset_num.begin());
            max_depth--;
        }
        return true;
    }

    for (int next : adj[now]) {
        can_go[next] -= 1;
        if (can_go[next] == 0) {
            if (dfs(next, adj, subset, subset_num, visited, can_go)) {
                return true;
            }
        }
        can_go[next] += 1;
    }

    for (int next : adj[now]) {
        can_go[next] -= 1;
    }
    subset[now] = false;
    subset_num.pop_back();
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    vector<bool> visited(n);
    for (int i = 0; i < m; i++) {
        int f, t;
        cin >> f >> t;
        f--; t--;
        adj[f].push_back(t);
    }

    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            vector<bool> subset(n);
            vector<int> ans;
            vector<int> can_go(n);
            if (dfs(i, adj, subset, ans, visited, can_go)) {
                cout << ans.size() << endl;
                for (int j : ans) {
                    cout << j + 1 << endl;
                }
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b >= c){
        cout<<"No\n";
        return;
    }

    ll l = (2*a*b);
    ll r = (a*a) + (b*b) + (c*c) - (2*a*c) - (2*b*c);
    if(l<r) cout<<"Yes\n";
    else cout<<"No\n";
    return;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

const int MAXN = 200005;
LL n, k;
LL A[MAXN];

bool check(LL x){
    //cout<<x<<endl;
    LL cnt=0;
    for(int i=1;i<=n;++i){
        if(A[i]>=0){
            int l=i,r=n;
            int ans=l;
            while(l<=r){
                int mid=l+r>>1;
                if(A[mid]*A[i]<=x){
                    ans=mid;
                    l=mid+1;
                }else{
                    r=mid-1;
                }
            }
            cnt+=(ans-i);
            //cout<<x<<" "<<i<<" "<<ans-i<<endl;
        }else{
            int l=i,r=n;
            int ans=r+1;
            while(l<=r){
                int mid=l+r>>1;
                if(A[mid]*A[i]<=x){
                    ans=mid;
                    r=mid-1;
                }else{
                    l=mid+1;
                }
            }
            cnt+=n-ans+1;
            if(ans==i)--cnt;
            //cout<<x<<" "<<i<<" "<<n-ans+1<<endl;
        }
    }
    //cout<<x<<" "<<cnt<<endl;
    return cnt>=k;
}

int main(){
    cin>>n>>k;
    for(int i=1;i<=n;++i)cin>>A[i];
    sort(A+1, A+n+1);
    LL l=-1e18, r=1e18;
    LL ans=-1e18;
    while(l<=r){
        LL mid=(l+r)/2;
        if(check(mid)){
            ans=mid;
            r=mid-1;
        }else{
            l=mid+1;
        }
        //return 0;
        //cout<<l<<" "<<r<<endl;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cstdio>
#include <cmath>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>
#include <math.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll INF = 1e9;
const ll MOD = (1e9)+7;
const ll MAX_N = 1 << 17;

int main(){
	ll N;
	cin >> N;
	ll hoge=(ll)sqrt((double)N)+1;
	ll ans=INF;
	for(ll i=1;i<=hoge;i++){
		if(N%i==0){
			ans = min((ll)(log10((double)N/i))+1, ans);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512