akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 100

    int main(){
    int a[N][3],b[N],num=-1;
    int i,j;
    
        while(1){
            num+=1;
        scanf("%d %d %d",&a[num][0],&a[num][1],&a[num][2]);
        
        if(a[num][0]==-1 && a[num][1]==-1 && a[num][2] == -1)break;
  }
    for( i = 0 ; i < num ; i++){
        b[i]=a[i][0]+a[i][1];
            if((a[i][0]+a[i][1]) < 30 || a[i][0] == -1 || a[i][1]==-1)
            printf("%c\n",'F');
            
            else if(( a[i][0] + a[i][1]) >= 80)
            printf("%c\n",'A');
            
            else if( b[i] >= 65 && b[i] < 80)
            printf("%c\n",'B');
            
            else if( b[i] >= 50 && b[i] < 65)
            printf("%c\n",'C');
            
            else if( b[i] >= 30 && b[i] < 50 && a[i][2] >= 50)
            printf("%c\n",'C');
            
            else printf("%c\n",'D');
  }
  return 0;
}


Measured memory_bytes: 2624
import itertools
import numpy as np

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

d_list = []
sum_d = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
  for i in range(Q):
    a = abcd[i][0]
    b = abcd[i][1]
    c = abcd[i][2]
    d = abcd[i][3]
    if A[b-1]-A[a-1] == c:
      d_list.append(abcd[i][3])
  if sum_d <= sum(d_list):
    sum_d = sum(d_list)
  d_list.clear()
