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

int main(){
  int n,m=0;
  cin >> n ;
  for(int i=0;i<n;i++){
     string s;
    cin >> s;
    if(s=="Y"){
       m=1;
    }
  }

  if(m==1){cout<<"Four"<<endl;}
  else{cout<<"Three"<<endl;}
  

}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn is_prime(x: usize) -> bool {
  let mut i = 2;
  while i * i <= x {
    if x % i == 0 {
      return false;
    }
    i += 1;
  }
  true
}

fn main() {
  input! {
    n: usize,
  }
  let mut primes = vec![];
  for i in 2 .. 55555 + 1 {
    if i % 5 == 1 && is_prime(i) {
      primes.push(i);
    }
  }
  for x in primes.iter().take(n) {
    print!("{} ", x);
  }

  println!("");
}


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

int main(){
  int N;
  cin >> N;
  string S[N];
  int P[N];
  for(int i=0;i<N;i++){
    cin >> S[i] >> P[i];
  }
  vector<pair<string,int> > SP(N);
  int maxi = 0;
  for(int i=0;i<N;i++){
    maxi = max(P[i],maxi);
  }
  for(int i=0;i<N;i++){
    SP[i] = make_pair(S[i],maxi - P[i]);
  }
  sort(SP.begin(),SP.end());
  int ans[N];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(S[j] == SP[i].first){
        if(P[j] == maxi - SP[i].second){
          ans[i] = j+1;
        }
      }
    }
  }
