akhauriyash/Code-Regression huggingface dataset:
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  lint n, k; cin >> n >> k;
  vector<lint> a(n + 1, 0);
  vector<lint> s(n + 1, 0);
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  
  map<lint, lint> mp;
  lint ans = 0;
  for(int j = 0; j <= n; j++) {
    lint val = (s[j] - j) % k;
    // cerr << j << " " << val << " " << mp[val] << endl;
    ans += mp[val];
    mp[val] = mp[val] + 1;
    int di = j - k + 1;
    if(di < 0) continue;
    lint dval = (s[di] - di) % k;
    mp[dval] = mp[dval] - 1;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
main = do
  [r,g,b,n] <- map read . words <$> getLine
  print $ length $ filter (\x -> (n-x) `mod` b == 0) [r*x+g*y | x <- [0..(n `div` r)], y <- [0..(n `div` g)], r*x+g*y<=n]


Measured memory_bytes: 1276
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    double t,a;
    cin>>n>>t>>a;
    int x[n];
    double b[n];
    int min_idx = 0;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        b[i]=abs((t-x[i]*0.006)-a);
        if(b[min_idx] > b[i])
            min_idx = i;
    }
    cout << min_idx + 1 << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int count = 0;
  int count_b = 0;
  int count_w = 0;
  
  //黒からor白からの2パターンだけ調べればよい
  
  //黒スタート//
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      if (S.at(i) == '1'){
        count_b++;
      }
    } else {
      if (S.at(i) == '0'){
        count_b++;
      }
    }
  }
  
  //白スタート//
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      if (S.at(i) == '0'){
        count_w++;
      }
    } else {
      if (S.at(i) == '1'){
        count_w++;
      }
    }
  }    
  count = min(count_b, count_w);  
  cout << count << endl;  
}
     

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