print(sum_d)

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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    double l; cin >> l;

    double ans = l * l * l /27;
    printf("%.12lf\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n, q;
	int S[100000], T[50000];
	int count = 0;
        cin >> n;
	for( int i = 0; i < n; i++ )
	{
		cin >> S[i];
	}
	cin >> q;
	for( int i = 0; i < q; i++ )
	{
		cin >> T[i];
	}

	for( int i = 0; i < q; i++ )
	{
		int low = 0;
		int high = n - 1;
		while( low <= high )
		{
			int mid = ( low + high ) / 2;
			if( S[mid] < T[i] )
			{
				low = mid + 1;
			}
			else if( S[mid] > T[i] )
			{
				high = mid - 1;
			}
			else
			{
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

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

using namespace std;

const int N = (int) 2e5 + 7;
const int INF = (int) 1e9;
string s;
int n, dp[N][3];

string get(int i, int j)
{
        string a;
        while (i <= j)
                a += s[i++];
        return a;
}

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

        cin >> s;
        n = (int) s.size();
        s = "." + s;

        for (int i = 0; i < N; i++)
                for (int j = 0; j <= 2; j++)
                        dp[i][j] = -INF;

        dp[1][1] = dp[2][2] = 1;
        for (int i = 1; i <= n; i++)
                for (int j = 1; j <= 2; j++)
                        if (dp[i][j] != INF)
                                for (int j2 = 1; j2 <= 2 && i + j2 <= n; j2++)
                                        if (get(i - j + 1, i) != get(i + 1, i + j2))
                                                dp[i + j2][j2] = max(dp[i + j2][j2], 1 + dp[i][j]);
        cout << max(dp[n][1], dp[n][2]) << "\n";

        return 0;
}


Measured memory_bytes: 2896
#include <stdio.h>
#include <stdlib.h>

int main(void){
    char s[4];
    scanf("%s", s);
    if(s[0]==s[1] && s[1]==s[2] && s[0]==s[2]){
        printf("No");
    }else{
        printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char s;
    int i,j,walk,n=1,m,x,y,count;
    int a[21][21] = {};
 
    
    while(n != 0){
   
        for(i = 0;i<21;i++){
            for(j = 0;j<21;j++){
                a[i][j] = 0;
            }
        } 
        
        cin >> n;
        if(n >0){
        count = n;
        for(i = 0;i<n;i++){
            cin >> x >> y;
            a[x][y] = 1;
        }
    
        x=10;
        y=10;
    
        cin >> m;
        for(i = 0;i<m;i++){
            cin >> s >> walk;
            if(s == 'N') {
                for(j=0;j<walk;j++){
                    y++;
                    if( a[x][y] == 1) {
                        count--;
                        a[x][y] = 0;
                    } 
                } 
            }
        
            else if(s == 'S') {
                for(j=0;j<walk;j++){
                    y--;
                    if( a[x][y] == 1) {
                        count--;
                        a[x][y] = 0;
                    } 
                }   
            }
        
            else if(s == 'E') {
                for(j=0;j<walk;j++){
                    x++;
                    if( a[x][y] == 1) {
                        count--;
                        a[x][y] = 0;
                        } 
                } 
            }
        
            else if(s == 'W') {
                for(j=0;j<walk;j++){
                    x--;
                    if( a[x][y] == 1) {
                        count--;
                        a[x][y] = 0;
                    } 
                } 
            }
      
        }    
        
        if(count == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    
    }
    }
}



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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 5020;
int D, d[N], len; //d[]数组存储D的每一位数字。
ll ans, f[N][2][2]; 
//f[i][j][k]表示从低位到高位填了i位，保证合法，并且第n-i位对第n-i+1的进位贡献为j，第i位对第i+1位的进位贡献为k的方案数。 
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9') { x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
ll find(int len) {
	int lim = len/2; ll res = 0;
	memset(f, 0, sizeof(f));
	f[0][0][0] = 1; 
	rep(i, 0, lim-1) rep(j, 0, 1) rep(k, 0, 1) {
		if(f[i][j][k] != 0) rep(l, 0, 9) {
			int raw = l + d[i+1] + k, num = raw%10; 
			int _k = raw/10, _j = j*10 + l - num - d[len-i];
			if(_j < 0 || _j > 1) continue;
			if(i == 0 && (l == 0 || num == 0)) continue;
			f[i+1][_j][_k] += f[i][j][k]; 
		}
	}
	if(len % 2) {
		rep(j, 0, 1) rep(k, 0, 1) {
			if(f[lim][j][k] != 0) rep(i, 0, 9) {
				int num = i + d[(len+1)/2] + k;
				if(num%10 == i && num/10 == j) res += f[lim][j][k];
			}
		}
	}
	else rep(j, 0, 1) res += f[lim][j][j];
	return res;
}
void init(){
	D = read();
	while(D) d[++len] = D%10, D /= 10; //对D的各个位数的数字分解 
	rep(i, len, 2*len) ans += find(i); //枚举n的长度，可证明n的长度不超过D的长度的二倍 
	printf("%lld\n", ans);
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init(); 
	return 0;
}


Measured memory_bytes: 384
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-23 18:26:00
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int INF = 2e9;

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

  int n, m; cin >> n >> m;
  vector<int> a(m), b(m), c(m, 0);
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; ++j) {
      int t; cin >> t; --t;
      c[i] += (1<<t);
    }
  }

  // dp[i][j] : i 個目まで見て状態が j のときの最小コスト
  vector<vector<int>> dp(m + 5, vector<int>(1 << n, INF));
  dp[0][0] = 0;

  for (int i = 0; i < m; ++i) {
    for (int bit = 0; bit < (1 << n); ++bit) {
      dp[i + 1][bit] = min(dp[i + 1][bit], dp[i][bit]);
      int next = (bit | c[i]);
      dp[i + 1][next] = min(dp[i + 1][next], dp[i][bit] + a[i]);
    }
  }
  if (dp[m][(1 << n) - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << dp[m][(1 << n) - 1] << endl;
  }

  return 0;
}

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

int main()
{
    int c=0;
    string s,t;
    cin>>s>>t;
    for (int i=0;i<s.size();i++)
    {
        if(s[i]==t[i])
            continue;
        else
        {

            c++;
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3864
#include<stdio.h>

int main (void) {
   int W, H, x, y, r;
   scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

   if (x+r > W || y+r > H){
      printf("No\n");
   }
   else if (x-r < 0 || y-r < 0){
      printf("No\n");
   }
   else 
      printf("Yes\n");
    
   return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
// #define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n;
  cin>>n;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n,greater<ll>());
  ll ans=0;
  rrep(i,n-1,1) ans+= a[i/2];
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 5192
X = int(input())
ans = 0
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

for i in range(X, 100004, 1):
  if is_prime(i):
    ans = i
    break

print(ans)

Measured memory_bytes: 3068
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var H = new HashSet<int>();
		for(int i=0;i<N;i++) H.Add(D[i]);
		Console.WriteLine(H.Count);
		
	}
	int N;
	int[] D;
	public Sol(){
		N = ri();
		D = new int[N];
		for(int i=0;i<N;i++) D[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Yes" << endl;
    cout << 2 << endl;
    cout << 1 << " " << 1 << endl;
    cout << 1 << " " << 1 << endl;
    return 0;
  } else if (n == 2) {
    cout << "No" << endl;
    return 0;
  }
  vector<vector<int>> ans;
  vector<int> v;
  v.emplace_back(1);
  ans.emplace_back(v), ans.emplace_back(v);
  v.clear();
  int j = 0, m = 2;
  for (int i = 2; i <= n; i++) {
    ans[j].emplace_back(i);
    v.emplace_back(i);
    j++;
    if (j == m) {
      ans.emplace_back(v);
      j = 0, m++;
      v.clear();
    }
  }
  if (j != 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    cout << ans.size() << endl;
    for (auto &v : ans) {
      cout << v.size() << " ";
      for (auto &w : v) {
        cout << w << " ";
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;

class AOJ_Queue {
    struct Task {
        public string name;
        public int times;
    }

    static void Main()
    {
        string[] line = Console.ReadLine().Split(' ');

        int n = int.Parse(line[0]);
        int q = int.Parse(line[1]);

        int elaps = 0;
        Queue<Task> Q = new Queue<Task>();

        for (int i = 0; i < n; i++) {
            Task tmp;
            line = Console.ReadLine().Split(' ');
            tmp.name = line[0];
            tmp.times = int.Parse(line[1]);
            Q.Enqueue(tmp);
        }

        while (Q.Count > 0)
        {
            Task p = Q.Dequeue();
            if (p.times <= q) {
                elaps += p.times;
                Console.WriteLine("{0} {1}", p.name, elaps);
            }
            else
            {
                p.times -= q;
                elaps += q;
                Q.Enqueue(p);
            }
        }
    }
}

Measured memory_bytes: 15948
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll n; cin >> n;
    ll a[n];
    vector<ll> v1, v2, v4;
    string ans;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]%4 == 0) v4.push_back(a[i]);
        else if(a[i]%2 == 0) v2.push_back(a[i]);
        else v1.push_back(a[i]);
    }
    if(v2.size() == 0){
        if(v1.size() <= v4.size()+1){
            ans = "Yes";
        } else{
            ans = "No";
        }
    } else {
        if(v1.size() <= v4.size()){
            ans = "Yes";
        } else {
            ans = "No";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2296
#include<iostream>
using namespace std;
int main()
{
    int h,a;
    cin>>h>>a;
    int arr[a];
    for(int i=0;i<a;i++)
    cin>>arr[i];
    int sum=0;
     for(int i=0;i<a;i++)
     sum=sum+arr[i];
     int x=h-sum;
     if(x>0)
     {
         cout<<"No";
     }
     else
     cout<<"Yes";
}

Measured memory_bytes: 768
class RangeSumQuery(object):

    def __init__(self, size):
        self.size = 1
        while self.size <= size:
            self.size *= 2
        self.data = [0 for _ in xrange(self.size*2-1)]

    def add(self, idx, value):
        k = idx + self.size - 1
        self.data[k] += value
        while k > 0:
            k = (k - 1) / 2
            self.data[k] += value

    def get_sum(self, start, end):
        def query(k, left, right):
            if right <= start or end <= left:
                return 0
            if start <= left and right <= end:
                return self.data[k]
            vl = query(k*2+1, left, (left+right)/2)
            vr = query(k*2+2, (left+right)/2, right)
            return vl + vr
        return query(0, 0, self.size)


def main():
    n, q = map(int, raw_input().split())
    rsq = RangeSumQuery(n)
    for _ in xrange(q):
        com, x, y = map(int, raw_input().split())
        if com == 0:
            rsq.add(x, y)
        else:
            print rsq.get_sum(x, y+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 8640
#include <stdio.h>
int main()
{
    int n,x,count;
    int a,b,c;
    int max;
    while (1)
    {
        scanf("%d%d",&n,&x);
        if (n==0 && x==0)
            break;
        max=x;
        count=0;
        if  (n<max)
            max=n;

        for (a=1; a<=max; a++)
        {
            for(b=a+1; b<=max; b++)
            {
                c=x-a-b;
                if (c<=n && c>b)
                    count++;

            }
        }
        printf("%d\n",count);
    }




    return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<cstdint>
using namespace std; // 575

int main() {
	int64_t K, A, B;
	cin >> K >> A >> B;
	if (K < A) cout << A + 1;
	else if (A >= B - 1) cout << K + 1;
	else cout << (K - A + 1) / 2 * (B - A) + (K - A + 1 & 1) + A;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、A枚までは増やすものとする
ここで、A<B+1ならA→1円、1円→Bに変えると２手で必ず2枚以上増えるので最適
そうでないならずっとたたくのが最適

K-A+1
*/

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;

int main(){
    int i,N;
    double x;
    string u;
    double gokei=0;
    cin>>N;
    for(i=0;i<N;i++){
        cin>>x>>u;
        if(u=="JPY"){
            gokei+=x;
        }
        else{
            gokei+=x*380000.0;
        }
    }
    cout<<gokei;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    int x = c-a;
    int y = d-b;
    printf("%d %d %d %d\n", c-y, d+x, a-y, b+x);
    return 0;
}

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

int main(){

    string s;
    cin>>s;
    if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3))
    cout<<"Bad"<<endl;

    else cout<<"Good"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k;
typedef struct node
{
	long long a[51][51];
	struct node operator *(const struct node & tmp)
	{
		int i,j,l;
		struct node ret;
		memset(ret.a,0,sizeof(ret.a));
		for(l=1;l<=n;l++)
			for(i=1;i<=n;i++)
				for(j=1;j<=n;j++)
					if(a[i][l]&&tmp.a[l][j])
						ret.a[i][j]=(a[i][l]*tmp.a[l][j]+ret.a[i][j])%1000000007;
		return ret;
	}
}NODE,*PNODE;
NODE ans,g;
int main()
{
	int flag=0,i,j;
	long long a=0;
	scanf("%lld %lld",&n,&k);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			scanf("%lld",&g.a[i][j]);
	while(k)
	{
		if(k%2)
		{	
			if(!flag)
			{
				ans=g;
				flag=1;
			}
			else
				ans=ans*g;
		}
		g=g*g;
		k/=2;
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			a=(a+ans.a[i][j])%1000000007;
	printf("%lld",a);
	return 0;
}

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

public class Main {
    public static void main (String[] args ) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String check = "#";
        String period = ".";
        
        while(true) {
            String line = reader.readLine();
            String[] columns = line.split(" ");
            int y = Integer.parseInt(columns[0]);
            int x = Integer.parseInt(columns[1]);
            
            if (x == 0 && y == 0 ) 
                break;
            for ( int j = 0 ; j < y ; j++) {
                if (j % 2 == 0 )
                    builder.append(DrawChessBoard(check,period,x));
                else
                    builder.append(DrawChessBoard(period,check,x));
            }
            builder.append("\n");
        }
        System.out.print(builder);
    }
    public static StringBuilder DrawChessBoard(String check,String period,int x) {
        StringBuilder str = new StringBuilder();
        for ( int i = 0 ; i < x ; i++) {
                if (i % 2 == 0 ) 
                    str.append(check);
                else
                    str.append(period);
            }
            str.append("\n");
            return str;
    }
}

Measured memory_bytes: 25796
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int price = scan.nextInt(); // 商品価格
        scan.close();
        int num1000 = price / 1000; // 必要な1000円の枚数-1
        if (price % 1000 == 0) {
            // 価格が1000円で割り切れるときはお釣り０
            System.out.println("0");
        } else {
            System.out.println(1000 * (num1000 + 1) - price);
        }
    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,p; cin>>n>>p;
  ll even=0, odd=0;
  rep(i,n){
    ll a; cin>>a;
    if(a%2) odd++;
    else even++;
  }
  if(odd==0){
    if(p){
      cout<<0<<endl;
    }else{
      cout<<(ll)round(pow(2,even))<<endl;
    }
  }else{
    cout<<(ll)round(pow(2,even+odd-1))<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x[n],y[n],h[n];
    int s;
    for (int i=0; i<n; i++){
        cin >> x[i] >> y[i] >> h[i];
        if (h[i]!=0){
            s=i;
        }
    }
    for (int i=0; i<=100; i++){
        for (int j=0; j<=100; j++){
            for (int k=0; k<=n; k++){
                int H=h[s]+abs(x[s]-i)+abs(y[s]-j);
                if (k==n){
                    cout << i << " " << j << " "<< H <<endl;
                    exit(0);
                }
                if (h[k]==0){
                    if (H-abs(x[k]-i)-abs(y[k]-j)>0){
                        break;
                    }
                }
                else if (H!=h[k]+abs(x[k]-i)+abs(y[k]-j)){
                    break;
                }
            }
        }
    }
}
            


    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

const ll MOD = ll(1e9) + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll i, ll mod){
    return modpow(i, mod-2, mod);
}

ll comb(ll n, ll a, ll mod) {
    ll ans = 1, denom = 1;
    rep(i,a) {
        ans = ans * (n - i) % mod;
        denom = denom * (i+1) % mod;
    }
    ans = ans * modinv(denom, mod) % mod;
    return ans;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = (modpow(2, n, MOD) - 1) % MOD;
    ans = (ans - comb(n, a, MOD)) % MOD;
    ans = (ans - comb(n, b, MOD)) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include "stdlib.h"
#include <queue>

using namespace std;

typedef struct Graph graph;
typedef uint Result;

typedef struct {
    enum {
        RED, BLACK
    } color;
    bool has_probed;
}tile;

typedef struct {
    uint x,y;
}cordinate;

struct Graph{
    tile graph[22][22];
    uint height,width;
    uint pos_x,pos_y;
}checkborad;

Result init_graph(graph* out){
    uint H,W;
    scanf("%u %u",&W,&H);

    if(H==0&&W==0)
        return 0;

    out->height=H;
    out->width=W;



    for (uint h=1;h<H+1;h++)
        for(uint w=1;w<W+1;w++) {
            char c;
            c = getchar();
            if (c == '\n')
                c = getchar();
            switch (c) {
                case '#':
                    checkborad.graph[h][w].color = tile::RED;
                    break;
                case '@':
                    checkborad.pos_x = w;
                    checkborad.pos_y = h;
                case '.':
                    checkborad.graph[h][w].color = tile::BLACK;
                    break;
            }

            checkborad.graph[h][w].has_probed=false;
        }

    for (uint i=0;i<H+2;i++){
        out->graph[i][W+1]={tile::RED,true};
        out->graph[i][0]={tile::RED,true};
    }

    for (uint i=0;i<W+2;i++){
        out->graph[0][i]={tile::RED,true};
        out->graph[H+1][i]={tile::RED,true};
    }


    return 1;
}

// return 0 on encountering ending
uint count_graph(graph* self){
    //initialization
    queue<cordinate> q;
    uint count=1;
    q.push({self->pos_x,self->pos_y});
    self->graph[self->pos_y][self->pos_x].has_probed=1;

    while(!q.empty()){
        auto temp=q.front();
        q.pop();

        uint left=temp.x-1,right=temp.x+1,top=temp.y-1,bottom=temp.y+1;

        if(
                self->graph[top][temp.x].color==tile::BLACK
        &&!self->graph[top][temp.x].has_probed){
            count++;
            self->graph[top][temp.x].has_probed=1;
            q.push({temp.x,top});
        }

        if(
                self->graph[bottom][temp.x].color==tile::BLACK
                &&!self->graph[bottom][temp.x].has_probed){
            count++;
            self->graph[bottom][temp.x].has_probed=1;
            q.push({temp.x,bottom});
        }

        if(
                self->graph[temp.y][left].color==tile::BLACK
                &&!self->graph[temp.y][left].has_probed)
        {
            count++;
            self->graph[temp.y][left].has_probed=1;
            q.push({left,temp.y});
        }

        if(
                self->graph[temp.y][right].color==tile::BLACK
                &&!self->graph[temp.y][right].has_probed)
        {
            count++;
            self->graph[temp.y][right].has_probed=1;
            q.push({right,temp.y});
        }

    }

    return count;
}

int main() {

    while(1){
       if (!init_graph(&checkborad))
           break;

       printf("%u\n",count_graph(&checkborad));
    }

    return 0;
}


Measured memory_bytes: 2576
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
using P = pair<int, int>;
using ll = long long;
vector<int> to[100005];
int cost[100005];

signed main(){
    int a, b, c, d;
    cin >> a >> b >> c >>d;
    
    cout << max(0,min(d,b)-max(a,c)) << endl;
    
    return 0;
}



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

int n, m;
int s[100005], t[100005];
vector<int> edge[10005], redge[10005];
bool used[10005];
vector<int> ord;
int comp[10005];
int noin[10005], noout[10005];

void dfs1(int a){
  if(used[a]) return;
  used[a]=true;
  for(int i=0; i<edge[a].size(); i++){
    int b=edge[a][i];
    dfs1(b);
  }
  ord.push_back(a);
}

void dfs2(int a, int c){
  if(used[a]) return;
  used[a]=true;
  comp[a]=c;
  for(int i=0; i<redge[a].size(); i++){
    int b=redge[a][i];
    dfs2(b, c);
  }
}

int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> s[i] >> t[i];
    edge[s[i]].push_back(t[i]);
    redge[t[i]].push_back(s[i]);
  }
  fill(used, used+n, false);
  for(int i=0; i<n; i++) dfs1(i);
  int cnt=0;
  fill(used, used+n, false);
  for(int i=n-1; i>=0; i--) 
    if(!used[ord[i]]) dfs2(ord[i], cnt++);
  fill(noin, noin+n, 1);
  fill(noout, noout+n, 1);
  for(int i=0; i<m; i++){
    if(comp[s[i]]!=comp[t[i]]){
      noout[comp[s[i]]]=0;
      noin[comp[t[i]]]=0;
    }
  }
  int ans=0;
  if(cnt>1){
    int noincnt=0, nooutcnt=0;
    for(int i=0; i<cnt; i++) noincnt+=noin[i];
    for(int i=0; i<cnt; i++) nooutcnt+=noout[i]; 
    ans=max(noincnt, nooutcnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6468
map{/ /,push@
$`,$' for<>;map$q[$_]+=$q[$N]/@$N,@{$N=$_}}++$q[1]..<>;$e[$N]=1+${$b=0;$b+=$_ for@@=@e[@$N];b}/@@,$a<($~=$q[$N]*=$#@&&($b-(sort@@)[-1])/$#@-$b/@@)or$a=$~while--$N;print"@e"+$a

Measured memory_bytes: 42368
import java.util.Scanner;
class Main{
    public static void main(String[]args){
                Scanner scan =new Scanner(System.in);
        int n = scan.nextInt();
       	 int i,j,b;
        if(n!=0){
            do{
         		int[][] a=new int[n+1][n+1];
       	 for(i=0;i<n+1;i++){
           	 for(j=0;j<n+1;j++){
                 if(i!=n&&j!=n){
                     b = scan.nextInt();
                     a[i][j]=b;
               		 a[i][n]+=a[i][j];
                 	 a[n][j]+=a[i][j];
                     a[n][n]+=a[i][j];
                 }
                 System.out.printf("%5d",a[i][j]);
                 if(j==n)System.out.println();
       		      }
     		    }
                n = scan.nextInt();
            }
            while(n!=0);
        }
    }
}


Measured memory_bytes: 32480
#include <bits/stdc++.h>
using namespace std;
int sum(int x){
  int res = 0;
  while(x > 0){
    res += x%10;
    x /= 10;
  }
  return res;
}
int main(){
  int n, ans = 1e9;
  cin >> n;
  for(int a=1, b=n-1; a<=b; ++a, --b) ans = min(ans, sum(a)+sum(b));
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int p = (a * b) % 2;
  if(p == 0){
    cout << "Even" << endl;
  }
  else{
   cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val x = readInteger()
    val ans = when (x) {
        in 400..599 -> 8
        in 600..799 -> 7
        in 800..999 -> 6
        in 1000..1199 -> 5
        in 1200..1399 -> 4
        in 1400..1599 -> 3
        in 1600..1799 -> 2
        else -> 1
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)




Measured memory_bytes: 34212
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
using namespace std;
char s[100005];
int main(){
	scanf("%s",s);
	int n=strlen(s),g=1,p=0,ans=0;
	if(s[0]=='p') ans--;
	for(int i=1;i<n;i++){
		if(s[i]=='g'){
			if(p<g){
				ans++;
				p++;
			}else{
				g++;
			}
		}
		if(s[i]=='p'){
			if(p>=g){
				g++;
				ans--;
			}else{
				p++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

int main() {
		int N, L;
		cin >> N >> L;
		int a[N];
		int eating = 1e9, eating_i = -1;
		for (int i = 0; i < N; i++) {
				a[i] = L + (i+1) - 1;
				if (abs(a[i]) < eating) {
						eating = abs(a[i]);
						eating_i = i;
				}
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
				if (eating_i == i) continue;
				ans += a[i];
		}

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


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


int main() {
  long N;
  cin>>N;
  long A[N];
  for (int i = 0; i < N;i++) cin>>A[i];
  // int B[i];
  int NA[3] = {0,0,0};
  for (int i = 0; i < N;i++) {
    if (A[i]%2 == 1) NA[0]++;
    else if (A[i]%4 == 2) NA[1]++;
    else NA[2]++;
  }
  bool flag;
  if (NA[1] == 0) {
    if (NA[0] >= NA[2] + 2) flag = false;
    else flag = true;
  } else {
    if (NA[0] >= NA[2] +1) flag = false;
    else flag = true;
  }

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

Measured memory_bytes: 1024
from collections import deque
n = int(input())
s = input()

stack = []
que = deque()
for i in range(n):
    t = s[i]
    if t == '(':
        que.append('(')
        stack.append('(')
    else: # ')'
        if stack and stack[-1] == '(':
            stack.pop()
            que.append(')')
        else:
            que.appendleft('(')
            que.append(')')
            # stack.append(t)

ans = ''.join(que) + ')' * len(stack)
print(ans)

Measured memory_bytes: 38384
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
int A, B;
int P[100];

signed main(){
    cin >> N >> A >> B;
    rep(i, N) cin >> P[i];

    int cnt[3] ={};
    rep(i, N){
        if(P[i] <= A) cnt[0]++;
        if(A < P[i] && P[i] <= B) cnt[1]++;
        if(B < P[i]) cnt[2]++;
    }
    cout << min({ cnt[0], cnt[1], cnt[2] }) << endl;
}

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

//bubble sort with using flag
int bubbleSort(int A[], int n){
	int count = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n -1; j >= i + 1; j--) {
			if (A[j] < A[j-1]) {
				swap(A[j], A[j-1]);
				flag = 1;
				count++;
			}
		}
	}
	return count;
}

int main() {
	int n, A[100];
	cin >> n;

	for (int i = 0; i < n; i++) cin >> A[i];

	int c = bubbleSort(A, n);
	for (int i = 0; i < n; i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << c << endl;
	return 0;
	}
 
 


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

int main(){
    int N = 10000;
    vector<int> vh(N);
    vector<int> vw(N);
    int tmp = 0;
    for (int i = 0; i < N; i++) {
        int h,w;
        cin >> h >> w;
        if (w == 0 && h == 0) {
            tmp = i;
            break;
        }
        vh.at(i) = h;
        vw.at(i) = w;
    }

    for (int i = 0; i <= tmp; i++) {
        if (i > 0) cout << endl;
        for (int j = 0; j < vh[i]; j++) {
            for (int z = 0; z < vw[i]; z++) {
                if (z == 0 
                || j == 0
                || z == vw[i] - 1
                || j == vh[i] - 1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i,n) for(int i=0; i<(n); ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll INFLL = 100100100100100100;
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main () {
    
    ll n;
    cin >>n;
    vector<vector<vector<ll>>> f(n, vector<vector<ll> >(5, vector<ll>(2, 0)));
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < 5; j++) {
            for (ll k = 0; k < 2; k++) {
                cin >> f[i][j][k];
            }
        }
    }
    vector<vector<ll> > p(n, vector<ll>(11));
    REP(i,n) REP(j,11) cin >> p[i][j];
    
    ll m = 10;
    ll result = -INFLL;
    for (ll s = 1; s < (1<<m); s++) {
        vector<ll> sum(n, 0);
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < m; j++) {
                if (s & (1<<j)) {
                    sum[i] += f[i][j/2][j%2];
                }
            }
        }
        ll maxa = 0;
        for (ll i = 0; i < n; i++) {
            maxa += p[i][sum[i]];
        }
        result = max(result, maxa);
    }
    
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
using ll =long long;
int main() {
	int N, M;
	vector<int>A;
	int c;
	cin >> N >> M;
	int sum=0;
	double test;
	for (int i = 0; i <N; i++)
	{
		cin >> c;
		A.push_back(c);
	sum += A[i];



}
	test = (double)sum / (4 * M);
	sort(A.begin(), A.end(),greater<int>());

	if (A[M-1]>=test) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
n = int(input())

c = [0] * n
f = [0] * n
s = [0] * n

for i in range(n - 1):
    c[i], s[i], f[i] = map(int, input().split())

lapse = [0] * n

for i in range(n):
    for j in range(i + 1, n):

        t = 0
        while s[j - 1] + t * f[j - 1] < lapse[i]:
            t += 1

        lapse[i] = s[j - 1] + t * f[j - 1] + c[j - 1]

    print(lapse[i])


Measured memory_bytes: 42844
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    for(int j='a';j<='z';j++){
        int t = s.find((char)j);
        if(t==-1){
            cout << (char)j << endl;
            goto OUT;
        }
    }
    cout << "None" << endl;
    OUT:;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.size()<4){
		cout<<"No";
		return 0;
	}
	if(s.find("YAKI")==0)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool ans = true;
  for(int i; i < s.size(); i++){
    if(s.at(i) == 'L') {
      ans = false;
      break;
    }
    if(i+1 < s.size()){
      if(s.at(++i) == 'R'){
      ans = false;
      break;
      }
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
        int tate[150]={0},a,yoko,b1,b2,i,x;
        scanf("%d",&a);
        for(i=1;i<=a;i++)tate[i]=i;
        scanf("%d",&yoko);
        for(i=0;i<yoko;i++)
        {
                scanf("%d,%d",&b1,&b2);
                x=tate[b1];
                tate[b1]=tate[b2];
                tate[b2]=x;
                b1=0;b2=0;x=0;
        }
        for(i=1;i<100;i++)
        {
                if(tate[i]!=0)printf("%d\n",tate[i]);
        }
        return 0;
}

Measured memory_bytes: 596
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <climits>
#include <queue>

using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    vector<pair<int, int>> items;

    items.emplace_back(0, 0);
    for (int i = 0; i < N; ++i) {
        int v, w;
        cin >> v >> w;
        items.emplace_back(v, w);
    }

    int dp[101][10001];
    for (int i = 0; i <= W; ++i) {
        dp[0][i] = 0;
    }
    for (int i = 0; i <= N; ++i) {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (items[i].second > j) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = max(dp[i - 1][j], items[i].first + dp[i - 1][j - items[i].second]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;


//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

//repetition
//------------------------------------------
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

int main()
{
	ULL L, R;
	cin >> L >> R;

	R = min(R, L + 4038);

	LL ans = 2018;
	for (ULL i = L; i <= R; i++) {
		for (ULL j = i + 1; j <= R; j++) {
			LL x = (i*j) % 2019;
			ans = min(ans, x);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque

n, x, y = map(int, input().split())
a = []

for i in range(1, n + 1):
    if i == 1:
        a.append([2])
    elif i == n:
        a.append([n - 1])
    else:
        a.append([i - 1, i + 1])
a[x - 1].append(y)
a[y - 1].append(x)

d = {}
for i in range(n - 1):
    d[i + 1] = 0

def solve(s):
    queue = deque()
    queue.append(a[s - 1])
    visit = set()
    visit.add(s)
    depth = 0

    while queue:
        depth += 1
        nn = queue.popleft()
        adj = []
        for i in nn:
            if i not in visit:
                d[depth] += 1
                adj = adj + a[i-1]
            visit.add(i)
        if adj != []:
            queue.append(adj)

for i in range(n):
    solve(i + 1)

for i in range(n - 1):
    print(d[i + 1] // 2)


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  string S, T;
  cin >> S >> T;

  REP(i, N) {
    cout << S[i];
    cout << T[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;



int main(){


	int a;
	int b;
	int c;
	int d;
	int l;
	int r;
	int k;

	cin>>a>>b>>c>>d;

	if( a < c ){
		l=c;
	}else if( a > c ){
		l=a;
	}
	if( b < d ){
		r=b;
	}else if( d < b ){
		r=d;
	}

	k=(r-l);

	if( k < 0){
		k=0;
	}

	cout<<k<<endl;



}


Measured memory_bytes: 256
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  long h;
  cin >> h;
  cin >> n;
  
  vector<int> a(n);
  while(n--)
    cin >> a[n];

  // sort(a.begin(), a.end(), greater<int>());
  sort(a.begin(), a.end());
  // auto res = unique(a.begin(), a.end());
  // a.erase(res, a.end());
  long sum = accumulate(a.begin(), a.end(), 0);
  if(sum >= h)
    cout << "Yes";
  else
    cout << "No";


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



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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, m;
int a[N], q[N];

int get(int x)
{
	q[m] = -0x3f3f3f3f;
	int l = 0, r = m;
	while (l < r)
	{
		int mid = l + r >> 1;
		if (q[mid] < x) r = mid;
		else l = mid + 1; 
	}
	return r == m ? -1 : r;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	
	for (int i = 1; i <= n; i ++ )
	{
		int t = get(a[i]);
		if (t == -1) q[m ++ ] = a[i];
		else q[t] = a[i];
	}
	
	printf("%d\n", m);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] V = new int[N];
		int[] C = new int[N];
		int answer = 0;
		
		for(int i = 0; i < N; i++){

			V[i] = scanner.nextInt();
		}
		for(int i = 0; i < N; i++){

			C[i] = scanner.nextInt();
		}
		for(int i = 0; i < N; i++){
		
			if (V[i] - C[i] > 0){
				
				answer = answer + (V[i] - C[i]); 
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 21716