akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define mod 998244353
typedef long long ll;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    vector<mint> dp(n+1);
    vector<mint> dpsum(n+1);
    rep(i, k) cin >> l[i] >> r[i];

    dp[1] = 1;
    dpsum[1] = 1;

    for(int i=2; i<=n; i++){
        rep(j,k){
            int li = i-r[j];
            int ri = i-l[j];
            if(ri < 0) continue;
            li = max(li,1);
            dp[i] += dpsum[ri] - dpsum[li-1];
        }
        dpsum[i] = dpsum[i-1] + dp[i];
    }

    cout << dp[n] << endl;
    return 0;

    

}

Measured memory_bytes: 6360
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
char S[12];
char m[] = "MARCH";
long long cnt[5];
int main(){
  int Lj4PdHRW, i, j, k;
  long long res=0;
  rd(N);
  for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
    rd(S);
    for(i=0;i<(5);i++){
      if(S[0]==m[i]){
        cnt[i]++;
      }
    }
  }
  for(i=0;i<(5);i++){
    for(j=(i+1);j<(5);j++){
      for(k=(j+1);k<(5);k++){
        res += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// int N; char S[12];
// 
// char m[] = "MARCH";
// ll cnt[5];
// {
//   int i, j, k;
//   ll res = 0;
//   rd(N);
//   rep(N){
//     rd(S);
//     rep(i,5) if(S[0]==m[i]) cnt[i]++;
//   }
//   rep(i,5) rep(j,i+1,5) rep(k,j+1,5) res += cnt[i] * cnt[j] * cnt[k];
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

void printVec(std::vector<int> &vec)
{
    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it)
    {
        std::cout << *it << " ";
    }
    std::cout << std::endl;
}

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;

    ll a = abs(x) / d;
    if (a >= k)
    {
        if (x >= 0)
        {
            cout << abs(x - d * k) << endl;
            return 0;
        }
        else
        {
            cout << abs(x + d * k) << endl;
            return 0;
        }
    }

    if (x >= 0)
    {
        if ((k - a + 1) % 2 == 0)
        {
            cout << abs(x - d * (a + 1)) << endl;
            return 0;
        }
        else
        {
            cout << abs(x - d * (a + 1) + d) << endl;
            return 0;
        }
    }
    else
    {
        if ((k - a + 1) % 2 == 0)
        {
            cout << abs(x + d * (a + 1)) << endl;
            return 0;
        }
        else
        {
            cout << abs(x + d * (a + 1) - d) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int f(string s){
  int ans =0;
  rrep(i,s.size()-1){
    if(s[i]=='i'){
      if(i-1<0||!('2'<=s[i-1]&&s[i-1]<='9'))
        ans+=1;
      else
        ans+=1*(s[i-1]-'0');
    }
    if(s[i]=='x'){
      if(i-1<0||!('2'<=s[i-1]&&s[i-1]<='9'))
        ans+=10;
      else
        ans+=10*(s[i-1]-'0');
    }
     if(s[i]=='c'){
      if(i-1<0||!('2'<=s[i-1]&&s[i-1]<='9'))
        ans+=100;
      else
        ans+=100*(s[i-1]-'0');
     }
     if(s[i]=='m'){
      if(i-1<0||!('2'<=s[i-1]&&s[i-1]<='9'))
        ans+=1000;
      else
        ans+=1000*(s[i-1]-'0');
     }
    }

  return ans;
}

string g(int n){
  string s;
  if(n>=1000){
    if(n/1000!=1)
    s+=n/1000 + '0';
    s+='m';
    n%=1000;
  }
 if(n>=100){
   if(n/100!=1)
    s+=n/100 + '0';
    s+='c';
    n%=100;
  }

 if(n>=10){
   if(n/10!=1)
    s+=n/10 + '0';
    s+='x';
    n%=10;
  }

 if(n>=1){
   if(n!=1)
    s+=n + '0';
    s+='i';
  }
  return s;
}


int main(){
  int n;
  cin>>n;
  rep(i,n){
    string s,t;
    cin>>s>>t;
    int a = f(s);
    int b = f(t);
    
    cout<<g(a+b)<<endl;
  }

  return 0;
}


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

using namespace std;

int mod = 1e9 + 7;

int powM(int n, int p) { return (!p ? 1 : (p & 1) ? (1ll * n * powM(n, p - 1)) % mod : powM((1ll * n * n) % mod, p / 2)); }

int add(int a, int b) { return a + b - (a + b >= mod) * mod; }

int sub(int a, int b) { return a - b + (a - b < 0) * mod; }

int mul(int a, int b) { return (1ll * a * b) % mod; }

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

    int n, k;
    cin >> n >> k;
    int g[k + 1] = {}, ans = 0;

    for (int i = k; i >= 1; i--) {
        g[i] = powM(k / i, n);
        for (int j = i + i; j <= k; j += i)
            g[i] = sub(g[i], g[j]);

        ans = add(ans, mul(g[i], i));
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 4028
ms = list(map(int,input().split()))
if len(set(ms))==1 and ms[0]%2==0:
    print(-1)
else:
    ans=0
    while(all([i%2==0 for i in ms])):
        l = [0]*3
        for i in range(3):
            x = ms[i]/2
            if i==0:
                l[1]+=x
                l[2]+=x
            elif i==1:
                l[0]+=x
                l[2]+=x
            elif i==2:
                l[0]+=x
                l[1]+=x
        ms = l[:]
        ans+=1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<ll, ll> pll;
#define fi first
#define se second
#define pb push_back
#define ppb pop_back

int main() {
  ll n,a[10]={};
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    if (s[0]=='A') ++a[0];
    if (s[0]=='W') ++a[1];
    if (s[0]=='T') ++a[2];
    if (s[0]=='R') ++a[3];
  }
  cout << "AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,k,i,count=0;
    cin>>a>>b>>k;
    for(i=min(a,b);i>=1;i--){
        if(a%i==0 && b%i==0)
            count+=1;
        if(count==k){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define lint long long
using namespace std;
lint readint() {
	char c = getchar_unlocked();
	lint ans = 0;
	while ('0' <= c && c <= '9') {
		ans = ans * 10 + c - '0';
		c = getchar_unlocked();
	}
	return ans;
}
char ch[1024];
void writeint(lint x) {
	int ptr = 0;
	while (x) {
		ch[ptr++] = (x % 10) + '0';
		x /= 10;
	}
	while (ptr) {
		putchar_unlocked(ch[--ptr]);
	}
	putchar_unlocked(' ');
}
int q;
constexpr int m=1000000007;
lint x,y,f[99]={0,1,1};
int main(){
	q=readint();
	rep(i,96)f[i+3]=f[i+1]+f[i+2];
	rep(i,q){
		x=readint();y=readint();
		if(x>y)swap(x,y);
		if(y<=2){
			writeint(1);writeint(y==1?1:x==1?2:4);
			continue;
		}
		rep(j,99){
			if(x<f[j]||y<f[j+1]){
				lint a=x==1?2:1;
				rep(k,j-2){
					lint n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];
					if(n<=x&&m<=y)a+=(y-m)/n+1;
				}
				if(f[j]<=x){
					a++;
					rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);
				}
				writeint(j-2);writeint(a%m);
				break;
			}
		}
	}
}

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

int main() {
    int N;
    int cnt = 0;
    cin >> N;
    vector<int> L(N);
    for (int i=0;i<N;i++) {
        cin >> L.at(i);
    }
    sort(L.begin(),L.end());
    for (int i=0;i<N-2;i++) {
        for (int j=i+1;j<N-1;j++) {
            for (int k=j+1;k<N;k++) {
                if (L.at(i) != L.at(j) && L.at(j) != L.at(k) && (L.at(i) + L.at(j)) > L.at(k)) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}


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

namespace ABC112_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            var dM = Calcdivisors(M);
            long a = 0;

            foreach (var d in dM)
            {
                if (M / d >= N && d > a) a = d; 
            }
            Console.WriteLine(a);
        }

        public static List<long> Calcdivisors(long n)
        {
            var factors = new List<long>();

            for (long i = 1; i * i <= n; i ++)
            {
                if (n % i != 0) continue;
                factors.Add(i);
                if (n / i == i) continue;
                factors.Add(n / i);
            }
            return factors;
        }
    }
}


Measured memory_bytes: 13396
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
import numpy as np
from heapq import heappop, heappush
 
H,W = map(int,readline().split())
grid = np.full((H+2,W+2),b'#',dtype='S1')
grid[1:-1,1:-1] = np.frombuffer(read(),'S1').reshape(H,-1)[:,:W]
INF = 400
def shortest(grid, start, cost=0):
    dist = np.array([[INF for _ in range(W+2)] for _ in range(H+2)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    st = [(cost, start)]
    dist[start[0]][start[1]]=0
    while(st):
        c, [sx, sy] = heappop(st)
        for a, b in zip(dx, dy):
            x = sx + a
            y = sy + b
            if grid[x][y]==b'#':
              continue
            dxy = dist[sx][sy] + 1
            if dist[x][y] <= dxy:
                continue
            dist[x][y] = dxy
            heappush(st, (dist[x][y], [x, y]))
    return dist

m=0
for i in range(1,H+1):
  for j in range(1,W+1):
    if grid[i,j]==b'#':
      continue
    res=shortest(grid, [i,j], cost=0)[1:-1,1:-1]
    res[res==400]=0
    tm=np.max(res)
    if m < tm:
      m=tm
print(m)

Measured memory_bytes: 14404
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var input = Reads();
        var x1 = input[0];
        var y1 = input[1];
        var x2 = input[2];
        var y2 = input[3];
        var x = x2 - x1;
        var y = y2 - y1;
        var x4 = -y + x1;
        var y4 = x + y1;
        x = x1 - x4;
        y = y1 - y4;
        var x3 = -y +  x4;
        var y3 = x + y4;
        Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);

        Console.Out.Flush();
    }
}



Measured memory_bytes: 13396
// ayy
// ' lamo
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld; //CARE
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
const ld eps=1e-8;
const int inf=1e9+99;
const ll linf=1e18+99;
const int P=1e9+7;




string g1(string A,int X) {
	string Z="";
	// cerr<<A<<" * "<<X<<endl;
	for(;X--;) Z+=A;
	return Z;
}

string g2(string A,string B,int X,int Y) {
	// cerr<<"g2"<<" "<<A<<" "<<B<<" "<<X<<" "<<Y<<endl;
	assert(A<B);
	if(!X) return g1(B,Y);
	if(!Y) return g1(A,X);
	string AA=A;
	string BB=A;
	for(int i=1;i*X<=Y;i++) AA+=B, BB+=B;
	AA+=B;
	int XX=Y%X;
	int YY=X-XX;
	return g2(BB,AA,YY,XX);
}




string g3(string A,string B,string C,int X,int Y,int Z) {
	// cerr<<"g3"<<" "<<A<<" "<<B<<" "<<C<<" "<<X<<" "<<Y<<" "<<Z<<endl;
	assert(A<B && B<C);
	if(!X) return g2(B,C,Y,Z);
	if(!Y) return g2(A,C,X,Z);
	if(!Z) return g2(A,B,X,Y);
	string AA=A;
	string BB=A;
	string CC=A;
	for(int i=1;i*X<=Z;i++) AA+=C, BB+=C, CC+=C;
	AA+=C;
	int XX=Z%X;
	int qq=X-XX;
	assert(qq>=1);
	for(int i=1;i*qq<=Y;i++) BB+=B, CC+=B;
	BB+=B;
	int YY=Y%qq;
	int ZZ=qq-YY;
	assert(XX+YY+ZZ == X);
	return g3(CC,BB,AA,ZZ,YY,XX);
}


int32_t main() {
	int X,Y,Z;
	cin>>X>>Y>>Z;
	cout<<g3("a","b","c",X,Y,Z)<<endl;
}













Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    string s;
    cin >> s;
    if(s.size() == 3) reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

typedef pair<int,int> P;//shortest pass,vertex number

const int MAX=101;
const int INF=1<<28;

class edge
{
public:
	int to,cap,cost,rev;
	edge(){}
	edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

int V;
vector<edge> G[MAX];
int h[MAX];
int dist[MAX];
int prevv[MAX],preve[MAX];

void add_edge(int from,int to,int cap,int cost)
{
	G[from].push_back(edge(to,cap,cost,G[to].size()));
	G[to].push_back(edge(from,0,-cost,G[from].size()-1));
	return;
}

const int inf=1<<20;

void add_edge_lowerlimit(int from,int to,int cap,int cost,int limit)
{
	add_edge(from,to,cap-limit,cost);
	add_edge(from,to,limit,cost-inf);
	return;
}

int mincostflow(int s,int t)
{
	int res=0;
	int f=INF;
	fill(h,h+V,INF);
	h[s]=0;
	rep(v,V)rep(i,G[v].size())
	{
		edge e=G[v][i];
		if(e.cap!=0)h[e.to]=min(h[e.to],h[v]+e.cost);
	}
	while(h[t]<0)
	{
		priority_queue<P> Q;
		fill(dist,dist+V,INF);
		dist[s]=0;
		Q.push(P(0,s));
		
		while(!Q.empty())
		{
			P p=Q.top();Q.pop();
			int v=p.second;
			if(dist[v]<p.first*(-1))continue;
			for(int i=0;i<G[v].size();i++)
			{
				edge &e=G[v][i];
				if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to])
				{
					dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
					prevv[e.to]=v;
					preve[e.to]=i;
					Q.push(P(dist[e.to]*(-1),e.to));
				}
			}
		}
		
		if(dist[t]==INF)return -1;
		
		for(int v=0;v<V;v++)h[v]+=dist[v];
		int d=f;
		for(int v=t;v!=s;v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
		f-=d;
		res+=d*h[t];
		
		for(int v=t;v!=s;v=prevv[v])
		{
			edge &e=G[prevv[v]][preve[v]];
			e.cap-=d;
			G[v][e.rev].cap+=d;
		}
	}
	return res;
}

int main()
{
	int n,m;
	cin>>n>>m;
	V=n+1;
	int u,v,s;
	vector<P> GG[100];
	rep(i,m)
	{
		cin>>u>>v>>s;
		add_edge_lowerlimit(u,v,INF,-s,1);
		GG[u].pb(mp(v,s));
	}
	int S=0,T=n;
	int d[100]={};
	rep(i,n)
	{
		rep(j,GG[i].size())
		{
			P e=GG[i][j];
			d[e.fi]=max(d[e.fi],d[i]+e.se);
		}
	}
	add_edge(n-1,n,INF,d[n-1]);
	cout<<mincostflow(S,T)+m*inf<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>

int digit(int nb){
	int rem;
	
	while(nb!=0){
		rem=nb%10;
		if(rem==7)
			return 1;
		nb/=10;	
	}
	return 0;
}

int main(){
	
	int nb;
	scanf("%d",&nb);
	int check = digit(nb);
	if(check==1)
		printf("Yes\n");
	else
		printf("No\n");	

	return 0;
}




Measured memory_bytes: 1644
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<T>())
#define REVERCE(x) reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	ios::sync_with_stdio(false);

	string s;

	cin >> s;

	itn cnt = 0;
	itn posl, posr;

	posl = 0;

	posr = s.size() - 1;

	while (posl <= posr) {
		if (s[posl] != s[posr]) {
			cnt++;
		}
		posl++;
		posr--;
	}

	cout << cnt;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n;
	cin >> n;
	if (n >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 3648
Main = input => {
  s = input.trim();
  
  for (var i = 0; i < s.length; i++) {
    if (i % 2 === 0 && s[i] === "L") {
      console.log("No");
      return;
    }
    
    if (i % 2 && s[i] === "R") {
      console.log("No");
      return;
    }
  }
  
  console.log("Yes");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		ArrayList<Integer> array = new ArrayList<Integer>();
		int n = 0;
		array.add(Integer.parseInt(scan.next()));
		while(scan.hasNext()){
			int m = Integer.parseInt(scan.next());
			if(m == 0){
				System.out.println(array.get(n));
				array.remove(n);
				n--;
			}else{
				array.add(m);
				n++;
			}
		}
		System.exit(0);
	}
}

Measured memory_bytes: 12000
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second

// Efficient program to print all prime factors of a given number
// https://www.geeksforgeeks.org/print-all-prime-factors-of-a-given-number/
// 与えられた正整数についての素因数分解を計算.
// @param X: 素因数分解を行う整数.
// @return ret: 素因数分解 の 結果 を 返却.
map<LL, int> div(LL X){
    
    // 1. X を 2で割り切れなくなるまで割っていく.
    map<LL, int> ret;
    while(X % 2 == 0) ret[2]++, X >>= 1;
    
    // 2. X を 3以上の奇数で, 割り切れなくなるまで順次割っていく.
    for(LL i = 3; i <= sqrt(X); i += 2){
        while(X % i == 0){
            ret[i]++;
            X /= i;
        }
    }
    
    // 3. X が 2 より 大きな素数であれば, 追加.
    if(X > 2) ret[X]++;
    
    // 4. 出力.
    return ret;
}

int main(){
    
    // 1. 入力情報.
    LL N;
    scanf("%lld", &N);
    
    // 2. 素因数分解を行う.
    map<LL, int> m = div(N);
    
    // 3. 操作回数を計算.
    int ans = 0, cum, idx;
    for(auto &p : m){
        idx = 1;
        cum = 1;
        while(p.b >= cum) idx++, cum = (cum + idx), ans++;
    }
    
    // 4. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 3788
#include<iostream>
using namespace std;
int N,X;
long D;
long mod=1e9+7;
long dp[2002],ED[2001];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long C(long a,long b)
{
	long s=1,t=1;
	for(long i=1;i<=b;i++)
	{
		s=s*((a-i+1)%mod)%mod;
		t=t*i%mod;
	}
	return s*power(t,mod-2)%mod;
}
main()
{
	while(cin>>N>>D>>X,N)
	{
		for(int i=0;i<=N;i++)dp[i]=0;
		for(int i=0;i<=N;i++)ED[i]=0;
		dp[0]=1;
		for(int k=0;k<=N;k++)
		{
			ED[k]=dp[N];
			dp[N]=0;
			for(int j=N;j--;)
			{
				dp[j+1]+=dp[j];
				if(j+X<=N)dp[j+X]-=dp[j];
				dp[j]=0;
			}
			for(int j=0;j<=N;j++)
			{
				dp[j]=(dp[j]%mod+mod)%mod;
				dp[j+1]+=dp[j];
			}
		}
		long ans=0;
		for(int k=0;k<=N&&k<=D;k++)
		{
			(ans+=ED[k]*C(D,k)%mod)%=mod;
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3040
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define MAXN (100000 + 5)
#define LL long long
#define abs(a) (((a) > 0) ? (a) : (-(a)))
using namespace std;
LL a[MAXN], b[MAXN], sum, n;
int main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]), sum += abs(a[i] - a[i - 1]);
	sum += abs(a[n]);
	for (int i = 1; i <= n; i++)
		b[i] = abs(abs(a[i + 1] - a[i]) + abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i - 1]));
	for (int i = 1; i <= n; i++)
		printf("%lld\n", sum - b[i]);
	return 0;
}

Measured memory_bytes: 2816
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = Number(input.shift())
  input = input[0].split(' ').map(n => Number(n))
  let center = []
  for (let i = 0; i < N; i++) {
    center.push(input[i] - i - 1)
  }
  center = center.sort((a, b) => a - b)[Math.floor(center.length/2)]
  let ans = 0
  for (let i = 0; i < N; i++) {
    ans += Math.abs(input[i] - i - 1 - center)
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 38784
#include<iostream>
using namespace std;
int main()
{
    string weather;
    cin >> weather;
    if (weather == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(weather == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int vis[N][3]; 
vector<int> g[N];
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }   
    int s, t;
    cin >> s >> t;
    vis[s][0] = 1;
    queue<pi> q;
    q.push({s, 0});
    while(!q.empty()){
        pi x = q.front();
        q.pop();
        int nx = (x.se + 1) % 3;
        for(int i: g[x.fi]){
            if(vis[i][nx] == 0){
                vis[i][nx] = 1 + vis[x.fi][x.se];
                q.push({i, nx});
            }
        }
    }
    if(vis[t][0])
        cout << (vis[t][0]-1)/3;
    else
        cout << -1;
    return 0;
}

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

int cnt[500][500] = {};
char mat[1000][1000];

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

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> mat[i][j];
            int p = mat[i][j]-'0';
            if(p){
                cnt[(i >= n/2 ? n-1-i : i)][(j >= n/2 ? n-1-j : j)] += 1;
            }
        }
    }

    auto f = [&]()-> int{
        int ret = 0;
        for(int i = 0; i < n/2; i++){
            for(int j = 0; j < n/2; j++){
                if(cnt[i][j]%4) ret++;
            }
        }
        return ret;
    };

    int ans = 0;
    int problem = f();
    if(problem == 0)    ans++;

    for(int i = 0; i < c-1; i++){
        int d;
        cin >> d;
        while(d-- > 0){
            int r, c;
            cin >> r >> c;
            r--, c--;
            mat[r][c] = (mat[r][c] == '0' ? '1' : '0');
            if(cnt[(r >= n/2 ? n-1-r : r)][(c >= n/2 ? n-1-c : c)]%4==0)    problem++;
            cnt[(r >= n/2 ? n-1-r : r)][(c >= n/2 ? n-1-c : c)] += 2*(mat[r][c]=='1')-1;
            if(cnt[(r >= n/2 ? n-1-r : r)][(c >= n/2 ? n-1-c : c)]%4==0)    problem--;
        }
        if(problem == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define fst first
#define snd second
#define mp make_pair
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

template<typename T> inline LL squ(T x) { return (LL) x * x; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }

template<typename T> inline T read()
{
	T sum = 0, fg = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') fg = -1;
	for (; isdigit(c); c = getchar()) sum = (sum << 3) + (sum << 1) + (c ^ 0x30);
	return fg * sum;
}

const int maxn = 100 + 10;

vector<int> g[maxn];

int n, Ans;
pii E[maxn];

int dp[maxn];
inline void dfs(int x, int f = 0)
{
	dp[x] = 0;
	for (int y : g[x])
	{
		if (y == f) continue;
		dfs(y, x);
		chkmax(Ans, dp[x] + dp[y] + 1);
		chkmax(dp[x], dp[y] + 1);
	}
}

LL leaf;
int Max_dep, deg[maxn], dep[maxn];
inline void dfs1(int x, int f = 0)
{
	dep[x] = dep[f] + 1, chkmax(Max_dep, dep[x]);
	int cnt = 0;
	for (int y : g[x])
	{
		if (y == f) continue;
		dfs1(y, x), ++cnt;
	}
	chkmax(deg[dep[x]], cnt);
}

int main()
{

	Ans = 0, leaf = LLONG_MAX;

	n = read<int>();
	for (int i = 1; i < n; i++)
	{
		int x = read<int>(), y = read<int>();
		g[x].push_back(y), g[y].push_back(x);
		E[i] = mp(x, y);
	}

	dfs(1), ++Ans;

	for (int i = 1; i < n; i++)
	{
		int x = E[i].fst, y = E[i].snd;
		Max_dep = 0, memset(deg, 0, sizeof deg);
		dep[y] = 0, dfs1(x, y);
		dep[x] = 0, dfs1(y, x);
		if (Max_dep == (Ans + 1) / 2)
		{
			LL now = 2;
			for (int j = 1; j < Max_dep; j++) now *= deg[j];
			chkmin(leaf, now);
		}
	}

	if (Ans & 1)
	{
		for (int i = 1; i <= n; i++)
		{
			Max_dep = 0, memset(deg, 0, sizeof deg);
			dfs1(i);
			if (Max_dep == (Ans + 1) / 2)
			{
				LL now = 1;
				for (int j = 1; j < Max_dep; j++) now *= deg[j];
				chkmin(leaf, now);
			}
		}
	}

	printf("%d %lld\n", (Ans + 1) / 2, leaf);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h){
        cin >> a[i];
    }
    // 縦
    set<int> memotate;
    rep(j,w){
        bool J = 1;
        rep(i,h){
            if(a[i][j] == '#') {
                J = 0;
                break;
            }
        }
        if(J) memotate.insert(j);
    }
    //横
    set<int> memoyoko;
    rep(i,h){
        bool J = 1;
        rep(j,w){
            if(a[i][j] == '#') {
                J = 0;
                break;
            }
        }
        if(J) memoyoko.insert(i);
    }

    //結果
    rep(i,h){
        if(memoyoko.count(i)) continue;
        rep(j,w){
            if(memotate.count(j)) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
}

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

int main() {
	
	int n,k;
	int a = 1;

	std::cin >> n >> k;

	for (int i = 0; i < n; i++) {
		if (a > k)a += k;
		else a *= 2;
	}

	std::cout << a;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

using namespace std;



int main(){
	char s;
  	int cnt=0;
  	r(i,3){
  	cin>>s;
    if(s=='1')cnt++;
    }
  
  	cout<<cnt<<endl;

    return 0;
}



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

int main(){
  int n,x;
  vector<int> v;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x;
    v.push_back(x);
  }
  if(n==1) return 0;
  vector<int> dp(n,0);
  dp[n-2] = abs(v[n-2]-v[n-1]);
  
  for(int i=n-3;i>=0;i--){
    dp[i]=INT_MAX;
    dp[i] = min(dp[i],min(abs(v[i]-v[i+1]) + dp[i+1] , abs(v[i]-v[i+2]) + dp[i+2]));
  }
  cout << dp[0] << endl;
  return 0;
}
      


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

const int INF = 1001001001;
const int NV=100100;

int main() {
  string S, ans="No";
  bool hitachi=true;
  cin>>S;
  for(int i=0;i<S.size();i++){
    if(i%2==0&&S.at(i)!='h'){
      hitachi=false;
    }
    if(i%2!=0&&S.at(i)!='i'){
      hitachi=false;
    }
  }
  if(S.size()%2!=0){
    hitachi=false;
  }
  if(hitachi){
    ans="Yes";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

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

//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

int main() {
	int n, l;
	cin >> n >> l;
	if (l >= 0) cout << (n-1)*(2*l+n)/2;
	else if (l - 1 + n <= 0) cout << (n - 1)*(2*l - 2 + n) / 2;
	else cout << n*(2*l+n-1)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define inf 1e9
 
// int frog(vector<int> &h, int n, int dp[]){
 
//     if(n==1) return 0;
 
//     if(dp[n]!=0)
//         return dp[n];
 
//     int op1 = abs(h[n]-h[n-1]) + frog(h,n-1,dp);
//     int op2 = n==2 ? INT_MAX : abs(h[n]-h[n-2]) + frog(h,n-2,dp);
    
//     return dp[n] = min(op1,op2);
 
// }
 
int frog(vector<int> &h, int n){
 
    vector<int> dp(n+1,0);
    
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
 
    for(int i=3;i<=n;i++){
        int op1 = abs(h[i]-h[i-1]) + dp[i-1];
        int op2 = abs(h[i]-h[i-2]) + dp[i-2];
        dp[i] = min(op1,op2);
    }
 
    return dp[n];
 
}
 
int main() {
    
    int n;
    cin>>n;
 
    vector<int> h(n+1);
 
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
 
    // int dp[n+1] = {0};
    cout<<frog(h,n);
 
    return 0;
}

Measured memory_bytes: 3988
/*||>>>> Praveen Ojha <<<<>>>> 30 June 2019 <<<<>>>> 00:57:50 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
int cnt[26];
int32_t main(){__
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++){
		cnt[s[i]-'A']++;
	}
	int flag=0;
	for(int i=0;i<26;i++){
		if(cnt[i]==2)
			flag++;
	}
	if(flag==2)
		cout<<"Yes\n";
	else
		cout<<"No\n";
return 0;
}

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

const int INF = 1e+8;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef pair<PP,int> State;

// 入力
int w, h;
string s[20], p;

// d[ay][ax][by][bx][i] := (ax,ay),(bx,by),i分目のときの手数
// 5次元配列とかやばすぎ.
int d[20][20][20][20][10];

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

void debug(int ax, int ay, int bx, int by, int t){
	cout << "[debug]" << " t:" << t << endl;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( x == ax && y == ay ){
				cout << "A";
			}else if( x == bx && y == by ){
				cout << "B";
			}else{
				cout << s[y][x];
			}
		}
		cout << endl;
	}
	cout << endl;
}

// 初期化 
void ini(){
	for(int ay=0 ; ay < h ; ay++ ){
		for(int ax=0 ; ax < w ; ax++ ){
			for(int by=0 ; by < h ; by++ ){
				for(int bx=0 ; bx < w ; bx++ ){
					for(int i=0 ; i < p.size() ; i++ ){
						d[ay][ax][by][bx][i] = INF;
					}
				}
			}
		}
	}
}

// 幅優先探索.
pair<int,P> bfs(int ax, int ay, int bx, int by){
	queue<State> q;
	PP pp(P(ax,ay),P(bx,by));
	q.push( State( pp , 0 ) );
	d[ay][ax][by][bx][0] = 0;
	ini();
	
	while( !q.empty() ){
		int ax = q.front().first.first.first;
		int ay = q.front().first.first.second;
		int bx = q.front().first.second.first;
		int by = q.front().first.second.second;
		int t  = q.front().second;
		q.pop();
		//debug(ax,ay,bx,by,t);
		
		int bx_ = bx + dx[p[t % p.size()]];
		int by_ = by + dy[p[t % p.size()]];
		if( bx_ < 0 || w <= bx_ ) bx_ = bx;
		if( by_ < 0 || h <= by_ ) by_ = by;
		P b(bx_,by_);
		for(int i=0 ; i < 4 ; i++ ){
			int ax_ = ax + dx[i];
			int ay_ = ay + dy[i];
			if( ax_ < 0 || w <= ax_ ) ax_ = ax;
			if( ay_ < 0 || h <= ay_ ) ay_ = ay;
			if( s[ay_][ax_] == '#' ){
				ax_ = ax; ay_ = ay;
			}
			P a(ax_,ay_);
			
			if( a == b ){ // ゴールの時
				return pair<int,P>(t+1,a);
			}else if( d[ay_][ax_][by_][bx_][(t+1) % p.size()] == INF ){
				d[ay_][ax_][by_][bx_][(t+1) % p.size()] = t+1;
				PP pp(P(ax_,ay_),P(bx_,by_));
				q.push( State( pp , t+1 ) );
			}
		}
	}
	return pair<int,P>(-1,P(0,0));
}

int main(){
	dx['6'] = 1; dx['4'] = -1; dy['8'] = -1; dy['2'] = 1;
	
	while( cin >> h >> w , h || w ){
		for(int y=0 ; y < h ; y++ ){
			cin >> s[y];
		}
		cin >> p;
		
		int ax, ay, bx, by;
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( s[y][x] == 'A' ){
					ax = x; ay = y; s[y][x] = '.';
				}
				if( s[y][x] == 'B' ){
					bx = x; by = y; s[y][x] = '.';
				}
			}
		}
		
		pair<int,P> ans = bfs(ax, ay, bx, by);
		if( ans.first == -1 ){
			cout << "impossible" << endl;
		}else{
			cout << ans.first << " ";
			cout << ans.second.second << " ";
			cout << ans.second.first << endl;
		}
	}
}

Measured memory_bytes: 7496
#include <stdio.h>

int main() {

  int a, b, c, max, tyu, bot;

  scanf("%d %d %d", &a, &b, &c);

 if(a > b){
    if(b > c){
     max = a;
     tyu = b;
     bot = c;
    } else {
      if(a > c){
        max = a;
        tyu = c;
        bot = b;
      } else {
        max = c;
        tyu = a;
        bot = b;
      }
    }
  } else { // b > a
    if(a > c) {
        max = b;
        tyu = a;
        bot = c;
    } else {
      if(b > c) {
        max = b;
        tyu = c;
        bot = a;
      } else {
        max = c;
        tyu = b;
        bot = a;
      }
    }
  }
  
  printf("%d %d %d\n", bot, tyu, max);

  return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        
        int gapx = tx -sx;
        int gapy = ty -sy;
        
      	//1週目
        for(int i = 0; i < gapy; i++)System.out.print("U");
        for(int i = 0; i < gapx; i++)System.out.print("R");
        for(int i = 0; i < gapy; i++)System.out.print("D");
        for(int i = 0; i < gapx; i++)System.out.print("L");

        //2週目 
        System.out.print("L");
        for(int i = 0; i < gapy+1; i++)System.out.print("U");
        for(int i = 0; i < gapx+1; i++)System.out.print("R");
        System.out.print("DR");
        for(int i = 0; i < gapy+1; i++)System.out.print("D");
        for(int i = 0; i < gapx+1; i++)System.out.print("L");
        System.out.print("U");
    }
}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> dp(100001,10000000000);
int main(){
	int n;
	cin>>n;
	vector< vector<ll> > v(n,vector<ll>(3));
	vector< vector<ll> > dp(n,vector<ll>(3));
	for(int i=0;i<n;i++){
		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	dp[0][0]=v[0][0];dp[0][1]=v[0][1];dp[0][2]=v[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1]+v[i][0],dp[i-1][2]+v[i][0]);
		dp[i][1]=max(dp[i-1][2]+v[i][1],dp[i-1][0]+v[i][1]);
		dp[i][2]=max(dp[i-1][1]+v[i][2],dp[i-1][0]+v[i][2]);
	}
	ll z=dp[n-1][0];
	z=max(z,dp[n-1][1]);z=max(z,dp[n-1][2]);
	cout<<z;
	return 0;
}

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

using DD = double;
const DD INF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acosl(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

/* Point */
struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};
inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}


const int ITER = 100;

int N;
vector<Point> v;

DD f(DD x, DD y) {
    DD res = 0;
    for (int i = 0; i < N; ++i) res = max(res, abs(v[i] - Point(x, y)));
    return res;
}

DD g(DD x) {
    DD left = -1000, right = 1000;
    while(left+EPS<right) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (f(x, m1) > f(x, m2)) left = m1;
        else right = m2;
    }
    return f(x, left);
}

DD solve() {
    DD left = -1000, right = 1000;
    while(left+EPS<right) {
        DD m1 = (left * 2 + right) / 3;
        DD m2 = (left + right * 2) / 3;
        if (g(m1) > g(m2)) left = m1;
        else right = m2;
    }
    return g(left);
}

int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) cin >> v[i].x >> v[i].y;
    cout << fixed << setprecision(10) << solve() << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  cout << vec.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1]) {
			cnt++;
		}
		else {
			ans += cnt;
			cnt = 0;
		}
	}
  ans+=cnt;
	ans += 2 * k;
	if (ans >= n) cout << n-1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 512
a,b,c=map(int,input().split())
if a<b:
    if b<c: print(f'{a} {b} {c}')
    else:
        if a<c: print(f'{a} {c} {b}')
        else: print(f'{c} {a} {b}')
else:
    if a<c: print(f'{b} {a} {c}')
    else:
        if b<c: print(f'{b} {c} {a}')
        else: print(f'{c} {b} {a}')


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

int main()
{
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    for (int i = 0; i < M; i++) cin >> a[i] >> b[i];

    int all[N + 1] = {};

    for (int i = 0; i < M; i++)
    {
        all[a[i]]++;
        all[b[i]]++;
    }

    for (int i = 1; i < N + 1; i++)
    {
        cout << all[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm> 
using namespace std;
long long c,ans;
long long s[100001],l[100001],x[100001],v[100001],s1[100001],l1[100001];
int main(){
	int n,i,j,k;
	scanf("%d%lld",&n,&c);
    for(i=1;i<=n;i++)scanf("%lld%lld",&x[i],&v[i]);
    s[1]=v[1]-x[1];if(s[1]>ans)ans=s[1];
    s1[1]=s[1];
	l[n]=v[n]-c+x[n];if(l[n]>ans)ans=l[n];
	l1[n]=l[n];
	for(i=2;i<=n;i++){s[i]=s[i-1]+v[i]-x[i]+x[i-1];if(s[i]>ans)ans=s[i];s1[i]=s1[i-1];if(s1[i]<s[i])s1[i]=s[i];} 
		for(j=n-1;j>=1;j--){l[j]=-x[j+1]+x[j]+l[j+1]+v[j];if(l[j]>ans)ans=l[j];l1[j]=l1[j+1];if(l1[j]<l[j])l1[j]=l[j];}
		for(i=1;i<n;i++){
		if(s[i]-x[i]+l1[i+1]>ans)ans=s[i]-x[i]+l1[i+1];
		}
		for(i=n;i>1;i--){
		if(l[i]+x[i]-c+s1[i-1]>ans)ans=l[i]+x[i]-c+s1[i-1];
		}
		printf("%lld",ans);
		return 0;
	}



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

template <class T>
using lim = numeric_limits<T>;

int main() {
	ios_base::sync_with_stdio(false) ;
	cin.tie(0);
	
	ll n, m;
	cin >> n >> m;
	int a[m], b[m];
	
	for (int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	
	// holds pointers to parents
	int arr[n];
	// holds how many nodes are in the set
	int counter[n];
	for (int i = 0; i < n; i++){
		counter[i] = 1;
		arr[i] = i;
	}
	
	ll ans[m];
	// all disjoint
	ans[m-1] = ((n-1)*n)/2;
	for (int i = m-1; i >= 1; i--){
		int u = a[i];
		int v = b[i];
		while(counter[u]==0){
			u = arr[u];
		} 
		while(counter[v]==0){
			v = arr[v];
		}
		
		int cu = counter[u];
		int cv = counter[v];
		if (u != v){
			// small-to-large trick
			if (cu >= cv){
				counter[u] += counter[v];
				counter[v] = 0;
				
				ans[i-1] = ans[i] - cu*cv;
				arr[v] = u;
			}
			else{
				counter[v] += counter[u];
				counter[u] = 0;
				
				ans[i-1] = ans[i]- cu*cv;
				arr[u] = v;
			}
		}else{
			ans[i-1] = ans[i];
		}
	}
	
	for (int i = 0; i < m; i++){
		cout << ans[i] << endl;
	}
} 


Measured memory_bytes: 3712
'use strict'

const main = (input) => {
    input = input.split(' ').map(v => parseInt(v))
    const W = input[0]
    const a = input[1]
    const b = input[2]
    const aw = a + W
    const bw = b + W

    let arr = []
    if(a <= b){
        arr = [a, aw, b, bw]
    }else{
        arr = [b, bw, a, aw]
    }
    if(arr[1] < arr[2]){
        console.log(arr[2] - arr[1])
    }else{
        console.log(0)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M;

int main()
{
	in >> N >> M;
	if (N == 1 && M == 1)out << 1 << std::endl;
	else if (N == 2 || M == 2) out << 0 << std::endl;
	else out << std::max(1LL,N-2) * std::max(1LL,M - 2) << std::endl;
	return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
for i in range(q):
    bi, ci = map(int, input().split())
    b.append(bi)
    c.append(ci)

count = collections.Counter(a)
sums = sum(a)

for i in range(q):
    sums += count[b[i]] * (c[i] - b[i])
    print(sums)
    count[c[i]] += count[b[i]]
    count[b[i]] = 0


Measured memory_bytes: 29964