akhauriyash/Code-Regression huggingface dataset:
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

const double pi = 3.14159265358979323846;
signed main()
{   
    int n;
    cin>>n;
    string s = to_string(n);
    if(s[0]=='7' || s[1] == '7' || s[2] == '7')
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<iostream>
#include <algorithm>
using namespace std;

class DICE
{
private:
	const int dice_tem[4][6] = { { 3,2,6,1,5,4 },{ 2,6,3,4,1,5 },
	{ 5,1,3,4,6,2 },{ 4,2,1,6,5,3 } };
	const int sort_num[6] = { 1,4,2,5,3 ,6 };
	static int top;
	static int front;
	const int n = 6;
	int dice_i[6] = { 0 };
	int dice_j[6] = { 0 };
	int ee[6];
	int p;

	void setup() {
		for (int i = 0; i < n; i++) {
			cin >> dice[i];
			dice_i[i] = dice[i];
			ee[i] = dice[i];
		}
		sort(ee,ee+n);
		for (int i = 0, o = 0; i < n && o < 2; i++) {
			ee[o] = ee[i];
			if (ee[m] != ee[i])o++;
		}
		if (m == 0) {
			top = ee[0];
			front = ee[1];
		}
	}

	void dice_sort() {
		for (int d = 0; dice_i[0] != top; d++) {
			for (int i = 0; i < n; i++) {
				dice_j[i] = dice_i[dice_tem[d % 2][i] - 1];
			}
			for (int i = 0; i < n; i++)dice_i[i] = dice_j[i];
		}
		for (p = 0; p < 4; p++) {
			for (int i = 0; i < n; i++) {
				dice_j[i] = dice_i[dice_tem[p][i] - 1];
			}
			if (front == dice_j[0]) break;
		}
		int a = p == 0 ? 3 : p == 1 ? 0 : p == 2 ? 2 : p == 3 ? 1 : -1;
		if (a == 0) {
			for (int i = 0; i < n; i++)sort_dice[i] = dice_i[i];
		}
		else {
			for (int q = 0; q < a; q++) {
				for (int i = 0; i < n; i++)	sort_dice[i] = dice_i[sort_num[i] - 1];
				for (int i = 0; i < n; i++) dice_i[i]=sort_dice[i];
				
			}
		}
	}

public:
	int dice[6];
	int sort_dice[6];
	static int m;
	DICE() {
		setup();
		dice_sort();
		m++;
	}
};
int DICE::m = 0;
int DICE::top = 0;
int DICE::front = 0;
int main() {
	const int n = 6;
	bool flag = true;
	DICE i = DICE();
	DICE j = DICE();
	for (int w = 0; w < n; w++) {
		if (i.sort_dice[w] != j.sort_dice[w])flag = false;
	}
	if (flag == true) {
		cout << "Yes" << endl;
	}
	else if (flag == false) {
		cout << "No" << endl;
	}
	return 0;
}




Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char str[3];
  int ans = 0;
  for(int i = 0; i < 3; ++i){
    cin >> str[i];
    if(str[i] == '1'){
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

int UnionFindTree::find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

int UnionFindTree::same(int x, int y){
    return find(x) == find(y);
}

int gojohou(int a,int b){
    if(b == 0)return a;
    return gojohou(b,  a % b);
}
int main(){
    int N , X;
    cin >> N >> X;
    int gcd, x;
    cin >> gcd;
    gcd -= X;
    gcd = abs(gcd);
    REP(i, N - 1){
        cin >> x;
        x -= X;
        x = abs(x);
        gcd = gojohou(gcd, x);
    }
    printf("%d\n", gcd);
}


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

struct point{
	double x, y;
};

void kochkoch( point p1, point p2, int depth ){

	if( !depth ){
		return;
	}else{

		point tp1, tp2, tp3;
		tp1.x=( p2.x+2.0*p1.x )/3.0;
		tp1.y=( p2.y+2.0*p1.y )/3.0;
		tp3.x=( p1.x+2.0*p2.x )/3.0;
		tp3.y=( p1.y+2.0*p2.y )/3.0;
		tp2.x=( tp3.x-tp1.x )*cos(M_PI/3.0) - ( tp3.y-tp1.y )*sin(M_PI/3.0) + tp1.x;
		tp2.y=( tp3.x-tp1.x )*sin(M_PI/3.0) + ( tp3.y-tp1.y )*cos(M_PI/3.0) + tp1.y;

		kochkoch( p1, tp1, depth-1 );
		cout<<tp1.x<<' '<<tp1.y<<endl;
		
		kochkoch( tp1, tp2, depth-1 );
		cout<<tp2.x<<' '<<tp2.y<<endl;

		kochkoch( tp2, tp3, depth-1 );
		cout<<tp3.x<<' '<<tp3.y<<endl;

		kochkoch( tp3, p2, depth-1 );
	}
}

int main()
{
	point p1, p2;

	p1.x=0.0;
	p1.y=0.0;
	p2.x=100.0;
	p2.y=0.0;

	int depth;
	cin>>depth;

	cout<<p1.x<<' '<<p1.y<<endl;
	kochkoch( p1, p2, depth );
	cout<<p2.x<<' '<<p2.y<<endl;
}
		

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

vector<pair<ll,ll>> prime_factorize(ll N){
    vector<pair<ll,ll>> ret;
    for(ll a = 2; a * a <= N; a++){
        if(N % a != 0) continue;
        ll ex = 0;
        while(N % a == 0){
            ex++;
            N /= a;
        }
        ret.push_back({a, ex});
    }
    if(N != 1) ret.push_back({N, 1});
    return ret;
}

int main(){
    ll n, p;
    cin >> n >> p;
    auto v = prime_factorize(p);
    ll ans = 1;
    bool f = false;
    for(auto e : v) {
        if(e.second >= n) ans *= pow(e.first, (e.second / n));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for _ in range(n+1)] for _ in range(m+1)]
for i in range(m):
    for j in range(n):
        if t[i] == s[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
r=m
c=n
ans=[]
while r !=0 and c!=0:
    #print(r,c,dp[r][c],dp[r-1][c])
    if dp[r][c] != dp[r-1][c]:
        if dp[r][c] != dp[r][c-1]:
            ans.append(s[c-1])
            r-=1
            c-=1
        else:
            c-=1
    else:
        r-=1
print("".join(ans[::-1]))

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll>a(n);
    rep(i, 0, n)cin >> a[i];
    sort(a.begin(),a.end());
    //長さを置く
    ll right = e9 +1;
    ll left = 0;
    ll p = 0;
    if(k==0){
        cout << a[n-1] << endl;
        return 0;
    }
    while(right-left>1){
        ll templength = (right+left)/2;
        ll cnt = 0;
        rep(i, 0, n){
            cnt += (a[i]+templength-1)/templength-1;
            if(cnt>k)break;
        }
        if(cnt>k){
            //切る回数がkより大きい＝templengthが小さすぎ
            left = templength;
        }
        else{
            //切る回数がkより小さい＝templengthが大きすぎ
            right = templength;
        }
    }
    cout << right << endl;
    return 0;
    //cout << left << " " << right << endl;
}

Measured memory_bytes: 4804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int K;
  cin>>K;
  string S;
  cin>>S;
  
  if(S.size()<=K) cout<<S<<endl;
  else{
    rep(i,K) cout<<S[i];
    cout<<"..."<<endl;
  }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m)
    {
        cout << "Yes" << endl;

    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int n;
    while(cin >>n && n){
        int m;
        string str;
        cin >>m >>str;
        stringstream ss;
        REP(i, n + n + 1){
            if(i % 2 == 0) ss <<'I';
            else ss <<'O';
        }
        string ioi = ss.str();
        int ans = 0;
        REP(i, m){
            if(str.substr(i, n + n + 1) == ioi){
                ans++;
            }
        }
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll N,W;cin>>N>>W;
	ll wo[N+1],vo[N+1];
	wo[0]=vo[0]=0;
 
	for(ll i=1;i<=N;i++) cin>>wo[i]>>vo[i];
    ll mxv=100000;
	ll DP[mxv+1];
	for(ll i=0;i<=mxv;i++) DP[i]=INT_MAX;
    DP[0]=0;
	for(ll i=1;i<=N;i++){
		for(ll val=mxv;val>=0;val--){
			DP[val]=min(DP[val],(val>=vo[i])?wo[i]+DP[val-vo[i]]:INT_MAX);
		}
	}
	ll ans=0;
	for(ll val=0;val<=mxv;val++){
        if(DP[val]<=W) ans=val;
	}
	cout<<ans;
}

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

int main () {

	long long int n=0, x=0, i=0, y=0, res=0;
	vector <long long int> val, val2;

	cin >> n;

	for (i=0; i<=n; i++) {
		cin >> x;
		val.push_back(x);
	}

	for (i=0; i<n; i++) {
		cin >> x;
		val2.push_back(x);
	}

	for (i=0; i<n; i++) {

		if (val2[i] >= val[i]) {
			res += val[i];
			val2[i] -= val[i];
			//if (val2[i] < 0) val2[i] = 0;
		}
		else {
			res += val2[i];
			val2[i] = 0;
		}

		if (val2[i] >= val[i+1]) {
			res += val[i+1];
			val2[i] -= val[i+1];
			val[i+1] = 0;
		}
		else {
			res += val2[i];
			val[i+1] -= val2[i];
			val2[i] = 0;

		}

	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2548
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 
ll n, k;
const ll mod = (ll)(1e9 + 7);
vector<vll> adj;
ll ans;
void dfs(ll idx, ll parent) {
  ll mul = k - 1;
  if(parent != -1) mul--;
  for(auto it: adj[idx]) {
  	if(it == parent) continue;
  	ans = (ans%mod * mul%mod)%mod;
  	if(mul <= 0) {
  		ans = 0;
  		return;
  	}
  	mul--;
  	dfs(it, idx);
  }
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n >> k;
  adj.resize(n+1); 
  for(ll i = 0; i < n-1; i++) {
  	ll x, y;
  	cin >> x >> y;
  	adj[x].pb(y);
  	adj[y].pb(x);
  }
  ans = k;
  dfs(1, -1);
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    map<ll,ll>m;
    vector<ll>A;
    rep(i,N){
        ll a;
        cin>>a;
        m[a]++;
        if(m[a]==2){
            A.pb(a);
            m[a]=0;
        }
    }

    sort(all(A));
    reverse(all(A));
    if(A.size()>=2){
        cout<<A[0]*A[1]<<endl;;
    }else{
        cout<<0<<endl;
    }


    return 0;
    

}

Measured memory_bytes: 9656
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int X = sc.nextInt();
        int[] x = new int[n + 1];
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        x[n] = X;
        Arrays.sort(x);
        for (int i = 0; i < n; i++) {
            d[i] = x[i + 1] - x[i];
        }
        if (d.length == 1) {
            System.out.println(d[0]);
            System.exit(0);
        }
        int ans = gcd(d[0], d[1]);
        for (int i = 2; i < n; i++) {
            ans = gcd(ans, d[i]);
        }
        System.out.println(ans);
    }

    static int gcd(int x, int y) {
        if (y > x)
            return gcd(y, x);
        if (y == 0)
            return x;
        else
            return gcd(y, x % y);
    }
}


Measured memory_bytes: 56400
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int n,k; cin >> n >> k;

    int sum = 0;

    rep(i,n){
        int x; cin >> x;
        sum += 2 * min(x, k - x );
    }
    print(sum);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

bool k[] = {0,1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < 2; i++) {
    for(int j = 0; j < 2;++j){
      vector<bool> v(n+1);
      v[0] = k[j];
      v[1] = k[i];
      v[n] = k[j];
      rep(i,n-1){
        if(s[i] == 'o'){
          if(v[i+1] == 0){
            v[i+2] = v[i];
          }
          else{
            v[i+2] = !v[i];
          }
        }
        else{
          if(v[i+1] == 0){
            v[i+2] = !v[i];
          }
          else{
            v[i+2] = v[i];
          }
        }
      }
      bool f = true;
      f = v[0] == v[n];
      for (int i = 0; i < n-1; i++) {
        if(v[i+1]){//W
          if(s[i] == 'o'){
            if(v[i] == v[i+2]) f = false;
          }
          else if(s[i] == 'x'){
            if(v[i] != v[i+2]) f = false;
          }
        }
        else {
          if(s[i] == 'x' && v[i] == v[i+2]) f = false;
          if(s[i] == 'o' && v[i] != v[i+2]) f = false;
        }
      }
      if(v[n]){
        if(s[n-1] == 'o'){
          if(v[n-1] == v[1]) f = false;
        }
        else if(s[n-1] == 'x'){
          if(v[n-1] != v[1]) f = false;
        }
      }
      else{
        if(s[n-1] == 'x' && v[n-1] == v[1]) f = false;
        if(s[n-1] == 'o' && v[n-1] != v[1]) f = false;
      }
      if(f){
        for (int i = 0; i < n; i++) {
          if(v[i+1]){
            cout << 'W';
          }
          else{
            cout << 'S';
          }
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int H,W,D; cin>>H>>W>>D;
    vector<vector<ll>> A(H,vector<ll>(W,0));
    vector<pint> Z(H*W+1);
    rep(i,H)rep(j,W){
        cin>>A[i][j];
        Z[A[i][j]] = {i,j};
    }
    vector<vector<ll>> R(D);
    rep(d,D){
        R[d].push_back(0);
        int i = Z[d].first, j = Z[d].second;
        for(int n = 1; d+n*D<=H*W; n++){
            int x = Z[d+n*D].first;
            int y = Z[d+n*D].second;
            R[d].push_back(fabs(x-i)+fabs(y-j));
            i = x;
            j = y;
        }
        rep1(n,R[d].size()-1) R[d][n] += R[d][n-1];
    }
    int Q; cin>>Q;
    while(Q--){
        int l,r; cin>>l>>r;
        cout<<R[l%D][r/D] - R[l%D][l/D]<<endl;
    }
}


Measured memory_bytes: 9512
c = [['1', '3', '5', '7', '8', '10', '12'], ['4', '6', '9', '11'], ['2']]

a, b = input().split(' ')

if a in c[0] and b in c[0]:
  print("Yes")
elif a in c[1] and b in c[1]:
  print("Yes")
elif a in c[2] and b in c[2]:
  print("Yes")
else:
  print("No")


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

#define EPS (1e-7)
#define INF (99999999999L)
#define PI (acos(-1))

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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

using ll = long long;

int main() {
  ll x, y; cin >> x >> y;
  ll ans = INF;
  if (x <= y) chmin(ans, y-x);
  if (x <= -y) chmin(ans, -y-x+1);
  if (-x <= y) chmin(ans, y+x+1);
  if (-x <= -y) chmin(ans, -y+x+2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  ld a, b; cin >> a >> b;
  ll ans = floor(a*b);

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3748
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int p = Integer.parseInt(sc.next());
        String t = sc.next();
        Map<Character, Integer> point = new HashMap<Character, Integer>() {
            {
                put('r', r);
                put('s', s);
                put('p', p);
            }
        };
        StringBuilder win = new StringBuilder();
        int num = 0;
        for (int i = 0; i < t.length(); i++) {
            win.append(winChar(t.charAt(i)));
            num += point.get(winChar(t.charAt(i)));
        }
        for (int i = t.length() - 1 - k; i >= 0; i--) {
            if (win.charAt(i) == win.charAt(i + k)) {
                num -= point.get(win.charAt(i));
                int bb = i - k;
                if (bb >= 0) {
                    char before = win.charAt(bb);
                    if (before != win.charAt(i + k)) {
                        win.setCharAt(i, other(before, win.charAt(i + k)));
                    } else {
                        win.setCharAt(i, loseChar(before));
                    }
                } else {
                    win.setCharAt(i, loseChar(win.charAt(i)));
                }
            }
        }
        System.out.println(num);
    }

    private static char other(char c1, char c2) {
        Set<Character> rsp = new HashSet<>(Arrays.asList('r', 's', 'p'));
        rsp.remove(c1);
        rsp.remove(c2);
        char ans = 'r';
        for (char c : rsp) {
            ans = c;
        }
        return ans;
    }

    private static char winChar(char c) {
        if (c == 'r') {
            return 'p';
        } else if (c == 's') {
            return 'r';
        } else {
            return 's';
        }
    }

    private static char loseChar(char c) {
        if (c == 'r') {
            return 's';
        } else if (c == 's') {
            return 'p';
        } else {
            return 'r';
        }
    }
}

Measured memory_bytes: 35028
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;

int main(){
    vector<vector<int>> dist(10,vector<int>(10));
    int h,w;
    cin>>h>>w;
    auto a = dist;
    for(int i=0;i<=9;++i)for(int j=0;j<=9;++j)cin>>dist[i][j];
    for(int k=0;k<=9;++k)for(int i=0;i<=9;++i)for(int j=0;j<=9;++j)dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
    ll ret = 0ll;
    for(int i=0;i<h;++i)for(int j=0;j<w;++j){
        int cur; cin>>cur;
        if(cur != -1 and cur != 1){
            ret += dist[cur][1];
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main(){
  int D,N;
  cin >> D >> N;
  if(N==100)
  N=N+1;
  if(D==0)
  cout << N << endl;
  if(D==1)
  cout << N*100 << endl;
  if(D==2)
  cout << N*10000 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	//std::cout << "Hello World!\n"; 

	int N;
	vector<double> vec_d;
	cin >> N;

	for (int ic = 0; ic < N; ic++) {
		double buf;
		cin >> buf;
		vec_d.push_back(buf);
	}


	double max = vec_d.at(0);
	int max_index = 0;
	//一番大きいのは？
	for (int ic = 1; ic < N; ic++) {
		if (max < vec_d.at(ic)) {
			max = vec_d.at(ic);
			max_index = ic;
		}
	}

	//それ以外を合計
	double sum = 0.0;
	for (int ic = 0; ic < N; ic++) {
		if (max_index == ic) {
			continue;
		}

		sum += vec_d.at(ic);
	}

	string answer = "Yes";
	if (max >= sum) {
		answer = "No";
	}

	cout << answer.c_str();

	return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
 
int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    int a[50],b[50],c[50];
    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[n+1][500][500];

    rep(i,n+1){
        rep(j,500){
            rep(k,500){
                dp[i][j][k] = INF;
            }
        }
    }

    dp[0][0][0] = 0;

    rep(i,n){
        rep(aa,500){
            rep(bb,500){
                if(dp[i][aa][bb] != INF){
                    dp[i+1][aa][bb] = min(dp[i+1][aa][bb], dp[i][aa][bb]);
                    dp[i+1][aa+a[i]][bb+b[i]] = min(dp[i+1][aa+a[i]][bb+b[i]], dp[i][aa][bb] + c[i]);
                }
            }
        }
    }

    int ans = INF;

    for(int aa = 1; aa < 500; aa++){
        for(int bb = 1; bb < 500; bb++){
            if(aa * mb == bb * ma){
                ans = min(ans, dp[n][aa][bb]);
            }
        }
    }
    
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int a = -4;
  if(s[0]=='+') a=a+2;
  if(s[1]=='+') a=a+2;
  if(s[2]=='+') a=a+2;
  if(s[3]=='+') a=a+2;
  cout << a << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    n: usize, m: usize,
    hv: [usize; n],
    edges: [(Usize1, Usize1); m]
  };

  let mut max_h = hv.clone();
  for (a, b) in edges {
    max_h[a] = std::cmp::max(max_h[a], hv[b] + 1);
    max_h[b] = std::cmp::max(max_h[b], hv[a] + 1);
  }
  let mut res = 0;
  for i in 0..n {
    if hv[i] == max_h[i] {
      res += 1;
    }
  }
  println!("{}", res);
}


Measured memory_bytes: 7280
def main():
    n,m = map(int,input().split())
    l = []
    for i in range(m):
        l.append([i] + list(map(int,input().split())))

    l.sort(key=lambda x: (x[1],x[2]))

    p = -1
    no = 0
    for item in l:
        if item[1] != p:
            p = item[1]
            no = 1
        else:
            no += 1
        item.append(no)

    l.sort()

    for item in l:
        print("{:06}{:06}".format(item[1],item[3]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 35992
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>

using namespace std;

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int j = 0; j < H; j++) {
			for (int i = 0; i < W; i++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

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

	int mn = min(N, (ll)M);
	set<ll> S;
	vector<ll> A;
	ll a = X;
	ll sum_9 = 0; // sum of pre + cycle

	rp(_i, 0, mn){
		if(S.find(a) != S.end()) break;
		S.insert(a);
		A.push_back(a);
		sum_9 += a;
		a = a*a % M;
		if(a == 0){ cout<< sum_9 <<endl; return 0; }
	}

	if((int)A.size() >= mn){ cout<< sum_9 <<endl; return 0; }

	int pre_len = find(A.begin(), A.end(), a) - A.begin();
	int cyc_len = A.size() - pre_len;
	int btm_len = (N - pre_len) % cyc_len;

	ll cyc_num = (N - pre_len) / cyc_len;

	ll pre = 0; rp(i, 0, pre_len) pre += A[i];
	ll cyc = sum_9 - pre;
	ll btm = 0; rp(i, pre_len, pre_len + btm_len) btm += A[i];

	cout<< pre + cyc * cyc_num + btm <<endl;
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;pair<int,int>p[200100];int N,i,c,n[200100],d[200100];main(){cin>>N;for(;i<N;i++)cin>>p[i].first>>p[i].second;sort(p,p+N);d[N]=1;for(;i--;){c=i+1;while(c<N&&p[c].first<p[i].first+p[i].second)c=n[c];d[i]=(d[i+1]+d[n[i]=c])%998244353;}cout<<*d;}

Measured memory_bytes: 3328
N = gets.to_i
if N < 105 then
  puts 0
  exit
elsif N==105 then
  puts 1
  exit
else
  ans = 0
  (1..N).each do |i|
    cnt = 0
    i.times do |j|
      next if j%2==1
      if i%(j+1)==0 then
        #puts "  #{i}は#{j+1}で割り切れる"
        cnt += 1
      end
    end
    if cnt==8 then
      ans += 1
      #puts "#{i} の約数は#{cnt}あった"
    else
      #puts "#{i} の約数は#{cnt}あった"
    end
  end
end
p ans

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;


/**
 *
 * @author
 *
 *
 *
 */

public class Main {

//	public find() {
//	}

    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner();
        PrintStream out = System.out;

        Main main = new Main();

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        long price;
        if (n <= k) {
            price = n * x;
        } else {
            price = k * x +  (n - k)*y;
        }

        out.println(price);

        scanner.reader.close();
        out.close();
    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader reader;

        public MyScanner() {
            this.reader = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() throws IOException {
            this.reader.close();
        }

        int nextInt() {
            return Integer.parseInt(this.next());
        }

        long nextLong() {
            return Long.parseLong(this.next());
        }

        double nextDouble() {
            return Double.parseDouble(this.next());
        }

        String next() {
            String str = "";
            try {
                str = this.reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        String[] nextStringArray() {
            String[] str = null;
            try {
                str = this.reader.readLine().trim().split(" ");
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] nextIntArray() {
            String[] data  = nextStringArray();
            int[] a  = new int[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        Integer[] nextIntegerArray() {
            String[] data  = nextStringArray();
            Integer[] a  = new Integer[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        long[] nextLongArray() {
            String[] data  = nextStringArray();
            long[] a  = new long[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Long.parseLong(data[i]);
            }

            return a;
        }
    }
}



Measured memory_bytes: 7892
n=int(input())
x=n/1.08
x_int=round(x)
a=int(x_int*1.08)
if int(x_int*1.08)==n:
    print(x_int)
elif int((x_int+1)*1.08)==n:
    print(x_int+1)
else:
    print(':(')



Measured memory_bytes: 2940
import java.util.*;

public class Main { 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		String[] arr = input.nextLine().split(" ");
		
		HashMap<String, Integer> words = new HashMap<String, Integer>();
		String max = arr[0];
		String frequent = max;
		words.put(max, 1);
		
		
		for (int i = 1; i < arr.length; i++) {
			String word = arr[i];
			
			
			
			if (words.containsKey(word)) {
				words.put(word, words.get(word) + 1);
			} else {
				words.put(word, 1);
			}
			
			if (words.get(word) > words.get(frequent)) {
				frequent = word;
			}
			
			if (word.length() > max.length()) {
				max = word;
			}
		}

		System.out.println(frequent + " " + max);
		
		input.close();
	}	
}
 

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

import itertools
import copy

H, W, k = map(int, input().split())
c = [list(input()) for _ in range(H)]

clist = list(itertools.product([0, 1], repeat=H+W))
#print(clist)

ans = 0 
for q in clist:
    black = 0 
    h = q[:H]
    w = q[H:]
    # print('h =', h)
    # print('w =', w)
    # print()

    for i in range(H):
        for j in range(W):
            if h[i] == w[j] == 1 and c[i][j] == '#':
                black += 1
    if black == k:
        ans += 1

print(ans)


Measured memory_bytes: 9488
/*
    与えられた重み付きグラフ G=(V,E) に対する最小全域木の辺の重みの総和を計算するプログラムを作成してください。

    入力
    最初の行に G の頂点数 n が与えられます。続く n 行で G を表す n×n の隣接行列 A が与えられます。A の要素 aij は、頂点 i と頂点 j を結ぶ辺の重みを表します。ただし、辺がなければ-1 で示されます。

    出力
    G の最小全域木の辺の重みの総和を１行に出力してください。

    制約
    1≤n≤100
    0≤aij≤2,000 (aij≠−1 のとき)
    aij=aji
    グラフ G は連結である。
*/

#include <iostream>
#include <cstdio>
#include <climits>
#include <cstring>

using namespace std;

#define SWAP(type, a, b) do { type t = a; a = b; b = t; } while(0)

typedef struct {
    int weight;
    int to;
} Edge;

typedef struct {
    Edge *edge;
    int num;
} Heap;

void makeMinHeap(Heap *heap, int idx);
void insert(Heap *heap, int key);
int extract(Heap *heap);

static inline int getParent(int idx) { return idx / 2; }
static inline int getLeft(int idx) { return idx * 2; }
static inline int getRight(int idx) { return idx * 2 + 1; }
static inline bool isCorrectHeapIdx(int idx, int heapSize) { return idx <= heapSize && 1 <= idx; }
static inline bool isEmpty(Heap *heap) { return heap->num <= 0; }

void makeMinHeap(Heap *heap, int idx) {
    int left = getLeft(idx);
    int right = getRight(idx);

    int minIdx = idx;
    if(isCorrectHeapIdx(left, heap->num) && heap->edge[minIdx].weight > heap->edge[left].weight) {
        minIdx = left;
    } if(isCorrectHeapIdx(right, heap->num) && heap->edge[minIdx].weight > heap->edge[right].weight) {
        minIdx = right;
    }

    if(minIdx != idx) {
        SWAP(Edge, heap->edge[minIdx], heap->edge[idx]);
        makeMinHeap(heap, minIdx);
    }
}

void insert(Heap *heap, Edge* key) {
    heap->edge[++heap->num] = *key;
    for(int i = getParent(heap->num); i >= 1; i = getParent(i)) {
        makeMinHeap(heap, i);
    }
}

void extract(Heap *heap, Edge* key) {
    *key = heap->edge[1];
    heap->edge[1] = heap->edge[heap->num--];
    makeMinHeap(heap, 1);
}

int n;
int* weight;

static inline bool isConnected(int s, int t) {
    return weight[s * n + t] != INT_MAX;
}

static inline int getWeight(int s, int t) {
    return weight[s * n + t];
}

int getMimimumSpanningTree() {
    bool* isAddMst = new bool[n]();
    Heap connectEdge;
    Edge edge;
    int sum = 0;
    int v = 0;

    connectEdge.edge = new Edge[n * n];
    connectEdge.num = 0;
    
    while(1) {
        isAddMst[v] = true;

        for(int i = 0; i < n; i++) {
            if(isConnected(v, i) && !isAddMst[i]) {
                edge.weight = getWeight(v, i);
                edge.to = i;
                insert(&connectEdge, &edge);
            }
        }

        while(1) {
            if(isEmpty(&connectEdge)) {
                return sum;
            }

            extract(&connectEdge, &edge);

            if(!isAddMst[edge.to]) {
                break;
            }
        }

        v = edge.to;
        sum += edge.weight;
    }

    return sum;
}

int main() {

    scanf("%d", &n);

    weight = new int[n * n];
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            int w;
            scanf("%d", &w);
            weight[i * n + j] = (w == -1) ? INT_MAX : w;
        }
    }

    cout << getMimimumSpanningTree() << endl;
}


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

using namespace std;

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

	string s;
	cin >> s;
	int n;
	n = s.size();
	s = s[0] + to_string(n-2) + s[n-1];
	cout << s;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){

int n;
char st[4906],sh[4906];

scanf("%d",&n);

int ct=0,ch=0;
for(int i = 1; i<=n; i++){
scanf("%s %s",st,sh);
if(strcmp(st, sh) == 0){
ct += 1;
ch += 1;
}
else if(strcmp(st, sh) > 0){
ct += 3;
}
else{
ch += 3;
}
}
printf("%d %d\n",ct,ch);

return 0;
}


Measured memory_bytes: 2104
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

////////////////いろいろあるよ//////////////////////////////////
int main(){
	
      int a;
      cin >> a;
      if(a>=30)cout << "Yes" << endl;
  	  else cout << "No" << endl;
}


Measured memory_bytes: 3632
#BBBBBBBBBBB

import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

t = rl()
li = []
for i in range(len(t)):
    if t[i] == '?':
        li.append('D')
    else:
        li.append(t[i])
print(''.join(li))

Measured memory_bytes: 28952
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
      	String s = "s";
      if (a.substring(a.length() - 1).equals(s)) {
		System.out.println(a + "es"); 
      } else {
       System.out.println(a + "s");
      }
	}
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int A[2][110], dp[2][110];

int main() {
	cin >> N;
	rep(i, 2) {
		rep(j, N) {
			cin >> A[i][j];
		}
	}

	dp[0][0] = A[0][0];

	rep(i, 2) {
		rep(j, N) {
			if (i == 0) {
				dp[i+1][j] = max(dp[i+1][j], dp[i][j] + A[i+1][j]);
			}
			if (j + 1 < N) {
				dp[i][j+1] = max(dp[i][j+1], dp[i][j] + A[i][j+1]);
			}
		}
	}
	cout << dp[1][N-1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long a,b,c,d;
    string s;
    cin>>a>>s;
    b=int(s[3])-48+10*(int(s[2])-48)+100*(int(s[0])-48);
    //cout<<b<<endl;
    c=a*b;
    cout<<c/100<<endl;
}

Measured memory_bytes: 3648
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    four = 0
    two = 0
    etc = 0
    for i in A:
        if i % 4 == 0:
            four += 1
        elif i % 2 == 0:
            two += 1
        else:
            etc += 1

    if four >= N // 2 or \
        etc == 0 or \
        two >= 2 and four >= etc:
        print('Yes')
    else:
        print('No')

main()


Measured memory_bytes: 14352
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

vector<int> decode(ll a,ll N){
    vector<int> ret(N);
    for(int i=0;i<N;i++){
        ret[i]=a%4;
        a/=4;
    }
    
    return ret;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,A,B,C;
    cin>>N>>A>>B>>C;
    vll l(N);
    for(ll i=0;i<N;i++)cin>>l[i];
    
    ll ans=LLMAX;
    ll count_max=pow(4,N);
    for(ll count=0;count<count_max;count++){
        vector<int> p=decode(count,N);
        vvll split(4);
        for(int i=0;i<N;i++){
            split[p[i]].push_back(l[i]);
        }
        
        bool continue_loop=false;
        for(int i=0;i<3;i++){
            if(split[i].size()==0) continue_loop=true;
        }
        if(continue_loop)continue;
        
        ll cost=0;
        for(int i=0;i<3;i++){
            cost+=10*(split[i].size()-1);
            ll sum=0;
            for(int j=0;j<split[i].size();j++){
                sum+=split[i][j];
            }
            if(i==0) cost+=abs(A-sum);
            if(i==1) cost+=abs(B-sum);
            if(i==2) cost+=abs(C-sum);
        }
        if(cost<ans)ans=cost;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
int N, M, R;
vector <int> r;
const int INF = 1000000000;

class Warshall {
	private:
		vector <vector <int>> G;

	public:
		Warshall(int v) {
			G = vector <vector <int>> (v, vector <int> (v));
			for(int i = 0; i < G.size(); i++)
				for(int j = 0; j < G.size(); j++)
					G[i][j] = (i == j ? 0 : INF);
		}

		void addEdge(int start, int end, int cost) {
			G[start][end] = cost;
		}

		int dist(int start, int end) {
			return G[start][end];
		}

		bool checkNegativeCircle() {
			bool flag = false;
			for (int i = 0; i < G.size(); i++)
				if(G[i][i] < 0)
					flag = true;
			return flag;
		}

		void execute() {
			for(int k = 0; k < G.size(); k++)
				for(int i = 0; i < G.size(); i++)
					for(int j = 0; j < G.size(); j++)
						if(G[i][k] != INF && G[k][j] != INF)
							G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
		}

};

int main() {
	cin >> N >> M >> R;
	r = vector <int> (R);
	rep (i, R) {
		cin >> r[i];
		r[i]--;
	}
	Warshall G(N);
	rep (i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G.addEdge(a, b, c);
		G.addEdge(b, a, c);
	}
	G.execute();
	sort(r.begin(), r.end());
	int ans = INF;
	do {
		int sum = 0;
		rep (i, R - 1) sum += G.dist(r[i], r[i + 1]);
		ans = min(ans, sum);
	} while (next_permutation(r.begin(), r.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
string a;
  cin>>a;
  int ans=0;
  int n= a.size();
  for(int i=0;i<n/2;i++){
      if(a.at(i)!=a.at(n-i-1)) ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
judge=1
for i in A:
    if(i%2==0):
        if(i%5==0 or i%3==0):
            judge=1
        else:
            judge=0
            break

if(judge==0):
    print("DENIED")
else:
    print("APPROVED")
            

Measured memory_bytes: 3060
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    #define mp make_pair
    #define pb push_back
    //#define M_PI           3.1415926535  /* pi */
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100224;

    void solve(){
      ll n, m,x,y,sum=0;
      cin >> n >> m ;
      pii a[n];
      rep(i,n) cin >> x >> y, a[i] = {x,y};
      sort(a,a+n);
      rep(i,n){
          //cout << a[i].fst<<" "<<a[i].snd<<endl;
          if(a[i].second > m){
          sum+=m*a[i].fst;
          break;
        }
        sum+=(a[i].fst*a[i].snd);
        m-=a[i].snd;
        //cout<<m<<" "<<sum<<endl;
      }
      cout<<sum<<endl;
    }
    
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      solve();
      return 0;
    }   

Measured memory_bytes: 1792