akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

typedef struct {
    int left;
    int down;
} MAP;


int main(void)
{
    int w, h;
    MAP map[103][103];
    int x, y;
    int i, j;

    while (1){
        scanf("%d%d", &w, &h);
        if (w == 0 && w == 0){
            break;
        }
        
        memset(map, 0, sizeof(map));
        
        for (y = 1; y <= h; y++){
            for (x = 1; x <= w; x++){
                if (x == 1 && y == 1){
                    map[2][1].down = 1;
                    map[1][2].left = 1;
                    continue;
                }
                map[y][x + 1].left += map[y][x].left;
                map[y][x + 1].left %= 100000;
                
                map[y + 2][x].down += map[y][x].left;
                map[y + 2][x].down %= 100000;

                map[y][x + 2].left += map[y][x].down;
                map[y][x + 2].left %= 100000;

                map[y + 1][x].down += map[y][x].down;
                map[y + 1][x].down %= 100000;
#if 0                
                printf("<%d %d>\n", x, y);
                for (i = h; i >= 1; i--){
                    printf("[");
                    for (j = 1; j <= w; j++){
                        printf("%d-%d ", map[i][j].left, map[i][j].down);
                    }
                    printf("]\n");
                }
                
#endif                
            }
        }
        
        printf("%d\n", (map[h][w].down + map[h][w].left + map[h][w - 1].down + map[h - 1][w].left) % 100000);
    }
    return (0);
}

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

int main(){
  int  N, H, W;
  cin >> N >> H >> W;

  int count;
  count = 0; 

  for(int x=1; x <= N; x++){
    for(int y=1; y <= N; y++){
      if(x + W-1 <= N && y + H-1 <= N)count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
A=[list(map(int,input().split())) for _ in range(3)]
b=[i for i in [int(input()) for _ in range(int(input()))] for j in A if i in j]
A=[[0 if A[i][j] in b else A[i][j] for j in range(len(A[i]))] for i in range(len(A))]
print('NYoe s'[any([1 if sum(i)==0 else 0 for i in A]) or any([1 if sum(i)==0 else 0 for i in list(zip(*A))]) or not A[0][0]+A[1][1]+A[2][2] or not A[0][2]+A[1][1]+A[2][0]::2])

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int remainder = a - b;
        // 容器1の空き容量が0の場合、容器2の水は移動できない
        if (remainder == 0) {
            System.out.println(c);
        } else {
            System.out.println(Math.max(c - remainder, 0));
        }
        sc.close();
    }
}

Measured memory_bytes: 35540
function main() 
  n = parse(Int128, readline())
  a = parse.(Int128, split(readline()))

  a = sort(a)

  ans::Int128 = 1
  for i = 1:n
    ans *= a[i]
    if (ans > 10^18)
      ans = -1
      break
    end
  end
  
  println(ans)
end

main()

Measured memory_bytes: 223016
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<max(A*B,C*D)<<endl;

    return 0;
}


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

using namespace std;


int main(){
  
  string s;
  cin >> s;
  long long int a=0,b =0;
  
  for(int i=0;i<s.size();i++){
    
    if(s[i] == '0'){
      a++;
    }
    else if(s[i] =='1'){
      b++;
    }
  }
  if(a <= b){
  
  cout << 2*a << endl;
    return 0;
  }
  else if(a >b) {
cout << 2*b << endl;
    
    return 0;
    
}
  else{
    cout << "0" << endl;
  }
  
}

  

  




Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int x,y,i,j,flag=0;

  scanf("%d %d",&x,&y);

  for(i=0;i<=x;i++){
      if(i+3*(x-i)==y-x){
        flag=1;
      }
  }

  if(flag==1){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

return 0;
}


