akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define fi first
#define se second
using ii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Thu Dec 12 16:46:25 PST 2019
 **/

template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

using B = bitset<160 * 160>;
constexpr Int offset = 160 * 80;
signed main() {
    Int H = in(), W = in();
    auto a = make_vec<Int>(H, W, 0);
    auto b = make_vec<Int>(H, W, 0);
    REP(i, H) REP(j, W) cin >> a[i][j];
    REP(i, H) REP(j, W) cin >> b[i][j];
    auto c = make_vec<Int>(H, W, 0);
    REP(i, H) REP(j, W) c[i][j] = abs(a[i][j] - b[i][j]);
    auto dp = make_vec<B>(H, W, 0);
    dp[0][0][c[0][0] + offset] = true;
    dp[0][0][-c[0][0] + offset] = true;
    REP(i, H) {
        REP(j, W) {
            if (i + 1 < H) {
                dp[i + 1][j] |= dp[i][j] << c[i + 1][j];
                dp[i + 1][j] |= dp[i][j] >> c[i + 1][j];
            }
            if (j + 1 < W) {
                dp[i][j + 1] |= dp[i][j] << c[i][j + 1];
                dp[i][j + 1] |= dp[i][j] >> c[i][j + 1];
            }
        }
    }
    REP(k, 81) {
        if (dp[H - 1][W - 1][k + offset]) {
            cout << k << endl;
            return 0;
        }
    }
}


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

int main(void){
	const int Q[][4]={
	  {1,2,3,4},
	  {2,-1,4,-3},
	  {3,-4,-1,2},
	  {4,3,-2,-1}
	};
  int n;
  while(cin>>n,n){
  	for(int x=0;x<n;++x){
	    int a[4],b[4],c[4]={};
	    for(int i=0;i<4;++i) cin>>a[i];
	    for(int i=0;i<4;++i) cin>>b[i];
	    for(int i=0;i<4;++i){
	      for(int j=0;j<4;++j){
	        c[((Q[i][j]>0)?Q[i][j]:-Q[i][j])-1]+=((Q[i][j]<0)?-1:1)*a[i]*b[j];
	      }
	    }
	    for(int i=0;i<4;++i)cout<<c[i]<<((i==3)?"\n":" ");
    }
  }
  return 0;
}

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


int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  rep(i,k){
    if(a>0){
      ans+=1;
      a--;
    }
    else if(b>0){
      ans+=0;
      b--;
    }
    else {
      ans--;
      c--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<char> one(n,'0');
    vector<char> zero(n,'0');
    
    for(int i = 0; i < n; i += 2){
        one[i] = '1';
    }
    
    for(int i = 1; i < n; i += 2){
        zero[i] = '1';
    }
    
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
        if(s[i]!=one[i]) a++;
        else if(s[i]!=zero[i]) b++;
    }
    
    cout << min(a,b);
}

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

rel = [[] for _ in [0]*(n+1)]

for i in range(m):
  a,b = map(int,input().split())
  rel[a] += [b]

for r in rel[1]:
  if n in rel[r]:
    print("POSSIBLE")
    exit()
        
print("IMPOSSIBLE") 

Measured memory_bytes: 29072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int n = sc.nextInt();
		
		boolean[] isP = new boolean[102];
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			isP[p] = true;
		}
		
		int ans = -1;
		int minAbs = Math.abs(x + 1);
		for (int i = 0; i <= 101; i++) {
			if (isP[i]) continue;
			
			int abs = Math.abs(x - i);
			if (abs < minAbs) {
				minAbs = abs;
				ans = i;
			}
		}
		
		System.out.println(ans);

		sc.close();
	}
}