int main(void){
    string s;
    cin>>s;
    string ans;
    for (int i=0;i<s.size();i++){
        if (s[i]=='0'){
            ans.push_back('0');
        }
        if (s[i]=='1'){
            ans.push_back('1');
        }
        if (s[i]=='B'){
            if (ans.size()!=0){
                ans.erase(ans.end()-1);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








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


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

int main() {
    string s;
    string p;
    cin >> s;
    cin >> p;

    string s_twice = s + s;

    bool can_p_create = false;
    string result;
    for(int i=0; i<s_twice.size()-p.size()+1; ++i) {
        result = "";
        for(int j=0; j<p.size(); ++j) {
            char c = s_twice[i+j];
            string c_str = {c};     // char -> string
            result += c_str;
        }
        if(result == p) {
            can_p_create = true;
            break;
        }
    }

    if(can_p_create) cout << "Yes" << endl;
    else cout << "No" << endl; 
    
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	vector<ld> v(n);
	rep(i, 0, n - 1) cin >> v[i];
	sort(all(v));
	ld ans = 0;
	int base = 2;
	ans += v[0] + v[1];
	rep(i, 2, n - 1) {
		ans += base * v[i];
		base *= 2;
	}
	// cout << ans;
	cout << prec << ans / pow(2, n - 1);
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define TEST 0

	if (TEST) {
		test;
		solve();
	} else {
		solve();
	}

	return 0;
}

Measured memory_bytes: 4156
# -*- coding: utf-8 -*-

if __name__ == '__main__':
    sx, sy, tx, ty = map(int, input().split(' '))

    right = tx - sx
    up = ty - sy

    R = ['R'] * right
    U = ['U'] * up
    down = ['D'] * (up+1)
    left = ['L'] * (right+1)

    one = []
    one.extend(R)
    one.extend(U)
    one.append('R')
    one.extend(down)
    one.extend(left)
    one.append('U')

    one.extend(U)
    one.extend(R)
    one.append('U')
    one.extend(left)
    one.extend(down)
    one.append('R')

    out = ''.join(one)
    print(out)


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

int main(){
  int n,k;
  cin >> n >> k;
  if( (n-1)*(n-2)/2 < k){
    cout << -1 << endl;
  }
  else{
    int add = (n-1)*(n-2)/2 - k;
    //cout << add << endl;
    cout << n-1+add << endl;
    for(int i = 2;i <= n;i++){
      cout << 1 << ' ' << i << endl;
    }
    for(int i = 2;i <= n;i++){
      for(int j = i+1;j <= n;j++){
        if(add == 0) break;
        cout << i << ' ' << j << endl;
        add--;
      }
      if(add == 0) break;
    } 
  }
}

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

using namespace std;

int N;
vector <int> a;
bool is;
int main() {
  cin >> N;

  for(int i = 0; i < N; i++) {
    int v;
    cin >> v;
    if(i > 0 && a[a.size()-1] == v) continue;
    a.push_back(v);
  }

  if(a[1] > a[0]) is = true;

  int ans = 1;

  for(int i = 2; i < a.size(); i++) {
    if(is && a[i] < a[i-1]) {
      ans++;
      i++;
      if(a[i] > a[i-1]) is = true;
      else is = false;
    }

    else if(!is && a[i] > a[i-1]) {
      ans++;
      i++;
      if(a[i] < a[i-1]) is = false;
      else is = true;
    }
  }

  cout << ans <<endl;
}
 



Measured memory_bytes: 892
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int P=1e9+7;
int n,m,t1,t2,s1,s2,cnt;char a[1010][1010];ll k;
int ksm(int a,ll b){
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%P) if(b&1) ans=1ll*ans*a%P;
    return ans;
}
struct Mat{
    int a[2][2];
    Mat(){a[0][0]=a[0][1]=a[1][0]=a[1][1]=0;}
    Mat(int x,int y,int u,int v){a[0][0]=x;a[0][1]=y;a[1][0]=u;a[1][1]=v;}
    int* operator [](int x){return a[x];}
}A;
Mat operator *(Mat a,Mat b){Mat c;rep(i,0,1) rep(j,0,1) rep(k,0,1) c[i][j]=(c[i][j]+1ll*a[i][k]*b[k][j]%P)%P;return c;}
Mat ksm(Mat a,ll b){
    Mat ans(1,0,0,1);
    for(;b;b>>=1,a=a*a) if(b&1) ans=ans*a;
    return ans;
}
int main(){
    scanf("%d%d%lld",&n,&m,&k);
    if(k==0) return puts("0"),0;
    rep(i,1,n) rep(j,1,m) scanf(" %c",&a[i][j]),cnt+=a[i][j]=='#';
    rep(i,1,n) t1+=a[i][1]=='#'&&a[i][m]=='#';
    rep(i,1,m) t2+=a[1][i]=='#'&&a[n][i]=='#';
    rep(i,1,n) rep(j,1,m) s1+=a[i][j]=='#'&&a[i][j+1]=='#',s2+=a[i][j]=='#'&&a[i+1][j]=='#';
    if(t1&&t2) return puts("1"),0;
    if(!t1&&!t2) return printf("%d\n",ksm(cnt,k-1)),0;
    if(!t1) swap(t1,t2),swap(s1,s2);
    A=Mat(cnt,s1,0,t1);
    A=ksm(A,k-1);
    printf("%d\n",(A[0][0]-A[0][1]+P)%P);
    return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    String[] strings = new String[3];
    strings[0] = scanner.next();
    strings[1] = scanner.next();
    strings[2] = scanner.next();
    scanner.close();
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int[] counts = new int[3];
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if (strings[j].charAt(i) != strings[k].charAt(i)) {
            counts[j]++;
          }
        }
      }
      int min = counts[0];
      if (counts[1] < min) {
        min = counts[1];
      }
      if (counts[2] < min) {
        min = counts[2];
      }
      ans += min;

    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 22868
N = int(input())
judge = 0
for h in range(1,3501):
    for w in range(1,3501):
        if 4*w*h - N*h - N*w > 0 and N*h*w % (4*w*h - N*h - N*w) == 0:
            n = N*h*w // (4*w*h - N*h - N*w)
            judge = 1
            break
    if judge == 1:
        break

print(h,w,n)

Measured memory_bytes: 3060
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); 
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
    ll n;
    ll m,k,t,i,j;
    cin>>n>>k>>t;
    ll a[t],f[n+1];
    in0(f);
    in(i,t){
        cin>>a[i];
        f[a[i]]++;
    }
    fon(i,1,n+1){
        //cout<<f[i]<<endl;
        f[i]=f[i]-t+k;
        if(f[i]>0)cout<<"Yes"<<endl;
        else{
            cout<<"No"<<endl;
        }
    }
    
}
 
 








 

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int m, n;
int a[114514];
int b[114514];
signed main() {
	cin >> m >> n;
	rep(i, n)cin >> a[i];
	a[n] = -1;
	int memo = 0, ans = 0;
	rep(i, n) {
		if (a[i] == a[i + 1])memo++;
		else {
			ans += (memo + 1) / 2;
			memo = 0;
		}
	}
	if (m != 2)cout << ans << endl;
	else {
		int p = 0, q = 0;
		rep(i, n) {
			if (i % 2 == 0) {
				if (a[i] != 1)p++;
			}
			else {
				if (a[i] != 2)p++;
			}
		}
		rep(i, n) {
			if (i % 2 == 0) {
				if (a[i] != 2)q++;
			}
			else {
				if (a[i] != 1)q++;
			}
		}
		cout << min(p, q) << endl;
	}
	ggr
}




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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N; cin >> N;
    
    ll l = 0;
    ll r = N;
    while (l + 1 < r) {
        ll m = (l + r) / 2;
        if (m * (m + 1) / 2 >= N) {
            r = m;
        } else {
            l = m;
        }
    }
    
    while (N != 0) {
        if (N - r >= 0) {
            cout << r << endl;
            N -= r;
        }
        r--;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, m;
    cin >> n >> m;
    int a[m];
    long long ans = n;
    REP(i, m)
    {
        cin >> a[i];
        ans -= a[i];
    }
    ans = max(ans, -1LL);

    cout << ans << endl;
}