Measured memory_bytes: 1644
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    if(a.length() > b.length()){
      System.out.println("GREATER");
    }else if(a.length() < b.length()){
      System.out.println("LESS");
    }else{
      for(int i = 0; i < a.length(); i++){
        if(a.charAt(i) == b.charAt(i)){
          continue;
        }else if(a.charAt(i) > b.charAt(i)){
          System.out.println("GREATER");
          System.exit(0);
        }else{
          System.out.println("LESS");
          System.exit(0);
        }
      }
      System.out.println("EQUAL");
    }
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int freq[N];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, p;
    cin>>n>>p;
    string s;
    cin>>s;
    freq[0] = 1;
    int curr = 1, prv = 0;
    if(p != 2 && p != 5) {
        for (int i = n - 1; i >= 0; i--) {
            int to = mul(curr, s[i] - '0', p);
            prv = add(to, prv, p);
            curr = mul(curr, 10ll, p);
            freq[prv]++;
        }
        int ans = 0;
        f(i, p) {
            //cout<<freq[i]<<' ';
            ans += (freq[i] * (freq[i] - 1)) / 2;
        }
        cout << ans;
    }
    else if(p == 2) {
        int ans = 0, prvv = -1;
        f(i, n) {
            int dig = s[i] - '0';
            if(dig % 2 == 0) {
                ans += i + 1;
                prvv = i;
            }
        }
        cout<<ans;
    }
    else {
        int ans = 0, prvv = -1;
        f(i, n) {
            int dig = s[i] - '0';
            if(dig == 0 || dig == 5) {
                ans += i + 1;
                prvv = i;
            }
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
 
 
int main(){
    int N; cin >> N;
    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    ll ans = LINF;
    rep(i,1<<N){
        int p = __builtin_popcount(i);
        if(p == N/2){
            vector<int> a2(N,-1),b2(N,-1);
            rep(j,N){
                if(j % 2 == 0){
                    if(i>>j&1){
                        b2[j] = B[j];
                    }
                    else a2[j] = A[j];
                }
                else{
                    if(i>>j&1){
                        b2[j] = A[j];
                    }
                    else a2[j] = B[j];
                }
            }
            vector<Pi> c;
            rep(j,N){
                if(a2[j] != -1){
                    c.emplace_back(a2[j],j);
                }
            }
            sort(c.begin(),c.end());
            map<int,int> mp;
            rep(j,c.size()){
                mp[c[j].second] = j*2;
            }

            vector<Pi> c2;
            rep(j,N){
                if(b2[j] != -1){
                    c2.emplace_back(b2[j],j);
                }
            }
            sort(c2.begin(),c2.end());
            rep(j,c2.size()){
                mp[c2[j].second] = j*2+1;
            }
            vector<int> ab(N);
            rep(j,N){
                if(a2[j] == -1) ab[j] = b2[j];
                else ab[j] = a2[j];
            }
            bool ok = true;
            int tmp = 0;
            vector<int> t(N);
            rep(j,N){
                t[mp[j]] = ab[j];
            }
            rep(j,N){
                if(t[j] < tmp) ok = false;
                tmp = t[j];
            }
            if(!ok) continue;
            ll now = 0;
            rep(j,N){
                rep(k,j){
                    if(mp[j] < mp[k]) now++;
                }
            }
            ans = min(ans,now);

        }
    }
    if(ans == LINF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
if a%2==0 or b%2==0 or c%2==0:
  print(0)
else:
  a,b,c = sorted([a,b,c])
  s = (a*b)*(c//2+1)
  t = (a*b)*(c//2)
  print(s-t)
  
  

Measured memory_bytes: 9008
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int h, w;
char grid[310][310];
int dp[310][310];
int cost[310][310];

int main() {
    memset(grid, 0, sizeof(grid));
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++) {
        scanf("%s", &grid[i][1]);
    }
    int ans = 0;
    for (int i = 1; i < w; i++) {
        memset(dp, 0, sizeof(dp));
        memset(cost, 0, sizeof(cost));
        for (int off = 0; off < h; off++) {
            for (int j = off + 1; j <= h; j++) {
                cost[j][j - off] = cost[j - 1][j - off - 1] + (grid[j][i] == grid[j - off][i + 1]);
                if (off != 0) {
                    cost[j - off][j] = cost[j - off - 1][j - 1] + (grid[j][i + 1] == grid[j - off][i]);
                }
            }
        }
        for (int j = 1; j <= h; j++) {
            for (int k = 1; k <= h; k++) {
                dp[j][k] = min(dp[j - 1][k], dp[j][k - 1]) + cost[j][k];
            }
        }
        ans += dp[h][h];
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n,m,x;
    cin >> n >> m >> x;
    int mn=mod;
    int c[n];
    int a[n][m];
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    rep(i,bit(n)){
        int cst=0;
        int b[m]={};
        rep(j,n){
            if(bit(j) & i){
                cst+=c[j];
                rep(k,m){
                    b[k]+=a[j][k];
                }
            }
        }
        bool can=true;
      	rep(j,m)if(b[j]<x)can=false;
        if(can)chmin(mn,cst);
    }
    if(mn==mod)cout << -1;
    else cout << mn;
    


}

/*



 */




Measured memory_bytes: 3656
// failed to generate code

#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> PII;
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(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#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<LL> A(N);
	REP(i, N) {
		cin >> A[i];
	}
/*
	cout << endl;
	REP(i, N) {
		cout << A[i] << " ";
	}
	cout << endl;
*/
	SORT(A);
/*
	cout << endl;
	REP(i, N) {
		cout << A[i] << " ";
	}
	cout << endl;
*/
	deque<LL> C;
	C.push_back(A[0]);   // min value
	LL s = 1, e = N - 1;
	while (1) {
		C.push_front(A[e]);
		e--;
		if (s > e) {
			break;
		}
		LL val = A[e];
		e--;
		if (s > e) {
			if (abs(C[0] - val) >= abs(C[SZ(C) - 1] - val)) {
				C.push_front(val);
			} else {
				C.push_back(val);
			}
			break;
		}		else {
			C.push_back(val);
		}
		C.push_front(A[s]);
		s++;
		if (s > e) {
			break;
		}
		val = A[s];
		s++;
		if (s > e) {
			if (abs(C[0] - val) >= abs(C[SZ(C) - 1] - val)) {
				C.push_front(val);
			} else {
				C.push_back(val);
			}
			break;
		}		else {
			C.push_back(val);
		}
	}
/*
	cout << endl;
	REP(i, SZ(C)) {
		cout << C[i] << " ";
	}
	cout << endl;
	cout << endl;
*/

	LL ans = 0;
	REP(i, SZ(C) - 1) {
		ans += abs(C[i + 1] - C[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1920
moji = input()
moji_split = [moji[i:i+1] for i in range(len(moji))]
moji_middle = []
flag1 = False
flag2 = False
flag3 = False

if moji_split[0] == "A":
    flag1 = True

for i in range(2, len(moji_split)-1):
    moji_middle += moji_split[i]
if moji_middle.count("C") == 1:
    flag2 = True

while "A" in moji_split:
    moji_split.remove("A")
while "C" in moji_split:
    moji_split.remove("C")
if "".join(moji_split).islower() ==True:
    flag3 = True
    
if flag1 == True and flag2 == True and flag3 == True:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

class FC{
public:
	int p[31];
	int n;
	bool is_over(){
		return p[1] == p[2] && p[2] == p[3] && p[3] == p[4]
			&& p[4] == p[5] && p[5] == p[6] && p[6] == p[7]
			&& p[7] == p[8] && p[8] == p[9] && p[10] == p[11]
			&& p[11] == p[12]&& p[13] == p[14] && p[14] == p[15]
			&& p[16] == p[17] && p[17] == p[18] && p[19] == p[20]
			&& p[20] == p[21];
	}
	void rot1(){
		swap(p[7], p[22]);
		swap(p[8], p[23]);
		swap(p[9], p[24]);
		swap(p[13], p[18]);
		swap(p[10],p[12]);
	}
	void rot2(){
		swap(p[1], p[28]);
		swap(p[2], p[29]);
		swap(p[3], p[30]);
		swap(p[15], p[16]);
		swap(p[19], p[21]);
	}
	void rot3(){
		swap(p[7], p[30]);
		swap(p[4], p[27]);
		swap(p[1], p[24]);
		swap(p[10], p[21]);
		swap(p[16], p[18]);
	}
	void rot4(){
		swap(p[3], p[22]);
		swap(p[6], p[25]);
		swap(p[9], p[28]);
		swap(p[12], p[19]);
		swap(p[13], p[15]);
	}
};
int main(){
	int N;
	cin >> N;
	for (int i = 0; i < N; i++){
		FC now;
		for (int j = 1; j < 31; j++){
			cin >> now.p[j];
		}
		now.n = 0;
		queue<FC> que;
		que.push(now);

		while (!que.empty()){
			now = que.front();
			que.pop();
			if (now.is_over()){
				cout << now.n << endl;
				break;
			}
			FC nex1 = now;
			nex1.rot1();
			nex1.n++;
			que.push(nex1);

			FC nex2 = now;
			nex2.rot2();
			nex2.n++;
			que.push(nex2);

			FC nex3 = now;
			nex3.rot3();
			nex3.n++;
			que.push(nex3);

			FC nex4 = now;
			nex4.rot4();
			nex4.n++;
			que.push(nex4);
		}
	}
	return 0;
}

Measured memory_bytes: 12168
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int ll;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int n;
    cin >> n;
    cout << n*800-int(n/15)*200 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>

int main() {
  intmax_t N, K;
  scanf("%jd %jd", &N, &K);

  intmax_t res=0;
  for (intmax_t b=K+1; b<=N; ++b) {
    intmax_t M=N-K+1;
    res += M/b*(b-K) + std::min(M%b, b-K);
    //fprintf(stderr, "%jd: %jd + %jd\n", b-K, M/b*(b-K), std::min(M%b, b-K));
  }

  if (K == 0)
    res -= N;

  printf("%jd\n", res);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    int pi[N+1];
    for (int i=1; i<=N; i++) {
        scanf("%d", &(pi[i]));
    }

    int count = 0;
    for (int i=1; i<N; i++) {
        if (pi[i] == i) {
            int tmp = pi[i];
            pi[i] = pi[i+1];
            pi[i+1] = tmp;
            count++;
        }
    }
    if (pi[N] == N) {
        count++;
    }

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

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N;
double x[500],r[500];
int main(){
	cin>>N;
	rep(i,N) cin>>r[i];
	rep(i,N){
		x[i]=r[i];
		rep(j,i){
			chmax(x[i],x[j]+sqrt((r[i]+r[j])*(r[i]+r[j]) - (r[i]-r[j])*(r[i]-r[j])));
		}
	}
	double ans=0;
	rep(i,N) chmax(ans,x[i]+r[i]);
	printf("%.12f\n",ans);
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ll a, b;
	cin >> a >> b;
	
	if(a * 500 >= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		
		long ans = n-1;
		
		for(long i = 2 ; i * i <= n ; i++) {
			if(n % i == 0) {
				long p = n /i;
				long q = i;
				ans = Math.min(ans, (long)(p+q -2));
			}
		}
		System.out.println(ans);

	}
	

}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define ll long long

using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    double d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        double x, y;
        cin >> x >> y;
        if (sqrt(pow(x, 2) + pow(y, 2)) <= d)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3836
N=int(input())
H=list(map(int, input().split()))

for i in range(N):
    if i == 0:
        H[i] -= 1
    else:
        if H[i-1] < H[i]:
            H[i] -= 1
        elif H[i-1] > H[i]:
            print("No")
            break
else:
    print("Yes")


Measured memory_bytes: 15020
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	vector<vector<int>>c(3, vector<int>(3));
	vector<int>a(3), b(3);
	repp(i, 0, 3)repp(j, 0, 3)cin >> c[i][j];
	repp(i, -100, 100) {
		b[0] = i;
		a[0] = c[0][0] - b[0];
		a[1] = c[1][0] - c[0][0] + a[0];
		a[2] = c[2][0] - c[0][0] + a[0];
		b[1] = c[0][1] - c[0][0] + b[0];
		b[2] = c[0][2] - c[0][0] + b[0];
		int count = 0;
		repp(j, 1, 3) {
			repp(k, 1, 3) {
				if (a[j] + b[k] == c[j][k])++count;
			}
		}
		if (count == 4) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n, k; cin >> n >> k;
    long long ans = 0;
    constexpr int mod = 1000000007;
    for (long long i = k; i <= n+1; i++) {
        ans += (n-i+1) * i + 1;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3648
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S, T = list(input().split())
	A, B = getlist()
	U = input()
	if S == U:
		A -= 1
	else:
		B -= 1
	print(A, B)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
ll mod = 1000000007;
ll N;
string S;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> mod >> S;
    if(mod == 2 or mod == 5) {
        ll ans = 0;
        for(int i = 0; i < S.size(); i++) {
            ll val = S[i] - '0';
            if(val % mod == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    map<ll, ll> mp;
    ll now = 0;
    mp[now]++;
    ll digit = 1;
    ll ans = 0;
    for(int i = N - 1; i >= 0; i--) {
        now += digit * (S[i] - '0');
        now %= mod;
        ans += mp[now];
        mp[now]++;
        digit = digit * 10 % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1044
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  int key;
  struct node *r,*l,*par;
}Node;

Node *root,*NIL;

Node* treemin(Node *value){
  while(value->l != NIL)value=value->l;
  return value;
}
Node* find(Node *value,int k){
  while(value!=NIL&&k!=value->key){
    if(k<value->key)value=value->l;
    else value=value->r;
  }
  return value;
}
Node* treesuccess(Node *value1){
  if(value1->r!=NIL)return treemin(value1->r);
  Node *value2=value1->par;
  while(value2!=NIL&&value1==value2->r){
    value1=value2;
    value2=value2->par;
  }
  return value2;
}
void treedel(Node *z){
  Node *x,*y;
  if(z->l==NIL||z->r==NIL)y=z;
  else y=treesuccess(z);
  if(y->l!=NIL){
    x=y->l;
  }
  else{
    x=y->r;
  }
  if(x!=NIL){
    x->par=y->par;
  }
  if(y->par==NIL){
    root=x;
  }
  else{
    if(y==y->par->l){
      y->par->l=x;
    }
    else{
      y->par->r=x;
    }
  }
  if(y!=z){
    z->key=y->key;
  }
  free(y);
}
void insert(int value){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=value;
  z->l=NIL;
  z->r=NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->l;
    }
    else{
      x=x->r;
    }
  }

  z->par=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->l=z;
    }
    else{
      y->r=z;
    }
  }
}
void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}
int main(){
  int n,i,a;
  char ary[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",ary);
    if(strncmp(ary,"f",1)==0){
      scanf("%d",&a);
      Node *v=find(root,a);
      if(v!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(ary,"insert")==0){
      scanf("%d",&a);
      insert(a);
    }
    else if(strcmp(ary,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(ary,"delete")==0){
      scanf("%d",&a);
      treedel(find(root,a));
    }
  }
  return 0;
}
    



Measured memory_bytes: 20524
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		if (h >= K) ans++;
	}
	cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++)
    {
        c[i] = i + 1;
    }

    map<vector<int>, int> mp;
    do
    {
        mp[c] = mp.size();
    } while (next_permutation(c.begin(), c.end()));
    
    cout << abs(mp[b] - mp[a]) << endl;
}

Measured memory_bytes: 8616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>

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

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

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    string s;

    for(int i = 0; i < n; i++) {
        cin >> s;
        if(s == "AC") {
            ac++;
        } else if(s == "WA") {
            wa++;
        } else if(s == "TLE") {
            tle++;
        } else {
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

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

int main()
{
  long double A , B , H , M , sa ,ans;
  cin >> A >> B >> H >> M ;
  
  H*=30;
  M*=6;
  H+=M/12;
  if(H==0)
    H=360;
  if(M==0)
    M=360;
  sa = min(abs(H-M),abs(M-H));
  sa/=180;
  sa*=3.14159265358979323846;
  ans=A*A+B*B-(2*A*B*cos(sa));
  ans=sqrtl(ans);
  cout << setprecision(15) << ans << endl;
     
return 0;
}

Measured memory_bytes: 4168
// problem: "https://atcoder.jp/contests/abc156/tasks/abc156_a"

#include<bits/stdc++.h>

using namespace std;

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

    if(n >= 10)
        cout<<r;

    else
        cout<<r + 100*(10-n);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n), for(int i=0;i<n;i++)





int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int N;
    cin>>N;
    if(N%2==0){
        cout << N <<endl;
    }else{
        cout << 2*N <<endl;
    }
    


    return 0;
}

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

#define INF (INT32_MAX/2)
#define MAX 100000

int N, M;
vector<int> v[MAX + 1];

int memo[MAX + 1];

int dfs( int i )
{
	if( v[i].size() == 0 ) {
		return 0;
	}
	if( memo[i] ) {
		return memo[i];
	}
	int res = 0;
	for( int j = 0; j < v[i].size(); j++ ) {
		int d = dfs( v[i][j] ) + 1;
		res = max( res, d );
	}
	memo[i] = res;
	return res;
}

int main() {
	cin >> N >> M;
	for( int i = 0; i < M; i++ ) {
		int x, y;
		cin >> x >> y;
		v[x].push_back( y );
	}

	int ans = 0;
	for( int i = 1; i <= N; i++ ) {
		if( v[i].size() == 0 ) {
			continue;
		}
		int d = dfs( i );
		ans = max( ans, d );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8192
#include <iostream>

int main()
{
    int oddCount = 0;
    std::cin >> oddCount;

    int evenCount = 0;
    std::cin >> evenCount;

    int answer = 0;
    if (oddCount >= 2)
    {
        answer += oddCount * (oddCount - 1) / 2;
    }

    if (evenCount >= 2)
    {
        answer += evenCount * (evenCount - 1) / 2;
    }

    std::cout << answer;
    return 0;
}

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

int main() {
	string s, s1;
	cin >> s >> s1;
	int len = s.length();
	int len1 = s1.length();
	
	if (len != len1) {
		cout << "No" << endl;
		return 0;
	}
	
	for (int i = 1; i <= len; i++) {
		if (s == s1) {
			cout << "Yes" << endl;
			return 0;
		}
		char tmp = s[len-1];
		for (int j = len-1; j > 0; j--) {
			s[j] = s[j-1];
		} 
		s[0] = tmp;
	}
	
	if (s == s1) {
			cout << "Yes" << endl;
			return 0;
	}
	
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char c[100005],d[100005];
long long int a[100005],b[100005],s,n,m;
long long int findmin(long long int x,long long int y)
{
    long long int n=x,m=y,z;
    while(y!=0)
    {
        z=x%y;
        x=y;
        y=z;
    }
    return m*n/x;
}
int judge()
{
    int flag=1;
    a[0]=1,b[0]=1;
    for(int i=1; i<=n-1; i++)
    {
        a[i]=(i*(s/n))+1;
    }
    for(int i=1; i<=m-1; i++)
    {
        b[i]=(i*(s/m))+1;
    }
    for(int i=0,j=0; j<m&&i<n;)
    {
        if(a[i]==b[j])
        {
            if(c[i]!=d[j])
                flag=0;
            i++;j++;
        }
        else if(a[i]>b[j])
            j++;
        else
            i++;
    }
    if(flag)
        return 1;
    return 0;
}
int main()
{
    while(scanf("%lld%lld",&n,&m)==2)
    {

        scanf("%s",c);
        scanf("%s",d);
        s=findmin(n,m);
        int flag=judge();
        if(flag)
            printf("%lld\n",s);
        else
            printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	char a;
	int b=0;
	while(cin>>a){
		if(b==0 and a=='L'){cout<<"No"<<endl;return 0;}
		if(b==1 and a=='R'){cout<<"No"<<endl;return 0;}
		b=abs(b-1);
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

ll gcd(ll a,ll b){
    if(a == 0) return b;
    else return gcd(b%a, a);
}

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

	cin >> M;
	ans = abs(M-X);
	for (int i = 1; i < N; i++) {
		cin >> M;
		ans = gcd(ans, abs(M - X));
	}
	cout << ans << endl;
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  char a;
  cin >> a;

  if (a <= 'Z')
    cout << 'A' << '\n';
  else
    cout << "a\n";
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define sf1(a); scanf("%d",&a);
#define sf2(a,b); scanf("%d %d",&a, &b);
#define sf3(a,b,c); scanf("%d %d %d",&a, &b,&c);
#define sf4(a,b,c,d); scanf("%d %d %d %d",&a, &b,&c,&d);
#define pf1(a); printf("%d\n",a);
#define pf2(a,b); printf("%d %d\n",a,b);
#define pf3(a,b,c); printf("%d %d %d\n",a,b,c);
#define pf4(a,b,c,d); printf("%d %d %d %d\n",a,b,c,d);

using namespace std;

int main()
{
    int a,b,c,mx=0,ans;
    cin>>a>>b>>c;
    mx=max(a,max(b,c));
    if(mx==a) ans=a*10+b+c;
    else if(mx==b) ans=b*10+a+c;
    else ans=c*10+b+a;
    cout<<ans<<endl;
    return 0;
}


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

const int maxn = 3e5+2;

int a[maxn];
int t;

int main()
{
	int k,n; cin>>k>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+1+n);
	int big = 0;
	for(int i=2;i<=n;++i)
	{
		big = max(big,a[i]-a[i-1]);
	}
	big = max(big,k-a[n]+a[1]);
	cout<<k-big<<"\n";
}

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

int main(){
   int a,b,x;
   cin >> a >> b >> x;
   if(x>=a && a+b>=x){
      cout<<"YES";
   }else{
      cout<<"NO";
   }
   return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> S( n + 1 );
	for( int i = 0; i < n; i++ ) {
		cin >> S[i];
	}

	int ans = 0;
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		int T;
		cin >> T;
		S[n] = T;
		int j = 0;
		while( S[j] != T ) j++;
		if( j < n ) ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int K,T;
    cin >> K >> T;
    priority_queue<pair<int,int>> A;
    rep(i,T){
        int a;
        cin >> a;
        A.push({a,i});
    }
    int ans = 0;
    pair<int,int> yest;
    pair<int,int> today;
    rep(i,K){
        if(i==0){
            yest = A.top();
            A.pop();
            yest.first--;
            //cout << yest.second << endl;
            if(A.empty() && yest.first != 0) A.push(yest);
            continue;
        }
        today = A.top();
        A.pop();
        if(today.second == yest.second) ans++;
        today.first--;
        if(A.empty() && today.first != 0) A.push(today),yest = today;
        else{
            if(yest.first != 0) A.push(yest);
            yest = today;
        }
        //cout << yest.second << endl;
        
    }
    //cout << endl;
    cout << ans << endl;
    
    
    return 0;
}



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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int A,B,C;

cin>>A>>B>>C;

int limit=A-B;
int nokori=C-limit>0 ?C-limit:0;
cout<<nokori<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

string s;
int main(){
    cin>>s;
    ll ans=s.length();
    ll scnt=0;
    for(auto c:s){
        if(c=='S'){
            scnt++;
        }else{
            if(scnt>=1){
                ans-=2;
                scnt--;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
//  ©   ___MRX___

#include <bits/stdc++.h>
    using namespace std;

#define ll long long int

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

    int a, b, x;
    cin >> a >> b;
    x = a + b;

    if(x % 2) {
        cout << "IMPOSSIBLE" << '\n';
    }
    else {
        cout << x / 2 << '\n';
    }

    return 0;
}


Measured memory_bytes: 3632
N,X=map(int,input().split())

a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(N,X):
    if N==0:
        return 0 if X<=0 else 1
    elif X<=1+a[N-1]:
        return f(N-1,X-1)
    else:
        return p[N-1]+1+f(N-1,X-2-a[N-1])

print(f(N,X))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll= long long;
using ld= long double;
using P =pair<ll,ll>;
 
//これを見る初心者の方へ:mainより上のいっぱい書いてあるやつはプログラムを簡略化するためのものです。自分も最近知りました。各種コメントをつけているので参考にしてみてください(検索すればqittaとかでも色々見つかるので探してみてください)
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sort(a) sort(ALL(a))//sortの省略
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define in(T, x) T x;cin >> x;//Tは型,xが入力値
#define vec(T,a,n,x) vector<T> a(n,x);
#define vec2(T,a,n,m) vector<vector<T>> a(n,vector<T>(m));
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define out(x) cout << x << endl//出力
#define bout(b) if(b){out("Yes");}else{out("No");}//真偽問題に対する出力
#define ain(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}//配列の宣言と入力
#define a2in(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}//2つの配列を同時宣言、入力
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }//dp表とかで最大値更新するやつ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }//最小値更新
 
 
 
signed main(){
  in(ll,N);
  ll dp[100010][3];
  ll h[100010][3];
  
  REP(i,N){
    REP(j,3){
      cin>>h[i][j];
    }
  }
  
  
  
  REP(i,N){
    REP(j,3){
      REP(k,3){
        if(j==k) continue;
        chmax(dp[i + 1][k], dp[i][j] + h[i][k]);
      }
    }
  }
  ll ans=0;
  REP(i,3) chmax(ans,dp[N][i]);
  out(ans);
  
  
}

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

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll total = b - a + 1;
  ll cd = lcm(c, d);
  ll mula = b / c - a / c;
  if (a % c == 0) {
    mula += 1;
  }

  ll mulb = b / d - a / d;
  if (a % d == 0) {
    mulb += 1;
  }

  ll mulc = b / cd - a / cd;
  if (a % cd == 0) {
    mulc += 1;
  }
  ll k = mula + mulb - mulc;
  cout << total - k << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int a[500000] = { 0 },cnt=0;

void merge(int left, int mid, int right)
{
	int i, j;
	int n1 = mid - left;
	int n2 = right - mid;
	int *L = new int[n1 + 1];
	int *R = new int[n2 + 1];

	for (i = 0; i != n1; ++i)
	{
		L[i] = a[left + i];
	}
	for (i = 0; i != n2; ++i)
	{
		R[i] = a[mid + i];
	}
	L[n1] = R[n2] = 1000000001;
	i = j = 0;

	for (int k = left; k != right; ++k)
	{
		++cnt;
		if (L[i] > R[j])
		{
			a[k] = R[j];
			++j;
		}
		else
		{
			a[k] = L[i];
			++i;
		}
	}
	delete []L;
	delete []R;
}


void mergeSort(int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
}


int main()
{
	int n;
	

	ios::sync_with_stdio(false);

	cin >> n;

	for (int i = 0; i != n; ++i)
	{
		cin >> a[i];
	}

	mergeSort(0, n);

	for (int i = 0; i != n; ++i)
	{
		if (i)
		{
			cout << " ";
		}
		cout<< a[i];
	}
	cout << endl << cnt << endl;

	return 0;

}


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

using namespace std;
typedef long long LL;

LL gcd(LL a, LL b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

LL calc(LL X, LL C, LL D) {
  LL E = C / gcd(C, D) * D;

  LL ret = X - X / C - X / D + X / E;
  // cout << ret << endl;
  return ret;
}

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

  cout << calc(B, C, D) - calc(A - 1, C, D) << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC118
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[] array = ReadInts();
            Array.Sort(array);
            int[] costs = new int[9] { 2, 5, 5, 4, 5, 6, 3, 7, 6 };
            int[] dp = new int[n + 10];
            for (int i = 0; i < dp.Length; i++) dp[i] = int.MinValue;
            dp[0] = 0;
            for (int i = 0; i < n; i++)
            {
                if (i > 0 && dp[i] == int.MinValue) continue;
                
                for (int j = 0; j < m; j++)
                {
                    dp[i + costs[array[j] - 1]] 
                        = Math.Max(dp[i] + 1, dp[i + costs[array[j] - 1]]);
                }
            }
            string res = "";
            //for (int i = 0; i <= n; i++) Console.WriteLine(dp[i]);
            for (int i = n; i > 0;)
            {
                for (int j = m - 1; j >= 0; j--)
                {
                    if (i - costs[array[j] - 1] < 0) continue;
                    if (dp[i - costs[array[j] - 1]] == dp[i] - 1)
                    {
                        res += (char)(array[j] + '0');
                        i -= costs[array[j] - 1];
                        break;
                    }
                }
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 26964
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
   int n;
   string s,t;
   cin >>n >> s >> t;
   for(int i =0; i<n-1; i++){
       cout <<  s.at(i) << t.at(i);
   }
   cout << s.at(n-1) << t.at(n-1) <<  endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int vmax = 2e5 + 5;

signed main() {
  int N, C;
  cin >> N >> C;
  vector<int> s(N), t(N), c(N);
  for (size_t i = 0; i < N; i++) {
    cin >> s[i] >> t[i] >> c[i];
  }
  vector<vector<int>> tbl(C, vector<int>(vmax, 0));

  for (int i = 0; i < N; i++) {
    tbl[c[i] - 1][2 * s[i] - 1]++;
    tbl[c[i] - 1][2 * t[i]]--;
  }
  for (int j = 0; j < C; j++) {
    for (int i = 0; i < vmax - 1; i++) {
      tbl[j][i + 1] += tbl[j][i];
    }
  }
  int ans = 0;
  for (int i = 0; i < vmax; i++) {
    int mx = 0;
    for (int j = 0; j < C; j++) {
      if (tbl[j][i] > 0) mx++;
    }
    ans = max(ans, mx);
  }
  cout << ans << endl;
}

Measured memory_bytes: 25728
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x)
	cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,k,n,c=0;
    char ch[100],p;
    scanf("%d",&n);
    p=getchar();
        for(i=0;i<n;i++)
        {
            scanf("%c",&ch[i]);
        }
    if(n%2!=0)
        printf("No\n");
    else{  k=n/2;
        for(i=0,j=k;i<n/2;i++,j++)
        {
            if(ch[i]==ch[j])
            {
                c++;
            }
            //printf("%c ",ch[i]);
            //printf("%c ",ch[j]);
        }
        if(c==k)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128