akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+1000;
const ll INF=1e9+7;
inline ll read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll n,m;
char str[maxn];
int main()
{
    scanf("%s",str+1);
    int len=strlen(str+1);
    for(int i=1;i<=len;i++)
    {
        if(i%2&&str[i]!='R'&&str[i]!='U'&&str[i]!='D')
        {
            printf("No\n");
            return 0;
        }
        if(i%2==0&&str[i]!='L'&&str[i]!='U'&&str[i]!='D')
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n, m;
  cin >> n >> m;
  vvi to(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].pb(b);
    to[b].pb(a);
  }

  rep(i,to[0].size()) {
    int u = to[0][i];
    rep(j,to[u].size()) {
      if (to[u][j] == n-1) {
        puts("POSSIBLE");
        return 0;
      }
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}

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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, M;
    std::cin >> N >> M;

    vector<vector<ll>> cakes(N, vector<ll>(3, 0));
    REP(i, N) {
        ll x, y, z;
        std::cin >> x >> y >> z;
        cakes[i][0] = x;
        cakes[i][1] = y;
        cakes[i][2] = z;
    }

    ll ans = 0;
    for(int i = 0; i < (1 << 3); i++) {
        vector<ll> val(N, 0);
        for(int j = 0; j < 3; j++) {
            REP(k, N) {
                val[k] += (i & (1 << j)) ? cakes[k][j] : -cakes[k][j];
            }
        }
        RSORT(val);
        ans = max(ans, accumulate(val.begin(), val.begin() + M, 0LL));
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main() {
  
  int A, C, B;
  cin >> A >> C >> B;

  if( (A<B&&B<C) || (C<B&&B<A) ){ cout << "Yes" << endl; }
  else{ cout << "No" << endl; }
  

}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args) {
		int big=20;
		int sml=19;
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int[][] dat=new int[n][3];
		int[] ans=new int[n];
		for (int i=0;i<dat.length;i++){
			for(int j=0;j<3;j++){
				dat[i][j]=scn.nextInt();
			}
			int cnt=dat[i][0]+1;
			int bcnt=0;
			int scnt=0;
			int a=0;
			if(dat[i][1]%2==0){
				if(dat[i][0]%3==0){a++;}
				for(int d=dat[i][2];d<=sml;d++) a++;
			}else{
				for(int d=dat[i][2];d<=big;d++) a++;
			}
			for(int m=dat[i][1]+1;m<=10;m++){
				if(m%2==0&&dat[i][0]%3!=0){scnt++;}
				else{bcnt++;}
			}
			while(cnt<1000){
				if(cnt%3==0){
					bcnt+=10;
				}else{
					bcnt+=5;
					scnt+=5;
				}
				cnt++;
			}
			ans[i]=bcnt*big+scnt*sml+a;
		}

		for(int i=0;i<ans.length;i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 26956
#include<iostream>
using namespace std;
long a[200050];
int main(){
	int n,i;
	long cnt1=0,cnt2=0,cnt3=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%4==0) cnt1++;
		else if(a[i]%2==0) cnt2++;
		else cnt3++;
	}
	if(cnt3&&cnt1<cnt3&&cnt2||cnt3&&cnt2==0&&cnt1<cnt3-1) cout<<"No";
	else cout<<"Yes"; 
	return 0;
}

Measured memory_bytes: 1024
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()
ans = ""
for i in range(len(s)):
	ans += "x"
print(ans)

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

  int main() {
    string s, p;
    cin >> s >> p;
    string s2 = s;
    s += s2;
    if(s.find(p) != string::npos) {
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }
  }



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
bool fld[60][60];
int W, H;
void dfs(int x, int y){
    fld[y][x] = false;
    REP(i, -1, 2) REP(j, -1, 2){
        int nx = x + i, ny = y + j;
        if(nx < 0 || ny < 0 || W <= nx || H <= ny) continue;
        if(!fld[ny][nx]) continue;
        dfs(nx, ny);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    while(cin >> W >> H && W){
        memset(fld, 0, sizeof(fld));
        rep(i, H) rep(j, W) cin >> fld[i][j];
        int cnt = 0;
        rep(i, H) rep(j, W) if(fld[i][j]){
            dfs(j, i);
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<long long,long long> mp;
    long long sum=0;
    mp[sum]++;
    long long ans=0, a;
    for ( int i=0; i<n; i++ ) {
        cin >> a;
        sum+=a;
        if ( mp.count(sum) ) ans+=mp[sum];
        mp[sum]++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 16100
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Jigsaw Puzzle
public class Main{

	int h, w, n;
	int[] puzzle;
	List<R>[] piece;
	boolean[] res;
	
	class R{
		int H, W;
		int[] p;
		String str;
		public R(int h, int w, char[][] m) {
			H = h;
			W = w;
			p = new int[H];
			str = "";
			for(int i=0;i<H;i++)for(int j=0;j<W;j++){
				p[i] = (p[i]<<1) + (m[i][j]=='#'?1:0);
				str+=m[i][j];
			}
		}
		boolean eq(R r){
			if(H!=r.H || W!=r.W)return false;
			return str.equals(r.str);
		}
	}
	
	char[][] rot(char[][] a){
		int H = a.length, W = a[0].length;
		char[][] res = new char[W][H];
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)res[W-j-1][i] = a[i][j];
		return res;
	}
	
	void dfs(int i, int j, int U){
		if(j==w){
			dfs(i+1, 0, U); return;
		}
		if(i==h){
			res[U] = true; return;
		}
		for(int u=0;u<n;u++)if(((U>>u)&1)==0){
			for(R r:piece[u]){
				if(h < i+r.H || w < j+r.W)continue;
				boolean ok = true;
				for(int y=0;y<r.H;y++)if( (puzzle[i+y] & (r.p[y]<<(w-r.W-j))) != (r.p[y]<<(w-r.W-j))){
					ok = false; break;
				}
				if(!ok)continue;
				for(int y=0;y<r.H;y++){
					puzzle[i+y] -= (r.p[y]<<(w-r.W-j));
				}
				if(((puzzle[i]>>(w-j-1))&1)==0){
					dfs(i, j, U + (1<<u));
				}
				for(int y=0;y<r.H;y++){
					puzzle[i+y] |= (r.p[y]<<(w-r.W-j));
				}
				
			}
		}
		if(((puzzle[i]>>(w-j-1))&1)==0)
			dfs(i, j+1, U);
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		piece = new List[10];
		for(;;){
			h = sc.nextInt(); w = sc.nextInt();
			if((h|w)==0)break;
			puzzle = new int[h];
			for(int i=0;i<h;i++){
				char[] s = sc.next().toCharArray();
				for(char c:s)puzzle[i] = (puzzle[i]<<1) + (c=='#'?0:1);
			}
			n = sc.nextInt();
			for(int i=0;i<n;i++){
				piece[i] = new ArrayList<R>();
				int H = sc.nextInt(), W = sc.nextInt();
				char[][] m = new char[H][];
				for(int j=0;j<H;j++)m[j]=sc.next().toCharArray();
				piece[i].add(new R(H, W, m));
				for(int k=0;k<3;k++){
					m = rot(m);
					int t = H;
					H = W; W = t;
					piece[i].add(new R(H, W, m));
				}
				for(int j=0;j<piece[i].size();j++)for(int k=j+1;k<piece[i].size();k++)if(piece[i].get(j).eq(piece[i].get(k))){
					piece[i].remove(k--);
				}
			}
			res = new boolean[1<<n];
			dfs(0, 0, 0);
			int Q = sc.nextInt();
			while(Q--!=0){
				int k = sc.nextInt(), S = 0;
				while(k--!=0)S+=(1<<(sc.nextInt()-1));
				System.out.println(res[S]?"YES":"NO");
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n,MOD = [int(i) for i in input().split()]

to = [[] for _ in [0]*n]
for _ in range(n-1):
    x,y = [int(i)-1 for i in input().split()]
    to[x].append(y)
    to[y].append(x)


dp = [[0]*len(to_i) for to_i in to]
parent_index = [-9999]*n 
ans = [0]*n

def dfs(v, p):
    res = 1
    for i, vc in enumerate(to[v]):
        if vc == p:
            parent_index[v] = i
            continue
        dp[v][i] = dfs(vc, v)
        res *= dp[v][i]+1
        res %= MOD
    return res

def dfs2(v, res_p, p):
    deg = len(to[v])
    if p >= 0:
        dp[v][parent_index[v]] = res_p

    accl = [1]*(deg+1)
    accr = [1]*(deg+1)

    for i in range(1, deg+1):
        accl[i] = accl[i-1] * (dp[v][i-1] + 1) % MOD
        accr[-i-1] = accr[-i] * (dp[v][-i] + 1) % MOD

    ans[v] = accr[0]
    for i,vc in enumerate(to[v]):
        if vc == p: continue
        dfs2(vc, accl[i]*accr[i+1]%MOD, v)

dfs(0,-1)
#print(dp)
dfs2(0,0,-1)
#print(dp)
for i in ans:
    print(i)


Measured memory_bytes: 135420
from itertools import permutations
from math import sqrt

n = int(input())
p = [tuple(map(int, input().split())) for _ in range(n)]
pers = permutations(p)
sums = 0
cnt = 0

for per in pers:
    cnt += 1
    sx, sy = per[0]
    for x, y in per:
        sums += sqrt((sx - x) ** 2 + (sy - y) ** 2)

print(sums / cnt)

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int main(){

  while(1){
    ll n;
    vector<string> s;
    vector<ll> a[30];

    cin>>n;

    if(n==0)break;
    s.resize(n);
    rep(i,n){
      ll m;
      cin>>s[i];
      cin>>m;
      rep(j,m){
        ll b;
        cin>>b;
        a[b].push_back(i);
      }
    }

    vector<ll> p(n,0);
    rep(i,30){
      ll add=n+1-a[i].size();
      for(ll j : a[i]){
        p[j]+=add;
      }
    }

    string res="~";
    ll resp=10000000;
    rep(i,n){
      if(p[i]<resp||(p[i]==resp&&s[i]<res)){
        res=s[i]; resp=p[i];
      }
    }
    cout<<resp<<" "<<res<<endl;
  }

  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define int long long 
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

///////////////////////
const int N = 1e6; 
ll fact[N+1];

void set_fact() {
    fact[0] = 1;
    rep(i,N) fact[i+1] = ((((ll)i+1) % mod) * fact[i]) % mod;
}

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

// n! mod p 
ll mod_fact(ll n, ll p, ll &e) {
    e = 0;
    if (!n) return 1;
    ll res = mod_fact(n/p, p, e);
    e += n/p;

    if ((n/p)%2) 
        return res * (p - fact[n%p]) %p;
    else
        return res * fact[n%p] % p;
}

// nCk mod p ; O(log_p n)
ll mod_comb(ll n, ll k, ll p) {
    if (n<0 || k<0 || n<k) return 0;
    ll e1, e2, e3;
    ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n-k, p, e3);
    if (e1 > e2+e3) return 0;
    return a1 * mod_inv(a2*a3%p, p) % p;
}

// nHk mod p ;
ll mod_h_comb(ll n, ll k, ll p) {
    return mod_comb(n+k-1, k, p);
}
///////////////////////

signed main(void){
    set_fact();

    int h, w, a, b; cin >> h >> w >> a >> b;

    int res = 0;
    int y = h - a - 1, ry = a - 1;

    rep(x, b, w){
        int rx = w - x - 1;
        int numu = DIV(fact[x + y], MUL(fact[x], fact[y], mod), mod);
        int numd = DIV(fact[rx+ry], MUL(fact[rx],fact[ry],mod), mod);
        res = ADD(res, MUL(numu, numd, mod), mod);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	cout<<min(k,a)-max(k-a-b,0)<<endl;
	return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  1e9 + 7;
const int N = 1e6;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
   	ll n,k;
   	cin>>n>>k;
   	int a[105] = {0};
   	for(int i=1;i<=n;i++)
   	{
   		cin>>a[i];
   	}

   	ll dp[105][100005] = {0};
   	dp[0][0] = 1;
   	ll sum[105][100005] = {0};
   	for(int i=1;i<=n;i++)
   	{
   		sum[i-1][0] = dp[i-1][0];
   		for(int j=1;j<=k;j++)
   		{
   			sum[i-1][j] = (sum[i-1][j-1] + dp[i-1][j])%mod; 
   		}

   		for(int j=0;j<=k;j++)
   		{
   			int l = min(j,a[i]);
   			if(j-l==0)
   			{
   				dp[i][j] = sum[i-1][j];
   			}
   			else
   			{
   				dp[i][j] = (sum[i-1][j] - sum[i-1][j-l-1])%mod;
   			}
   		}
   	}

   	cout << (dp[n][k]%mod + mod)%mod << '\n';
    return 0;
}

Measured memory_bytes: 164352
/*
X Cubic
Write a program which calculates the cube of a given integer x.

Input
An integer x is given in a line.

Output
Print the cube of x in a line.

Constraints
1 ≤ x ≤ 100
*/
#include <iostream>

using namespace std;

int main(){
	int i;
	cin>>i;
	cout<<i*i*i<<endl;
	
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	lli X,Y;
	cin>>X>>Y;
	
	if(X%Y==0)cout<<-1;
	else cout<<X;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a;
    map <int, int> cnt;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        ++cnt[a];
        sum += a;
    }
    int q, b, c;
    cin >> q;
    while (q--) {
        cin >> b >> c;
        sum -= cnt[b] * b;
        sum += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << '\n';
    }
}


Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
int main(void){

   int sec=0, x;
   vector <int> a(5);
   int min=9;
   for (int i=0;i<5;i++){
       cin>>a[i];
       if(a[i]%10<min&&a[i]%10!=0) {
           min=a[i]%10;
           x=i;
       }
   }
   //cout<<x<<endl;
   for(int i=0;i<5;i++){
       if(i!=x) {
           sec+=a[i];
       }
       while (sec%10!=0){ sec++; }
     //  cout<<sec<<endl;
   }
   //cout<<sec<<endl;
  // cout<<a[x]<<endl;
   sec+=a[x];
   cout<<sec<<endl;
}


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

typedef long long ll;
typedef vector<ll> vll;

const double PI=acos(-1.0);

ll N;
void input()
{
    cin>>N;
}

void solve()
{
    if(N==1){
        cout<<0<<endl;
        return;
    }

    map<ll,int> M;
    while(N%2==0){
        N/=2; M[2ll]++;
    }
    for(ll i=3;i*i<=N;i+=2){
        while(N%i==0){
            N/=i; M[i]++;
        }
    }
    if(N!=1) M[N]++;

    ll ans=0;
    for(auto m:M){
        // cout<<m.first<<" "<<m.second<<endl;
        int add=0;
        for(int i=1;;++i){
            add+=i;
            if(m.second>=add) ++ans;
            else break;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	while(1){
	int n,k,x=0,ma=0,p=0,q=0;
	cin>>n>>k;
		q=k-1;
		if(n==0 && k==0)
		break;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
		for(int i=0;i<k;i++){
			x+=a[i];
		}
		ma=max(ma,x);
		for(int i=0;i<n-k;i++){
			q++;
			x+=a[q];
			x-=a[p];
			p++;
			ma=max(ma,x);
		}
	cout<<ma<<endl;
	}
return 0;
}

Measured memory_bytes: 1548
#include<bits/stdc++.h>
using namespace std;
#define min(a,b) (a)<(b)?a:b

/*int minm(int H[], int pos, int N)
{
  if(pos==N-1)
  {
    return Min[pos]=0;
  }
  if(Min[pos]!=-1)
  {
    return Min[pos];
  }
  if(pos==N-2)
  {
    return Min[pos]=( diff(H[pos],H[N-1]) );
  }
    return Min[pos]=min( ( diff(H[pos],H[pos+1])+minm(H,pos+1,N) ),  ( diff(H[pos],H[pos+2])+minm(H,pos+2,N) ) );         
}*/
int main()
{
  
  /*for(int i=0;i<100004;i++)
  {
    Min[i]=-1;
  }*/
  
    int N,K;
  cin>>N>>K;
  int H[N];
  int Min[N];
  for(int i=0;i<N;i++)
  {
    cin>>H[i];
    Min[i]=0;
  }
  
  //int ans=minm(H,0,N);
  for(int i=N-1;i>=0;--i)
{
	if(i==N-1)
		Min[i]=0;
	else if(i==N-2)
		Min[i]=abs(H[i]-H[N-1]);
	else
    {
		//Min[i]=min( (abs(H[i]-H[i+1])+Min[i+1]) , (abs(H[i]-H[i+2])+Min[i+2]) );
      int count=1,minm;
      minm=abs(H[i]-H[i+count])+Min[i+count];
      //count++;
      int K1=min(K,(N-1-i));
      for(count=2;count<=K1;count++)
      {
        minm=min((minm),(abs(H[i]-H[i+count])+Min[i+count]) );
      }
      Min[i]=minm;
    }
}
  cout<<Min[0];
}

Measured memory_bytes: 1024
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//nCr,nPr,modの逆元
//経路探索：(0,0)->(dx,dy) nHr(dx,dy-1)  (配列確保が2*n必要なので注意)
class Combination {
public:
	Array fact;//n！
	Array inv;//n!の逆元
	ll mod;
	Combination(ll n, ll _mod) {
		mod = _mod;
		fact.resize(n + 1);
		fact[0] = 1;
		REP(i, n) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n + 1);
		inv[n] = mod_inv(fact[n]);
		for (int i = n; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
	//modの逆元
	ll mod_inv(ll x) {
		ll n = mod - 2;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	ll nCr(ll n, ll r) {
		return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		//重複組み合わせ：n種類のものからr個取り出す組み合わせ
		return nCr(r + n - 1, r);
	}
};

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

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

	ll n, m;
	cin >> n >> m;

	map<ll, ll>mp;
	factoring(m, mp);

	Combination comb(202020, MOD);

	ll ans = 1;
	for (auto i : mp) {
		(ans *= comb.nHr(n, i.second)) %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

//2つの要素をまとめてソート、前の変数が優先。flag=0で小さい順、1で大きい順
void mysort2(vi &a,vi &b,ll flag){
  vector<pair<ll, ll>> p(a.size());
  REP(i,n){
    p[i].first=a[i];
    p[i].second=b[i];
  }
  sort(p.begin(),p.end());
  if (flag==1){
    reverse(p.begin(),p.end());
  }
  REP(i,n){
    a[i]=p[i].first;
    b[i]=p[i].second;
  }
  return;
}




int main(){
  ll ans=0;
  cin >> n ;
  vi a(n),b(n),c(n),d(n),e(n);
  REP(i,n){
    cin>>a[i];
    b[i]=i;
  }
  mysort2(a,b,1);
  ll r=n-1,l=0;

  REP(i,n){
    c[i]=a[i];
    d[i]=b[i];
  }


  for(ll i=0;i<n;i++){
    if (abs(r-b[i])>abs(b[i]-l)){
      ans+=abs(r-b[i])*a[i];
      c[r]=a[i];
      d[r]=b[i];
      r--;
    }else{
      ans+=abs(b[i]-l)*a[i];
      c[l]=a[i];
      d[l]=b[i];
      l++;
    }
  }




/*
  REP(i,n){
    cout<<c[i]<<"("<<d[i]<<")";
  }
  cout<<endl;
*/

  for(ll xxx=0;xxx<5;xxx++){


          r=n-1;l=0;
          for(ll i=0;i<n;i++){
            //cout<<c[r]<<" "<<c[l]<<endl;
            if (c[r]>c[l]){
              ll gk=c[r]*( abs(d[r]-l)-abs(d[r]-r) );
              //1こ右にずらす
              for(ll j=l;j<r;j++){
                gk+=c[j]*( abs(d[j]-(j+1))-abs(d[j]-j) );
              }
              if (gk>0){
                gk=c[r];
                ll dgk=d[r];
                //1こ右にずらす
                for(ll j=r-1;j>=l;j--){
                  c[j+1]=c[j];
                  d[j+1]=d[j];
                }
                c[l]=gk;
                d[l]=dgk;
                l++;
              }else{
                r--;
              }
              
            }else{

              ll gk=c[l]*( abs(d[l]-r)-abs(d[l]-l) );
              //1こ左にずらす
              for(ll j=l+1;j<=r;j++){
                gk+=c[j]*( abs(d[j]-(j-1))-abs(d[j]-j) );
              }
              if (gk>0){
                gk=c[l];
                ll dgk=d[l];
                //1こ左にずらす
                for(ll j=l;j<r;j++){
                  c[j]=c[j+1];
                  d[j]=d[j+1];
                }
                c[r]=gk;
                d[r]=dgk;
                r--;
              }else{
                l++;
              }
            }

          }



  }









/*
  REP(i,n){
    cout<<c[i]<<"("<<d[i]<<")";
  }
*/

  ans=0;
  REP(i,n){
    ans+=c[i]*abs(d[i]-i);
  }
  cout<<ans<<endl;
  return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    ll l[n];
    rep(i, n)cin >> l[i];

    ll dp[n+1];
    rep(i, n+1)dp[i] = LINF;
    dp[0] = 0;

    rep(i, n-1){
        ll k_i = 0;
        while(k_i<=i && k_i < k){
            dp[i+1] = min(dp[i+1], dp[i-k_i]+abs(l[i-k_i]-l[i+1]));
            k_i++;
        }
    }

    cout << dp[n-1];
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int cnt = 0;
  while(n>0){
    n /=k;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3528
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	double a, b, x, t;
	cin >> a >> b >> x;
	t = 2 * x / (a * b);
	if (t <= a) {
		printf("%0.8lf", atan(b / t) / (atan(1) * 4) * 180);
	}
	else {
		double leave;
		leave = a * a * b - x;
		printf("%0.8lf", atan(leave * 2 / (a * a) / a) / (atan(1) * 4) * 180);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void pre(int);
void in(int);
void post(int);

typedef struct Node
{
  int p;
  int l;
  int r;
}tree;

tree T[25];
int n;

int main()
{
  int i;
  int v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      T[i].p=-1;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d%d",&v,&l,&r);
      T[v].l=l;
      T[v].r=r;
      if(l!=-1)T[l].p=v;
      if(r!=-1)T[r].p=v;    
    }

  for(i=0;i<n;i++)
    {
      if(T[i].p==-1)root=i;
    }

  printf("Preorder\n");
  pre(root);
  printf("\n");
  
  printf("Inorder\n");
  in(root);
  printf("\n");
  
  printf("Postorder\n");
  post(root);
  printf("\n");

  return 0;
}

void pre(int u)
{
  if(u==-1)return;
  printf(" %d",u);
  pre(T[u].l);
  pre(T[u].r);
}

void in(int u)
{
  if(u==-1)return;
  in(T[u].l);
  printf(" %d",u);
  in(T[u].r);
}

void post(int u)
{
  if(u==-1)return;
  post(T[u].l);
  post(T[u].r);
  printf(" %d",u);
}



Measured memory_bytes: 2076
using System;
using System.Collections.Generic;
using System.Linq;

namespace A
{

    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineIntSpilit();
            var a = ReadLineIntSpilit();
            var all = 0; for (int i = 0; i < a.Length; i++) { all += a[i]; }
            var result = "Yes";

            //降順
            a = a.OrderBy(x => -x).ToArray();

            for (int i = 0; i < n[1]; i++) {
                if(a[i] < (all*1.0 / (4 * n[1])) ) {
                    result = "No";
                    break;
                }
            }

            Console.WriteLine(result);
            ReadLine();
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a;
    int b;
    int c;
    
    scanf("%d %d %d", &a, &b, &c);

    if (a>=c && b>=c) {
        printf("%d ", c);
        if (a>=b) {
            printf("%d %d\n", b, a);
        }else{
            printf("%d %d\n", a, b);
        }
    }else if (a>=b && c>=b) {
        printf("%d ", b);
        if (a>=c) {
            printf("%d %d\n", c, a);
        }else{
            printf("%d %d\n", a, c);
        }
    }else {
        printf("%d %d %d\n", a, b, c);
    }
    
    
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair <int, int>;
const int N = 80 + 2;
const int M = 13000;
const ll mod = 1e9 + 7;
bool f[N][N][M];
int a[N][N], b[N][N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cin >> b[i][j];
		}
	}
	f[1][1][abs(a[1][1] - b[1][1])] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			for (int k = 0; k < M; ++k)
			{
				if (!f[i][j][k])
					continue;
				int x = a[i + 1][j], y = b[i + 1][j];
				f[i + 1][j][abs(k + x - y)] = f[i + 1][j][abs(k + y - x)] = 1;
				x = a[i][j + 1];
				y = b[i][j + 1];
				f[i][j + 1][abs(k + x - y)] = f[i][j + 1][abs(k + y - x)] = 1;
			}
		}
	}
	for (int i = 0; i < M; ++i)
		if (f[n][m][i])
		{
			cout << i;
			return 0;
		}
}


Measured memory_bytes: 84096
if __name__ == "__main__":
    list = []
    tmp = []
    sort_list = []
    num = int(input())
    list = input().split()
    for i,v in enumerate(list):
        tmp.append([int(v),i+1])
    sort_list=sorted(tmp)
    ans = [str(i[1]) for i in sort_list ]
    print(" ".join(ans))

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int Q;
vector< pair<int, int> > Query;

int prime[MAX_N];           // i 番目の素数
bool is_prime[MAX_N + 1];   // is_prime[i] が true なら i は素数

// n 以下の素数の数を返す
int sieve(int n) {
    int p = 0;
    for(int i = 0; i <= n; ++i) {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i = 1; i <= n; ++i) {
        if(is_prime[i]) {
            prime[p++] = i;
            for(int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return p;
}

int alike[MAX_N];   // 2017 に似た数なら true
int alike_num[MAX_N];   // [0, i] までの 2017 に似た数の合計

int main()
{
    cin >> Q;
    REP(i, Q) {
        int l, r;
        cin >> l >> r;
        Query.push_back(make_pair(l, r));
    }
    // 素数テーブルを作る
    sieve(100000);
    // 2017 に似た数テーブルを作る
    ZERO(alike);
    REP(i, MAX_N) {
        if(is_prime[i] && is_prime[(i+1)/2]) { alike[i] = true; }
    }
    alike_num[0] = 0;
    for(int i=1; i < MAX_N; ++i) {
        alike_num[i] = alike_num[i-1];
        if(alike[i]) { alike_num[i]++; }
    }
    // クエリの処理
    for(auto& tmp : Query) {
        printf("%lld\n", alike_num[tmp.second] - alike_num[tmp.first-1]);
    }
    return 0;
}


Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        int h = Integer.parseInt(str[0]);

        for(int i=0; i<h; i++){
            String in = br.readLine();
            System.out.println(in);
            System.out.println(in);
        }
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;                                
struct node{
  int d;
  struct node* next;  
};
struct node* init(){
  struct node* n = (struct node*)malloc(sizeof(struct node));
  n->d = -1;
  n->next = NULL;   
  return n; 
}
void insert(struct node* n,int d){
  struct node* ne = (struct node*)malloc(sizeof(struct node));
  ne->d = d;
  ne->next = n->next;
  n->next = ne;   
}

void pl(long int counter[],struct node* a[],int n,int p){
  if(n != p){
      counter[n] += counter[p];
  }
  struct node* n1 = a[n];
  while(n1->next != NULL){
    if(n1->next->d != p) pl(counter,a,n1->next->d,n);
    n1 =n1->next;  
  }
}

int main(void){                                     
  int N,Q;
  cin >> N >> Q;
  struct node* ki[N];
  long int counter[N] = {};
  int min_pare = N;
  for(int i = 0; i < N;i++){
    ki[i] = init();  
  }
  for(int i = 1; i <= N-1;i++){
    int a,b;
    cin >> a >> b;
    if(min_pare > a) min_pare = a;
    insert(ki[a-1],b-1);  
    insert(ki[b-1],a-1);  
  }
  for(int i = 0; i < Q;i++){
    int p,x;
    cin >> p >> x;
    counter[p-1] += x;  
  }
  pl(counter,ki,min_pare-1,min_pare-1);
  for(int i = 0; i < N;i++){
    cout << counter[i] << " ";  
  }

  cout << endl;
  return 0;                                         
}     


Measured memory_bytes: 33664
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   a : Integer;
   b : Integer;
   c : Integer;
   max : Integer;
begin
   Get (a);
   Get (b);
   Get (c);
   max := a;
   if b > max then
      max := b;
   end if;
   if c > max then
      max := c;
   end if;
   if a+b+c = max*2 then
      Put_Line ("Yes");
   else
      Put_Line ("No");
   end if;
end Solve;

Measured memory_bytes: 3680
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
string s,t;
int l1,l2,i,j;
bool ok;
int main(void){
  cin>>s>>t;
  l1=s.size();
  l2=t.size();
  for(i=0;i<l1;i++){
    ok=true;
    for(j=0;j<l2;j++){
      if(s[(i+j)%l1]!=t[j]){
        ok=false;
        break;
      }
    }
    if(ok)break;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3168
import numpy as np
from operator import itemgetter
N,M=(int(x) for x in input().split())
A=[]
 
for i in range(N):
  D=[int(x) for x in input().split()]
  A+=[D]    
result=A.sort(key=itemgetter(0))
count=M
sum=0
for i in range(N):
  if count-A[i][1]>0:
    count=count-A[i][1]
    sum+=A[i][0]*A[i][1]
  else:
    sum+=count*A[i][0]
    break
print(sum) 

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

using namespace std;

int main(){
	
	while(1){
		
		int m,mi,ma;
		
		cin >> m >> mi >> ma;
		if(m==0) break;
		
		int p[m];
		for(int i=0;i<m;i++) cin >> p[i];
		
		int dif;
		int k=0,md=0,mem=0;
		
		for(int i=mi-1;i<ma;i++){
			dif=p[i]-p[i+1];
			md=max(md,dif);
			if(md==dif) mem=i;
			k++;
		}
		cout << mem+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,m = get_nums_l()

groups = n
node_groups = [ i for i in range(n)]
group_sizes = [ 1 for _ in range(n)]
group_ranks = [ 0 for _ in range(n)]

edges = []
for i in range(m):
    tmp=input().split(" ")
    edges.append([int(tmp[0])-1, int(tmp[1])-1])


def root(i):
    if node_groups[i] == i:
        #print(i, "is root.")
        return i
    else:
        #_1 = node_groups[i]
        node_groups[i] = root(node_groups[i])
        #_2 = node_groups[i]
        #print ("root: ", _1, _2)
        return node_groups[i]

def same(a, b):
    return root(a) == root(b)

def size(i):
    return group_sizes[root(i)]

def unite(a, b):
    global groups

    a = root(a)
    b = root(b)

    if a == b:
        return
    
    # 合体したらグループ数が減る
    groups -= 1

    if group_ranks[a] < group_ranks[b]:
        group_sizes[b] += size(a)
        node_groups[a] = b
    else:
        group_sizes[a] += size(b)
        node_groups[b] = a
        if group_ranks[a] == group_ranks[b]:
            group_ranks[a] += 1


for i in range(m-1, -1, -1):
    edge = edges[i]
    # print("edge: ",edge)
    #print("node_groups: ", node_groups)
    node_1 = edge[0]
    node_2 = edge[1]

    root_1 = root(node_1)
    root_2 = root(node_2)

    unite(root_1, root_2)
print(groups)

Measured memory_bytes: 90668
a,b,k=map(int,input().split())
m=[]
for i in range(a,min(a+k,b+1)):
    m.append(i)
for i in range(max(b-k+1,a),b+1):
    m.append(i)
l=set(m)
ll=list(l)
lll=sorted(ll)
for i in range(len(lll)):
    print(lll[i])


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>

using namespace std;

int main()
{
	int n, x;
	int count;
	while(true) {
		count = 0;
		cin >> n >> x;
		if(n == 0 && x == 0)
			break;
		for (int i = 1; i <= n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				for (int k = j + 1; k <= n; ++k) {
					if(i + j + k == x)
						count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		bool ans = 0;
		if(s.size()>=4 && s.substr(0, 4)=="YAKI") ans = 1;
		
		cout<<(ans?"Yes":"No")<<endl;
	}
	
	return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

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

int a[10][10];
int used[10][10];

int h, w, k;

int check(int r, int c) {
    memset(used, 0, sizeof used);
    for (int i = 0; i < h; i++) {
        if ((r >> i) & 1) {
            for (int j = 0; j < w; j++) {
                used[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < w; i++) {
        if ((c >> i) & 1) {
            for (int j = 0; j < h; j++) {
                used[j][i] = 1;
            }
        }
    }
    int res = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            res += (used[i][j] == 0 && a[i][j]);
        }
    }
    return (res == k);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

//    int h, w, k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            a[i][j] = (s[j] == '#');
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            ans += check(i, j);
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
      cout<<"Yes"<<endl;
    }
    else if(s[1]==s[2]&&s[2]==s[3]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3620