Measured memory_bytes: 3632
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vector2 = vector <vector  <T>>;
template <typename T> using vector3 = vector <vector2 <T>>;
template <typename T> using vector4 = vector <vector3 <T>>;
using lint = long long;
#define FOR( i, a, b ) for( lint i=(a) ; i <= (b) ; ++i )
#define REP( i, n )    for( lint i= 0  ; i <  (n) ; ++i )
#define ALL( v )       (v).begin(), (v).end()
#define MOD            1000000007

//	cinからvectorへ入力
template<typename T>
istream& operator >> ( istream& is, vector<T>& vec ) {
    for( T& x: vec ) {
        is >> x;
    }
    return is;
}

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

    vector<bool> A(N, false);
    REP( i, M ) {
        int a;
        cin >> a;
        A[a] = true;
    }

    vector<int> dp(N);
    dp[0] = 1;
    dp[1] = A[1] ? 0 : 1;

    for( int i=2; i<N; i++ ) {
        if( !A[i] ) {
            dp[i] = (dp[i-1] + dp[i-2]) % MOD;
        }
    }

    cout << (dp[N-1] + dp[N-2]) % MOD << endl;

}


Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<queue>
#include<ctime>
#include<string>
#include<string.h>
#include<cstring>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<cassert>
#include<complex>
#include<deque>
#include<stdio.h>
using namespace std;
int main()
{
	int a,b,c,d;
	char a1,b1,c1,d1;
	a1=getchar();b1=getchar();c1=getchar();d1=getchar();
	a=a1-48;b=b1-48;c=c1-48;d=d1-48;
	if (a+b+c+d==7)
		cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
	else if (a+b+c-d==7)
		cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
	else if (a+b-c-d==7)
		cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
	else if (a-b-c-d==7)
		cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7";
	else if (a-b-c+d==7)
		cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
	else if (a-b+c+d==7)
		cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
	else if (a+b-c+d==7)
		cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
	else if (a-b+c-d==7)
		cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
	else if (-a+b+c+d==7)
		cout<<'-'<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
	else if (-a+b+c-d==7)
		cout<<'-'<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
	else if (-a+b-c-d==7)
		cout<<'-'<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
	else if (-a-b-c-d==7)
		cout<<'-'<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7";
	else if (-a-b-c+d==7)
		cout<<'-'<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
	else if (-a-b+c+d==7)
		cout<<'-'<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
	else if (-a+b-c+d==7)
		cout<<'-'<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
	else if (-a-b+c-d==7)
		cout<<'-'<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
	return 0;
}

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