for(int i=0;i<N;i++){
  cout << ans[i] << endl;
}
return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    string s; cin >> s;
    int res = 0;
    FOR(i, 0, 9) {
        FOR(j, 0, 9) {
            FOR(k, 0, 9) {
                bool f1 = false, f2 = false, f3 = false;
                REP(l, n) {
                    if (!f1 && (s[l] - '0' == i)) {
                        f1 = true;
                    } else if (f1 && !f2 && (s[l] - '0' == j)) {
                        f2 = true;
                    } else if (f1 && f2 && !f3 && (s[l] - '0' == k)) {
                        f3 = true;
                    }
                }
                if (f3) {
                    res++;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

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

    static class Flatten {
        final int MOD = 1000000000 + 7;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int PrimeMax[] = new int[1000001];
            for (int i = 0; i < n; i++) {
                int now = a[i];
                for (int j = 2; j * j <= now; j++) {
                    int cnt = 0;
                    while (now % j == 0) {
                        now /= j;
                        cnt++;
                    }
                    PrimeMax[j] = Math.max(PrimeMax[j], cnt);
                }
                if (now > 1) {
                    PrimeMax[now] = Math.max(PrimeMax[now], 1);
                }
            }
            int GCD = 1;
            for (int i = 0; i < PrimeMax.length; i++) {
                if (PrimeMax[i] == 0) continue;
                GCD = (int) (((long) GCD % MOD) * (ModPow(i, PrimeMax[i]) % MOD) % MOD);
            }
            int ans = 0;
            for (int i = 0; i < n; i++) {
                ans = ((ans % MOD) + (DivMod(GCD, a[i]) % MOD)) % MOD;
            }
            out.println(ans);
        }

        private int DivMod(int gcd, int i) {
            return (int) ((long) (gcd % MOD) * (ModPow(i, MOD - 2) % MOD) % MOD);
        }

        private int ModPow(int i, int primeMax) {
            int now = primeMax;
            long res = 1;
            long nowi = i;
            while (now > 0) {
                if (now % 2 == 1) {
                    res = (res % MOD) * (nowi % MOD) % MOD;
                }
                now >>= 1;
                nowi = ((nowi % MOD) * (nowi % MOD)) % MOD;
            }
            return (int) res;
        }

    }
}



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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

//最大公約数の計算
ll GCD(ll a, ll b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
ll lcm(ll a, ll b) { return a * b / GCD(a, b); }

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  int L = 1, first = 1;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    L = lcm(L, a[i]);
    first = lcm(first, a[i] / 2);
    if (first > M) {
      cout << 0;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if ((first / (a[i] / 2)) % 2 == 0) {
      cout << 0;
      return 0;
    }
  }
  int ans = (M - first) / L + 1;
  cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    int winner;
    int p = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    while(true) {
        if(p == 0) {
            if(A[a] == 'a') p = 0;
            else if(A[a] == 'b') p = 1;
            else p = 2;
            if(a == A.size()) {
                winner = 0;
                break;
            }
            a += 1;
        } else if(p == 1) {
            if(B[b] == 'a') p = 0;
            else if(B[b] == 'b') p = 1;
            else p = 2;
            if(b == B.size()) {
                winner = 1;
                break;
            }
            b += 1;
        } else {
            if(C[c] == 'a') p = 0;
            else if(C[c] == 'b') p = 1;
            else p = 2;
            if(c == C.size()) {
                winner = 2;
                break;
            }
            c += 1;
        }
    }

    if(winner == 0) cout << "A" << endl;
    else if(winner == 1) cout << "B" << endl;
    else cout << "C" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            99999999999999


void solve()
{
   long long a,b;
   cin>>a>>b;
   if(a==b) cout<<"0"<<endl;
   else if(a<b) cout<<min(a,abs(a-b))<<endl;
   else
   {
       long long mod=a%b;
       //cout<<mod<<endl;
       cout<<min(mod,abs(mod-b))<<endl;
   }


}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; cin>>t; while(t--) solve();
    solve();
}


Measured memory_bytes: 3620
n,ye = map(int,input().split())
for x in range(n+1):
    if 10000 * x > ye: break
    for y in range(n-x+1):
        z = n - x - y
        tmp = 10000 * x + 5000 * y + 1000 * z
        if tmp == ye:
            print("{} {} {}".format(x,y,z))
            exit(0)
        elif tmp > ye:
            break
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//const ll mod = 1000000007;
const ll INF = 1e9;
int N, M;
string S;

void solve() {
    //cout.precision(10);
    cin >> N >> M >> S;
    vector<int> dist(N + 1, INF);
    vector<int> MostLeft(N + 1, INF);
    dist[N] = 0;
    MostLeft[0] = N;
    int Next = N-1;
    int Left = N;
    int timer = 0;
    while(true) {
        timer++;
        int newLeft = Left;
        while(Next >= Left - M && Next >= 0) {
            if(S[Next] == '0') {
                dist[Next] = timer;
                newLeft = Next;
            }
            Next--;
        }
        if(newLeft == Left) {
            cout << -1 << endl;
            return;
        }
        Left = newLeft;
        MostLeft[timer] = Left;
        if(Next < 0) break;
    }
    timer = dist[0];
    for(int i = 0; i <= N; i++) {
        cerr << dist[i] << endl;
    }
    vector<int> ans;
    int now = 0;
    while(timer >= 1) {
        timer--;
        ans.push_back(MostLeft[timer] - now);
        now = MostLeft[timer];
    }
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if(i + 1 != ans.size()) cout << " ";
    }
    cout << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1912
n = int(input())
p = map(int, input().split())
q = map(int, input().split())

def ranking(n, numbers):
  tmp = list(range(1, n+1))
  ranking = []
  for n in numbers:
    index = tmp.index(n)
    ranking.append(index+1)
    tmp.pop(index)
  return ranking

def ranking2output(n, ranking):
  ret = 1
  x = 1
  for i in range(1, n+1):
    ret += (ranking[n-i]-1)*(x)
    x *= i
  return ret

a = ranking2output(n, ranking(n, p))
b = ranking2output(n, ranking(n, q))

print(abs(a-b))

Measured memory_bytes: 40452
def e_picking_goods():
    # 参考: https://atcoder.jp/contests/abc175/submissions/16044254
    R, C, K = [int(i) for i in input().split()]
    Goods = [[0] * (C + 1) for _ in range(R + 1)]
    for _ in range(K):
        r, c, v = [int(i) for i in input().split()]
        Goods[r][c] = v

    # editorial に対し、行の情報を除去する
    dp = [[0] * 4 for _ in range(C + 1)]
    for i in range(1, R + 1):
        dp_next = [[0] * 4 for _ in range(C + 1)]
        for j in range(1, C + 1):
            up_max = max(dp[j])  # 上のマスで 0~3 回アイテムを拾っていたときの、価値の最大値
            v = Goods[i][j]

            # 左か上から来て、アイテムを拾わない
            dp_next[j][0] = max(up_max, dp_next[j - 1][0])
            # 上から来て拾う or 左から来て拾う or 左から来て拾わない
            dp_next[j][1] = max(up_max + v, dp_next[j - 1][0] + v, dp_next[j - 1][1])
            # 左から来て k-1 個拾っており、ここで拾う or k 個拾っており、ここで拾わない
            for k in range(2, 4):
                dp_next[j][k] = max(dp_next[j - 1][k - 1] + v, dp_next[j - 1][k])
        dp = dp_next  # 次の行へ注目を移す
    return max(dp[-1])

print(e_picking_goods())

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

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

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

    int n, x, y;
    cin>>n>>x>>y; x--; y--;

    vector<ll> ans(n - 1);
    rep(i, n) {
        for (int j = i + 1; j < n; ++j) {
            ans[min(abs(i - x) + 1 + abs(y - j), j - i) - 1]++;
        }
    }
    rep(i, n - 1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=set([int(input()) for o in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
        dp[i]=0
print(dp[n])

Measured memory_bytes: 56664
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

ll N;

int main(void) {
    scanf("%lld", &N);

    if (N % 2 == 0) printf("%lld\n", N);
    else printf("%lld\n", N*2);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Test int T;cin>>T;while(T--)
#define ls lower_bound
#define up upper_bound
#define bs binary_search
#define S second
#define F first
#define vi vector<int>  
#define pii pair<int,int>
#define vpi vector<pii>
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define m_n(v) *min_element(all(v))
#define m_x(v) *max_element(all(v))
/* 
#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
*/
int power(int x, int y,int mod){
    int res = 1;
    while (y)
    {
        if (y & 1)
        res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res;
}
int modInverse(int a, int m){
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int binomial(int n,int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
/*vector<int> prime;
void sieve(){
    bool arr[300000]={0};
    prime.pb(2);
    for(int i=3;i<300000;i+=2){
        if(arr[i])continue;
        for(int j=i*i;j<300000;j+=i) arr[j]=1;
        prime.pb(i);
    }
}*/
const int mod=1e9+7;
int32_t main() {
    IOS;
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<5;i++)
    {
        if(a[i] == 0)
        {
            cout<<i+1;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

const int N = 200010, SIZE = 26;

int n;
int cnt[SIZE];
char ch[N];

int main() {
    scanf("%s", ch + 1);
    n = strlen(ch + 1);
    for (int i = 1; i <= n; ++i)
        ++cnt[ch[i] - 97];
    LL res = 0;
    for (int i = 0; i < SIZE; ++i)
        res += LL(n - cnt[i]) * cnt[i];
    res >>= 1;
    printf("%lld\n", res + 1);
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

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

    int n = sc.nextInt();
    int halfN = n / 2;

    List<Integer> list = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }

    Collections.sort(list);

    int result = list.get(halfN) - list.get(halfN - 1);

    System.out.println(result);
  }
}


Measured memory_bytes: 61108
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int cost = 1001001001;
  for(int i = -100; i <= 100; i++) {
    int tmp = 0;
    for(int j = 0; j < n; j++) {
      tmp += abs(a[j] - i) * abs(a[j] - i);
    }
    cost = min(cost, tmp);
  }
  cout << cost << endl;
  return 0;
}

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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    int n, x;
    cin >> n;
    vector<int> v;
    REP(_, n) { cin >> x; v.pb(x); }
    sort(ALL(v));
    v.erase(unique(ALL(v)), v.end());
    cout << v.size() << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


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

int main() {
    int N;
    cin >> N;
    int t = 0, x = 0, y = 0;
    bool valid = true;
    for (int i = 0; i < N; i++)
    {
        int t_i, x_i, y_i;
        cin >> t_i >> x_i >> y_i;

        int move = abs(x - x_i) + abs(y - y_i);
        int time_diff = t_i - t;

        // 経過時間と移動距離の差が偶数ならば適当に移動できる。
        if ((time_diff - move) % 2 == 0 && time_diff >= move) {
            t = t_i;
            x = x_i;
            y = y_i;
        }
        else {
            valid = false;
            break;
        }
    }

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

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          Console.WriteLine((a[0]<=a[2] && a[2] <= a[0]+a[1]) ? "YES" : "NO");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N)cin>>A.at(i);
    ll sum=0;
    rep(i,N)sum+=A.at(i);
    vector<ll> kouho(0);
    for(int i=1;i*i<=sum;i++){
        if(sum%i==0){kouho.pb(i);}
    }
//rep(i,sz(kouho))cout<<kouho.at(i)<<" ";
//cout<<endl;
    int s=sz(kouho);
    rep(i,s){int j=sum/kouho.at(s-1-i);kouho.pb(j);}
//rep(i,sz(kouho))cout<<kouho.at(i)<<" ";
    ll ans=1;
    rep(i,sz(kouho)){
        ll d=kouho.at(i);
        vector<ll> amari(N),ruiplus(N+1),ruiminus(N+1);
        rep(j,N){amari.at(j)=A.at(j)%d;}
        sort(amari.begin(),amari.end());
        rep(j,N){
            ruiplus.at(j+1)=ruiplus.at(j)+amari.at(j);
            ruiminus.at(j+1)=ruiminus.at(j)+d-amari.at(N-j-1);
        }
/*cout<<"kouho="<<d<<endl;
rep(j,N+1)cout<<ruiplus.at(j)<<" ";
cout<<endl;
rep(j,N+1)cout<<ruiminus.at(j)<<" ";
cout<<endl;*/
        ll mn,mx;
        for(int j=0;j<=N;j++){
            mx=max(ruiplus.at(j),ruiminus.at(N-j));
            if(j==0){mn=mx;}
            chmin(mn,mx);
        }
//cout<<"mx="<<mx<<endl;
        if(mn<=K){ans=max(ans,d);}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

// ARC 82-C
// https://beta.atcoder.jp/contests/arc082/tasks/arc082_a

public class Main {

	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();

		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		
		for (int i = 0; i < N; i++) {
			int n = in.nextInt();
			
			if (map.containsKey(n - 1)) {
				int count = map.get(n - 1);
				map.put(n - 1, count + 1);
			} else {
				map.put(n - 1, 1);
			}
			if (map.containsKey(n)) {
				int count = map.get(n);
				map.put(n, count + 1);
			} else {
				map.put(n, 1);
			}
			if (map.containsKey(n + 1)) {
				int count = map.get(n + 1);
				map.put(n + 1, count + 1);
			} else {
				map.put(n + 1, 1);
			}
		}
		
		int answer = 0;
		
		for (int k : map.keySet()) {
			answer = Math.max(answer, map.get(k));
		}
		
		System.out.println(answer);
	}
}



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

int main() {
  	string sa, sb;
  	cin >> sa >> sb;
  	
  	unsigned long sum, c, a = stol(sa);
  	double b = stod(sb);
  	c = (unsigned long)(b * 100 + 0.5);
  	sum = c * a / 100;
  	cout << to_string(sum) << endl;
  	
	return 0;  
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
const int MAX_nodes=1e5;
vector<int> adj[MAX_nodes+1];
vector<bool> visited(MAX_nodes+1, 0);
vector<int> cnt(MAX_nodes+1, 0);
vector<int> topo;
void dfs(int u){
	visited[u]=true;
	for(auto v: adj[u]){
		if(!visited[v]) dfs(v);
		cnt[u]=max(cnt[u], cnt[v]+1);
	}
	topo.push_back(u);
}
void topo_sort(int n){
	for(int i=1; i<=n; i++){
		if(!visited[i]) dfs(i);
	}
	reverse(topo.begin(), topo.end());
}
int main(){
	int n, m;
	cin >> n >> m;
	while(m--){
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	topo_sort(n);
	cnt.assign(MAX_nodes+1, 0);
	visited.assign(MAX_nodes+1, 0);
	int res=1;
	for(int i=0; i<n; i++){
		if(!visited[topo[i]]) dfs(topo[i]);
		res=max(res, cnt[topo[i]]);
	}
	cout << res;
}

Measured memory_bytes: 13560
n = int(input())
A = list(map(int, input().split()))

sm = sum(A)
x = 0
y = sm
ans = 1001001001001001001

for idx, a in enumerate(A):
  if idx == n - 1:
    break
  
  x  = x + a
  y = y - a
  # print(x, y, abs(x - y))
  ans = min(ans, abs(x - y))
print(ans)

Measured memory_bytes: 24824
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))


Measured memory_bytes: 9468
#include <iostream>
#include <algorithm>

using namespace std;

bool check(string& s)
{
    const int size[] = {7, 5, 6, 5};
    const string dic[] = {"remaerd", "maerd", "resare", "esare"};
    int N = s.size();
    if (N < 5) return false;

    reverse(s.begin(), s.end());
    
    for (int i = 0; i < N; ) {
        bool ok = 0;
        for (int j = 0; j < 4; j++) {
            if (N - i - size[j] < 0) continue;
            bool match = 1;
            for (int k = 0; k < size[j]; k++) {
                if (s[i + k] != dic[j][k]) {
                    match = 0;
                    break;
                }
            }
            if (match) {
                i += size[j];
                ok = 1;
                break;
            }
        }
        if (!ok) return false;
    }

    return true;
}

int main()
{
    string s;
    cin >> s;
    cout << (check(s) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
s = raw_input()

# s = "ABCD" -> first = AB, second = CD
first  = int(s[:2])
second = int(s[2:])

if first in range(1, 12+1):
    if second in range(1, 12+1):
        print "AMBIGUOUS"
    else:
        print "MMYY"
elif second in range(1, 12+1):
    print "YYMM"
else:
    print "NA"

Measured memory_bytes: 2568
//rotateも何も知らず、また頂いたPDFもまともに読まないまま知っている知識のみで解いた結果です。
//少なくとも提出してAcceptは出ています。
//「きれいなプログラム」がどんなものかまだ把握できていないため、この点に関してもご指摘等頂ければと思います。
//千田 直輝

#include<iostream>

#define R input[0][1]

using namespace std;

int getTop() {
	int input[51][2];

	/*入力*/
	cin >> input[0][0] >> input[0][1];								//まずnとrを受け取る。
	if (input[0][0] == 0 && input[0][1] == 0) {						//n=r=0なら0を返して関数終了。
		return 0;
	}
	for (char pos = 1; pos <= input[0][1]; pos++) {					//シャッフルの仕方をr回分入力
		cin >> input[pos][0] >> input[pos][1];
	}

	/*シャッフルもどし*/
	int whtop = 1;													//最後一番上にいるカードは、今何番目にいる？
	if (R==0)return input[0][0];									//一回もシャッフルしないならコレ
	while (input[0][1] != 0) {	
		if (whtop <= input[R][1]) whtop = whtop + input[R][0] - 1;
		else if ((input[R][0] + input[R][1] - 1) < whtop) whtop = whtop;
		else whtop = whtop - input[R][1];
		R--;
	}
	return input[0][0] - whtop + 1;

}


int main()
{
	while (1) {
		int check;
		check = getTop();
		if (check == 0)break;
		else cout << check << endl;
	}
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9

int main(){

    int A, B; cin >> A >> B;

    A--;
    B--;
    bool g[100][100] = {};
    for(int i = 0; i < 50; i++){
        for(int j = 0; j < 100; j++){
            g[i][j] = true;
        }
    }

    bool flag = false;

    for(int i = 0; i < 50; i += 2){
        for(int j = 0; j < 100; j += 2){

            if(A == 0){
                flag = true;
                break;
            }

            g[i][j] = false;
            A--;
        }
        if(flag) break;
    }

    flag = false;

    for(int i = 99; i >= 50; i -= 2){
        for(int j = 0; j < 100; j += 2){

            if(B == 0){
                flag = true;
                break;
            }

            g[i][j] = true;
            B--;
        }
        if(flag) break;
    }

    cout << 100 << " " << 100 << endl;

    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            if(g[i][j]) cout << '#';
            else cout << '.';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;	
public class Main {
public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		String[] s=new String[N];
		String[] sorts=new String[N];
		String[][] splits=new String[N][10];
		
		long count=0;
		int count1=0;
		for(int i=0; i<N; i++) {
			s[i]=sc.next();
			splits[i]=s[i].split("");
			Arrays.sort(splits[i]);
			for(int j=0; j<10; j++) {
				sorts[i]+=splits[i][j];
			}
			
		}
		Arrays.sort(sorts);
		for(int i=0;i<N-1;i++) {
			if(sorts[i].equals(sorts[i+1])) {
			        count1++;
					count+=count1;
			}else {		
				count1=0;
		}			
			
		}
		System.out.println(count);
	  }	          	
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n; cin>>n;
    //if(n%2)
     cout<<(n-1)/2<<endl;
    //else cout<<n/2<<endl;
    return 0;
}

Measured memory_bytes: 3584
n = gets.chomp
#n = gets.chomp.to_i
#a,b,c = gets.split.map(&:to_i)

len = n.length
num = n.to_i
rtn = 0

(1..len).each do |i|
  if i.modulo(2) == 1
    if i == len
      rtn += num - ((10 ** (i - 1)) - 1)
    else
      rtn += 9 * (10 ** (i - 1))
    end
  end
end
puts rtn


Measured memory_bytes: 1788
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main() -> None:
    a, b, x = map(int, input().split())

    print (b // x - (a - 1) // x)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 62628
#include <bits/stdc++.h>
using namespace std;
int n,h[100005],dp[100005];
int solve(int idx){
    if(idx == n)
        return 1e9;
    if(idx == n - 1)
        return 0;
    if(dp[idx] != -1)
        return dp[idx];

    return dp[idx] = min(abs(h[idx] - h[idx + 1]) + solve(idx + 1),abs(h[idx]- h[idx + 2] )  + solve(idx + 2));
}
int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >>h[i];
    cout << solve(0) << endl;
    return 0;
}


Measured memory_bytes: 2560
package main

import (
	"fmt"
	"sort"
)

type rest struct {
	num int
	c string
	p int
}

type rests []rest

func (a rests) Len() int {
	return len(a)
}

func (a rests) Swap(i,j int) {
	a[i],a[j] = a[j],a[i]
}

func (a rests) Less(i,j int) bool {
	if a[i].c == a[j].c {
		return a[i].p > a[j].p
	}
	return a[i].c < a[j].c
}

func main() {
	var n int
	fmt.Scan(&n)

	r := make(rests, n)

	for i:=0; i<n; i++ {
		var s string
		var p int
		fmt.Scan(&s,&p)
		r[i].num = i+1
		r[i].c = s
		r[i].p = p
	}

	sort.Sort(r)
	for i:=0; i<n; i++ {
		fmt.Println(r[i].num)
	}
}


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N, M;
  cin >> N >> M;
  vvi s(M, vi(10));
  rep(i, M) {
    int k;
    cin >> k;
    rep(j, k) cin >> s[i][j];
  }
  vi p(M);
  rep(i, M) cin >> p[i];

  int res = 0;
  for (int b = 0; b < (1 << N); b++) {
    bitset<10> bs(b);
    int cnt = 0;
    rep(i, M) {
      int on = 0;
      rep(j, 10) {
        if (s[i][j] == 0) break;
        if (bs[s[i][j] - 1]) on++;
      }
      if (on % 2 == p[i]) cnt++;
    }
    if (cnt == M) res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        ArrayList<Long> list = new ArrayList<>();
        dfs(list,0);
        Iterator<Long> itr = list.iterator();
        while(itr.hasNext()){
            String s = itr.next().toString();
            if(!(s.contains("3")&&s.contains("5")&&s.contains("7"))){
                itr.remove();
            }
        }
            System.out.println(list.size());        
    }
    void dfs(ArrayList<Long> list,long x){
        if(x<=n){
            list.add(x);
        }else{
            return;
        }
        dfs(list,x*10+3);
        dfs(list,x*10+5);
        dfs(list,x*10+7);
    }
}


Measured memory_bytes: 24172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e8

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M, 0));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) cin >> A[i][j];
    }

    int ans = INF;
    for (int bit = 0; bit < (1 << N); ++bit) {
        vector<int> D(M, 0);
        int s = 0;
        for (int i = 0; i < N; i++)
            if (bit & (1 << i)) {
                s += C[i];
                for (int j = 0; j < M; j++) D[j] += A[i][j];
            }
        if ([&]() -> bool {
                for (int j = 0; j < M; j++)
                    if (D[j] < X) return false;
                return true;
            }())
            ans = min(ans, s);
    }
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

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

using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;

#define rng(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(n) for(int _ = 0, __ = (int)n; _ < __; _++)
#define FOR(x, cont) for (auto &x: cont)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define SZ(x) (int)(x).size()
#define pq(T,COMP) priority_queue<T, vector<T>, COMP>

using pii = pair<int,int>;
using vb = vector<bool>;

vi get_prime(int n) {
    vi minp(n+1);
    vi p;
    for (int i = 2; i <= n; i++) {
        if (!minp[i]) {
            minp[i] = i;
            p.pb(i);
        }
        FOR(x, p) {
            if (x <= minp[i] && x * i <= n)
                minp[x * i] = x;
        }
    }
    return p;
}

const int mod = 1e9 + 7;

void add_mod(ll &x, const ll &y) {
    x += y;
    if (x >= mod) x -= mod;
}



// AGC028 B Remove Blocks
// p(i,j)：[当拿走i时,j还在且ij连通]的概率
// 这个事件也可以表述为j是i到j这一段中第一个被拿走的
// 因此 p(i,j) = 1 / (abs(i-j)+1)
// 因此j对期望的贡献是 a[j]*sum_{1<=i<=n} 1/(abs(i-j)+1)
// 令 f(j) = sum_{1<=i<=n} 1/(abs(i-j)+1)，那么 f(j) = f(j-1) + 1/j - 1/(n-j+2)
// f(1) = 1 + 1/2 + ... + 1 / n


int main() {
#ifdef LOCAL
    freopen("main.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vl inv(n + 1);
    vi a (n + 1);
    rng (i, 1, n + 1) cin >> a[i];
    inv[1] = 1;
    ll sum = 1;
    rng(i, 2, n + 1) {
        inv[i] = mod - ll(mod / i) * inv[mod % i] % mod;
        add_mod(sum, inv[i]);
    }
    ll ans = sum * a[1] % mod;
    rng(i, 2, n + 1) {
        add_mod(sum, inv[i]);
        add_mod(sum, mod - inv[n - i + 2]);
        add_mod(ans, sum * a[i] % mod);
    }
    rng (i, 1, n + 1) {
        ans = ans * i % mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    vector< pair<ll,ll> > a[n];
    for(ll i=0;i<m;i++){
        ll p,y;cin>>p>>y;
        a[p-1].push_back({y,i});
    }
    vector<string> ans(m);
    for(ll i=0;i<n;i++){
        if(a[i].empty())continue;
        sort(a[i].begin(),a[i].end());
        string cur = to_string(i+1);
        while(cur.length()<6)cur="0"+cur;
        for(ll j=0;j<a[i].size();j++){
            string idx=to_string(j+1);
            while(idx.length()<6)idx="0"+idx;
            ans[a[i][j].second]=cur+idx;
        }
    }
    for(auto &s:ans)cout<<s<<"\n";
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c){
    cout << 1;
  }
  else if(a==b||b==c||c==a){
    cout << 2;
  }
  else{
    cout << 3;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int a[210]={};
  int n;
  cin >> n;
  for(int i=0; i<2*n; i++){
    cin >> a[i];
  }
  sort(a, a+2*n);
  reverse(a, a+2*n);

  int cnt=0;
  for(int i=1; i<2*n; i+=2){
    cnt += a[i];
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

N, M, Q = (int(x) for x in input().split())
h = [[int(i) for i in input().split()] for _ in range(Q)]
ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    temp = 0
    for a, b, c, d in h:
        if A[b-1] - A[a-1] == c:
            temp += d
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 9200
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
N = int(input())
L = []
s_dict = {}
for x in range(1,N+1):
    for y in range(1,N+1):
       if(x == y):
           L.append(x)
           s_dict[(x,y)] = x
       elif(x % y == 0):
           L.append(y)
           s_dict[(x,y)] = y
       elif(y % x == 0):
           L.append(x)
           s_dict[(x,y)] = x
       else:
           tmp = gcd(x,y)
           L.append(tmp)
           s_dict[(x,y)] = tmp

for x in L:
    for z in range(1,N+1):
        ans += s_dict[(x,z)]
        
print(ans) 


Measured memory_bytes: 13356
#include <bits/stdc++.h>
typedef long long ll;
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define Fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
const int N=1e5+5; 

bool bl[N];
int perm[N];
int SS[N];
vector<int> G[N];

void dfs(int v,int k);

 int main()
 {
        int n,m;
        scanf("%d%d",&n,&m);
        F(i,1,n) scanf("%d",&perm[i]), bl[i]=false;
        
        int a,b;
        F(i,1,m) scanf("%d%d",&a,&b), G[a].push_back(b),G[b].push_back(a);

        int Z=0;
        F(i,1,n)
        {
                if(!bl[i]) Z++,dfs(i,Z);
        }

        int il=0;
        F(i,1,n) il+=(int)(SS[perm[i]]==SS[i]);
        printf("%d\n",il);
 }
///////
 void dfs(int v,int k)
 {
        bl[v]=true;
        SS[v]=k;
        for(auto z : G[v])
        {
                if(bl[z]) continue;
                dfs(z,k);
        }
 }

Measured memory_bytes: 8576
using System;


class Program
{
    static void Main()
    {
        int x = int.Parse(Console.ReadLine()); //???????????????????????????????????°
        int[,] cards = new int[4, 13];

        for (int i= 0; i < x; i++)
        {
            string[] str = Console.ReadLine().Split(' ');
            string Class = str[0];
            int num = int.Parse(str[1]);
            int number = 0;
            switch (Class)
            {
                case "S": number = 0; break;
                case "H": number = 1; break;
                case "C": number = 2; break;
                case "D": number = 3; break;
            }

            cards[number, num-1] = 1;
        }

        //???????????§?????????????????\???

        int[,] CollectCards = new int[4, 13];

        for(int i= 0; i < cards.GetLength(0);i++)
        {
            for (int i2= 0; i2 < cards.GetLength(1);i2++)
            {
                if (CollectCards[i,i2] == cards[i,i2])
                {
                    
                    string OutClass = "";

                    switch(i)
                    {
                        case 0: OutClass = "S"; break;
                        case 1: OutClass = "H"; break;
                        case 2: OutClass = "C"; break;
                        case 3: OutClass = "D"; break;
                    }

                    Console.WriteLine("{0} {1}", OutClass, i2+1);
                }
            }
        }
    

    }


}

Measured memory_bytes: 9208
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	string S;
	long long Q;
	cin >> S;
	cin >> Q;
	long long i;
	long long T,F;
	char C;
	int count = 1;
	for(i = 1;i <= Q;i++)
	{
		cin >> T;
		if(T == 1) count = count*(-1);
		else if(T == 2)
		{
			cin >> F;
			cin >> C;
			if(((count == 1)&&(F == 1))||
			((count == -1)&&(F == 2)))
			{
				S.insert(S.begin(),C);
			}
			else
			{
				S.push_back(C);
			}
		}
	}
	if(count == 1) cout << S;
	else 
	{
		reverse(S.begin(),S.end());
		cout << S;
	}
	return 0;
}
			

Measured memory_bytes: 900
H = list(map(int,input().split()))

h = H[2]-H[0]
m = H[3]-H[1]

if h < 0:
    h = h + 24

if m < 0:
    h -= 1
    m = 60 + m

mini = h*60 + m - H[4]

if mini < 0:
    mini = 24*60 + mini

print(mini)

Measured memory_bytes: 9188
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define PRIME 999998727899999 			// (largest prime below 10^16)
#define PB push_back
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0)
#define EPS 1e-11
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL res = base; if (power == 0) return 1;
	for (int I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 1e6;
string S;

int main()
{
	BOOST
	///READ();
	///WRITE();
	int T, I, J, K, N, n, m, cnt = 0, len;

	cin >> S;
	len = S.length();

	if(S[0] != S[2])
		cout << "No\n";
	else
		cout << "Yes\n";

	return 0;
}






Measured memory_bytes: 256