Measured memory_bytes: 27124
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int ans = 0;
  priority_queue<int, vector<int>, greater<int> > pq;
  REP(i, N){
    int tmp; cin >> tmp;
    ans += tmp;
    if(tmp%10 != 0){
      pq.push(tmp);
    } 
  }
  if(ans%10 == 0){
    if(!pq.empty()){
      ans -= pq.top(); pq.pop();
    }else{
      cout << 0 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    double ans =a[0];
    for(int i=1;i<n;i++){
        ans = (ans + a[i])/2;
    }
    printf("%.5f\n",ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <cmath>

int main()
{
    uint64_t A;
    uint64_t B;
    uint32_t e;
    std::string Bs;

    std::cin >> A >> Bs;
// 9.10
    for (int i = 0; i < Bs.length(); i++)
    {
        if (Bs[i] == '.')
        {
            Bs.erase(i, 1);
            B = std::stoi(Bs);
        }
    }

    std::cout << A * B / 100 << "\n";

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;
int main(){
	int N;
	cin>>N;
	vector<int>d(N);
	rep(i,N){
		cin>>d.at(i);
	}
	int sum=0;
	rep(i,N){
		rep(j,N){
			if(i!=j){
				sum+=d.at(i)*d.at(j);
			}
		}
	}
	cout<<sum/2<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int a,b;
    cin >> a >> b;
    if(b>=a){
        cout << a << endl;
        return 0;
    }
    else{
        cout << a-1 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a, b, c;
    a = n % 10;
    n = n / 10;
    b = n % 10;
    n = n / 10;
    c = n % 10;
    if (a == 7 || b == 7 || c == 7)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, k, n) for(ll i = k; i < n; i++)



int main(){
  ll a, b, t;
  cin >> a >> b >> t;
  vll v1(a+1, 0);
  vll v2(b+1, 0);

  rep(i, 1, a+1){
    ll k; cin >> k; 
    v1[i] = v1[i-1] + k;
  }
  rep(i, 1, b+1){
    ll k; cin >> k; 
    v2[i] = v2[i-1] + k;
  }

  ll res = 0;
  ll cnt = 0;
  ll st = b;
  rep(i, 0, a+1){
    ll c = 0;
    for(ll j = st; j >= 0 ; j--){
      if(v1[i] + v2[j] <= t){c = i + j; st = j; break;}
    }
    cnt = max(c, cnt);
  }

  

  cout << cnt << endl;
}


Measured memory_bytes: 6376
/* Poisonous Cookies */

#include <iostream>

using namespace std;

int main(){
	int a, b, c, caneat, heal;
	cin >> a >> b >> c;
	heal = a + b;
	if(c > heal + 1){
    	caneat = b + heal + 1;
    }else{
    	caneat = b + c;
    }
    
    cout << caneat << endl;
}

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

int n, dis1, dis2, v[650][650];

void calc(int d) {
	int ti = 0;
	while(!(d & 3)) d >>= 2, ti++;
	if((d & 3) == 1) {
		for(int i = 0; i < n << 1; i++)
			for(int j = 0; j < n << 1; j++)
				if((i >> ti) + (j >> ti) & 1) v[i][j] = 1;
	} else if((d & 3) == 2) {
		for(int i = 0; i < n << 1; i++)
			for(int j = 0; j < n << 1; j++)	
				if((i >> ti) & 1) v[i][j] = 1;
	}
}

int main() {
	cin >> n >> dis1 >> dis2;
	calc(dis1), calc(dis2);
	for(int i = 0, cnt = 0, cur = n * n; i < n << 1; i++)
		for(int j = 0; j < n << 1; j++) {
			if(!v[i][j]) printf("%d %d\n", i, j), cnt++;
			if(cnt == cur) return 0;
		}
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll fast(ll x,ll n) {ll ans=1;for(;n;n>>=1,x=x*x%mod) if(n&1) ans=ans*x%mod; return ans;}
const int N=1e6+100;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}
ll c(ll x) {
    return x*(x+1)/2;
}
ll ans[N],siz[N],temp[N],a[N],n;
vector<int>edge[N];

void dfs(int x,int f) {
    ll t=temp[a[x]];
    siz[x]=1;
    for(auto v:edge[x]) if(v!=f) {
        ll pre=temp[a[x]];
        dfs(v,x);siz[x]+=siz[v];
        ans[a[x]]-=c(siz[v]-(temp[a[x]]-pre));
    }
    temp[a[x]]=t+siz[x];
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=1;i<n;i++) {
        int u,v;
        u=read();v=read();
        //scanf("%d%d",&u,&v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) {
        ans[i]+=c(n)-c(n-temp[i]);
        printf("%lld\n",ans[i]);
    }
}


Measured memory_bytes: 58352
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int d = scanner.nextInt();
		int x = scanner.nextInt();

		int co = 0;
		for (int i = 0; i < n; i++) {
			co += eat(scanner.nextInt(), d);
		}

		System.out.println(x + co);
	}

	private static int eat(int t, int d) {
		int co = 0;
		for (int i = 1; i <= d; i += t) {
			co++;
		}
		return co;
	}
}


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

int main()
{
    int count, a, b;
    count = 1;
    while (cin >> a >> b)
    {
        if (a > 0 || b > 0)
        {
            if (a > b)
            {
                int tmp = b;
                b = a;
                a = tmp;
            }
            cout << a << " " << b << endl;
        }
        count++;
        if (count > 3000)
        {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3004
/*Lucky_Glass*/
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=1e5,inf=(1<<29);

struct GGRAPH{
	struct GNODE{int to,lim;GNODE *nxt,*rev;}Gnod[N*20];
	GNODE *Gtop[N*5],*Gcnt;
	void Init(){
		Gcnt=Gnod;
		memset(Gtop,NULL,sizeof Gtop);
	}
	void AddEdge(int u,int v,int lim){
		GNODE *p=++Gcnt,*q=++Gcnt;
		*p=(GNODE){v,lim,Gtop[u],q};Gtop[u]=p;
		*q=(GNODE){u,0  ,Gtop[v],p};Gtop[v]=q;
	}
}Gflw;
GGRAPH::GNODE *cap[N*5];

int n,Gn,Ps,Pt;
int Ip[N+3],Iq[N+3],Edep[N*5];
bool Bp[N+3],Bq[N+3];

bool BFS(){
	for(int i=1;i<=Gn;i++) Edep[i]=inf;
	queue<int> que;
	que.push(Ps);Edep[Ps]=0;
	while(!que.empty()){
		int u=que.front();que.pop();
		for(auto it=Gflw.Gtop[u];it;it=it->nxt){
			int v=it->to;
			if(Edep[v]!=inf || !it->lim) continue;
			Edep[v]=Edep[u]+1;
			que.push(v);
		}
	}
	return Edep[Pt]!=inf;
}
int Aug(int u,int flwin){
	if(u==Pt) return flwin;
	int flwout=0;
	while(cap[u]){
		int v=cap[u]->to;
		if(!cap[u]->lim || Edep[u]+1!=Edep[v]){
			cap[u]=cap[u]->nxt;
			continue;
		}
		int flwv=min(cap[u]->lim,flwin-flwout);
		flwv=Aug(v,flwv);
		cap[u]->lim-=flwv;
		cap[u]->rev->lim+=flwv;
		flwout+=flwv;
		if(flwout==flwin) break;
		cap[u]=cap[u]->nxt;
	}
	return flwout;
}
int Dinic(){
	int maxflw=0;
	while(BFS()){
		for(int i=1;i<=Gn;i++) cap[i]=Gflw.Gtop[i];
		maxflw+=Aug(Ps,inf);
	}
	return maxflw;
}
int main(){
	Gflw.Init();
	scanf("%d",&n);Gn=2*n;
	Ps=++Gn,Pt=++Gn;
	for(int i=1;i<=n;i++) scanf("%d",&Ip[i]),Ip[i]++; // 1~n
	for(int i=1;i<=n;i++) scanf("%d",&Iq[i]),Iq[i]++; // n+1~2n
	for(int i=1;i<=n;i++)
		if(!Bp[i]){
			Gn++;
			int u=i;
			while(!Bp[u]){
				Bp[u]=true;
				Gflw.AddEdge(Gn,u,inf);
				Gflw.AddEdge(u,Gn,inf);
				u=Ip[u];
			}
		}
	for(int i=1;i<=n;i++)
		if(!Bq[i]){
			Gn++;
			int u=i;
			while(!Bq[u]){
				Bq[u]=true;
				Gflw.AddEdge(Gn,u+n,inf);
				Gflw.AddEdge(u+n,Gn,inf);
				u=Iq[u];
			}
		}
	for(int i=1;i<=n;i++){
		if(Ip[i]==i && Iq[i]==i && Ip[i]==Iq[i]){
			Gflw.AddEdge(Ps,i+n,1);
			Gflw.AddEdge(i+n,Pt,1);
		}
		if(Ip[i]!=i && Iq[i]==i && Ip[i]!=Iq[i]){
			Gflw.AddEdge(Ps,i,1);
		}
		if(Ip[i]==i && Iq[i]!=i && Ip[i]!=Iq[i]){
			Gflw.AddEdge(i+n,Pt,1);
		}
		if(Ip[i]!=i && Iq[i]!=i && Ip[i]==Iq[i]){
			Gflw.AddEdge(i,i+n,1);
			Gflw.AddEdge(i+n,i,1);
		}
		if(Ip[i]!=i && Iq[i]!=i && Ip[i]!=Iq[i]){
			Gflw.AddEdge(i+n,i,1);
		}
	}
	int Rr=Dinic();
	printf("%d\n",n-Rr);
	return 0;
}


Measured memory_bytes: 42880
x1,y1,x2,y2 = map(int, input().split(" "))

moveX = x2 - x1
moveY = y2 - y1

x3 = x2 - moveY
y3 = y2 + moveX
x4 = x1 - moveY
y4 = y1 + moveX

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int x[100000] = {};

int main(){
    int n, k, i, res = MOD;
    cin >> n >> k;
    for(i=0; i<n; i++){
        cin >> x[i];
    }
    for(i=0; i<n-k+1; i++){
        if(x[i] < 0 && x[i+k-1] > 0){
            res = min(res, 2*min(abs(x[i]), x[i+k-1])+max(abs(x[i]), x[i+k-1]));
        }else{
            res = min(max(abs(x[i]), abs(x[i+k-1])), res);
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 640
N = int(input())
num_list = [int(item) for item in input().split()]

def partition(A, p, r):
    x = A[r]
    i = p - 1

    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return A, i+1


res, index = partition(num_list, 0, len(num_list)-1)

res_out = ''
for i, v in enumerate(res):
    if i == index:
        res_out += '['+ str(v) + '] '
    else:
        res_out += str(v) + ' ' 
    
print(res_out[:-1])


Measured memory_bytes: 16368
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////

#define N 10
int n,m;
vector<int> edge[N];
bool used[N];
int ans=0;
void dfs(int x,int p){
    if(x==n)ans++;
    else{
        for(auto y:edge[p]){
            if(used[y]==true)continue;
            used[y]=true;
            dfs(x+1,y);
            used[y]=false;
        }
    }
}


int main(){
    cin>>n>>m;
    while(m--){
        int a,b;cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    used[1]=true;
    dfs(1,1);
    
    cout<<ans<<endl;
    
    return 0;
}



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

int main(){
  int a=1;
  int n,k;
  cin >> n >> k;
  rep(i,n){
    if(a*2<a+k){
      a *=2;
    }else a +=k;
  }

  cout << a <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int res=0,a=1;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    } 
    while(a){
        for (int i = 0; i < N; i++){
            if(A.at(i)%2!=0){
                a=0;
                break;
            }else A.at(i)/=2;
        }
        if(a==1) res++; 
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 3010;
char s1[MAXN], s2[MAXN];
int dp[MAXN][MAXN];
pii frm[MAXN][MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> (s1 + 1) >> (s2 + 1);
	int n1 = strlen(s1 + 1);
	int n2 = strlen(s2 + 1);
	rep (i, 1, n1) {
		rep (j, 1, n2) {
			if (dp[i - 1][j] >= dp[i][j]) frm[i][j] = mp(i - 1, j), dp[i][j] = dp[i - 1][j];
			if (dp[i][j - 1] >= dp[i][j]) frm[i][j] = mp(i, j - 1), dp[i][j] = dp[i][j - 1];
			if (dp[i - 1][j - 1] + (s1[i] == s2[j]) >= dp[i][j]){
				frm[i][j] = mp(i - 1, j - 1), dp[i][j] = dp[i - 1][j - 1] + (s1[i] == s2[j]);
			}
		}
	}
	string ans;
	while (n1 || n2) {
		if (s1[n1] == s2[n2]) {
			ans += s1[n1];
		}
		pii x = frm[n1][n2];
		n1 = x.fst;
		n2 = x.sed;
	}
	reverse(all(ans));
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 106368
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int x,y;
int main(){
	x=read(),y=read();
	if (x%y==0)
		puts("-1");
	else {
		LL a=x+x;
		while (a%y==0)
			a+=x;
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n;
  while(cin >> n, n) {
    i64 pr = 1;
    i64 nx = 1;
    i64 sum = 0;
    i64 ans = 0;
    for(; nx < n; nx++) {
      sum += nx;
      while(pr <= nx && sum > n) {
        sum -= pr;
        pr++;
      }
      if(sum == n) {
        ans++;
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3016
from functools import reduce 

ss = input()
st = input()


ls = [c for c in ss]
lt = [c for c in st]

#print(ls)


ls.sort()
lt.sort(reverse = True)

ans_s = reduce( lambda x,y: x+y, ls,'' )
ans_t = reduce(lambda x, y: x+y, lt)


#print((ans_s, ans_t))
#ans_s.
print( 'Yes' if ans_s < ans_t else 'No' )

Measured memory_bytes: 3572
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        edges: [i64; 3],
    }
    let mut edges = edges;
    edges.sort();
    if edges.iter().any(|e| e % 2 == 0) { println!("0"); }
    else { println!("{}", edges[0] * edges[1]); }
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    double a=in(),b=in(),x=in();
    setp(20);
    cout<<atan(
        x>a*a*b/2?2*(b/a-x/(a*a*a))
        :         a*b*b/(2*x)
    )/M_PI*180<<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pi;


void solve()
{
	ll a,b,c,k;
	cin >> a >> b >> c>> k;
	if (k<=a){
		cout<< k <<"\n";
	}
	else if (k <= a+b ){
		cout<< a << "\n";
	}
	else{
		cout<<a-(k-a-b)<<"\n";
	}
}


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

	solve();


	return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
int main()
{
    char c[11];
    scanf("%s", c);
    int cnt = 0;
    int max = 0;
    for (int i = 0; i < 11; ++i) {
        if (c[i] == '\n') break;
        if (c[i] == 'A' || c[i] == 'T' || c[i] == 'G' || c[i] == 'C') {
            ++cnt;
            if (max < cnt) {
                max = cnt;
            }
        }
        else {
            cnt = 0;
        }
    }
    printf("%d", max);
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint MOD = 1000000007;
lint N, M;

int main()
{
    cin >> N >> M;
    lint ret = 1;

    if (abs(N-M) > 1) ret = 0;
    else
    {
        for (int i=N; i>0; i--) ret = ret * i % MOD;
        for (int i=M; i>0; i--) ret = ret * i % MOD;
        if (N == M) ret = ret * 2 % MOD;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI 3.14159265358979
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &it : A)
    cin >> it;
  vector<int> cnt(1000010);
  for (auto it : A)
  {
    if (cnt[it] != 0)
    {
      cnt[it] = 2;
      continue; // それ自身の倍数は既にインクリメントされていて約数が存在していることが確定しているためそれ自身の倍数の処理はスキップ
      // 自分自身はインクリメントしておかないと重複していることの判定が出来ないため重複しているという意味でcnt[it] = 2にしておく
    }
    for (int i = it; i < 1000010; i += it)
      cnt[i]++; // それ自身の倍数をインクリメントしていく
  }
  int ans = 0;
  for (auto it : A)
  {
    if (cnt[it] == 1)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    char[][] board;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        board = new char[n][n];
        for (int i = 0; i < n; i++) {
            board[i] = sc.next().toCharArray();
        }
        solve();
    }

    void solve() {
        long count = 0;
        for (int a = 0; a < n; a++) {
            int b = 0;
            boolean flag = true;
            b:
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (board[(i + a) % n][(j + b) % n] !=
                            board[(j + a) % n][(i + b) % n]) {
                        flag = false;
                        break b;
                    }
                }
            }
            if (flag) {
                count++;
            }
        }
        System.out.println(count * n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

using namespace std;
#define int long long
const int INF = 200000000007;


  
signed main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];
    int c[h][w],t[w],t2[h],k;
    for(int i=0;i<h;i++){
        k=INF;
        for(int j=0;j<w;j++){
            if(s[i][j]=='#')k=0;
            t[j]=k;
            k++;
        }
        k=INF;
        for(int j=0;j<w;j++){
            if(s[i][w-1-j]=='#')k=0;
            c[i][w-1-j]=min(t[w-1-j],k);
            k++;
        }
    }
    int ans=0;
    
    for(int j=0;j<w;j++){
        k=INF;
        for(int i=0;i<h;i++){
            t2[i]=min(k,c[i][j]);
            k=t2[i]+1;
        }
        k=INF;
        for(int i=h-1;i>=0;i--){
            c[i][j]=min(c[i][j],k);
            k=c[i][j]+1;
        }
        for(int i=0;i<h;i++){
            ans=max(min(t2[i],c[i][j]),ans);
           // cerr<<min(t2[i],c[i][j]);
     
        }
        //cerr<<endl;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int n,i,a[100005],b[100005],c[100005],d[100005],top,sum,x,y,ans,book[100005];
int nex[200005],to[200005],fir[100005];
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
struct nyh{
	int x,id;
}o[200005];
bool cmp(nyh u,nyh v){
	return u.x<v.x;
}
void ss(int v){
	book[v]=2;
	for(int top1=fir[v];top1;top1=nex[top1])
		if(book[to[top1]]!=2)
			ss(to[top1]);
}
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();
   	for(i=1;i<=n;i++){
   		a[i]=read();
   		a[n+1]^=a[i];
   	}
   	for(i=1;i<=n;i++){
   		b[i]=read();
   		b[n+1]^=b[i];
   	}
   	for(i=1;i<=n+1;i++)
   		c[i]=a[i];
   	for(i=1;i<=n+1;i++)
   		d[i]=b[i];
   	sort(c+1,c+n+2);
   	sort(d+1,d+n+2);
   	for(i=1;i<=n+1;i++)
   		if(c[i]!=d[i]){
			pus(-1,2);
			return 0;
		}
	for(i=1;i<=n+1;i++){
		top++;
		o[top].x=a[i];
		o[top].id=i;
	}
	for(i=1;i<=n+1;i++){
		top++;
		o[top].x=b[i];
		o[top].id=n+1+i;
	}
	sort(o+1,o+top+1,cmp);
	for(i=1;i<=top;i++){
		if(i==1||o[i].x!=o[i-1].x)
			sum++;
		if(o[i].id<=n+1)
			a[o[i].id]=sum;
		else
			b[o[i].id-n-1]=sum;
	}
	top=0;
	for(i=1;i<=n+1;i++){
		if(a[i]!=b[i]||i==n+1){
			book[a[i]]=1;
			book[b[i]]=1;
			lj(a[i],b[i]);
			lj(b[i],a[i]);
			ans++;
		}
	}
	for(i=1;i<=sum;i++)
		if(book[i]==1){
			ans++;
			ss(i);
		}
	ans-=2;
	pus(ans,2);
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct tranp {
	string mark;
	int value;
};
bool isStable(vector<tranp> card, vector<tranp> card2, int n) {
	for (int i = 0;i < n;i++) {
		if (card[i].mark != card2[i].mark)return false;
	}
	return true;
}
void trace(vector<tranp> a, int n) {
	for (int i = 0;i < n;i++) {
		cout << a[i].mark << a[i].value;
		if (i < n - 1)cout << " ";
		if (i == n - 1) cout << endl;
	}
}
void bubbleSort(vector<tranp>& a, int n) {
	bool flag = true;
	int cnt = 0;
	while (flag) {
		flag = 0;
		for (int j = n - 1;j > 0;j--) {
			if (a[j].value < a[j - 1].value) {
				tranp tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
				flag = 1;
			}
		}
	}
	trace(a, n);
}
void selectionSort(vector<tranp>& a, int n) {
	for (int i = 0;i < n;i++) {
		int minj = i;
		for (int j = i;j < n;j++) {
			if (a[j].value < a[minj].value) {
				minj = j;
			}
		}
		tranp tmp = a[i];
		a[i] = a[minj];
		a[minj] = tmp;
	}
	trace(a, n);
}
int main(void) {
	int n;
	cin >> n;
	vector<tranp> card(n), card2(n);
	for (int i = 0;i < n;i++) {
		string s;
		cin >> s;
		card[i].mark = s[0]; card[i].value = s[1] - '0';
	}
	for(int i=0;i<n;i++) card2[i] = card[i];
	bubbleSort(card, n);
	cout << "Stable" << endl;
	selectionSort(card2, n);
	if (isStable(card, card2, n)) {
		cout << "Stable" << endl;
	}
	else cout << "Not stable" << endl;
	return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {
    public static void main(String[] a) {
        Scanner scan = new Scanner(System.in);
        String[] t = scan.nextLine().split("\\s");
        int people = Integer.parseInt(t[0]);
        int ht = Integer.parseInt(t[1]);
        int count = 0;
        while (scan.hasNextInt()) {
            int memHt = scan.nextInt();
            if (memHt >= ht) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 49888
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
//#define EPS 0.000000001
using namespace std;

#define EPS 0.000000000001


#define MAX 25

typedef vector<double> V;
typedef vector<V> MATRIX;
ll A,M,B,N;
ll SIZE;
ll nCm[MAX][MAX];

ll calc_pow(ll num,ll count){

	if(count == 0)return 1;
	if(count == 1)return num;

	ll ret;

	if(count%2 == 0){

		ret = calc_pow(num,count/2);
		ret = ret*ret;

	}else{

		ret = calc_pow(num,(count-1)/2);
		ret = ret*ret;
		ret *= num;
	}

	return ret;
}

void gauss_jordan(MATRIX matrix){

	MATRIX C(SIZE,V(SIZE+1));

	for(int row = 0; row < SIZE; row++){
		for(int col = 0; col <= SIZE; col++){
			C[row][col] = matrix[row][col];
		}
	}

	int base_row;
	double tmp;

	for(int i = 0; i < SIZE; i++){

		base_row = i;

		for(int row = i+1; row < SIZE; row++){
			if(fabs(C[row][i]) > fabs(C[base_row][i])){
				base_row = row;
			}
		}

		if(fabs(C[base_row][i]) < EPS)continue;

		if(base_row != i)swap(C[base_row],C[i]);

		tmp = C[i][i]; //係数
		for(int col = 0; col <= SIZE; col++){
			C[i][col] /= tmp;
		}

		for(int row = 0; row < SIZE; row++){
			if(row == i || fabs(C[row][i]) < EPS)continue;

			tmp = C[row][i];

			for(int col = i; col <= SIZE; col++){
				C[row][col] -= C[i][col]*tmp;
			}
		}
	}

	printf("%lld",ll(round(C[0][SIZE])));

	for(int row = M*N; row > 0; row--){

		printf(" %lld",ll(round(C[row][SIZE])));
	}
	printf("\n");
}

void func(){

	SIZE = M*N+1;

	MATRIX matrix(SIZE,V(SIZE+1));

	for(int row = 0; row < SIZE; row++){
		for(int col = 0; col <= SIZE; col++){
			matrix[row][col] = 0.0;
		}
	}

	matrix[0][0] = 1.0;
	matrix[0][SIZE] = 1.0;

	for(ll dim = 0; dim <= N*M; dim++){
		for(ll i = 0; i <= dim; i++){

			ll add = nCm[dim][i];
			add *= calc_pow(A,i/M)*calc_pow(B,(dim-i)/N);

			ll row = (i%M)*N+(dim-i)%N+1;
			ll col;

			if(dim < M*N){

				col = dim+1;

			}else{ //dim == M*N

				col = 0;
			}

			matrix[row][col] += add;
		}
	}

	gauss_jordan(matrix);
}

void make_table(){

	nCm[0][0] = 1;
	for(ll n = 1; n <= MAX-1; n++) {
		for (int m = 0; m <= n; m++) {
			if(m > 0){
				nCm[n][m] = nCm[n-1][m]+nCm[n-1][m-1];
			}else{ //m == 0
				nCm[n][m] = 1;
			}
		}
	}
}

int main(){

	make_table();

	while(true){

		scanf("%lld %lld %lld %lld",&A,&M,&B,&N);
		if(A == 0 && M == 0 && B == 0 && N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 551;  

int main()  
{  
   // freopen("in.txt", "r", stdin);
    int a, b, c;
    while (~scanf("%d%d%d", &a, &b, &c))
    {
    	printf("%s\n", b - a == c - b?"YES":"NO");
    }
  
   return 0;  
}  

Measured memory_bytes: 256
from functools import cmp_to_key
n, w = [int(e) for e in input().split()]
d = [[int(e) for e in input().split()] for i in range(n)]
d.sort(key = cmp_to_key(lambda x, y: x[1] / x[0] - y[1] / y[0]))
t = {}
t[w] = 0
for i in range(n):
  keys = list(sorted(t.keys())) # sort しないと品物iを複数回ナップサックに詰める可能性がある
  tw, tv = d[i]
  for j in keys:
    nw = j - tw
    if nw < 0:
      continue
    nv = t[j] + tv
    if nw not in t or nv > t[nw]:
      t[nw] = nv
print(max(t.values()))


Measured memory_bytes: 133600
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			String numbers = reader.readLine();
			long resultSum = 0;
			int len = numbers.length();
			if(len > 1) {
				int plusSpaces = len -1;
				int[] plusArray = new int[plusSpaces];
				for (int i = 0; i <  (int) Math.pow(2, plusSpaces); i++) {
					String plus = String.format("%"+plusSpaces+"s", Integer.toBinaryString(i)).replace(" ", "0");
					String numbersWithPlus = "";
					for (int j = 0; j < plus.length(); j++) {
						numbersWithPlus += numbers.charAt(j);
						char p = plus.charAt(j);
						if(p == '1') {
							numbersWithPlus += "+";
						}
					}
					numbersWithPlus += numbers.charAt(len-1);
					long sum = 0;
					if(numbersWithPlus.contains("+")) {
						String[] fomula = numbersWithPlus.split("\\+");	//特殊文字なので\\が必要
						for(String value : fomula) {
							sum += Long.parseLong(value);
						}
					} else {
						sum = Long.parseLong(numbersWithPlus);
					}
					resultSum += sum;
				}
			} else {
				resultSum = Integer.parseInt(numbers);
			}
			
			System.out.println(resultSum);
			
		} catch(IOException e) {
			System.out.println(e);
		}
		
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    if (n % 2 == 1) {
        if (n / 2 + 1 >= k) {
            cout << "YES" << endl;
            return 0;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    } else {
        if (n / 2 >= k) {
            cout << "YES" << endl;
            return 0;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
local n = io.read("*n")
local t, sum = {}, {}
for i = 1, n do
  t[i] = io.read("*n")
end
table.sort(t)
sum[1] = t[1]
for i = 2, n do
  sum[i] = sum[i - 1] + t[i]
end
local ret = 1
for i = n - 1, 1, -1 do
  if t[i + 1] <= sum[i] * 2 then
    ret = ret + 1
  else
    break
  end
end
print(ret)


Measured memory_bytes: 2304
n, x = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

ans = 0
n.times.with_index(1) do |_, i|
  break if as[i].nil?
  next if as[i-1] + as[i] <= x
  a = as[i-1]
  b = as[i]
  tmp = [a-x, 0].max
  ans += tmp
  c = a - tmp
  d = x - c
  ans += [b-d, 0].max
  as[i-1] = c
  as[i] = d
end

puts ans


Measured memory_bytes: 13068
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  bool game=true;
  for(int i=0;i<s.size();i++)
  {
      if(i&1)
      {
          if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
               {
                   game=false;
                   break;
               }
      }
      else
      {
          if(s[i]!='U'&&s[i]!='R'&&s[i]!='D')
               {
                   game=false;
                   break;
               }
      }
  }
  if(game)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}


Measured memory_bytes: 256
//#pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
//#define int long long
#define inf 200000000
const int maxnodes=1005;
#define ll long long
#define N 501
#define EPS 0.01


int32_t main()
{
    IOS;


    int n;
    cin >> n;
    cout << 90 * (2*n -4 );
    




    
    return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <set>
#include <map>
#define X first
#define Y second
using namespace std;
const int maxn = 100000;
const int oo = (int) 1e9;
int n,a[maxn+1];
map<int,int> M[2];
int vtres[2][2];
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n;
	
	for (int i=1; i<=n; i++)
	{
		cin >> a[i];
		M[i%2][a[i]]++;
	}
	
	M[0][oo]=0;
	M[1][oo]=0;
	
	for (int i=0; i<=1; i++)
	{
		for (auto it=M[i].begin(); it!=M[i].end(); it++)
		{
			for (int j=0; j<=1; j++)
			{
				//cout << "I'm here";
				if (vtres[i][j]==0)
				{
					vtres[i][j]=(*it).X;
					break;
				}
				else
				if (M[i][vtres[i][j]]<=(*it).Y)
				{
					if (j==0) 
						vtres[i][j+1]=vtres[i][j];
					
					vtres[i][j]=(*it).X;
					
					break;
				}
			}
		}
	}
	
	//cout << vtres[0][0] << ' ' << vtres[0][1] << '\n';
	int res=oo;
	if (vtres[0][0]!=vtres[1][0])
		res=n/2-(M[0][vtres[0][0]])+n/2-(M[1][vtres[1][0]]);
	else
		res=min(n-M[0][vtres[0][0]]-M[1][vtres[1][1]],n-M[0][vtres[0][1]]-M[1][vtres[1][0]]);
	
	cout << res;
						
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)
long long a[114514];
int main() {
	int n;
	cin >> n;
	long long ans = 0;
	rep(i, n) { cin >> a[i]; }
	rep(i, n) {
		while (1) {
			if (a[i] % 2 == 0) { a[i] = a[i] / 2; ans++; }
			else { break; }
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>	
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>	
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <fstream>
#include <cstdio>
#include <memory.h>

using namespace std;

vector <pair<int, int>> adj[100001];
bool visited[100001];
int x[100001];
void dfs(int now,int dist)
{
	visited[now] = true;
	x[now] = dist;

	for (int i = 0; i < adj[now].size(); i++)
	{
		int next = adj[now][i].first;
		int d = adj[now][i].second;
		if (visited[next] == false)
		{
			dfs(next, dist + d);
		}
	}
}

int main(void)
{
	int n, m;
	int l, r, d;
	bool ok = true;

	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> l >> r >> d;
		adj[l].push_back(make_pair(r, d));
		adj[r].push_back(make_pair(l, -d));
	}

	memset(x, 0, sizeof(x));
	memset(visited, false, sizeof(visited));

	for (int i = 1; i <= n; i++)
	{
		if (visited[i]==false)
		{
			dfs(i, 0);
		}
	}

	/*
	for (int i = 1; i <= n; i++)
	{
		cout << x[i] << ' ';
	}
	cout << '\n';
	*/

	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < adj[i].size(); j++)
		{
			int v = adj[i][j].first;
			if (adj[i][j].second != x[v]-x[i])
			{
				ok = false;
				break;
			}
		}
		if (ok == false)
		{
			cout << "No" << '\n';
			break;
		}

	}

	if (ok == true)
	{
		cout << "Yes" << '\n';
	}

	return 0;
}

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;


int main() {
    long long N;
    cin>>N;
    long long A[N];
    for(long long i=0;i<N;i++){
        cin>>A[i];
    }
    long long now[3];
    now[0]=-1;
    now[1]=-1;
    now[2]=-1;
    long long kazu=1;
    for(long long i=0;i<N;i++){
        /*if(A[i]==0){
            if(now[0]==-1){
                now[0]=0;
                continue;
            }else if(now[1]==-1){
                now[1]=0;
                continue;
            }else if(now[2]==-1){
                now[2]=0;
                continue;
            }
        }*/
        long long count=0;
        for(long long j=0;j<3;j++){
            if(now[j]+1==(A[i])){
                count++;
            }
        }
        kazu*=count;
        kazu%=MOD;
        for(long long j=0;j<3;j++){
            if(now[j]+1==(A[i])){
                now[j]++;
                break;
            }
        }

    }
    /*long long count=0;
    for(long long i=0;i<3;i++){
        if(now[i]==-1){
            count++;
        }
    }
    if(count==1||count==2) {
        kazu *= 3;
        kazu %= MOD;
    }else if(count==0){
        kazu*=6;
        kazu%=MOD;
    }*/
    cout<<kazu<<endl;






}












Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using vl = vector<long long>;
using P = pair<long long,long long>;

struct UnionFind{
	vl d;
	UnionFind(ll n = 0): d(n,-1) {};
	int root(ll x){
		if(d[x] < 0)return x;
		return d[x] = root(d[x]); 
	}
	bool unite(ll x,ll y){
		x = root(x); y = root(y);
		if(x == y)return false;
		if(d[x] > d[y]) swap(x,y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	int qua(int n) {
		ll ans = 0;
		rep(i,n)if(d[i] < 0)ans++;
		return ans; 
	}
};



int main(){
	ll n,m; cin >> n >> m;
	UnionFind uf(n);
	rep(i,m){
		ll x,y,z; cin >> x >> y >> z;
		--x; --y;
		uf.unite(x,y);
	}
	cout << uf.qua(n) << endl;
}

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

int main() {
    string s; cin >>s;
    int ret = 0;
    if (s.size()==1) {ret = 1;}
    else if (s.size() == 2 && s[0] == s[1]) { ret = 1;}
    else if (s.size() == 2 && s[0] != s[1]) { ret = 2;}
    else {
        string bef = "";
        while (true) {
            if (s.size()==3) {
                if (bef==s.substr(0,1)) {ret+=2;break;}; // bef is 1 char: ab-c
                if (bef!=s.substr(0,1) && s[0]!=s[1] && s[1]!=s[2]) {ret+=3;break;} // a-b-c or a-b-a
                ret+=2; break;
            }
            if (s.size()==2) {
                if (bef!=s.substr(0,1) && s[0]!=s[1]) {ret+=2;break;}
                else {ret+=1;break;}
            }

            int i = 1;
            while ( s.substr(0,i) == bef ) i++;
            bef = s.substr(0,i);
            s = s.substr(i,s.size()-i);
            ++ret;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric> // accumulate
#include <queue>
#include <string>
#include <cmath> // sqrt
using namespace std;
typedef long long ll;

typedef pair<int, int> P;
const int MAX_V = 110;
const int INF = 1e9;

struct edge {
    int to, cap, cost, rev;
};

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

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

int min_cost_flow(int s, int t, int f) {
    int res = 0;
    fill(h, h + V, 0);
    while (f > 0) {
        priority_queue<P, vector<P>, greater<P> > que; //greaterで小さい数から取り出す仕様に変更
        fill(dist, dist + V, INF);
        dist[s] = 0;
        que.push(P(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) 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;
                    que.push(P(dist[e.to], 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 E, F;
    cin >> V >> E >> F;
    for (int i = 0; i < E; i++) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        add_edge(u, v, c, d);
    }

    cout << min_cost_flow(0, V-1, F) << endl;

    return 0;
}



Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define N 10

char s1[N],s2[N];
int ans;

int main() {
    scanf("%s%s",s1+1,s2+1);
    for(int i = 1 ; i <= 3 ; i++) {
        if(s1[i] == s2[i]) ans++;
    }
    printf("%d \n",ans);
    //system("pause");
    return 0;
}

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

#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 0; (int)(n) < i; i--)
#define Int long long
using namespace std;


int main() {
    double a,b,h,m,rad1,rad2,rad,nagasa;
    cin >>a >>b >> h >> m;

    //長針
    rad1 = m * 6;

    //短針
    rad2 = (((h*60)+m)*360)/720;

    rad = abs(rad1 - rad2);



    nagasa = sqrt((a*a)+(b*b)-(2*a*b)*cos(PI/(180/rad)));
    printf("%.16f",nagasa);
}


Measured memory_bytes: 4224