int main(){
  int N, A, B, a, b;
  cin >> N >> A >> B;
  a = A * N;
  b = B;
  if(a < b){
    cout << a << endl;
  }
  if(a > b){
    cout << b << endl;
  }
  if(a == b){
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int h, w; cin >> h >> w;
    vector<string> s(h); cin >> s;

    int dy[] = { -1,0,0,1 }, dx[] = { 0,-1,1,0 };
    vector<VI> dis(h, VI(w, INF));
    dis[0][0] = 1;
    queue<pair<int, int>> bfs;
    bfs.push({ 0,0 });
    while (!bfs.empty()) {
        int y, x;
        tie(y, x) = bfs.front(); bfs.pop();
        FOR(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (out(ny, nx, h, w))continue;
            if (s[ny][nx] == '#')continue;
            if (chmin(dis[ny][nx], dis[y][x] + 1)) {
                bfs.push({ ny,nx });
            }
        }
    }
    if (dis[h - 1][w - 1] == INF) {
        cout << "-1\n";
        return 0;
    }

    int cnt = 0;
    FOR(y, 0, h)FOR(x, 0, w)cnt += s[y][x] == '.';
    cout << cnt - dis[h - 1][w - 1] << "\n";
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
x_diff = tx-sx
y_diff = ty-sy
path = 'U'*(y_diff) + 'R'*(x_diff) + 'D'*(y_diff) + 'L'*(x_diff)
path += 'L' + 'U'*(y_diff+1) + 'R'*(x_diff+1) + 'DR' + 'D'*(y_diff+1) + 'L'*(x_diff+1) + 'U'
print(path)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            
            int k;
            cin >> k;
            int sum = 0;
            for(int i = 1; i <= k; i++)
            {
                for(int j = 1; j <= k; j++)
                {
                    for(int l = 1; l <= k; l++)
                        sum += __gcd(i,__gcd(j,l));
                }
            }
            cout << sum << endl;




           return 0;
        }
          

Measured memory_bytes: 3648
n, K = map(int, input().split())
As = list(map(int, input().split()))

# doubling
m = 0
while 2**m < K:
    m += 1
d = [[0] * n for i in range(m)]
for i in range(n):
    d[0][i] = As[i] - 1 

for k in range(m-1):
    for i in range(n):
        d[k+1][i] = d[k][d[k][i]]

now = 0
for k in range(m):
    if (K >> k) & 1:
        now = d[k][now]

print(now+1)


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

#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define cot cout.tie(0)

using namespace std;

int main()
{
    int r,d,x[11];

    cin>>r>>d>>x[0];
    
    for (int i=1;i<11;i++){
        x[i] = (r * x[i-1]) - d;
        cout<<x[i]<<"\n";
    }
    

return 0;
}

Measured memory_bytes: 256
def sieve(n):
    prime = []

    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n + 1):
        if is_prime[i]:
            prime.append(i)

            for j in range(2 * i, n + 1, i):
                is_prime[j] = False

    return prime, is_prime


N = int(input())
prime, _ = sieve(10 ** 5 + 10)
for v in prime:
    if v >= N:
        print(v)
        break


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


