akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    map<string, int> m;
    REP(i, N){
        string S;
        cin >> S;
        m[S]++;
    }
    pr("AC", "x", m["AC"]);
    pr("WA", "x", m["WA"]);
    pr("TLE", "x", m["TLE"]);
    pr("RE", "x", m["RE"]);
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <fstream>
#include <complex>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <complex>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
        os << '\"' << *it << '\"' << (it + 1 == v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

int cur[101];
vi b[1000];

int main(){
    int n, m, a;
    while (cin >> n >> m >> a, n){
        
        rep(i, 101) cur[i] = i;
        rep(i, m){
            int a, p, q; cin >> a >> p >> q;
            b[i] = vi{ a, p, q };
        }

        sort(b, b + m);
        rep(i, m) swap(cur[b[i][1]], cur[b[i][2]]);
        cout << cur[a] << endl;
    }
}

Measured memory_bytes: 1248
import Data.List
import Data.Maybe

solve :: Int -> Int
solve n
  | n `mod` 2 /= 0 = 0
  | otherwise = 1 + solve (n `div` 2)

main :: IO ()
main = do
  n <- readLn
  let res = solve <$> [1..n]
  print . (+1) . fromJust $ maximum res `elemIndex` res

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

class Combination{
	private:
		const static long long MOD = 1e9+7;
		const static long long MAX = 510000;
		vector<long long> fact;
		vector<long long> finv;
		vector<long long> inv;
	public:
		Combination() : fact(MAX),finv(MAX),inv(MAX){
			fact[0] = fact[1] = 1;
			finv[0] = finv[1] = 1;
			inv[1] = 1;
			for(int i=2;i<MAX;i++){
				fact[i] = fact[i-1] * i % MOD;
				inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
				finv[i] = finv[i-1] * inv[i] % MOD;
			}
		}

		long long nCk(long long n,long long k){
			if(n<k) return 0;
			if(n<0 || k<0) return 0;
			return fact[n] * (finv[k] * finv[n-k] % MOD) % MOD;
		}
};

long long modpow(long long a,long long n,long long p = 1e9+7){
    long long result = 1;
    while(n > 0){
        if(n & 1) (result *= a) %= p;
        (a*=a) %= p;
        n >>= 1;
    }
    return result;
}
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll mod = 1e9+7;
ll kaiz[200100];
void kaizyo(){
    kaiz[0] = 1;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    Combination C;
    ll ans = 0;
    rep(i,0,min(k+1,n)){
		ans+= (C.nCk(n,i) * C.nCk(n-1,n-i-1)%mod);
		ans%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12288
#include <stdio.h>

int main()
{
	int N, K, Q;
	scanf("%d %d %d", &N, &K, &Q);
	int A[Q];
	int i = 1;
	while (i <= Q)
		scanf("%d", &A[i++]);
	int nb[N];
	i = 1;
	while (i <= N)
	{
		nb[i] = K - Q;
		i++;
	}
	i = 1;
	while (i <= Q)
	{
		nb[A[i]] += 1;
		i++;
	}
	i = 1;
	while (i <= N)
	{
		if (nb[i] > 0)
			printf("Yes\n");
		else
			printf("No\n");
		i++;
	}
	return (0);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 998244353;

template <typename T> void add(T &x, const T &y)
{
	x = (x+y) % MOD;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

unordered_map<ull, ll> mp;

ull get_hash(string s)
{
	ull h = 0;
	for(auto x : s) h = h*31 + x;
	return h;
}

string str_and(string s, string t)
{
	string ret(s.length(), '0');
	assert(s.length() == t.length());
	for(int i=0; i<s.length(); i++)
		if(s[i]=='1' && t[i]=='1')
			ret[i] = '1';
	return ret;
}

ll calc(string s)
{
	if(!s.length()) return 1;
	else if(s.length() == 1) return s[0]-'0'+1;
	ull h = get_hash(s);
	if(mp.count(h)) return mp[h];
	ll ret = calc(s.substr(1)) * (s[0]-'0'+1) % MOD;
	for(int i=1; i*2<=s.length(); i++)
	{
		string ns = s.substr(0, i);
		for(int j=2; i*j<=s.length(); j++)
		{
			ns = str_and(ns, s.substr(i*(j-1), i));
			add(ret, calc(ns) * calc(s.substr(i*j, s.length()-i*j)));
		}
	}
	mp[h] = ret;
	return ret;
}

int main()
{
	string s;
	cin >> s;
	cout << calc(s) << endl;
	return 0;
}

Measured memory_bytes: 2188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  ll N;
  cin>>N;
  
  vector<ll>a(N);
 
  rep(i,N){
    cin>>a[i];
  }
  
  sort(all(a));
  ll ans=0;
  for(ll i=0;i<N;i++){//初項と末覗く
    ll first=lower_bound(all(a),a[i]-1)-a.begin();//a-1の初項
    ll end=upper_bound(all(a),a[i]+1)-a.begin()-1;//a+1の松高
    
    ll sum=abs(end-first)+1;
    
    if(ans<sum){
      ans=sum;
    }
  }

  
  cout<<ans<<endl;
}

  

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
def main():
    X, Y = map(int, input().split())
    ans = "No"
    for i in range(101):
        for j in range(101):
            if i + j == X and 2 * i + 4 * j == Y:
                ans = "Yes"
                break
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 62976
using System;
using System.Collections.Generic;

class Procon
{
  public Procon() {}
  static void Main(string[] agrs)
  {
    new Procon().Do();
  }

  Scanner cin;

  public void Do()
  {
    cin = new Scanner();
    int N = cin.nextInt();
    List<int[]>[] node = new List<int[]>[N];
    for (int i=0; i<N; i++) {
      node[i] = new List<int[]>();
    }
    for (int i=0; i<N-1; i++) {
      int a = cin.nextInt()-1;
      int b = cin.nextInt()-1;
      int c = cin.nextInt();
      node[a].Add(new int[]{b, c});
      node[b].Add(new int[]{a, c});
    }

    int Q = cin.nextInt();
    int K = cin.nextInt() - 1;
    long[] d = new long[N];
    for (int i=0; i<N; i++) 
    {
      d[i] = -1;
    }
    d[K] = 0;

    recur(node, d, K);

    for (int i=0; i<Q; i++) 
    {
      int x = cin.nextInt() - 1;
      int y = cin.nextInt() - 1;
      Console.WriteLine((long)d[x] + (long)d[y]);
    }
  }
  
  public static void recur(List<int[]>[] node, long[] d, int n) 
  {
    for (int i=0; i < node[n].Count; i++) 
    {
      if (d[n] >= 0 && d[node[n][i][0]] < 0) 
      {
        d[node[n][i][0]] = d[n] + node[n][i][1];
        recur(node, d, node[n][i][0]);
      }
    }
  }
}


class Scanner
{
  string[] s;
  int i;
  int max_i;

  public Scanner()
  {
    s = new string[0];
    max_i = 0;
    i = 0;
  }

  public string nextString()
  {
    if (i >= s.Length) 
    {
      s = Console.ReadLine().Split(' ');
      max_i = s.Length;
      i = 0;
      if (max_i == 0) 
      {
        return "";
      }
      return s[i++];
    } else 
    {
      return s[i++];
    }
  }

  public int nextInt()
  {
    return int.Parse(nextString());
  }


  public long nextLong()
  {
    return long.Parse(nextString());
  }

  public double nextDouble()
  {
    return double.Parse(nextString());
  }

  public string[] arrayString()
  {
    return Console.ReadLine().Split(' ');
  }

  public int[] arrayInt()
  {
    string[] str = Console.ReadLine().Split(' ');
    int[] array = new int[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = int.Parse(str[i]);
    }
    return array;
  }

  public long[] arrayLong()
  {
    string[] str = Console.ReadLine().Split(' ');
    long[] array = new long[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = long.Parse(str[i]);
    }
    return array;
  }

  public double[] arrayDouble()
  {
    string[] str = Console.ReadLine().Split(' ');
    double[] array = new double[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = double.Parse(str[i]);
    }
    return array;
  }
}


Measured memory_bytes: 46880
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		if (Ai[i] <= B + tmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = B + tmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			hunt += B + tmp;
    			tmp = 0L;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
}

Measured memory_bytes: 82200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int check(int i, int j, int k)
{
    if (i + j <= k)
        return 0;
    else
        return 1;
}
int main()
{
    ll n, a[105];
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = 0;
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n - 2; i++)
    {
        for (int j = i + 1; j <= n - 1; j++)
        {
            if (a[j] == a[i])
                continue;
            for (int k = j + 1; k <= n; k++)
            {
                if (a[k] == a[j])
                    continue;
                if (check(a[i], a[j], a[k]))
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define MAX 252

int main(){
  int datanum,i,heaptree[MAX];
  scanf("%d",&datanum);
  for(i=1;i<=datanum;i++){
    scanf("%d",&heaptree[i]);
  }
    for(i=1;i<=datanum;i++){
      printf("node %d: key = %d, ",i,heaptree[i]);
      if(i != 1)printf("parent key = %d, ",heaptree[i/2]);
      if(datanum >= i * 2)printf("left key = %d, ",heaptree[i*2]);
      if(datanum >= i * 2 + 1)printf("right key = %d, ",heaptree[i*2+1]);
      printf("\n");
    }
  return 0;
}




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

int main(){
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if ( m1 == m2){
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l),S.substr(l, r)
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//'0'+cnt 数字cntからcharへの変換

int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    string alpha;
    alpha = "abcdefghijklmnopqrstuvwxyz";
    bool up,down;
    int cnt;
    int ans =0;
    rep(i,n-1){
        cnt = 0;
        rep(j,26){
            up = false;
            down = false;
            rep(k,i+1){
                if(s.at(k) == alpha.at(j)) up = true;
            }
            for(int l = i+1; l < n; l++){
                if(s.at(l) == alpha.at(j)) down = true;
            }
            if(up&&down) cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//@uthor: _|EE|_RB30

#include<bits/stdc++.h>
using namespace std;
#define int long long

#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pb push_back

#define pii pair<int,int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>

#define M 1000000009
#define pi 3.141592653589793238
#define endl "\n"
#define brisk ios_base::sync_with_stdio(false);cin.tie(NULL);

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

     vi a(n);
     for(int i=0;i<n;i++)cin>>a[i];

     sort(a.begin(),a.end(),greater<int>());
     
     int ans = a[0], end = a[1];
     
     int z = 1;
     for(int i=2;i<n;i+=2){
          ans+=2*a[z++];
          //cout<<ans<<" ";
     }

     if(n%2)ans-=a[n/2];

     cout<<ans;
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 998244353;
const int INF = 1e18;

long long mod_pow(long long x, long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x*x % mod, n / 2);
    if(n & 1) res = res*x % mod;
    return res;
}

int dp[100000], nxt[100000];
int dp2[100000], nxt2[100000];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    int sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }
    dp[0] = 1;
    dp2[0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 100000; j++) nxt[j] = 0, nxt2[j] = 0;
        for(int j = 0; j < 100000; j++){
            if(j + a[i] < 100000){
                (nxt[j + a[i]] += dp[j]) %= mod;
                (nxt2[j + a[i]] += dp2[j]) %= mod;
            }
            (nxt[j] += dp[j] * 2) %= mod;
            (nxt2[j] += dp2[j]) %= mod;
        }
        swap(dp, nxt);
        swap(dp2, nxt2);
    }
    for(int i = (sum + 1) / 2; i <= sum; i++){
        (ans += dp[i]) %= mod;
    }
    if(sum % 2 == 0) ans = (ans - dp2[sum / 2] + mod) % mod;
    (ans *= 3) %= mod;
    // cout << mod_pow(3, n) << ' ' << ans << endl;
    ans = (mod_pow(3, n) - ans + mod) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
 
//________________________________________________________________________________________________________
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in freopen("input.txt","r",stdin)
#define out freopen("output.txt","w",stdout);
#define ll long long 
//________________________________________________________________________________________________________
ll lcm(ll a,ll b) {if(a==0 || b==0){return 0;}else{return (a*b)/__gcd(a,b);}} //


//--------------------------------------------------------------------------------------------------------
int main()
{
// #ifndef ONLINE_JUDGE
//     in;
//    //out;
// #endif
    //fastread;
    int n;cin>>n;
    string s;cin>>s;
    int l = s.size();
    for(int i=0;i<l;i++)
    {
        int tmp = s[i]-'A'+n;
        printf("%c",tmp%26+'A');
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		String[] mozi = new String[n];
		int count = 0;

		for(int i=0;i<n;i++) {
			mozi[i] = scan.next();
		}

		List<String> listA = new ArrayList<String>(Arrays.asList(mozi));
		List<String> listB = new ArrayList<String>(new HashSet<>(listA));

		for(String s:listB) {
			count++;
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 70080
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
#define ll long long
#define ld long double
#define ALL(x) begin(x),end(x)
     
int main(){
  ll n; cin >> n;
  vector<ll> vec; //順列生成
  for(ll i=1;i<=n;i++) vec.push_back(i);
  
  vector<ll> p(n),q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  ll pa = 0,qb  =0;
  ll now  =1;
  do{
    if(vec==p) pa = now;
    if(vec==q) qb = now;
    now++;
  } while (std::next_permutation(vec.begin(), vec.end()));
  
  cout << abs(pa-qb) << endl;
}

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

#define int long long
const int INF = 100000000000000000;

const int MAX_T = 305;

int T;
int A[MAX_T], B[MAX_T], C[MAX_T], D[MAX_T];

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    if(m < n) {
        swap(m, n);
    }

	// ユークリッドの方法
	while( n != 0 )
	{
        int nn = m%n;
        m = n;
        n = nn;
	}
	return m;
}//gcd


signed main()
{
    cin >> T;
    for(int i = 0; i < T; i++) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        if(D[i] < B[i] || A[i] < B[i]) {
            cout << "No" << endl;
            continue;
        }

        if(C[i]-1 >= B[i]) {
            cout << "Yes" << endl;
            continue;
        }

        // if(D[i] == B[i]) {
        //     int X = A[i] % B[i];
        //     if(C[i] >= X) {
        //         cout << "Yes" << endl;
        //     } else {
        //         cout << "No" << endl;
        //     }
        //     continue;
        // }

        unordered_set<int> SET;
        int AA = A[i];
        SET.insert(AA);
        AA %= B[i];
        if(C[i] < AA) {
            cout << "No" << endl;
            continue;
        }
        int oldAA = AA;
        AA += D[i];

        AA %= B[i];
        if(C[i] < AA) {
            cout << "No" << endl;
            continue;
        }

        int diffAA = AA - oldAA;

        if(diffAA < 0) {
            diffAA *= -1;
        }

        if(diffAA == 0) {
            cout << "Yes" << endl;
            continue;
        }

        SET.insert(AA);
        while(true) {
            AA += ((C[i] - AA)/diffAA + 1) * diffAA;
            if(AA < B[i]) {
                cout << "No" << endl;
                break;
            }
            AA %= B[i];
            if(!SET.insert(AA).second) {
                cout << "Yes" << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
alist = [[a for a in input()] for i in range(h)]

alist1 = []
for row in alist:
  if '#' in row:
    alist1.append(row)

alist2 = []
for row in zip(*alist1):
  if '#' in row:
    alist2.append(row)

for row in zip(*alist2):
  print(''.join(row))

Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    # dp[1]: flipped
    dp = [[float('inf')] * N for _ in range(2)]
    dp[0][0] = A[0]
    dp[1][0] = -A[0]
    for i, a in enumerate(A[1:], 1):
        dp[0][i] = max(dp[0][i-1]+a, dp[1][i-1]-a)
        dp[1][i] = max(dp[0][i-1]-a, dp[1][i-1]+a)
    return max(dp[0][N-2]+A[-1], dp[1][N-2]-A[-1])


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 33012
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
  input! {
    N:usize, D:i64,
    XY:[(i64,i64);N]
  }
  let mut ans = 0;
  let D2 = D * D;
  for (x, y) in XY.iter() {
    if x.pow(2) + y.pow(2) <= D2 {
      ans += 1;
    }
  }
  println!("{}", ans);
}


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

using namespace std;

int main()
{
	long long n, x;
	long long a = 0, r = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		long long b;
		cin >> b;
		if (a + b > x)
		{
			r += (a + b) - x;
			a = b - ((a + b) - x);
		}
		else a = b;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 384
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ; 
long long n,k;
vector<pair<long long,long long> > h;
long long INF=1e9+10;
long long dx[110][100010];
vector<bool>vis;
long long dp(ll i,ll W){
	// debug() << imie(x);
	if(W>k)return -INF;
	if(i==n)return 0;
	if(dx[i][W]!=-1)return dx[i][W];
	ll choice1 = dp(i+1,W);
	ll choice2 = h[i].second+dp(i+1,W+h[i].first);
	return dx[i][W]=max(choice1,choice2);
}
int main(){
	fastio;
	cin>>n>>k;
	memset(dx,-1,sizeof dx);
	h.resize(n);
	vis.resize(n);
	for(int i=0;i<n;i++){
		cin>>h[i].first>>h[i].second;
	}
	cout << dp(0,0) << endl;
	// cout<<ans<<endl;
	// debug() << imie(dx);
}	

Measured memory_bytes: 86272
import sys
import math
a=0
N=int(input())
i=N
if N==2:
  print(2)
  sys.exit()
elif N==3:
  print(3)
  sys.exit()
elif N==4:
  print(5)
  sys.exit()
elif N==5:
  print(5)
  sys.exit()
while True:
  c=int(math.sqrt(i))
  for j in range(2,c+1):
    if i%j==0:
      a+=1
      break
  if a==0:
    print(i)
    sys.exit()
  a=0
  i=i+1

Measured memory_bytes: 3064
#include <iostream>
#include <string>

#include <stdio.h>
using namespace std;

int main(void) {
	while (1) {
		string num;
		int sum = 0;
		cin >> num;
		if (num == "0") break;
		for (int i = 0; i < num.length(); i++) {
			sum += num[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}



Measured memory_bytes: 3152
n,k=map(int,input().split())
td=[]
for _ in range(n):
  td.append(list(map(int,input().split())))
td.sort(key=lambda x:x[1],reverse=True)
td_core=[]
td_sel=[]
td_sub=[]
cat=[0]*(n+1)
for i in range(n):
  if i < k and cat[td[i][0]]==0:
    td_core.append(td[i])
    cat[td[i][0]]=1
  elif i < k:
    td_sel.append(td[i])
  elif cat[td[i][0]]==0:
    td_sub.append(td[i])
    cat[td[i][0]]=1
# i >= k and cat[td[i][0]]==1 となるものはすでにtd_core,td_sel,td_sub内ものと種類も被っている上に美味しさも低い
# 後の工程は種類を増やす処理なので、同じ種類のネタはそのネタの中で美味しさが最大のもの一つで十分。なので捨てる

# dの大きい順に貪欲にネタを取得したときの満足ポイント
kiso=sum([x[1] for x in td_core])+sum([x[1] for x in td_sel])
bns=len(td_core)
ans=kiso+bns**2
# この状態からネタの種類を増やしていき最大が出てくるか検証
# td_sel内のネタは同一ネタが複数あり、そのネタ内で最大じゃないものが美味しさの大きい順に入っている。
# td_subにはtd_core,td_selにないネタの最大美味しさの寿司が入っている。
td_sel.sort(key=lambda x:x[1])
for i in range(min(len(td_sel),len(td_sub))):
  kiso-=td_sel[i][1]
  kiso+=td_sub[i][1]
  bns+=1
  ans=max(ans,kiso+bns**2)
print(ans)


Measured memory_bytes: 29760
#include <iostream>
#include <vector>
#include <algorithm>

#define LIM 2000000

using namespace std;

int main(){

	int n, m, h[2000], w[2000];
	
	while(cin>>n>>m, (n||m)){
		
		for(int i=0; i<n; ++i){
			cin>>h[i];
		}
		
		for(int i=0; i<m; ++i){
			cin>>w[i];
		}
		
		int res=0;
		vector<int> hlen, wlen;
		
		for(int p=0; p<n; ++p){
			
			int hsum=0;
			
			for(int q=p; q<n; ++q){
				
				hsum+=h[q];
				hlen.push_back(hsum);
			}
		}
		
		for(int r=0; r<m; ++r){
		
			int wsum=0;
			
			for(int s=r; s<m; ++s){
				
				wsum+=w[s];
				wlen.push_back(wsum);
			}
		}
		
		sort(hlen.begin(), hlen.end());
		sort(wlen.begin(), wlen.end());
		
		for(int i=0; i<hlen.size(); ++i){
			
			vector<int>::iterator it1 = lower_bound(wlen.begin(), wlen.end(), hlen[i]),
								  it2 = upper_bound(wlen.begin(), wlen.end(), hlen[i]);
			
			res += it2-it1;
		}
		
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 18832
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	
	ll k;
	int n;
	cin >> k >> n;
	vl a(n);
	for (auto& x : a)
		cin >> x;
	ll max_dif = 0;
	for (int i = 0; i < n - 1; i++)
	{
		ll cdif = abs(a[i + 1] - a[i]);
		max_dif = max(max_dif, cdif);
	}
	ll last_dif = k - a[n - 1] + a[0];
	max_dif = max(last_dif, max_dif);
	cout << k - max_dif;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
h = [int(x) for x in input().split()]
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(1,n):
    for j in range(1,min(2,i)+1):
        dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])

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

void Main(){
    
}

int cnt[4][3][10];
int main() {
	int n; cin >> n;
	rep(i, n) {
		int b, f, r, v; cin >> b >> f >> r >> v; b--; f--; r--;
		cnt[b][f][r] += v;
	}
	rep(i, 4) {
		rep(j, 3) {
			rep(k, 10) {
				cout << ' ' << cnt[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) {
			rep(j, 20)cout << '#';
			cout << endl;
		}
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    set<string> se;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << (int)se.size() << endl;
}


Measured memory_bytes: 19204
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

int main()
{
    int N, M, L;
    scanf("%d %d %d", &N, &M, &L);

    std::vector<std::vector<int64_t>> fuel(N + 1, std::vector<int64_t>(N + 1));
    std::vector<std::vector<int64_t>> dist(N + 1, std::vector<int64_t>(N + 1));
    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= N; ++j)
        {
            fuel[i][j] = INT_MAX;
            dist[j][i] = INT_MAX;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }

    for (int i = 0; i < M; ++i)
    {
        int ai, bi, ci;
        scanf("%d %d %d", &ai, &bi, &ci);
        fuel[ai][bi] = std::min(fuel[ai][bi], (int64_t)ci);
        fuel[bi][ai] = fuel[ai][bi];
    }

    for (int i = 1; i <= N; ++i)            // 中継地点
    {
        for (int j = 1; j <= N; ++j)        // 始点
        {
            for (int k = 1; k <= N; ++k)    // 終点
            {
                fuel[j][k] = std::min(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= N; ++j)
        {
            if (i == j) continue;
            if (fuel[i][j] <= L) dist[i][j] = std::min(dist[i][j], (int64_t)1);
        }
    }

    for (int i = 1; i <= N; ++i)            // 中継地点
    {
        for (int j = 1; j <= N; ++j)        // 始点
        {
            for (int k = 1; k <= N; ++k)    // 終点
            {
                dist[j][k] = std::min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    int Q;
    scanf("%d", &Q);

    struct data
    {
        int s;
        int t;
    };
    std::vector<data> route(Q);
    for (auto& d : route)
    {
        scanf("%d %d", &d.s, &d.t);
    }

    for (auto& d : route)
    {
        if (dist[d.s][d.t] < INT_MAX)
        {
            printf("%lld\n", dist[d.s][d.t] - 1);
            continue;
        }
        printf("-1\n");
    }
}


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

int main() {
   ll D, G, ans = 1000000;
   cin >> D >> G;
   ll p[D], c[D];
   rep(i, D) cin >> p[i] >> c[i];
   for(ll bit = 0;bit < (1 << D);bit++) {
      ll sum = 0, cnt = 0;
      rep(i, D) {
         if(bit & (1 << i)) {
            sum += 100 * (i + 1) * p[i] + c[i];
            cnt += p[i];
         }
      }
      if(sum >= G) {
         ans = min(ans, cnt);
      }else {
         for(ll i = D-1;i >= 0;i--) {
            if(bit & (1 << i)) continue;
            for(ll j = 0;j < p[i];j++) {
               if(sum >= G) break;
               sum += 100 *(i + 1);
               cnt++;
            }
           
         }
         ans = min(ans, cnt);
      }

   }
   cout << ans << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int lli;
#define MAX 1000005
#define endl "\n"
lli arr[MAX];
bool p[MAX];
lli check(lli a){
	lli ctr = 0;
	for(lli i = 1;; i++){
		if(a - i < 0)
			return ctr;
		else{
			a = a-i;
			ctr++;
		}
	}
	return ctr;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(p,true,MAX*sizeof(bool));
	for(lli i = 2; i<=MAX; i++){
		if(p[i]){
			for(lli j = i*i; j<=MAX; j+=i)
				p[j] = false;
		}
	}
	lli n;
	cin>>n;
	map <lli,lli> mp;
	for(lli i = 2; i<1000000; i++){
		if(p[i] & n%i == 0){
			lli counter = 0;
			while(n%i == 0){
				n/= i;
				counter++;
			}
			mp[i] = counter;
		}
	}
	lli ans = 0;
	if(n != 1){
		ans++;	
	}
	for(auto i : mp){
		ans += check(i.second);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4628
# 初期入力
N = int(input())
V = list(map(int, input().split()))
V.sort()

#小さい順足してみる
sum_heikin=0
for i in range(N-1):
    V[i+1] = (V[i+1] +V[i])/2
print(V[i+1])

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const ll mod = 1000000007LL;
const ll limit = 5000;
ll F[limit + 10];
ll C[limit + 10][limit + 10];

ll dp[limit + 10][limit + 10];

void init() {
	F[0] = 1LL;
	rep(i, 1, limit + 1) F[i] = 1LL * i *  F[i - 1] % mod;

	rep(i, limit + 1) {
		rep(j, i + 1) {
			if (j == 0 or j == i)
				C[i][j] = 1LL;
			else
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
}

vector<int> graph[limit];
int sz[limit];
vector<int> centroid;

int dfs(int v, int p, int total) {
	sz[v] = 1;
	const int thr = total / 2;
	bool ok = true;

	for (auto &v2 : graph[v]) {
		if (v2 == p) continue;
		sz[v] += dfs(v2, v, total);
		if (sz[v2] > thr) ok = false;
	}

	if (total - sz[v] > thr) ok = false;
	if (ok) centroid.push_back(v);

	return sz[v];
}

int main(void) {
	init();

	int n;
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	dfs(0, -1, n);

	if (centroid.size() == 2) {
		ll ans = F[n / 2] * F[n / 2] % mod;
		cout << ans << endl;
		return 0;
	}

	const int c = centroid[0];
	dfs(c, -1, n);

	vector<int> ary;
	for (auto &v : graph[c]) ary.push_back(sz[v]);
	const int m = ary.size();
	dp[0][0] = 1LL;
	int total = 0;

	rep(i, m) {
		const int ni = ary[i];
		rep(j, total + 1) {
			if (dp[i][j] == 0) continue;
			rep(k, ni + 1) {
				const ll add = C[ni][k] * C[ni][k] % mod * F[k] % mod * dp[i][j] % mod;
				dp[i + 1][j + k] = (dp[i + 1][j + k] + add) % mod;
			}
		}
		total += ni;
	}

	rep(i, total)  dp[m][i] = dp[m][i] * F[total + 1 - i] % mod;


	ll ans = 0LL;
	rep(i, total + 1) {
		if (i % 2 == 1)
			ans = (ans + mod - dp[m][i]) % mod;
		else
			ans = (ans + dp[m][i]) % mod;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 390784
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h+2, vector<char>(w+2));
  vector<vector<int>> b(h+2, vector<int>(w+2));
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cin >> a.at(i).at(j);
    }
  }
  int flag=0;
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if(a.at(i).at(j) =='#'){
        if(a.at(i-1).at(j) =='#' || a.at(i+1).at(j) =='#' || a.at(i).at(j-1) =='#' ||a.at(i).at(j+1) =='#');
        else  flag=1;
      }
    }
  }
  if(flag==1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

switches = []
for i in range(M):
    switches.append(list(map(int, input().split()))[1:])
mods = list(map(int, input().split()))

total = 0
import itertools
for p in itertools.product([0, 1], repeat=N):
    good = True
    for i, switch in enumerate(switches):
        ons = 0
        for si in switch:
            ons += p[si-1]
        if ons % 2 != mods[i]:
            good = False
            break
    if good:
        total += 1

print(total)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll now = a[0];
    ll res = 0;
    rep(i, N){
        if(now < a[i]){
            now = a[i];
        }else{
            res += now - a[i];
        }
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 9004
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int main(){
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++){
cin>>a[i];
}
ll count=0;
for(ll i=0;i<n;i++){
if(a[i]%2==1)
count++;
}
if(count!=0)
cout<<"first";
else
cout<<"second";
  return 0;
 
}
 

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll berger[55];  //bn = 2*bn-1 + 3   層の数(パティ+バン)
ll patti[55];   //an = 2*an-1 + 1   パティの数

int main(){
    ll N, X;
    cin >> N >> X;

    patti[0] = 1;
    for(int i = 1; i <= N; i++){
        patti[i] = patti[i-1] * 2 + 1;
    }
    berger[0] = 1;
    for(int i = 1; i <= N; i++){
        berger[i] = berger[i-1] * 2 + 3;
    }

    ll ans = 0;
    while(0 < X){
        if(X == berger[N]){
            ans += patti[N];
            X = 0;
        }else if(berger[N] / 2 + 1 <= X){
            ans += patti[N-1] + 1;
            X -= berger[N] / 2 + 1;
        }else{
            X--;
        }
        N--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;
int n, w;
ll weight[A], val[A];
ll dp[A][100005];
ll solve()
{
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			dp[i][j] = dp[i-1][j];
			if (j >= weight[i])
				dp[i][j] = max(dp[i][j], dp[i-1][j-weight[i]] + val[i]);
		}
	}
	return dp[n][w];
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
		cin >> weight[i] >> val[i];
	cout << solve();
	return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto it : a)
#define INF 100001
//#define MOD lo(1e17)
#define M 1000000007
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define endl "\n"
#define eps 1e-9
#define PI 3.141592653589793
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}


int main(){
        string s;
        cin>>s;
        lo x=0;
        REP(0,s.length()){
                if(s[i]=='1')
                        x++;
        }
        cout<<x;
        return 0;
}

Measured memory_bytes: 256
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    a, b = gets.chomp.split.map(&:to_i)

    if 1 <= a && a <= 9 && 1 <= b && b <= 9
      puts a * b
    else
      puts -1
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1e9+7
typedef pair<int,int> P;
typedef pair<int,P> PP;

signed main(){
  int n,k;
  cin>>n>>k;
  cout<<n-k+1<<endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
        cnt += 1

print(cnt)


Measured memory_bytes: 3316
N = int(input())

import numpy as np

X = np.arange(N+1)
A = X.copy()

for i in [1,10,100,1000,10000,100000]:
    A[i:i*10] = X[i:i*10] // i
B = X % 10

C = np.zeros((10,10), dtype=int)

for i in range(1,N+1):
    C[A[i], B[i]] += 1
count = 0

for i in range(10):
    for j in range(10):
        count += C[i][j] * C[j][i]

print(count)

Measured memory_bytes: 17188