akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  cout<<n*800-n/15*200<<endl;
  return 0;
}


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

struct UF {
    vector<int> v;
    UF(int n) : v(n, -1) {}

    int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (-v[x] < -v[y]) swap(x, y);
        v[x] += v[y];
        v[y] = x;
        return;
    }
    bool root(int x) { return v[x] < 0; }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -v[find(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    UF uf(n + 10);
    vector<long long> ans;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }

    long long cur = 1LL* n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; --i) {
        ans.push_back(max(0LL, cur));
        if (!uf.same(a[i], b[i])) {
            cur -= (1LL* uf.size(a[i]) * uf.size(b[i]));
            uf.unite(a[i], b[i]);
        }
    }

    reverse(ans.begin(), ans.end());
    for (long long x : ans) {
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3444
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N,L;cin>>N>>L;
    ll min=INT64_MAX;
    ll ttl=0;
    ll mv=0;
	for(ll i = 1; i <= N; ++i) {
		ll v = L + i - 1;
		ttl += v;
		if(min > abs(v)) {
			min = abs(v);
			mv = v;
		}
	}
    cout<<ttl-mv<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

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

		String N=sc.nextLine();
		//System.out.println(N.length());
		String ans = "No";

		for(int i=0; i<N.length(); i++) {
			if(N.charAt(i) == '7') {
				ans = "Yes";
			}
		}

		System.out.println(ans);


		sc.close();


		}

	}




