akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 5000005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"Yes\n";
#define N cout<<"No\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

void solve() {
    lli x, k, d;
    cin>>x>>k>>d; // k is the total no. of moves
    x = abs(x); //considering that we are on +ve x-axis
    lli  steps = x/d; // no. of steps we are away from origin
    if(k <= steps) x -= k*d; //if k<=steps, we will try to move as close to origin as 
                             //possible
    else { //if we are forced to move more steps than required
        k -= steps; //now k is the extra steps which we are condemned to move
        if(k%2==0) x -= d*steps; //if extra steps is even, we can simply waste them by 
                              //moving 1 step forward and 1 step backward again and again
        else { //if odd, we will cross origin (atleast) once as we have no other choice
            x -= d*(steps+1);
        }
    }
    x = abs(x); //finally getting the distance from origin
    cout<<x<<"\n";
    return;
}
int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 3608
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

vi at;
vector<vi> vec;
int n, m, q;
void gen(int last, int i) {
    if(i == n) {
        vec.PB(at);
        return;
    }
    for(int j = last; j <= m; j++) {
        at.PB(j);
        gen(j, i+1);
        at.pop_back();
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> q;
    for(int i = 1; i <= m; i++) {
        gen(i, 0);
    }

    ll ans = 0;

    vector<vi> seqs;

    for(int i = 0; i < q; i++ ) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        vi v = {d, a-1, b-1, c};
        seqs.PB(v);
    }
    sort(seqs.rbegin(), seqs.rend());
    for(int i = 0; i < vec.size(); i++) {
        ll val = 0;
        for(int j = 0; j < q; j++) {
            ll a = seqs[j][1];
            ll b = seqs[j][2];
            ll c = seqs[j][3];
            ll d = seqs[j][0];
            if(vec[i][b] == vec[i][a]+c) val += d;
        }
        ans = max(ans, val);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 15588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int t[3][30];
int d[30][30];

int main()
{
  int n,c;
  cin >> n >> c;
  REP(i,c) REP(j,c) cin >> d[i][j];
  REP(i,n) REP(j,n){
    int x;
    cin >> x;
    t[(i+j)%3][x-1]++;
  }
  int ans = 2e9;
  REP(i,c) REP(j,c){
    if(i!=j){
      REP(k,c){
        if(k!=i && k!=j){
          int tt = 0;
          REP(l,c) tt += d[l][i] * t[0][l];
          REP(l,c) tt += d[l][j] * t[1][l];
          REP(l,c) tt += d[l][k] * t[2][l];
          ans = min(ans, tt);
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

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

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

    int a, b;
    cin >> a >> b;
    cout << (a + b) / 2 << endl;

    return 0;
}


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

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == b[0][0]) {
        if (j <= n - m && i <= n - m) {
          int cnt = 0;
          for (int z = 0; z < m; z++) {
            if (a[i + z].substr(j, m) == b[z]) { cnt++; }
          }
          if (cnt == m) {
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "No" << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll x;
    cin>>x;
    ll ans=0;
    ans+=(x/500)*1000;
    x%=500;
    ans+=(x/5)*5;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int cnt[100];

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

    rep(i, 2 * M) {
	int a;
	cin >> a;
	a--;
	cnt[a]++;
    }

    rep(i, N) cout << cnt[i] << endl;

    return 0;
}


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

int main(){
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int sum = 0;

    if(N <= K){
        sum += N * X;
    }
    else{
        sum += K * X;
        sum += (N - K) * Y;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
while True:
    h,m,s = [int(x) for x in input().split()]
    if h < 0 and m < 0 and s < 0:
        break
    r = 7200 - h * 3600 - m * 60 - s
    
    for m in [ 1, 3]:
        tmp = r * m
        dh = tmp // 3600
        dm = (tmp % 3600) // 60
        ds = tmp % 60
        print("{:02d}:{:02d}:{:02d}".format(dh,dm,ds))
    
    


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

template<class V, class Delta, class Index>
vector<ll> bfs(int n, V s, Delta delta, Index index) {
  vector<ll> dist(n,-1);
  queue<V> que;
  dist[index(s)] = 0;
  que.push(s);
  while(!que.empty()) {
    V v = que.front(); que.pop();
    auto update = [&](V t) {
      if (dist[index(t)] == -1) {
        dist[index(t)] = dist[index(v)]+1;
        que.push(t);
      }
    };
    delta(v,update);
  }
  return dist;
}

template<class F>
struct lattice_delta {
  int h,w;
  F check;
  const int dx[8] = {-1,0,1,0,-1,1,-1,1};
  const int dy[8] = {0,-1,0,1,-1,-1,1,1};
  lattice_delta(int h, int w, F f):h(h),w(w),check(f){}
  template<class G>
  void operator()(P v, G update) {
    int y = v.first, x = v.second;
    for (int i=0; i<4; ++i) {
      int ny = y+dy[i], nx = x+dx[i];
      if (nx<0 || ny<0 || nx>=w || ny>=h) continue;
      check(v, P(ny,nx), update);
    }
  }
};

template<class F>
lattice_delta<F> make_lattice_delta(int h, int w, F f) { return lattice_delta<F>(h, w, f);}

struct lattice_index {
  int h,w;
  lattice_index(int h, int w):h(h),w(w){}
  int operator()(P v){ return v.first*w+v.second;}
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  auto index = lattice_index(h,w);
  auto check = [&](P v, P t, auto update) {
    if (s[t.first][t.second] == '.') update(t);
  };
  auto delta = make_lattice_delta(h,w,check);

  ll ans = 0;
  rep(y,h) rep(x,w) {
    if (s[y][x] == '#') continue;
    auto res = bfs(h*w, P(y,x), delta, index);
    for(auto &x : res) {
      chmax(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
struct gen{
  int time;
  int basyo;
  int syozi;
};
int main(){
  while(1){
  int n;cin >> n;
  if(n==0) break;
  int dp[4][100];
  rep(i,4){
    rep(j,100)dp[i][j]=INF;
  }
  int bef=0,beft=0;
  vector<pair<int,int>> v(n);
  rep(i,n){
    int a,b;cin >> a >> b;
    v[i] = {a,b};//場所,時間
  }
  rep(i,n){
    int a,b;
    a=v[i].first;
    b=v[i].second;
    if(i==0){
      if(a>b){
        cout << "NG 1" << endl;
        break;
      }
      dp[1][i] = a;
      bef=a;
      beft=b;
      continue;
    }
    int check = 0;
    rep(j,4){
      if(j==0) continue;
      if(dp[j][i-1]==INF) continue;
      if(abs(a-bef)*(j+1)<=b-beft&&j<3){
        dp[j+1][i]=dp[j][i-1]+abs(a-bef);
      }
      if(bef*(j+1)+a<=b-beft){
					dp[1][i]=min(dp[j][i-1]+a+bef,dp[1][i]);
				}
    }
    bef=a;
    beft=b;
    rep(j,4){
      if(dp[j][i]!=INF) check=1;
    }
    if(check==0){
      cout << "NG " << i+1 << endl;
      break;
    }
  }
    int ans = INF;
    rep(i,3){
      ans = min(ans,dp[i+1][n-1]+bef);
    }
    if(ans==INF) continue;
    cout << "OK " << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 2972
def combnk_mod(n, k, p):
    # pが素数かつaとpが互いに素であるとき
    # フェルマーの小定理より以下が成り立つ.
    # 1 / a = a ** (p - 2) (mod p)
    # これを使って (1 / k!) mod p を計算する.

    if  2 * k > n:
        k = n - k
    x = 1 # 分母にあたる数 1 / n! mod p
    y = 1 # 分子にあたる数. n! / (n - k)! mod p
    for i in range(1, k + 1):
        x *= pow(i, p - 2, p)
        y *= n - i + 1
        x %= p
        y %= p
    return (x * y) % p

n, m, k = map(int, input().split())
MOD = 10 ** 9 + 7
p = combnk_mod(n * m - 2, k - 2, MOD)
x, y = 0, 0
for i in range(2):
    for d in range(1, n):
        x += d * (n - d) * m ** 2
        x %= MOD
    x, y = y, x
    n, m = m, n
print(p * (x + y) % MOD)


Measured memory_bytes: 3064
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long n;
long long y;
int main(){
cin>>n>>y;
for (int i=0;i<=n;i++){
  for (int j=0;j<=n;j++){
    int k=n-i-j;
      if (i+j+k==n && i*10000+j*5000+k*1000==y && k>=0) 
      {
        cout<<i<<" "<<j<<" "<<k<<endl;
        system("pause");
        return 0;
     }
    } 
 }
cout<<"-1 -1 -1"<<endl;
return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		if(n == 1) {
			System.out.println("Hello World");
		}else {
			System.out.println(ni() + ni());
		}
	}
	
	private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	}

	private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

long long int gcd(long long int g_a,long long int g_b){
	if(g_a<g_b)gcd(g_b,g_a);
	if(g_b==0)return g_a;
	return gcd(g_b,g_a%g_b);
}

long long int divide(long long int d_a,long long int d_b,long long int d_p=1e9+7){
	// d_a/d_b mod d_p
	// prime:d_p is prime
	if(d_a>=d_p)d_a%=d_p;
	if(d_a<0)d_a+=d_p;
	if(d_b>=d_p)d_b%=d_p;
	if(d_b<0)d_b+=d_p;
	d_a*=pow_mod(d_b,d_p-2,d_p);
	return d_a%d_p;
}

LL kai[420000];

LL comb(LL a,LL b){
	LL s=kai[a];
	s=divide(s,kai[b]);
	s=divide(s,kai[a-b]);
	return s;
}

int main(){
	LL n,m;
	LL i,j,k;
	LL a,b,c;
	cin>>n>>m;
	kai[0]=1;
	for(i=1;i<=n*2;i++){
		kai[i]=kai[i-1]*i;
		kai[i]%=MAX;
	}
	if(m>=n-1){
		cout<<comb(2*n-1,n-1)<<endl;
		return 0;
	}
	LL s=1;
	for(i=1;i<=m;i++){
		a=comb(n,i)*comb(n-1,i);
		s+=a%MAX;
	}
	cout<<s%MAX<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    int n,p,i;
    cin>>n>>p;
    std::string s;
    cin>>s;
    ll ans=0;

    if(p==2){
        rep(i,n){
            if((s[i]-'0')%2==0) ans+=i+1;
        }
    }else if(p==5){
        rep(i,n){
            if((s[i]-'0')%5==0) ans+=i+1;
        }
    }else{
        int k=1;
        vector<int> a(p,0);
        a[0]=1;
        int b=0;
        rep(i,n){
            b=(b+k*(s[n-1-i]-'0'))%p;
            b=b%p;
            ans+=a[b];
            a[b]+=1;
            k=(k*10)%p;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 8)

def dfs(now, par, d, dist, g):
    dist[now] = d
    for to, cost in g[now]:
        if to == par: continue
        dfs(to, now, d + cost, dist, g)


n = int(raw_input())
g = [[] for _ in xrange(n)]
for i in xrange(n - 1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1
    g[a].append([b, c])
    g[b].append([a, c])
q, k = map(int, raw_input().split())
k -= 1
dist = [-1] * n
dfs(k, -1, 0, dist, g)
for i in xrange(q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print dist[x] + dist[y]


Measured memory_bytes: 136808
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;
void  print(int n)    {printf("%d ", n);}
void  printl(long long n)     {printf("%I64d ", n);}
long long  readline(){long long x;scanf("%I64d", &x);return x;}
template <typename T> inline void readline(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
  while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
#define   all(n) n.begin(),n.end()
#define  pb             push_back
#define  ll             long long int
#define  nl             printf("\n");
#define  happy          cin.tie(0);
#define  coding         ios::sync_with_stdio(false);
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;

typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define  mpsi std::map<string, int>

const int N             = 4e5 + 5;
const int N1            = 1e5 + 5;
int a[N];
string s;

bool isPal(int s1 ,int e)
{
	//error(s1,e);
	int z =0;
	for(int i=s1;i<(s1+e+1)/2;i++){
		//error(i,e-1-z);
		if(s[i]!=s[e-1-z++]){
			return false;
		}
	}
	return true;
}

int solve() 
{
	//happy coding
	cin>>s;
	int n = s.size();
	if(isPal(0,n)){
		if(isPal(0,(n-1)/2)){
		if(isPal((n+3)/2-1,n)) {
			cout<<"Yes"<<endl;
		}
		else
			cout<<"No"<<endl;
		}else{
		cout<<"No"<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	//if(isPal((n+3)/2-1,n)) cout<<"Yes"<<endl;
	return 0;
	//error();
}
int main(){
	int test = 1, tc = 0;
	//scanf("%d", &test);//(void)getchar();
	while (test--)solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007

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

ll lcm(ll a, ll b)  {
    return (a*b)/gcd(a, b);
}

ll fact(ll n){
    if(n==0)
        return 1;
    else
        return n*fact(n-1);
}

const int MAX = 1000001;

ll factor[MAX] = { 0 };

void generatePrimeFactors(){
    factor[1] = 1;
    ll i;
    for (i = 2; i < MAX; i++)
        factor[i] = i;
    for (i = 4; i < MAX; i += 2)
        factor[i] = 2;
    for (i = 3; i * i < MAX; i++) {
        if (factor[i] == i) {
            for (ll j = i * i; j < MAX; j += i) {
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

ll calculateNoOFactors(ll n){
    if (n == 1)
        return 1;

    ll ans = 1, dup = factor[n], c = 1, j = n / factor[n];
    while (j != 1) {
        if (factor[j] == dup)
            c += 1;
        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }
        j = j / factor[j];
    }
    ans = ans * (c + 1);

    return ans;
}

void solve(){

    ll N;
    cin>>N;
    generatePrimeFactors();
    ll i,c=0;
    for(i=1;i<N;i++){
        ll x = calculateNoOFactors(i);
        //cout<<x<<"\n";
        c += x;
    }
    cout<<c;



}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("D:\\codes\\1input.txt","r",stdin);
    //freopen("D:\\codes\\1output.txt","w",stdout);
    ll T=1;
    //cin>>T;
    for(ll t=1;t<=T;t++){
        //cout<<"Case #"<<t<<": ";
        solve();
        //cout<<"\n";
    }
}


Measured memory_bytes: 11476
import scala.annotation.tailrec

object Main{
	@tailrec
	def gcd(a:Int,b:Int):Int ={
		if(b==0) a
		else if(a % b == 0) b else gcd(b,a % b)
	}
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n = s.nextInt
		val a = Array.fill(n)(s.nextInt)
		val l,r = Array.fill(n + 2)(0)
		for(i <- 1 to n)
			l(i) = gcd(l(i - 1),a(i - 1))
		for(i <- n to 1 by -1)
			r(i) = gcd(r(i + 1),a(i - 1))
		println((1 to n).map(i => gcd(l(i - 1),r(i + 1))).max)
	}
}

Measured memory_bytes: 56344
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
ans = 0
a = 100
while 1:
    ans += 1
    a = int(1.01*a)
    if a >= x:
        print(ans)
        quit()

Measured memory_bytes: 67200
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  vi p(a),q(b),r(c);
  for(auto &aa:p)cin>>aa;
  for(auto &aa:q)cin>>aa;
  for(auto &aa:r)cin>>aa;
  sort(ALL(p),greater<ll>());
  sort(ALL(q),greater<ll>());
  sort(ALL(r));
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<>>que,que2;
  for(int i=0;i<x;i++)que.push(mp(p[i],0));
  for(int i=0;i<y;i++)que2.push(mp(q[i],0));
  for(int i=0;i<c;i++){
    if(que.top().F > que2.top().F){
      if(r[i] > que2.top().F){
      que2.pop();
      que2.push(mp(r[i],1));
      }
    }else{
      if(r[i] > que.top().F){
	que.pop();
	que.push(mp(r[i],1));
      }
    }
  }
  ll ans = 0;
  while(!que.empty()){
    ans += que.top().F;
    que.pop();
  }
  while(!que2.empty()){
    ans += que2.top().F;
    que2.pop();
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7152
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::BTreeMap;

fn main() {
    input!{
        n:usize,
        a:[usize; n],
    }
    let mut map = BTreeMap::new();
    for aa in a {
        *map.entry(aa).or_insert(0) += 1;
    }
    let mut ans=0;
    for (_, c) in map {
        if c%2==1 {
            ans+=1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
<?php

fscanf(STDIN, "%s", $a);

$length = strlen($a);
$arr = [];
$sum = 0;

for ($i = 0; $i < $length; $i++) {
    $tem = substr($a, 0, 1);
    array_push($arr, $tem);
    $a = substr($a, 1);
}

$arr_count = count($arr);

for ($i = 0; $i < $arr_count; $i++) {
     if ($arr[$i] === "+") {
         $sum = $sum + 1; 
     } else {
         $sum = $sum - 1;
     }
}

echo $sum;

?>


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

bool ok(string s){
  int l = 0, r = (int)s.length() - 1;
  while(l < r){
    if(s[l] != s[r]) return false;
    l++;
    r--;
  }
  return true;
}

int main(){
  string s; cin >> s;
  int n = s.length();
  if(ok(s.substr(0, n)) && ok(s.substr(0, n/2)) && ok(s.substr(n/2+1, n/2))){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
         
        while (true) {
            int h = sc.nextInt(); int w = sc.nextInt();
            if (h==0 && w==0) return;
             
            for (int i=0; i<h; i++) {
                StringBuilder sb = new StringBuilder();
                for (int j=0; j<w; j++) {
                    if (i%2==0) {
                        if (j%2==0) sb.append("#");
                        else sb.append(".");
                    }
                    else {
                        if (j%2==0) sb.append(".");
                        else sb.append("#");
                    }
                }
                System.out.println(sb);
            }
             
            System.out.println();
        }
         
    }
}


Measured memory_bytes: 28764
//C
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	int H[N + 1];
	for (int i = 1; i <= N; i++) {
		scanf("%d", &H[i]);
	}
	vector<int> adjlist[N + 1];
	set<pair<int, int> > data;
	for (int i = 0; i < M; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		if (u > v) swap(u, v);
		if (data.count(mp(u, v)) == 0) {
			adjlist[u].pb(v);
			adjlist[v].pb(u);
			data.insert(mp(u, v));
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		bool cek = 1;
		for (auto j : adjlist[i]) {
			if (H[j] >= H[i]) cek = 0;
		}
		ans += cek;
	}	
	printf("%d\n", ans);
}

Measured memory_bytes: 13916
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        int count = 0;
        while (true)
        {
            if (n[0] == n[1] && n[1] == n[2]) break;
            count++;
            int Max = n.Max();
            int Min = n.Min();
            if (Max - Min == 1)
            {
                if (Max == n[0])
                {
                    if (n[1] == n[2]) { n[1] += 1; n[2] += 1; }
                    else
                    {
                        if (Min == n[1]) n[1] += 2;
                        else if (Min == n[2]) n[2] += 2;
                    }
                }
                else if (Max == n[1])
                {
                    if (n[0] == n[2]) { n[0] += 1; n[2] += 1; }
                    else
                    {
                        if (Min == n[0]) n[0] += 2;
                        else if (Min == n[2]) n[2] += 2;
                    }
                }
                else if (Max == n[2])
                {
                    if (n[1] == n[0]) { n[1] += 1; n[0] += 1; }
                    else
                    {
                        if (Min == n[1]) n[1] += 2;
                        else if (Min == n[0]) n[0] += 2;
                    }
                }
            }
            else
            {
                if (Min == n[0]) n[0] += 2;
                else if (Min == n[1]) n[1] += 2;
                else if (Min == n[2]) n[2] += 2;
            }
            //Console.WriteLine(n[0] + " " + n[1] + " " + n[2]);
        }
        Console.WriteLine(count);
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13396
S = input()
M = int(input())
for _ in range(M):
    op, *args = input().split()
    a = int(args.pop(0))
    b = int(args.pop(0))
    if op == "print":
        print(S[a:b + 1])
    elif op == "reverse":
        S = S[:a] + S[a:b + 1][::-1] + S[b + 1:]
    elif op == "replace":
        p = args.pop(0)
        S = S[:a] + p + S[b + 1:]



Measured memory_bytes: 5612
n = gets.to_i
a = gets.split(" ").map{|d|d.to_i}

def func m, a
    a.inject(0){|sum, i| sum += m%i }
end


# 2 <= N < 3000
# 2 <= ai <= 100000

c=1
a.each do |aa|
    c *= aa
end

puts func c-1, a


Measured memory_bytes: 11388
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#import itertools #list(accumulate(A))
#from collections import deque

## FlagをもたせたDFS

N = ii()
ele = [3, 5, 7]
l = []

def dfs(num, flag):
    if num > N:
        return 
    if flag == 7:
        l.append(num)
    num *= 10
    for i, e in enumerate(ele):
        dfs(num+e, flag | 1<<i)

dfs(0, 0)
print(len(l))

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//世界の皆は頭ええな

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


	ll N, D;
	cin >> N >> D;
	ll kotae = (N - 1) * D;
	ll A[200001], C[200001];
	C[0] = 1e18;
	rep1(i, N) {
		cin >> A[i];
		kotae += A[i];
		C[i] = min(C[i - 1] + D, A[i]);
	}
	ll mae = 1e18;
	for (int i = N - 1; i > 1; i--) {
		mae = min(mae + D, A[i + 1]);
		ll kari = min(mae, C[i - 1]) + D;
		kotae += min(A[i], kari);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define mp make_pair
#define fr first
#define sc second
#define pI pair <int, int>
const int MOD = 1e9 + 7;
using namespace std;
int n;
const int N = 300000;
int xi[N], vi[N], sx[N], sv[N], ai[N];
int mx[N], L[N], R[N];
void put(int t, int d) {for (; t <= n; t += (t & -t)) mx[t] = max(mx[t], d);}
int query(int t) {int d = 0; for (; t; t -= (t & -t)) d = max(d, mx[t]); return d;}
pI V[N]; int psum[N], ans;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> xi[i] >> vi[i];
    for (int i = 1; i <= n; ++ i) sx[i] = xi[i], sv[i] = vi[i];
    sort(sx + 1, sx + n + 1); sort(sv + 1, sv + n + 1);
    for (int i = 1; i <= n; ++ i)
        ai[lower_bound(sv + 1, sv + n + 1, vi[i]) - sv] = lower_bound(sx + 1, sx + n + 1, xi[i]) - sx;
    for (int i = 1; i <= n; ++ i)
    {
        put(n - ai[i] + 1, n - i + 1);
        L[i] = n - query(n - ai[i] + 1) + 1;
    }
    for (int i = 1; i <= n; ++ i) mx[i] = 0;
    for (int i = n; i >= 1; -- i)
    {
        put(ai[i], i);
        R[i] = query(ai[i]);
    }
    // for (int i = 1; i <= n; ++ i) cout << L[i] << " " << R[i] << endl;
    for (int i = 1; i <= n; ++ i) V[i] = mp(R[i], L[i]);
    sort(V + 1, V + n + 1);
    // for (int i = 1; i <= n; ++ i) cerr << V[i].sc << " " << V[i].fr << endl;
    for (int i = 1; i <= n; ++ i)
    {
        int j = lower_bound(V + 1, V + n + 1, mp(V[i].sc - 1, 0)) - V;
        psum[i] = (0ll + psum[i - 1] + psum[i - 1] - psum[j - 1] + MOD) % MOD;
        if (V[i].sc == 1) psum[i] ++;
        if (V[i].fr == n) ans = (0ll + ans + psum[i] - psum[i - 1] + MOD) % MOD;
        // cerr << j << " " << i << " " << psum[i] << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12416
import bisect

N = int(input())
INF = 10**10
nums = list(map(int, input().split()))
nums.sort()
n_max = nums[-1]
n_half = n_max//2
nums = [-INF] + nums + [INF]
pos = bisect.bisect_left(nums, n_half)
if abs(n_half-abs(n_max-nums[pos])) >= abs(n_half-abs(n_max-nums[pos-1])):
  print(n_max, nums[pos-1])
else:
  print(n_max, nums[pos])



Measured memory_bytes: 14052
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	int a, b, c;

	cin >> a >> b >> c;

	if ( a == b && b == c) {
		cout << "No";
		return 0;
	}

	if ( a != b && b != c && a != c) {
		cout << "No";
		return 0;
	}

	cout << "Yes";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

int main() {
  int N,M;cin>>N>>M;
  vector<int> a(N);
  rep(i,N) {
    cin>>a[i];
    a[i]/=2;
  }
  int fst = a[0], two = 1;
  while(1) {
    if(fst % 2 == 0) {
      two*=2;
      fst/=2;
    } else {
      break;
    }
  }
  rep(i,N-1) {
    if(!((a[i+1] % two == 0) && (a[i+1] % (two*2) != 0))) {
      cout<<0<<endl;
      return 0;
    }
  }
  ll lcm = 1;
  rep(i,N) {
    lcm = LCM(lcm,a[i]);
  }
  cout<< (M / lcm + 1) / 2 << endl;
}


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

using namespace std;

using ll = long long;
using p_ll = pair<ll, ll>;
#define INF (ll) 1e15


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

    int n;
    cin >> n;
    struct edge { ll to, cost; };
    vector<edge> G[n + 1];
    ll a, b, c;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >>  b >> c;
        edge ab { b, c };
        G[a].push_back(ab);
        edge ba { a, c };
        G[b].push_back(ba);
    }

    int q, k;
    cin >> q >> k;

    ll d[n + 1];

    priority_queue<p_ll, vector<p_ll>, greater<p_ll>> que;
    fill(d, d + n + 1, INF);
    d[k] = 0;
    que.push(p_ll(0, k));

    while (!que.empty()) {
        p_ll p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(p_ll(d[e.to], e.to));
            }
        }
    }


    int x, y;
    while (q--) {
        cin >> x >>  y;
        cout << d[x] + d[y] << '\n';
    }

    return 0;
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<ll> h(n+1);
    for(int i=1;i<=n;i++) cin>>h[i];
    vector<ll> adj[n+1];
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll maxi=-1;
        for(ll j:adj[i]) maxi=max(maxi,h[j]);
        if(h[i]>maxi) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9796
#include <iostream>
#include <cstdio>

using namespace std;

int main(){

  int w, n, a, b;

  cin >> w >> n;

  int lot[w];

  for(int i = 0; i < w; ++i){
    lot[i] = i + 1;
  }

  for(int i = 0; i < n; ++i){
    scanf("%d,%d", &a, &b);
    int temp = lot[a - 1];
    lot[a - 1] = lot[b - 1];
    lot[b - 1] = temp;
  }

  for(int i = 0; i < w; ++i){
    cout << lot[i] << endl;
  }

}

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

int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    string ans = "Yes";
    for(int i = 0; i < a; i++){
        if(!(s[i] >= '0' && s[i] <= '9')) ans = "No";
    }
    if(s[a] != '-') ans = "No";
    for(int i = a+1; i < a+b+1; i++){
        if(!(s[i] >= '0' && s[i] <= '9')) ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	long[] nums=new long[4];
  	for(int i=0;i<4;i++){
  		nums[i]=sc.nextLong();
  	}
  	long e,g=0;
  	long n1=nums[2],n2=nums[3];
  	
  	while(g==0){
  		if(n2%n1==0){
  			g=n1;
  		}else{
  			e=n1%n2;
  			n1=n2;
  			n2=e;
  		}
  	}
  			
  	long f=(nums[1]-(nums[1]/nums[2]+nums[1]/nums[3]-nums[1]/(nums[2]*nums[3]/g)))-(nums[0]-1-((nums[0]-1)/nums[2]+(nums[0]-1)/nums[3]-(nums[0]-1)/(nums[2]*nums[3]/g)));
  	System.out.print(f);
  }
}

Measured memory_bytes: 21972
N = int(input())
A = sorted(list(map(int, input().split())))
M = A[-1]
b = [True]*(M + 1)

count = 0
for i, a in enumerate(A):
    if not b[a]:
        continue
    for j in range(a, M+1, a):
        b[j] = False
    if i < N-1 and A[i+1] == a:
        continue
    count += 1

print(count)


Measured memory_bytes: 32260
#include <stdio.h>
#include <math.h>

#define RAD60 60*M_PI/180

typedef struct {
  double x;
  double y;
} Point;

void kock(int, Point, Point);


int main() {
  int n;
  Point p1={0, 0}, p2={100, 0};
  
  scanf( "%d" , &n );
  printf( "%f %f\n" , p1.x , p1.y );
  kock(n, p1, p2);
  printf( "%f %f\n" , p2.x , p2.y );
  
  return 0;
}


void kock(int n, Point p1, Point p2) {
  Point s, t, u;
  
  if ( n == 0 ) return;
  s.x = (2*p1.x + 1*p2.x)/3;
  s.y = (2*p1.y + 1*p2.y)/3;
  t.x = (1*p1.x + 2*p2.x)/3;
  t.y = (1*p1.y + 2*p2.y)/3;
  u.x = (t.x-s.x)*cos(RAD60) - (t.y-s.y)*sin(RAD60) + s.x;
  u.y = (t.x-s.x)*sin(RAD60) + (t.y-s.y)*cos(RAD60) + s.y;

  kock(n-1, p1, s);
  printf( "%f %f\n" , s.x , s.y );;
  kock(n-1, s, u);
  printf( "%f %f\n" , u.x , u.y );;
  kock(n-1, u, t);
  printf( "%f %f\n" , t.x , t.y );;
  kock(n-1, t, p2);
}



Measured memory_bytes: 2048
import java.*;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {
	static int N;
	static int K;
	static int List[];
	static int[] status;
	static int Answer,Min;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner ss = new Scanner(System.in);
		N = ss.nextInt();
		K = ss.nextInt();
		List = new int[N+1];
		for (int i = 1; i < N+1; i++) {
			List[i] = ss.nextInt();
		}
		int flag=1;
		int num = K;
		for (int i = 1; i < N; i++) {
			if(List[N]<0) {
				flag = N+1;
				break;
			}
			if(List[i]<0 && List[i+1]<0)continue;
			if(List[i]==0) {
				flag = i;
				num = K-1;
				break;
			}
			if(List[i]<0 && List[i+1]>0) {
				flag =i+1;
				break;
			}	
		}
		Answer = Integer.MAX_VALUE;
		int L=0;
		int R=0;
		int cnt=0;
		for (int i = num; i >=0; i--) {
			if(flag == N+1) {
				cnt = Math.abs(List[N-K+1]);
				Answer = Math.min(cnt, Answer);
				break;
			}
			L = flag-i;
			R = flag+(K-1-i);
			if(L<=0 || R>N)continue;
			if(List[R]<=0) {
				cnt = Math.abs(List[L]);
				Answer = Math.min(cnt, Answer);
				continue;
			}
			if(List[L]>=0) {
				cnt = Math.abs(List[R]);
				Answer = Math.min(cnt, Answer);
				continue;
			}
			cnt = Math.min(Math.abs(List[L])*2+List[R], Math.abs(List[L])+List[R]*2);
			Answer = Math.min(cnt, Answer);
		}

		System.out.println(Answer);
	}


}


Measured memory_bytes: 51432
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	sum := func() int { stdin.Scan(); i, _ := strconv.Atoi(stdin.Text()); return i }()
	ichien := func() int { stdin.Scan(); i, _ := strconv.Atoi(stdin.Text()); return i }()
	sum = sum % 500
	var o = "No"
	if sum <= ichien {
		o = "Yes"
	}
	fmt.Println(o)
}

Measured memory_bytes: 640