int main() {

	int split_num[10];
	int A, B,result = 0;
	cin >> A >> B;

	for (int j = A; j <= B; j++) {
		int n = j;
		for (int i = 0; n > 0; i++) {
			split_num[i] = n % 10;
			n /= 10;
		}
		if (split_num[0] == split_num[4] && split_num[1] == split_num[3]) result++;
	}

	cout << result;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define MAXN 9999
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 200005
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;

char str[MAX_N];
int pre[30][MAX_N];

int main()
{
   //FREI;
   ll q,h,s,d;
   ll n;
   cin>>q>>h>>s>>d>>n;
   h=min(h,2*q);
   s=min(s,2*h);
   d=min(d,2*s);
   ll ans=0;
   ans=(n/2)*d;
   if(n%2)
   ans+=s;
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
from math import factorial


def resolve():
    n, a, b = map(int, input().split())
    v = list(map(int, input().split()))
    v.sort(reverse=True)
    max_ave = sum(v[:a]) / a
    ath = v[a - 1]
    num_ath = v.count(ath)
    large = len([vi for vi in v if vi > ath])
    if v[0] == ath:
        ans = 0
        for i in range(a - large, min(b - large, num_ath) + 1):
            ans += combi(num_ath, i)
    else:
        ans = combi(num_ath, a - large)
    print(max_ave)
    print(ans)


def combi(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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 namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    ll maxv = -1;
    ll sum = 0;
    rep(i, n){
        ll in; cin >> in;
        chmax(maxv, in);
        sum += in;
    }
    cout << sum -(maxv/2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    int size_of_table, size_of_dataset, i, j;
    char input;
    
    for(;;) {
        scanf("%d", &size_of_table);
        if(size_of_table==0) break;
        
        char table[size_of_table][2];
    
        for(i=0; i<size_of_table; i++) {
            scanf(" %c %c", &table[i][0],&table[i][1]);
        }
        scanf("%d", &size_of_dataset);

        for(i=0; i<size_of_dataset; i++) {
            scanf(" %c", &input);
        
            for(j=0; j<size_of_table; j++) {
            
                if(input == table[j][0]) {
                    input = table[j][1];
                    break;
                }
            }
            printf("%c", input);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int x=fsc.nextInt();
        System.out.println(x>=1200?"ARC":"ABC");
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 20308
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

  int H, W; cin >> H >> W;
  bool a[550][550]; //奇数はtrue,偶数はfalse
  rep(i, H) {
      rep(j, W) {
        int b; cin >> b;
        if(b % 2 == 0) a[i][j] = false;
        else a[i][j] = true;
      }
  }
  int N = 0;
  vector<int> y, x, y_, x_;
  rep(i, H) {
      if(i % 2 == 0) {
          rep(j, W - 1) {
              if(a[i][j]) {
                  N ++;
                  a[i][j] = !(a[i][j]);
                  a[i][j + 1] = !(a[i][j + 1]);
                  x.push_back(j + 1); y.push_back(i + 1);
                  x_.push_back(j + 2); y_.push_back(i + 1);
              }
          }
          int j = W - 1;
          if(a[i][j] && i <= H - 2) {
              N ++;
              a[i][j] = !(a[i][j]);
              a[i + 1][j] = !(a[i + 1][j]);
              x.push_back(j + 1); y.push_back(i + 1);
              x_.push_back(j + 1); y_.push_back(i + 2);
          }
      }
      if(i % 2 == 1) {
          per1(j, W - 1) {
              if(a[i][j]) {
                  N ++;
                  a[i][j] = !(a[i][j]);
                  a[i][j - 1] = !(a[i][j - 1]);
                  x.push_back(j + 1); y.push_back(i + 1);
                  x_.push_back(j); y_.push_back(i + 1);
              }
          }
          int j = 0;
          if(a[i][j] && i <= H - 2) {
              N ++;
              a[i][j] = !(a[i][j]);
              a[i + 1][j] = !(a[i + 1][j]);
              x.push_back(j + 1); y.push_back(i + 1);
              x_.push_back(j + 1); y_.push_back(i + 2);
          }
      }
  }

  cout << N << "\n";
  rep(i, N) {
      cout << y[i] << " " << x[i] << " " << y_[i] << " " << x_[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 4452
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	prime := make(map[int]struct{})
	for i := 2; i <= 5555; i++ {
		prime[i] = struct{}{}
	}

	for i := 2; i <= 5555; i++ {
		_, ok := prime[i]
		if ok {
			for p := range prime {
				if p > i && p%i == 0 {
					delete(prime, p)
				}
			}
		}
	}

	pArray := make([]int, 0)
	for p := range prime {
		if p%10 == 1 {
			pArray = append(pArray, p)
		}
	}

	for i := 0; i < n-1; i++ {
		fmt.Print(pArray[i])
		fmt.Print(" ")
	}
	fmt.Println(pArray[n-1])
}


Measured memory_bytes: 896
k, a, b = map(int, input().split())
ans = 1
cnt = 0

if  (b - a) / 2 > 1:
    ans += max(a - 1, 0)
    cnt += max(a - 1, 0)
    #print(ans)
    
    x = (k - max(a - 1, 0)) // 2
    ans += (b - a) * x
    cnt += 2 * x
    #print(ans)
    
    ans += k - cnt
    #print(ans)
    
else:
    ans = 1 + k
    
print(ans)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	vector<string> S( 3 );
	REP( i, 3 ) cin >> S[ i ];
	int turn = 0;
	while( true )
	{
		// cout << "-----" << endl;
		// cout << "turn = " << turn << endl;
		// REP( i, 3 ) cout << S[ i ] << endl;

		if( S[ turn ].empty() )
		{
			cout << static_cast<char>( 'A' + turn ) << endl;
			break;
		}

		int nextTurn = S[ turn ][ 0 ] - 'a';
		S[ turn ] = S[ turn ].substr( 1 );
		turn = nextTurn;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<string,string> P;
map<P,ll>num;

ll solution(int n,string s){
  ll ans = 0;
  string l, r;
  for(int i=0;i<(1<<n);++i){
		l="",r="";
		for(int j=0;j<n;++j){
			if(i>>j&1)l+=s[j];
			else r+=s[j];
		}
		num[P(l,r)]++;
	}
	for(int i=0;i<(1<<n);++i){
		l="",r="";
		for(int j=n-1;j>=0;--j){
			if(i>>j&1)l+=s[n+j];
			else r+=s[n+j];
		}
		ans+=num[P(r,l)];
	}
	return ans;
}

int main()
{
	int n = 2;
  cin>>n;
	string s = "abba";
  cin>>s;
	ll res = solution(n, s);
  cout<<res<<endl;
}


Measured memory_bytes: 91904
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int a,b;
    cin>>a>>b;
    if(a==0){
        if(b<0){
            cout<<b*-1+1<<endl;
        }
        else{
            cout<<b<<endl;
        }
    }
    else if(a<0){
        if(b<a){
            cout<<b*-1-a*-1+2<<endl;
        }
        else if(0<b&&b<=-a){
            cout<<b*-1-a+1<<endl;
        }
        else if(b<=0){
            cout<<b-a<<endl;
        }
        else{
            cout<<b-a*-1+1<<endl;
        }
        
        
    }
    else{
        if(b>a){
            cout<<b-a<<endl;
        }
        else if(b>0){
            cout<<b*-1-a*-1+2<<endl;
        }
        else if(b>a*-1){
            cout<<b-a*-1+1<<endl;
        }
        else{
            cout<<b*-1-a+1<<endl;
        }
    }
}


Measured memory_bytes: 256
S=list(map(int,input()[::-1]))
lenS=len(S)
cnt = [0]*2019
tmp = 0
for n,i in enumerate(S):
    tmp += i*pow(10,n,2019)
    cnt[tmp%2019]+=1
ans = cnt[0]*(cnt[0]+1)//2
for i in cnt[1:]:
    ans += i*(i-1)//2
print(ans)

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

using namespace std;

typedef long long ll;

int main(){
  int N,P ; cin >> N >> P; int k = 0; 
  vector<int> A(N);
  for(int i = 0; i < N; i++){  cin >> A[i]; A[i] %= 2;
                             if( A[i] == 0){ k++;}}
  
  long long ans = 1;
  for(int i = 0; i < k ;i++){
    ans *= 2; }
  
if( P == 0){
    for(int i = 0; i < N - k - 1; i++){
   ans *= 2;
  }}
  
else{
  
  if( N - k == 0){cout << 0 << endl; return 0;}
    for(int j = 0; j < N - k - 1; j++){
   ans *= 2;
    }}
    

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

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

bool solve() {
  long long n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  --n;
  if (a > b) swap(a, b);
  long long high = d*n;
  if (a+high < b) return false;
  long long mid = c*n;
  long long low = d*(n-1)-c;
  if (mid <= low) return true;
  long long k = (high-b+a)/(high-low);
  return high-k*(high-low) >= b-a && mid-k*(high-low) <= b-a;
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    puts(solve()?"YES":"NO");
  }
  return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> d(N);
  rep(i,N) cin >> d[i];
  sort(all(d));
  int ans = d[N / 2] - d[N / 2 - 1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3792
N = int(input())
li =input()
Rcount = 0
Wcount = 0

for i in range(N):
    if li[i] == "W":
        Wcount += 1
    else:
        Rcount += 1
anscount = 0

if Wcount >= Rcount:
    for i in range(Rcount):
        if li[i] == "W":
            anscount += 1
else:
    lire = li[::-1]

    for i in range(Wcount):
        if lire[i] == "R":
            anscount += 1
print(anscount)


Measured memory_bytes: 67568
#include <iostream>
using namespace std;
int main(){
  int t,d,l,x;

  int a[40];
  int count = 0;

  while(cin >> t >> d >> l){
    int check = 0;
    int num = 0;
    
    if(t == 0 && d == 0 && l == 0){ break; }

    for(int i = 0; i< t; i++){
        cin >> x;
        if(i != t-1){
            if(x >= l){ check = d; }
            if(check > 0){
                num++;
                check--;
            }
        }
    }

    a[count] = num;
    count++;
  }

  for(int j = 0; j < count; j++){
    cout << a[j] << endl;
  }

  return 0;
}

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

const ll MAX = 200010;
vector<ll> l[MAX];
ll p[MAX],res[MAX];
bool vis[MAX];

int dfs(ll x,ll s){
  s += p[x];
  res[x] += s;
  vis[x] = true;
  for(auto e:l[x]){
    if(vis[e]){
      continue;
    }
    dfs(e,s);
  }
}

int main(){
  ll n,q;
  cin >> n >> q;
  for(int i=0;i<n-1;i++){
    ll x,y;
    cin >> x>> y;
    l[x].push_back(y);
    l[y].push_back(x);
  }
  for(int i=0;i<q;i++){
    ll x,y;
    cin >> x >> y;
    p[x] += y;
  }
  dfs(1,0);
  for(int i=1;i<=n;i++){
    cout << res[i] << " ";
  }
  cout << endl;
}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    int k;
    cin >> k;
    long long sum = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                sum += __gcd(a, __gcd(b, c));
                // cout << a << " " << b << " " << c << " " << sum << endl;
            }
        }
    }
    cout << sum << endl;
    // cout << min(__gcd(200, 199), min(__gcd(199, 198), __gcd(198, 200)));
}


Measured memory_bytes: 3632
object Main {
  def main(args: Array[String]) = {
    val a = io.StdIn.readLine.split(' ').toList.map(_.toInt)
    val list = a.permutations.toList
    println(if (list.exists { x => (x(0) + x(1)) == x(2) }) "Yes" else "No")
  }
}

Measured memory_bytes: 21564
n = int(input())
a = list(map(int,  [input() for i in range(n)]))
ans = 0
for i in range(n):
	if i == 0:
		ans += a[i] - 1
		a[i] = 1
	else:
		if a[i - 1] + 1< a[i]:
			ans += (a[i] - 1) // (a[i - 1] + 1)
			a[i] = a[i - 1]
		else:
			a[i] = max(a[i - 1], a[i])
print(ans)

Measured memory_bytes: 14112
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;

int choosetwo(int a){
	return a*(a-1) / 2;
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);

	vector<int> b(n+1);
	rep(i,n){
		b.at(a.at(i))++;
	}

	int sum = 0;
	rep(i,n+1){
		sum += choosetwo(b.at(i));
	}

	rep(k,n){
		int tmp = a.at(k);
		int sum_out = sum - choosetwo(b.at(tmp)) + choosetwo(b.at(tmp) - 1);
		cout << sum_out << endl;

	}

	return 0;

}


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

main() {
  int n, add, a = 1;
  cin >> n >> add;
  for(int i = 0; i < n; i++) {
    if(a*2 >= a + add)
      a += add;
    else
      a *= 2;
    if( i == n-1)
    cout << a <<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int m, d;
	cin >> m >> d;

	int cnt = 0;
	for(int mi=1;mi<=m;mi++) {
		for (int di = 1; di <= d; di++) {
			int d1 = di % 10;
			int d10 = di / 10;
			d10 %= 10;

			if (2 <= d1 && 2 <= d10 && d1*d10 == mi) cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int Min(int a,int b){
    return a<=b?a:b;
}
int main()
{   int n,k;
    scanf("%d%d",&n,&k);
    int x[n];
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=2*Min(k-x[i],x[i]);
    }
    printf("%d",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    map<int, int> m;
    REP(i, 3) {
        int a; cin >> a;
        m[a]++;
    }
    if (m[5] == 2 && m[7] == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
int mp[1000][1000];
PA ku[1000001];
int main(){
  int h,w,ans=0;
  int one[1000001]={};
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mp[i][j];
      ku[ mp[i][j] ] = PA(i,j);
    }
  }
  int x,y,dy[4] = {1,-1,0,0};
  int dx[4] = {0,0,1,-1};
  for(int i=1;i<=h*w;i++){
    for(int j=0;j<4;j++){
      y = ku[i].first + dy[j];
      x = ku[i].second + dx[j];
      if(x<0||y<0||x>=w||y>=h||mp[ku[i].first][ku[i].second]>mp[y][x]||one[ mp[y][x]] == -1) continue;
      if(one[ mp[y][x] ] == 0){
	if(one[ mp[ku[i].first][ku[i].second]] == 0) one[ mp[y][x]] = i;
	else one[ mp[y][x] ] = one[mp[ku[i].first][ku[i].second]];
      }
      else if(one[ mp[y][x]] != one[ mp[ku[i].first][ku[i].second]]){
	one[ mp[y][x]] = -1;
      }
    }
  }
   for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(one[mp[i][j]] == -1) ans++;
    }
  }
  cout << ans << endl;
  return (0);
}

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

using namespace std;

typedef unsigned long int Uint;

int main(void)
{
	int t;

	cin >> t;
	for(int i = 0;i < t; i++)
	{
		int n, k;
		cin >> n >> k;
		vector<Uint> x(n);
		x[0] = 0;
		vector<Uint> y(n-1);

		cin >> x[0];
		for(int j = 1;j < n; j++)
		{
			cin >> x[j];
			y[j-1] = x[j] - x[j-1];
		}

		sort(y.begin(), y.end());

		int max = 0;
		for(int j = 0;j < n-k; j++)
			max += y[j];
	
		cout << max << endl;
	}

	return 0;
}


Measured memory_bytes: 4208
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   long double a,b,c;
   cin>>a>>b>>c;
   
   a*=1e8;
   b*=1e8;
   c*=1e8;
   a=sqrt(a);
   b=sqrt(b);
   c=sqrt(c);
   if(a+b<c)
   {
      cout<<"Yes";
   }
   else
   {
      cout<<"No";
   }
   
// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256