Measured memory_bytes: 35756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long n;
    cin >> n;
    long long memo, ans = 0;
    vector<long long> h(n);
    for (long long i = 0; i < n; i++) {
        cin >> h[i];
        if (i >= 1) {
            if (h[i-1] >= h[i]) memo++;
            else memo = 0;
            ans = max(memo, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

ll ncr(ll n, ll r){
  if(n < r) return 0;
  if(r > n-r) r = n-r;

  ll a = 1, b = 1;
  for(int i = 0; i < r; i++){
    a *= (n - i);
  }
  for(int i = 0; i < r; i++){
    b *= (i + 1);
  }
  return a/b;
}

ll modbeki(ll x, ll n){
  ll res = 1LL;
  while(n > 0){
    if(n & 1){
      res *= x % 2019;
      res %= 2019;
    }
    x = x * x % 2019;
    n >>= 1;
  }
  return res % 2019;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  ll N = S.size();
  vll num(2019, 0);
  vll dp(N, INF);
  ll initial = S.at(N-1) - '0';
  dp.at(N-1) = initial;
  num.at(dp.at(N-1))++;
  num.at(0) = 1;
  for(int i = N-2; i >= 0; i--){
    ll x = S.at(i) - '0';
    dp.at(i) = (x * modbeki(10, (N-1)-i) + dp.at(i+1)) % 2019;
    num.at(dp.at(i))++;
  }
  ll ans = 0;
  for(int i = 0; i < 2019; i++){
    ans += ncr(num.at(i), 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5072
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  vector <int> B(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(N%2==0){
      B[i]=i/2*2+1;
    }else{
      B[i]=(i+1)/2*2;
    }
  }
  sort(A.begin(),A.end());
  if(A==B){
    long long int ans=1;
    for(int i=0;i<N/2;i++){
      ans*=2;
      ans%=1000000007;
    }
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
ll G[1002];
void numb(int a){
    for(int i=2;i<=a;i++){
        if(a%i==0){
            G[i]++;
            a =a/i;
            break;
        }
    }
    if(a==1)return;
    numb(a);
}
int main(){
    int N;
    cin >>N;
    rep(i,N+1)G[i] = 0;
    for(int i=2;i<=N;i++){
        numb(i);
    }
    ll ans = 1;
    rep(i,N+1){
        if(G[i]!=0){
            ans *=(G[i]+1);
            ans %=MOD;
        }
        
    }
    cout << ans%MOD << endl;
    return 0;
}

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

int main() {
	string s;
	while (cin >> s) {
		string::size_type pos;
		while ((pos = s.find('@')) != string::npos) {
			s.replace(pos,3,(string::size_type)(s[pos+1]-'0'),s[pos+2]);
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    vector<int> P(N), v(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    rep(i, N) v[i] = i+1;
    sort(v.begin(), v.end());
    int p, q;
    int cnt = 0;
    do{
        cnt++;
        if(P==v) p = cnt;
        if(Q==v) q = cnt;
    } while (std::next_permutation(v.begin(), v.end()));

    cout << abs(p-q) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll i,mr,mc,h,w,m,x,y;
 cin >> h >> w >> m;
 ll r[h],c[w];
 for(i=0;i<h;i++)
 r[i]=0;
 for(i=0;i<w;i++)
 c[i]=0;
 set<pair<ll,ll>> s;
 while(m--)
 {
  cin >> x >> y;
  s.insert({x,y});
  r[x-1]++;
  c[y-1]++;
 }
 set<ll> sr,sc;
 mr=*max_element(r,r+h);
 mc=*max_element(c,c+w);
 for(i=0;i<h;i++)
 {
  if(r[i]==mr)
  sr.insert(i+1);
 }
 for(i=0;i<w;i++)
 {
  if(c[i]==mc)
  sc.insert(i+1);
 }
 for(auto ir:sr)
 {
  for(auto ic:sc)
  {
   if(s.find({ir,ic})==s.end())
   {
    cout << mr+mc;
    return 0;
   }
  }
 }
 cout << mr+mc-1;
 return 0;
}

Measured memory_bytes: 55144
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

class UFTree {
  std::vector<int> data, rank, _size;

public:
  UFTree(const int &n) : data(n), rank(n), _size(n, 1) { iota(all(data), 0); }

  int root(const int &x) { return data[x] == x ? x : data[x] = root(data[x]); }

  bool same(const int &a, const int &b) { return root(a) == root(b); }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rank[a] < rank[b]) std::swap(a, b);
    data[b] = a;
    _size[a] += _size[b];
    if (rank[a] == rank[b]) rank[a]++;
  }

  int sizeOf(int x) { return _size[root(x)]; }
};

main {
  int w, h;
  cin >> w >> h;
  vector<vector<char>> v(h, vector<char>(w));
  cin >> v;
  UFTree uf(h * w);
  int goal;
  rep(i, h) rep(j, w) {
    if (v[i][j] == 't') {
      goal = i * w + j;
      v[i][j] = '.';
    }
    if (i > 0 && v[i][j] == '.' && v[i - 1][j] == '.') uf.unite(i * w + j, (i - 1) * w + j);
    if (j > 0 && v[i][j] == '.' && v[i][j - 1] == '.') uf.unite(i * w + j, i * w + (j - 1));
  }
  int n;
  cin >> n;
  vpii q(n);
  cin >> q;
  if (uf.same(0, goal)) {
    cout << 0 << endl;
    return 0;
  }
  rep(k, n) {
    int i, j;
    tie(j, i) = q[k];
    if (v[i][j] != '#') continue;
    v[i][j] = '.';
    if (i > 0 && v[i - 1][j] == '.') uf.unite(i * w + j, (i - 1) * w + j);
    if (j > 0 && v[i][j - 1] == '.') uf.unite(i * w + j, i * w + (j - 1));
    if (i < h - 1 && v[i + 1][j] == '.') uf.unite(i * w + j, (i + 1) * w + j);
    if (j < w - 1 && v[i][j + 1] == '.') uf.unite(i * w + j, i * w + (j + 1));
    if (uf.same(0, goal)) {
      cout << k + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 27368
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
    {
        cin >> x;
        if(x==0)
          break;
        cout << "Case" << " " <<  i  << ":" << " " << x << endl;
    }
}


Measured memory_bytes: 3100
def main():
    sticks = int(input())
    stick_length = list(map(int, input().split()))
    length_count = {}
    for length in stick_length:
        if length in length_count:
            length_count[length] += 1
        else:
            length_count[length] = 1
    length_count = sorted(length_count.items(), key=lambda x: x[0], reverse=True)
    answer = 0
    for stick_info in length_count:
        if stick_info[1] < 2:
            continue
        elif stick_info[1] >= 4:
            if answer == 0:
                answer = stick_info[0] ** 2
                break
            else:
                answer *= stick_info[0]
                break
        else:
            if answer > 0:
                answer *= stick_info[0]
                break
            else:
                answer = stick_info[0]
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 21896
#include<stdio.h>
int main(){
	int n;
	long int max,min,sum=0;
	int i,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		max = i == 0 ? a : max < a ? a : max;
		min = i == 0 ? a : min > a ? a : min;
		sum+=a;
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}



Measured memory_bytes: 2108
def main():
  #import sys
  #input = sys.stdin.readline
  N,K=map(int,input().split())
  h=list(map(int,input().split()))
  DP=[0]*N
  DP[0]=0
  for i in range(1,N):
  #j=1
  #while j<=K and j<=i:
  #  DP[i]=min(DP[i],abs(h[i]-h[i-j])+DP[i-j])
  #for j in range(max(0, i-K),i):
    #DP[i]=min(DP[i],abs(h[i]-h[j])+DP[j])
    r=max(0, i-K)
    DP[i]=min([abs(h[i]-h[j])+DP[j] for j in range(r,i)])
  print(DP[-1])
if __name__ == '__main__':
  main()



Measured memory_bytes: 13980
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	string S;
	cin >> N >> S;
	ll ans = 0;
	for (ll n = 0; n + 2 < N; n++) {
		if (S.substr(n, 3) == string("ABC"))ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    //リュカ数　2 1 3 4 7 11 18 29 47 76 123 199
    int n;cin>>n;
   long long a = 2;
    long long b = 1;
    long long ryuca = 0;
    if(n==0){
        cout<<a<<endl;
    }
    else if (n==1){
        cout << b<<endl;
    }
    else if (n!=0&&n!=1){
        for(int i = 0; i< n-1 ; i++){
            //3番目ならint ryuca = 0; ryuca +=a+b;
            //a=b;b=ryuca;とかってすれば行けそう
           ryuca = a+b;
           a=b;
           b=ryuca; 
        }
        cout <<ryuca<<endl;
    }
}

Measured memory_bytes: 256
/* Tejus Tiwari */
#include <bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define INF               1e18L+1
#define pb                push_back
#define mp                make_pair
#define all(v)            v.begin(),v.end()
#define f(i,a,b,c)        for( i=a; i<b;i+=c)
#define rf(i,a,b,c)       for( i=b-1;i>=a;i-=c)
#define fo(i,n)           for( i=0; i < n ; i++)
#define rfo(i,n)          for( i=n-1; i >=0 ; i--)
#define MEM(a,b)          memset(a, (b), sizeof(a))
#define alldec(v)         v.begin(),v.end(),greater<int>()
#define fio               ios_base::sync_with_stdio(false); cin.tie(0);
#define dbg1(x)           cout<<#x<<"="<<x<<endl;
#define dbg2(x,y)         cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define dbg3(x,y,z)       cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define dbg4(x,y,z,w)     cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define dbgarray(arr,n)   for(int i=0;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}
#define dbgmatrix(a,n,m)  cout<<setw(5*m+8)<<"MATRIX\n\n";for(int i=0;i<n;i++){for(intj=0;j<m;j++){cout<<setw(10)<<a[i][j];}cout<<"\n";}
typedef long long int ll; typedef vector<int> vi; typedef vector<ll> vll;   typedef pair<int,int>	pi;  typedef pair<ll,ll>	 pll;
const  ll M =1000000007;  /* const ll M = 998244353; */     /* const double PI = 3.141592653589793; */  vll primefactors, factors, fact;
bool isPowerTwo(ll x)     {return (x && !(x & (x - 1))); }
ll   modadd(ll a,ll b)    {return((a%M)+(b%M)+M)%M;} ll modsub(ll a,ll b){return((a%M)-(b%M)+M)%M;}ll modmul(ll a,ll b){return((a%M)*(b%M))%M;}
void getFactorial(ll n)   {fact.pb(1);for(ll i=1;i<=n;i++)fact.pb((i*1ll*fact[i-1])%M);}
bool isPrime(ll n)        {if(n<2)return false;for(ll i=2;i*i<=n;i++)if(n%i==0)return false;return true;}
ll   power(ll a, ll b)    {ll res=1;while(b){if(b&1) res=(res*a);a=(a*a);b>>=1;}return res;}
ll   powerM(ll a, ll b)   {ll res=1;while(b){if(b&1) res=(res*a)%M;a=(a*a)%M;b>>=1;}return res;}
ll   modi (ll a)          {ll m=M,s=1,p=0; while(a>1){ll q=a/m,t=m;m=a%m;a=t;t=p;p=s-q*p;s=t;}return s>=0?s:s+M;}
void getPrimeFactors(ll n){primefactors.clear();for(ll i=2;i*i<=n;i++){if(n%i==0){primefactors.pb(i);while(n%i==0)n=n/i;}}if(n!=1)primefactors.pb(n);}
ll   ncr(ll n, ll r)      {if(r==0)return 1;fact[0]=1;for(int i=1;i<=n;i++)fact[i]=fact[i-1]*i%M;return(fact[n]*modi(fact[r])%M*modi(fact[n-r])%M)%M;}
void getFactors(ll n)     {factors.clear();for(ll i=1;i*i<=n;i++){if(n%i==0){factors.pb(i);if(n/i!=i)factors.pb(n/i);}}sort(all(factors));}

//****************************************************************************************************************************************************

int main()
{
  fio
  string s; cin>>s;
  ll n = s.length();
  if(s[n-1]=='s')
    cout<<s+"es";
  else
    cout<<s+"s";
return 0;
}

//****************************************************************************************************************************************************


Measured memory_bytes: 3664
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner input_line = new Scanner(System.in);
        String input = input_line.nextLine();
        String[] Array = input.split(" ");
        int a = Integer.parseInt(Array[0]);
        int b = Integer.parseInt(Array[1]);
        int c = Integer.parseInt(Array[2]);
        int num;
        int count = 0;
        for(num = a; num <=b ; num++){
            if(c%num == 0){
                count = count + 1;
            }
        }
        System.out.println(count);  
    }
}


Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
    while(true){
    int n;cin>>n;if(!n)break;
    int t[n][n+1];rep(i,n) rep(j,n+1) cin>>t[i][j];
    int dp[(1<<n)];rep(i,1<<n)dp[i]=mod;
    dp[0]=0;
    rep(i,1,(1<<n)){
        rep(j,n){
            if(!(i&(1<<j)))continue;
            rep(k,n){
                if(!(i&(1<<k)))continue;
                if(k==j)continue;
                chmin(dp[i],dp[i-(1<<j)]+t[j][k+1]);
            }
            chmin(dp[i],dp[i-(1<<j)]+t[j][0]);
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    }
}




Measured memory_bytes: 3356
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

int main() {
	ll h;
	cin >> h;
	
	ll ans=0;
	ll cnt=1;

	if (h == 1) {
		cout << 1 << endl;
		return 0;
	}

	while (true) {
		h /= 2;
		cnt++;
		if (h == 1) {
			break;
		}
	}

	for (int i = 0; i < cnt; i++) {
		ans += pow(2, i);
	}

	cout << ans << endl;	
}


Measured memory_bytes: 384
import itertools
def f(s):
 for a,b,c,d in itertools.permutations(s):
  for x,y,z in itertools.product('+-*',repeat=3):
   yield f"(({a} {x} {b}) {y} ({c} {z} {d}))"
   yield f"((({a} {x} {b}) {y} {c}) {z} {d})"
   yield f"({a} {x} ({b} {y} ({c} {z} {d})))"
   yield f"(({a} {x} ({b} {y} {c})) {z} {d})"
   yield f"({a} {x} (({b} {y} {c}) {z} {d}))"
for e in iter(input,'0 0 0 0'):
 s=list(map(int,e.split()));a=0
 for m in f(s):
  if eval(m)==10:a=m;break
 print(a)


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

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

    int happy = 0;
    happy += 1000 * (X / 500);
    X %= 500;

    int i = 0;
    while(X > 5){
        X -= 5;
        i++;
    }

    happy += 5 * i;
    cout << happy << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>

int main(){
    long long n;
    scanf("%lld",&n);

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

    int ans[n];
    for(i=0;i<n;i++)ans[i]=0;
    for(i=0;i<n;i++){
        ans[a[i]-1] = ans[a[i]-1] + 1;
    }
    for(i=0;i<n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

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

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

class interval {
public:
  std::int_fast64_t c;
  std::int_fast64_t s;
  std::int_fast64_t f;

  interval(const std::int_fast64_t c, const std::int_fast64_t s, const std::int_fast64_t f) :
    c(c),
    s(s),
    f(f) {
  }
};

class line {
private:
  std::int_fast64_t n;
  std::vector<interval> intervals;

public:
  line(const std::int_fast64_t n) :
    n(n),
    intervals() {
    this->intervals.reserve(n - 1);
  }

  friend std::istream& operator>>(std::istream& is, line& self) {
    for (std::int_fast64_t i = 0; i < self.n - 1; ++i) {
      std::int_fast64_t c_i, s_i, f_i;
      is >> c_i >> s_i >> f_i;
      self.intervals.emplace_back(c_i, s_i, f_i);
    }
    return is;
  }

  std::int_fast64_t calc(std::int_fast64_t i) const {
    std::int_fast64_t t = 0;
    for (; i < this->n - 1; ++i) {
      t = std::max(this->intervals[i].s, tools::ceil(t, this->intervals[i].f) * this->intervals[i].f) + this->intervals[i].c;
    }
    return t;
  }
};

int main(void) {
  std::int_fast64_t n;
  std::cin >> n;
  line line(n);
  std::cin >> line;

  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::cout << line.calc(i) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll gcd(ll x, ll y) {
    if (x < y) {
        x ^= y;
        y ^= x;
        x ^= y;
    }
    return y ? gcd(y, x%y) : x;
}

void solve() {
    ll a, b, c; cin >> a >> b >> c;
    if (c % gcd(a, b) == 0) cout << "YES";
    else cout << "NO";
}

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

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ldouble = long double;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n;
    cin >> n;
    vector<ll> b(n);
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    map<pair<ll, ll>, P> mp;
    vector<int> jj(3);
    rep(i, n) {
        if(a[i] != 0 && b[i] != 0) {
            ll a_ = abs(a[i]);
            ll b_ = abs(b[i]);
            if(a_ < b_) {
                swap(a_, b_);
            }
            while(a_ % b_) {
                ll cc = a_%b_;
                a_ = b_;
                b_ = cc;
            }
            a[i] /= b_;
            b[i] /= b_;
            
            if((a[i] < 0 && b[i] < 0) || (a[i] > 0 && b[i] > 0)) {
                a[i] = abs(a[i]);
                b[i] = abs(b[i]);
                mp[make_pair(a[i], b[i])].first++;
            } else {
                a[i] = abs(a[i]);
                b[i] = abs(b[i]);
                mp[make_pair(b[i], a[i])].second++;
            }
        }
        else if(a[i] == 0 && b[i] != 0) {
            jj[0]++;
        } else if(a[i] != 0 && b[i] == 0) {
            jj[1]++;
        } else {
            jj[2]++;
        }
    }


    mint ans=1;
    for(auto x:mp) {
        ans *= (mint(2).pow(x.second.first) + mint(2).pow(x.second.second)-1);
    }
    ans *= (mint(2).pow(jj[0]) + mint(2).pow(jj[1])-1);
    
    ans += jj[2];

    ans -= 1;

    cout << ans << endl;
}

Measured memory_bytes: 18740
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int main()
{
	string s;
	int a;
	int count;
	char c, d;
	cin >> s;

	a = s.length();
	//cout << a<<endl;
	count = a - 2;
	//cout << count << endl;
	c= s.at(0);
	//cout << c << endl;
	d = s.at(a-1);
	//cout << d << endl;
	cout << c << count << d;
	return 0;

}

Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

static int n, k;
vector<string> card;
unordered_set<string> chie;

signed main()
{
  while (cin >> n >> k, n || k) {
    card = vector<string>(n);
    REP(i, n) cin >> card[i];
    sort(ALL(card));
    do {
      string s;
      REP(i, k) s += card[i];
      chie.insert(s);
    } while (next_permutation(ALL(card)));
    print(chie.size());
    //cout << chie.size() << endl;
    chie.clear();
  }
  
  return 0;
}

Measured memory_bytes: 3488
#include <cstdio>
#include <vector>

using namespace std;

int main(){
    //freopen("testcase", "r", stdin);
    int N, T;
    scanf("%d%d", &N, &T);
    vector<int> interval(N, 0);

    int t, p;
    for(int i=0; i<N; i++){
        scanf("%d", &t);
        interval[i]=t-p;
        p=t;
    }

    long long total=0, waterbreak=0, push=0;
    for(int i=0; i!=interval.size(); i++){
        push+=interval[i];
        if(waterbreak>push){// water still flows
            total+=(T-waterbreak+push);
            waterbreak+=(T-(waterbreak-push));
        }else{
            waterbreak=push+T;
            total+=T;
        }
    }
    printf("%lld\n", total);
    return 0;
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d",&n);
  ll cities[n+1], braves[n+1], ans = 0;
  REP(i,n+1) cin >> cities[i];
  REP(i,n) cin >> braves[i];
  braves[n] = 0;
  ll leftPower = 0;
  REP(i,n+1) {
    ll sum = braves[i] + leftPower;
    if(cities[i] >= sum) {
      ans += sum;
      leftPower = 0;
    } else {
      ans += cities[i];
      if(cities[i] >= leftPower) leftPower = braves[i] - (cities[i] - leftPower);
      else leftPower = braves[i];
    }
  }

  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>

using namespace std;

struct data{
	int price, weight;
}box[1000005];

bool compare(struct data a, struct data b){
	double benefitA = (double)a.price/a.weight;
	double benefitB = (double)b.price/b.weight;
	return benefitA > benefitB;
}

int main(){
	int n, capacity;
	scanf ("%d %d", &n, &capacity);
	for (int i=0; i<n; i++){
		scanf ("%d %d", &box[i].price, &box[i].weight);
	}
	sort(box, box+n, compare);
	int idx = 0;
	double ans = 0;
	while (capacity > 0 && idx < n){
		if (capacity >= box[idx].weight){
			ans += box[idx].price;
			capacity -= box[idx].weight;
			idx++;
		}
		else{
			ans += (double)box[idx].price / box[idx].weight * capacity;
			break;
		}
	}
	printf ("%lf\n", ans);
	return 0;
}


Measured memory_bytes: 3516
//此程序使用了qt专属名称，请勿模仿。侵权必究！！！
//我真是太菜了…… 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=100100,P=1<<30;
int n,ans=0;
char a[N];
inline int read()
{
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	scanf("%s",a+1);
	for(int i=1;i<=n;++i)
	{
		if(a[i]!=a[i-1])
		{
			++ans;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>

#define TABLE_SIZE 22369620

class Dic{
    bool *table;
    int converter(char *str);
public:
    Dic(){table=(bool *)malloc(sizeof(bool)*TABLE_SIZE);memset(table, 0, sizeof(bool)*TABLE_SIZE);}
    void insert(char *str){table[converter(str)] = true;}
    bool find(char *str){return table[converter(str)];}
};

int Dic::converter(char *str){
    int key = 0;
    int len = strlen(str);
    for(int i=0;i<len;i++){
        switch(str[i]){
        case 'A':
            key += pow(4,i);
            break;
        case 'C':
            key += 2 * pow(4,i);
            break;
        case 'G':
            key += 3 * pow(4,i);
            break;
        case 'T':
            key += 4 * pow(4,i);
            break;
        default:
            break;
        }
    }
    return key - 1;
}

int main(){
    int i, n;
    char str[13];
    int bs = 0;
    Dic d;
    scanf("%d",&n);
    bool ans[n];
    for(i=0;i<n;i++){
        scanf("%s",str);
        if(!strcmp(str,"insert")){
            scanf("%s",str);
            d.insert(str);
        }else if(!strcmp(str,"find")){
            scanf("%s",str);
            ans[bs] = d.find(str);
            bs++;
        }
    }
    for(i=0;i<bs;i++){
        if(ans[i])printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 4492
N, K = map(int, input().split())

count = 0

if K % 2 == 0:
    first = N // K
    second = (N - K / 2) // K + 1
    
    count = first ** 3 + (second) ** 3
else:
    first = N // K
    count = first ** 3
print(int(count))

Measured memory_bytes: 3064
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, c;
		int edt[30] = {}, ch[30] = {};
		int ans = 0;
		cin >> n >> c;
		if (n < 0) return 0;
		vector<pair<pair<int, int>, int>> v(n);
		for (int i = 0; i < n; ++i) {
			cin >> v[i].first.first >> v[i].first.second >> v[i].second;
		}
		sort(v.begin(), v.end());
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 30; ++j) {
				if (edt[j] < v[i].first.first || (edt[j] == v[i].first.first && ch[j] == v[i].second)) {
					edt[j] = v[i].first.second;
					ch[j] = v[i].second;
					ans = max(ans, j + 1);
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>

using INT = long long;

static INT const P = 1000000007;

template<INT P>
class Modulo {
  INT val;

  friend
  std::ostream&
  operator<<(std::ostream& os, Modulo const& m) {
    return os << m.val;
  }

  friend
  Modulo<P>
  operator*(Modulo<P> const& a, Modulo<P> const& b) {
    return a.val * b.val;
  }

  static std::vector<INT> _facts;

public:
  Modulo(INT v) : val(v % P) {};

  Modulo<P>& operator+=(Modulo<P> const& other) {
    val += other.val;
    val %= P;
    return *this;
  }

  static INT facts(size_t n) {
    auto s = _facts.size();
    if (s < n+1) {
      _facts.resize(n+1);
      for (size_t i=s; i<n+1; i++) {
        if (i==0) {
          _facts[0] = 1;
        } else {
          _facts[i] = (_facts[i-1] * i) % P;
        }
      }
    }
    return _facts[n];
  }
};

template<INT P>
std::vector<INT> Modulo<P>::_facts;

template <INT P>
Modulo<P>
power(INT a, INT b) {
  if (b == 0) {
    return 1;
  }

  if (b % 2 == 0) {
    auto d = power<P>(a, b/2);
    return d*d;
  }

  return a * power<P>(a, b-1);
}

template <INT P>
Modulo<P>
comb(INT n, INT k) {
  if (n<0 || k<0 || n<k) return 0;
  if (n==0 || k==0) return 1;

  auto a = Modulo<P>::facts(n);
  auto b = Modulo<P>::facts(k);
  auto c = Modulo<P>::facts(n-k);

  return a * power<P>(b, P-2) * power<P>(c, P-2);;
}

int main() {
  INT N, K;
  std::cin >> N >> K;

  for (INT k=1; k<K+1; k++) {
    auto ans = comb<P>(K-1, k-1) * comb<P>(N-K+1, k);
    std::cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*g*b#条件1を満たす組み合わせの数
for i in range(1,(N-1)//2 +1):
    for j in zip(S,S[i:],S[2*i:]):#jには(S[j],S[i+j],S[2*i+j])がタプルで収納される
        if len(set(j))==3:
            ans-=1
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll p[n];
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  ll a[n], b[n];
  rep(i,n){
    a[i]=(i+1)*1LL*3e4;
    b[n-1-i]=(i+1)*1LL*3e4;
  }
  rep(i,n){
    b[p[i]]+=i;
  }
  rep(i,n) cout << a[i] << " ";
  cout << "" << endl;
  rep(i,n) cout << b[i] << " ";
  cout << "" << endl;
  //  rep(i,n) cout << a[p[i]]+b[p[i]] << " ";
  
  return 0;
    

}


Measured memory_bytes: 1152
#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 INF 2e9
#define ALL(v) v.begin(), v.end()

const char newl = '\n';

using namespace std;
using ll = long long;

auto main() -> int
{
	cin.tie(0);
  	ios::sync_with_stdio(0);

	int N; cin >> N;
    string mozi; cin >> mozi;
    
    if(mozi.size() > N) mozi = mozi.substr(0, N)+"...";
    
    cout << mozi << newl;
    
    return 0;
}

Measured memory_bytes: 3608
def main():
    S = int(input())
    x1, y1 = (0, 0)
    x2, y2 = (10**9, 1)

    x3 = (x2 - S%x2)%x2
    y3 = (S+x3)//x2

    print(x1, y1, x2, y2, x3, y3)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9088
s = input()
n = len(s)
sum = 0
# 数字の間を全探索
for i in range(2**(n-1)):
    f = ""
    for j in range(n):
        f += s[j]
        # iを右にj個削り、1桁目のビットが1かどうか
        if i>>j & 1 == 1:
            f += "+"
    sum += eval(f)
print(sum)

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

int main(void){
    
    int N,K;
    cin >> N >> K;
    
    long long ans = K;
    for(int i = 0; i < N - 1;i++){
        ans *= K - 1;
    }
    cout << ans <<endl;
    
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

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

const int MAX_PR = 10000000;
int lp[MAX_PR + 1] = {0};
vi factorSieve() {
  vi pr;
  rep(i, 2, MAX_PR + 1) {
    if (lp[i] == 0) pr.pb(lp[i] = i);
    for (auto p : pr) {
      if (lp[i] < p or i*p > MAX_PR) break;
      lp[i*p] = p;
    }
  }
  return pr;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  factorSieve();

  int n;
  cin >> n;

  ll ans = 0;
  rep(i,1,n+1) {
    map<int,int> pf;
    int x = i;
    while (x != 1) {
      pf[lp[x]]++;
      x /= lp[x];
    }
    ll res = 1;
    for (auto [a, b]: pf) res *= (b+1);
    ans += res*i;
  }
  cout << ans << '\n';

}

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

li_student = [list(map(int,input().split())) for _ in range(n)]
li_check = [list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    ans = []
    for j in range(m):
        s = abs(li_student[i][0] - li_check[j][0]) + abs(li_student[i][1] - li_check[j][1])
        ans.append(s)
    t = ans.index(min(ans)) + 1
    print(t)
    

    

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    int N,i,j;
    cin >> N;
    int n[2005400];
    int m[2005040];
    for(i=0;i<N-1;++i){
       cin >> n[i];
      
    }
     for(i=0;i<N-1;++i){
     
       m[n[i]-1]++;
    }
    for (j=0;j<N;++j){
        
         cout << m[j] << "\n";
    

    }   
    
  return 0;
}

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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c){
    cout << "Yes";
    return 0;
  }
  else if(b == c && a != c){
    cout << "Yes";
    return 0;
  }
  else if(a == c && b != c){
    cout << "Yes";
    return 0;
  }
  else { 
    cout << "No";
    return 0;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


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

    int n,m;
    cin >> n >> m;

    vector<ll> A(n);
    double sum = 0;
    for(ll i = 0; i < n;i++) {
        cin >> A[i];
        sum+= A[i];
    }

    VSORT(A);
    reverse(ALL(A));
    ll count = 0;

    for(ll i = 0; i < n;i++){
        if(A[i] >= sum/(4*m)){
            count++;
        }
    }

    if(count >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define ull unsigned long long
#define mod 1000000007 
 
int main() {

    std::ios::sync_with_stdio(false); 
    std::cin.tie(NULL);
    
    string s,ss;
    cin>>s>>ss;
    char ok=ss[ss.length()-1];
    s+=ok;
   if(s==ss) cout<<"Yes"<<"\n";
   else cout<<"No"<<"\n";
    return 0; 
}

Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int main(){
  string str;
  string w[3] = {"Sunny","Cloudy", "Rainy"};
  int i,out;
  
  cin >> str;
  
  for(i = 0;i<3;i++){
    if (str ==w[i]){
       out = (i+1)%3;
    }
  }
  
  cout <<  w[out];
  
 return 0;
}
  
  

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}

int main()
{
	checkpoint1();
	string s,t;
	cin>>s>>t;
	ll n=s.length(),k=t.length();
	ll ans=n,temp=0;
	for(ll i=0;i<n;i++)
	{
		temp=0;
		ll op=i+k;
		ll mm=0;
		if(op>n)
			break;
		for(ll j=i;j<op;j++)
		{
			if(s[j]!=t[mm]){
				temp++;
			}
			mm++;
		}
		ans=min(temp,ans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int n,A[55];
main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	sort(A+1,A+n+1);
	double tut=(A[1]+A[2]);
	tut/=2;
	for(int i=3;i<=n;i++){
		double y=A[i];
		tut=(tut+y)/2;
	}
	printf("%lf\n",tut);
	return 0;
}




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

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var n = cin.NextInt();
			var counts = new Dictionary<int, int>();
			for (var i = 0; i < n; i++)
			{
				var d = cin.NextInt();
				if (!counts.ContainsKey(d))
				{
					counts[d] = 0;
				}
				counts[d]++;
			}
			var m = cin.NextInt();
			for (var i = 0; i < m; i++)
			{
				var d = cin.NextInt();
				if (counts.ContainsKey(d) && counts[d] > 0)
				{
					counts[d]--;
				}
				else
				{
					Console.WriteLine("NO");
					return;
				}
			}
			Console.WriteLine("YES");
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			new Template().Solve();
			Console.ReadLine();
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

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

constexpr int H = 20000;
constexpr int INF = 1 << 30;

void solve() {
    int h, n;
    std::cin >> h >> n;

    std::vector<int> dp(H + 1, INF);
    dp[0] = 0;
    while (n--) {
        int a, b;
        std::cin >> a >> b;
        for (int w = 0; w + a <= H; ++w) {
            dp[w + a] = std::min(dp[w + a], dp[w] + b);
        }
    }

    std::cout << *std::min_element(dp.begin() + h, dp.end()) << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 384