akhauriyash/Code-Regression huggingface dataset:
using static System.Console;

namespace For_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = ReadLine();
            long K = long.Parse(ReadLine());
            int ans = 0;

            for (int i = 0;i< S.Length; i++)
            {
                int a = int.Parse(S.Substring(i, 1));
                if (a == 1)
                {
                    K--;
                    if (K == 0)
                    {
                        ans = 1;
                        goto Ken;
                    }
                }else
                {
                    ans = a;
                    goto Ken;
                }
            }
            Ken:

            WriteLine(ans);
            ReadLine();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    int i;
    int counta = 0;
    int countb = 0;
    scanf("%d %d",&a,&b);
    for (i = 0; i < a; i++){
        counta = counta * 10;

        counta = counta + b;
    }
    for (i = 0; i < b; i++){
         countb = countb * 10;

        countb = countb + a;     
    }
    if (a > b){
        printf("%d",counta);
    }else{
        printf("%d",countb);
    }

}


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

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

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

#define INF 1e16

ll n,W;
ll w[111],v[111];
ll dp[111][111][433];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>W;
  rep(i,n)cin>>w[i]>>v[i];
  rep(i,n)rep(j,100)rep(k,330){
    maxch(dp[i+1][j+1][k+w[i]-w[0]],dp[i][j][k]+v[i]);
    maxch(dp[i+1][j][k],dp[i][j][k]);
  }
  ll res=0;
  rep(j,111)rep(k,433){
    if(j*w[0]+k<=W){
      maxch(res,dp[n][j][k]);
    }
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 38656
#include <stdio.h>
int main() {

	int n, i, j, k, card[4][13], y;
	char x;

	for (i = 0; i < 4; i++)//初期化処理
	{
		for (j = 0; j < 13; j++) 
		{
			card[i][j] = 0;
		}
	}

	scanf("%d", &n);

	for (k = 0; k < n * 2; k++) //フラグ立て
	{
		scanf("%c %d", &x, &y);

		if (x == 'S') 
		{
			card[0][y - 1] = 1;
		}

		else if (x == 'H') 
		{
			card[1][y - 1] = 1;
		}

		else if (x == 'C')
		{
			card[2][y - 1] = 1;
		}

		else if (x == 'D')
		{
			card[3][y - 1] = 1;
		}
	}

	for (i = 0; i < 4; i++) //文字の方
	{

		for (j = 0; j < 13; j++)//数字
		{

			if (card[i][j] == 0) //フラグが立ってなかったら「ないよ」って表示
			{
				if (i == 0) 
				{
					printf("S %d", j + 1);
				}

				else if (i == 1) 
				{
					printf("H %d", j + 1);
				}

				else if (i == 2)
				{
					printf("C %d", j + 1);
				}

				else if (i == 3) 
				{
					printf("D %d", j + 1);
				}
				printf("\n");
			}
		}
	}
	return 0;//おわり
}



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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> all; all.reserve(N * 3);
	for (int i = K; i < K + N * 3; i++) {
		all.push_back(i);
	}
	int cnt = N / 2;
	vector<pair<ll, ll>> res;
	for (int i = 0; i < cnt; i++) {
		res.emplace_back(all[N - cnt + i], all[N + i]);
	}
	for (int i = cnt; i < N; i++) {
		res.emplace_back(all[i - cnt], all[N + i]);
	}
	sort(res.begin(), res.end(), [&](const auto& l, const auto& r) {
		return (l.first + l.second) < (r.first + r.second);
	});
	bool ng = false;
	for (int i = 0; i < N; i++) {
		if ((res[i]).first + (res[i]).second > (all[N * 2 + i])) {
			ng = true;
			break;
		}
	}
	if (ng) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		printf("%d %d %d\n", (int)(res[i]).first, (int)(res[i]).second, (int)(all[N * 2 + i]));
	}
	return 0;
}


Measured memory_bytes: 7280
#include<stdio.h>
int main(void)
{
	int n,m,a[200],b[200],k,x,i,j;
	scanf("%d %d", &n, &m);
	for(i=1; i<=2*n; i++)
	a[i]=i;
	for(i=0; i<m; i++)
	{
		scanf("%d", &k);
		for(j=1; j<=2*n; j++)
		b[j]=a[j];
		if(k>0)
		{
			for(j=k+1; j<=2*n; j++)
			a[j-k]=b[j];
			for(j=2*n-k+1; j<=2*n; j++)
			a[j]=b[j-(2*n-k)];
		}
		else
		{
			x=1;
			for(j=1; j<2*n; j+=2)
			{
				a[j]=b[x];
				x++;
			}
			for(j=2; j<=2*n; j+=2)
			{
				a[j]=b[x];
				x++;
			}
		}
	}
	for(i=1; i<=2*n; i++)
	printf("%d\n", a[i]);
	
	return 0;
}


Measured memory_bytes: 2032
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int cnt = 0;
		int N = sc.nextInt();
		int[] h = new int[N+1];
		h[0] = 0;
		for(int i=1;i<N+1;i++){
			h[i] = sc.nextInt();
        }	
		for(int j=1;j<N+1;j++){
			if(h[j]-h[j-1]>=0){
				cnt += (h[j]-h[j-1]);
			}
		}
		System.out.println(cnt);
    }
}

Measured memory_bytes: 21588
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
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*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
string s,t;
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin>>s;
    cin>>t;
    int len=s.length();
    for(int i=0;i<=len-1;i++){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int a, b, c, res;
int main(void){
    // Your code here!
    cin >> a >> b >> c;
    if (a == b) res++;
    if (b == c) res++;
    if (c == a) res++;
    if (res == 0) cout << 3 << endl;
    if (res == 1) cout << 2 << endl;
    if (res == 3) cout << 1 << endl;
}


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

int main()
{
    int a,b,ans=0;
    cin>>a>>b;
    for (int i=a; i<=b; i++)
    {
        string s=to_string(i);
        if (s[0]==s[4] && s[1]==s[3]) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
N = int(input())
graph = [[float("inf") for _ in range(N)] for _ in range(N)]
for i in range(N):
    a_list = list(map(int, input().split()))
    for j in range(N):
        if i == j:
            continue
        graph[i][j] = a_list[j]
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
w_graph = floyd_warshall(graph, directed=False)
for i in range(N):
    w_graph[i][i] = float("inf")
result = 0
for i in range(N):
     w_graph[i][i] = float("inf")
for i in range(N):
    for j in range(i):
        if w_graph[i][j] != graph[i][j]:
            print(-1)
            exit()
        if w_graph[i][j] < np.min(w_graph[i] + w_graph[j]):
            result += w_graph[i][j]
print(int(result))


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

int main() {
  string S;
  cin >> S;
  long long max = S.size();
  S += 'R';
  vector<long long> ans(max, 0);
  
  long long L_loc = 1;
  long long R_loc = 0;
  long long R_tmp = 0;
  long long L_tmp = 0;

  for (int i = 0; i < max; i++) {
    if (S.at(i) == 'R' && S.at(i+1) == 'L') {
      R_loc = i;
      L_loc = i + 1;
      R_tmp++;
      ans.at(R_loc) += (R_tmp / 2) + (R_tmp % 2);
      ans.at(R_loc + 1) += (R_tmp / 2);
      R_tmp = 0;
    }
    else if (S.at(i) == 'R' && S.at(i+1) == 'R') {
      R_tmp++;
    }
    else if (S.at(i) == 'L' && S.at(i+1) == 'L') {
      L_tmp++;
    }
    else if (S.at(i) == 'L' && S.at(i+1) == 'R') {
      L_tmp++;
      ans.at(L_loc) += (L_tmp / 2) + (L_tmp % 2);
      ans.at(L_loc - 1) += (L_tmp / 2);
      L_tmp = 0;
    }
  }
  
  for (int i = 0; i < max; i++) {
    cout << ans.at(i) << " ";
  }
  cout << endl;
}

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

long long ans=0;
vector<long long> v;

void dfs(int n, int i, long long sum, long long now){
  if(i==n-1)ans+=sum+now;
  else{    
    dfs(n, i+1, sum, now*10+v[i+1]);

    dfs(n, i+1, sum+now, v[i+1]);
  }
  
}

int main(){
  long long s;
  cin>>s;

  while(s!=0){
    v.push_back(s%10);
    s/=10;
  }

  reverse(v.begin(), v.end());
  int n=v.size();

  dfs(n, 0, 0, v[0]);

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }

            int[][] sp = new int[21][21];
            for (int i = 0; i < n; i++) {
                sp[sc.nextInt()][sc.nextInt()] = 1;
            }
            int m = sc.nextInt();
            int px = 10;
            int py = 10;
            int c = 0;
            for (int i = 0; i < m; i++) {
                String dir = sc.next();
                int d = sc.nextInt();
                int dx = 0;
                int dy = 0;
                if ("N".equals(dir)) {
                    dy = 1;
                } else if ("S".equals(dir)) {
                    dy = -1;
                } else if ("E".equals(dir)) {
                    dx = 1;
                } else {
                    dx = -1;
                }
                for (int j = 0; j < d; j++) {
                    px += dx;
                    py += dy;
                    if (sp[px][py] == 1) {
                        c++;
                        sp[px][py] = 0;
                    }
                }
            }
            System.out.println(c == n ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 42372
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n; string ans = "No";
    cin >> n;
    for(int i = 1; i <= 9; ++i){
        for(int j = 1; j <= 9; ++j){
            if(i * j == n) ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;
    
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
    while(x!=NIL){
        y=x;
        if(z->key<x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else{
        if(z->key<y->key) y->left=z;
        else y->right=z;
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 26708
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    uint32_t ll;
    double ans;
    cin >> ll;

    ans = ((double)ll / 3.0) * ((double)ll / 3.0) * ((double)ll / 3.0);

    cout << fixed;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
input=sys.stdin.readline


def solve():
    N, K = map(int, input().split())
    MOD = 10**9+7

    d = defaultdict(list)
    for _ in range(N-1):
        a, b = map(int, input().split())
        d[a].append(b)
        d[b].append(a)

    ans = K
    q = deque([1])
    used = [False]*(N+1)
    used[1] = True

    while q:
        s = q.popleft()
        pos = 1 if s==1 else 2
        for t in d[s]:
            if used[t]:continue
            used[t] = True
            ans *= (K-pos)
            ans %= MOD
            pos += 1
            q.append(t)

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 69652
// C++11
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  if (vec.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
    os << vec.back() << '}';
  }
  return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
  if (arr.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
    os << arr.back() << '}';
  }
  return os;
}

double siglog(double a){
  return a * log(a) - a;
}

double logComb(int n, int r){
  double ans = 0.0;
  ans += siglog(n);
  ans -= siglog(r);
  ans -= siglog(n-r);

  return ans;
}

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

  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());

  int ansai = a[1], ansaj = a[0];
  double maxComb = 0.0;
  for(int i = n-1; i > 0; i--){
    int const ai = a[i];
    int const ai2 = ai / 2;
    auto s = upper_bound(a.begin(), a.begin() + i, ai2);
    if(s == a.begin()) ;
    else if(abs(*s - ai / 2.0) < abs(*prev(s) - ai / 2.0)) ;
    else s = prev(s);
    if(logComb(ai, *s) > maxComb){
      maxComb = logComb(ai, *s);
      ansai = ai;
      ansaj = *s;
    }
  }
  cout << ansai << ' ' << ansaj << endl;

  return 0;
}

Measured memory_bytes: 1024
import heapq

def dijkstra(s,g,m):
    global pq
    global d
    color=[0]*n
    d=[float('inf')]*n
    d[s]=0
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        color[u]=2
        if d[u]<t:
            continue
        for v in g[u]:
            if color[v]!= 2:
                if d[u]+m[u][v]<d[v]:
                    d[v]=d[u]+m[u][v]
                    color[v]=1
                    heapq.heappush(pq,[d[v],v])

while 1:
    pq=[]
    n,m=map(int,raw_input().split())
    g=[[] for _ in xrange(m)]
    cost=[[0]*m for _ in xrange(m)]
    time=[[0]*m for _ in xrange(m)]
    if n==m==0:
        break
    for i in xrange(n):
        a,b,c,t=map(int,raw_input().split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)
        cost[a-1][b-1]=c
        cost[b-1][a-1]=c
        time[a-1][b-1]=t
        time[b-1][a-1]=t
    k=input()
    for i in xrange(k):
        p,q,r=map(int,raw_input().split())
        if r==0:
            dijkstra(p-1,g,cost)
            print(d[q-1])
        else:
            dijkstra(p-1,g,time)
            print(d[q-1])

Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    INIT;
    vi mem(26, INF);
    cin >> N;
    REP(i, N) {
        vi v(26);
        cin >> S;
        REP(j, S.size()) {
            int ind = S[j] - 'a';
            v[ind]++;
        }
        REP(j, 26) {
            mem[j] = min(v[j], mem[j]);
        }
    }
    REP(i, 26) {
        REP(j, mem[i]) {
            T += char('a' + i);
        }
    }
    sort(ALL(T));
    cout << T << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

int org[50];
int fix[50];

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

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

	sort(org, org+n);

	int count = 0;

	for(int i = 0; i < n; ++i){
		if(org[i] == fix[i]){
			//nothing
		}else{
			++count;
		}
	}

	if(count <= 2){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

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


int main() {
  long long X;
  cin >> X;
  long long A = 100;
  for(int i = 0; i < 10000000; i++) {
    A = A * 1.01;
    if(A >= X) {
      cout << i+1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3636
def score(a,b):
    if b-a >= 0:
        return a
    else:
        return 10**6+1-b

N = int(input())

A = [0]*N
B = [0]*N

for i in range(N):
    S = input()
    a = 0
    b = 0
    for j in range(len(S)):
        if S[j] == ')':
            a += 1
        else:
            a -= 1
        A[i] = max(A[i],a)

        if S[-j-1] == '(':
            b += 1
        else:
            b -= 1
        B[i] = max(B[i],b)

#print('S',S)
#print('A',A)
#print('B',B)

L = sorted(list(range(N)),key = lambda i:score(A[i],B[i]))

SA = 0
SB = 0

#print('L',L)

for i in range(N):
    if SB > A[L[i]]:
        SB += B[L[i]] - A[L[i]]
    else:
        SA += A[L[i]]-SB
        SB = B[L[i]]
    #print(SA,SB)

if SA == 0 and SB == 0:
    print('Yes')
else:
    print('No')

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

int array[20];

int dif(int n, int A, int B)
{
	int l, r;
	
	if (n < 0){
		return (abs(A - B));
	}
	
	l = dif(n - 1, A + array[n], B);
	r = dif(n - 1, A, B + array[n]);
	
	if (l < r){
		return (l);
	}
	else {
		return (r);
	}
}

int main(void)
{
	int i, n;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		printf("%d\n", dif(n - 1, 0, 0));
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int b[n+1];
    repr(i,1,n){
        cin>>b[i];
    }
    b[n]=b[n-1];
    b[0]=b[1];
    int res = b[0];
    repr(i,1,n){
        if(b[i]<b[i+1]){
            res += b[i];
        }else{
            res += min(b[i],b[i+1]);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N, M;
    cin >> N >> M;
    ll n = 2*M+N, m = MOD2, inv[n+1];
    rep2(i, 1, n){
        inv[i] = 1;
        ll e[31];
        e[0] = i;
        rep2(j, 1, 30) e[j] = (e[j-1]*e[j-1]) % m;
        ll k = m-2;
        int count = 0;
        while(k > 0){
            if(k % 2 == 1) inv[i] *= e[count], inv[i] %= m;
            k /= 2;
            count++;
        }
    }
    ll fac[n+1], ifac[n+1];
    fac[0] = 1, ifac[0] = 1;;
    rep2(i, 1, n){
        fac[i] = (fac[i-1]*i)%MOD2;
        ifac[i] = (ifac[i-1]*inv[i])%MOD2;
    }
    ll k = min(N, M);
    if((M-k)%2 == 1) k--;
    ll ans = 0;
    while(k >= 0){
        ll tmp1 = k, tmp2 = N-k, i = (3*M-k)/2, j = i-M, comb = fac[i+N-1], comb1 = fac[N];
        comb *= ifac[N-1], comb %= MOD2;
        comb *= ifac[i], comb %= MOD2;
        comb1 *= ifac[k], comb1 %= MOD2;
        comb1 *= ifac[N-k], comb1 %= MOD2;
        tmp1 *= fac[j+N-1], tmp1 %= MOD2;
        tmp1 *= ifac[N-1], tmp1 %= MOD2;
        tmp1 *= ifac[j], tmp1 %= MOD2;
        j--;
        if(j >= 0){
            tmp2 *= fac[j+N-1], tmp2 %= MOD2;
            tmp2 *= ifac[N-1], tmp2 %= MOD2;
            tmp2 *= ifac[j], tmp2 %= MOD2;
        }
        else tmp2 = 0;
        ll p = (comb + 2*MOD2 -(tmp1+tmp2))%MOD2;
        ans += comb1*p % MOD2;
        ans %= MOD2;
        k -= 2;
    }
    cout << ans << endl;
}

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

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

Measured memory_bytes: 256
#解説AC
#回転行列とベクトルで処理する
x1,y1,x2,y2 = map(int,input().split())
x4 = x1-(y2-y1)
y4 = y1+(x2-x1)
x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
print(x3,y3,x4,y4)

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

int main()
{
int w,a,b,x=0;
cin>>w>>a>>b;
if(a>b)
{
    x=a-(b+w);
    cout<<x;
}
else
{
    if(a+w>=b)
    {
        cout<<"0";
    }
    else
    {
        x=b-(a+w);
        cout<<x;
    }
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    int x; cin >> x;
    int y; cin >> y;

    cout << x + y / 2 << '\n';
    return 0;
}





Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int ind = max_element(a, a + N) - a;
  vector<int> b;
  for(int i = 0; i < N; i++){
    if(i != ind){
      b.push_back(a[i]);
    }
  }

  int mxa = *max_element(a, a + N);
  int mxb = *max_element(b.begin(), b.end());

  //cout << ind << endl;
  for(int i = 0; i < N; i++){
    if(i == ind){
      cout << mxb << endl;
    } else {
      cout << mxa << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && b == c) || (a != b && b != c && c != a)) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }

}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long; 
ll dp[3003][3003][4]; 
ll a[3003][3003];
int r,c; ll res=0;  
ll cal(int i,int j,int k)
{ 
  if(dp[i][j][k]!=-1) return dp[i][j][k]; 
  ll ans=0; 
  if(i==r-1 and j==c-1)
  {
    if(k) ans=a[i][j]; else ans=0; 
  }
  if(i<r-1 and k==0) ans=max(cal(i+1,j,3),ans); 
  if(i<r-1 and k>0) ans=max(cal(i+1,j,3)+a[i][j],ans); 
  
  if(j<c-1) ans=max(cal(i,j+1,k),ans);
  if(k>0 and j<c-1) ans=max({ans,cal(i,j+1,k-1)+a[i][j],cal(i,j+1,k)});
  else if(j<c-1){ ans=max(ans,cal(i,j+1,k)); }
  
  dp[i][j][k]=ans; 
  return ans;   
}
void solve()
{
 int k;  cin>>r>>c>>k; int x,y,v; 
 for(int i=0;i<=k-1;i++)
 {
  cin>>x>>y>>v; x--; y--; a[x][y]=v;  
 }
 memset(dp,-1,sizeof(dp)); 
 cout<<cal(0,0,3)<<"\n"; 
}
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  ios_base::sync_with_stdio(false); 
  cin.tie(nullptr); 
  int t=1; 
  while(t--)
  {
    solve(); 
  }
  return 0; 
}


Measured memory_bytes: 356204
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
	_typer init = 0;
	char ch = getchar(), k = 0;
	for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
	for ( ; isdigit(ch); ch = getchar()) init = (init << 3) + (init << 1) + (ch ^ 48);
	return k ? -init : init;
}
const ll N = 105, INF = 1e9;
const ll M = 32000, Mod = 1e9 + 7;

/*******************************************************************************
 *
 * 根号
 *
 ******************************************************************************/

int n, k;
ll f[N][M << 1], Cnt[M << 1];
int L[M << 1], R[M << 1];
// 把 sqrt(n) -> n 分成 sqrt(n) 份

int main() {
	k = read<int>(), n = read<int>();
	int y = 1, cnt = 0;
	while (y <= k) {
		int t = k / y;
		int c = k / t;
		L[++cnt] = y, R[cnt] = c;
		// cout << y << " " << c << endl;
		y = c + 1;
	}
	rep (i, 1, cnt) f[1][i] = Cnt[i] = R[i] - L[i] + 1;
	rep (i, 2, n) {
		ll Sum = 0;
		rep (j, 1, cnt) {
			(Sum += f[i - 1][j]) %= Mod;
			f[i][cnt - j + 1] = Sum * Cnt[cnt - j + 1] % Mod;
		}
	}
	ll Ans = 0;
	rep (i, 1, cnt) (Ans += f[n][i]) %= Mod;
	cout << Ans << endl;
	return 0;
}



Measured memory_bytes: 52992
#include<stdio.h>

int main(){
	int a, b, ans;
	char c;


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

		if (c == '+'){
			ans = a + b;
		}
		if (c == '-'){
			ans = a - b;
		}
		if (c == '*'){
			ans = a*b;
		}
		if (c == '/'){
			ans = a / b;
		}
		if (c == '?'){
			return 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
// #include<iterator>
// #include <iostream>
// #include<vector>
// #include<algorithm>
// #include<string>
//#define int long long int
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define umii unordered_map<int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second                                 
#define MOD 1000000007
#define space " "
#define endl "\n"
using namespace std;


// int minsteps(vector<int> arr,vector<int> &memo,int i,int n)
// {
//   if(memo[i]!=-1)
//    return memo[i];

//   else if(n-i<=3)
//   {
//   	memo[i]=abs(arr[i]-arr[n-1]);
//   	return memo[i];
//   }

//   else
//   {
//     int a,b;
//     a=abs(arr[i]-arr[i+1])+minsteps(arr,memo,i+1,n);
//     b=abs(arr[i]-arr[i+2])+minsteps(arr,memo,i+2,n);
//     memo[i]=min(a,b);
//     return memo[i];
//  }
// }

int minsteps2(vector<int> arr,int n)
{
  vector<int> memo(n,-1); int a,b;
  if(n<=3)
  {
    for(int i=0;i<n;i++)
    {
    	memo[i]=abs(arr[i]-arr[n-1]);
    }
  }
  else
  {
    int j=n-1;
    while((n-j)<=3)
    {
    	memo[j]=abs(arr[j]-arr[n-1]);
    	j--;
    }
    while(j>=0)
    {
    	a=abs(arr[j]-arr[j+1])+memo[j+1];
    	b=abs(arr[j]-arr[j+2])+memo[j+2];
    	memo[j]=min(a,b);
    	j--;
    }
  }
  return memo[0];
}

int main()
{
  // ios_base::sync_with_stdio(false);
  //     cin.tie(NULL);
      
  //     #ifndef ONLINE_JUDGE
  //     freopen("input.txt", "r", stdin);
  //     freopen("output.txt", "w", stdout);
  //     #endif
 
  int n,t,val; vector<int> arr;
  // cin>>t;
  // while(t--)
  // {
  	cin>>n;
  	vector<int> memo(n,-1);
     for(int i=0;i<n;i++)
      {
        cin>>val;
        arr.pb(val);
      }    
    //cout<<minsteps(arr,memo,0,n)<<endl;
    cout<<minsteps2(arr,n);
    arr.clear();
   memo.clear();
  //}
    return 0;
}

Measured memory_bytes: 1912
# encoding:utf-8
from collections import Counter

def judge(ds, ts):
	for word, cnt in ts.most_common():
		if cnt > ds[word]:
			return "NO"
	return "YES"


def main():
	n = int(input())
	ds = Counter(list(map(int, input().split())))
	m = int(input())
	ts = Counter(list(map(int, input().split())))

	print(judge(ds, ts))



if __name__ == '__main__':
	main()

Measured memory_bytes: 67296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		 Scanner scan = new Scanner(System.in);
		 int a = scan.nextInt();
		 int b = scan.nextInt();
		 int c = scan.nextInt();
		 if(a + b >= c) {
			 System.out.println("Yes");
		 }else {
			 System.out.println("No");
		 }
	}

}

Measured memory_bytes: 22996
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA = 0
sumB = 0
sumAB = 0

for i in range(n):
    sumA += A[i]
    sumB += B[i]

for i in range(n):
    if A[i] < B[i]:
        sumAB += int((B[i] - A[i]) / 2 + 0.5)

if sumAB <= sumB - sumA:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    map<int, int> mp;
    rep(i, n) {
        cin >> a[i];
        mp[-a[i]+i]++;
    }
    ll ans = 0;
    rep(i, n) {
        ans += mp[a[i]+i];
        mp[-a[i]+i]--;
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int counter = 1;
  rep(i,N-1){
    if(S.at(i) != S.at(i + 1)) counter++;
  }
  cout << counter <<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
int res[110][110];
vi v;
vii p;
int main() {
	int a,b,c;
	scanf("%d %d %d ",&a,&b,&c);
	while(c--) {
		int t;
		scanf("%d ",&t);
		v.push_back(t);
	}
	for(int i=0;i<a;i++) {
		for(int j=0;j<b;j++) {
			int id = j;
			if(i%2) {id = b-id-1;}
			p.push_back({i,id});
		}
	}
	int id = 0;
	for(int i=0;i<v.size();i++) {
		for(int j=0;j<v[i];j++) {
			int r = p[id].first,c = p[id].second;
			id++;
			res[r][c] = i+1;
		}
	}
	for(int i=0;i<a;i++) {
		for(int j=0;j<b;j++) {
			if(j > 0) printf(" ");
			printf("%d",res[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

ll dp[1005][1005];

int main() {
    int N, K; cin >> N >> K;

    rep(i, 1005) dp[i][0] = dp[i][i] = 1;

    for (int k = 2; k <= K; k++) {
        for (int n = 1; n <= k; n++) {
            dp[k][n] = dp[k-1][n-1] + dp[k-1][n];
            dp[k][n] %= MOD;
        }
    }
    cout << dp[K][N] << endl;
}



Measured memory_bytes: 9988
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let s: String = read();
    if s == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

ll dp[3005][3005][4];
void solve()
{
	ll r,c,k;
	cin>>r>>c>>k;
	memset(dp,0,sizeof(dp));
	vector<vector<ll>>v(r,vector<ll>(c));
	rep(i,k){
		ll a,b,x;
		cin>>a>>b>>x;
		a--;b--;
		v[a][b]=x;
	}
	rep(i,r){
		rep(j,c+1){
			if(j!=c)for(int a=2;a>=0;--a)chmax(dp[i][j][a+1],dp[i][j][a]+v[i][j]);
			if(j!=c)rep(a,4)chmax(dp[i][j+1][a],dp[i][j][a]);
			rep(a,4)chmax(dp[i+1][j][0],dp[i][j][a]);
		}
	}
	ll ans=0;
	rep(a,4)chmax(ans,dp[r][c][a]);
	cout<<ans<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

using ll=long long;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  bool ans = 0;
  for(int i = 1; i<= B-1; i++){
    if(A*i % B == C) ans = 1;
  }
  cout << ((ans) ?"YES" :"NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long 
using namespace std;

signed main() {
	int N,M;
	cin >> N >> M;
	vector<int> vec(M);
	for(int i = 0;i < M;i++) {
		cin >> vec.at(i);
	}
	bool bk[100010];
  	for(int i = 0;i < 100009;i++) {
      	bk[i] = true;
    }
	for(int i = 0;i < M;i++) {
		bk[vec.at(i)] = false;
	}
	int dp[100010];
	dp[0] = 1;
	if(bk[1] == true) {
		dp[1] = 1;
	}
	else {
		dp[1] = 0;
	}
	for(int i = 2;i <= N;i++) {
		if(bk[i] == true) {
			dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
		}
		else {
			dp[i] = 0;
		}
	}
	cout << dp[N] << endl; 
}

Measured memory_bytes: 1920
from sys import stdin

def main():

    input = stdin.readline

    A,V = map(int,input().split())
    B,W = map(int,input().split())
    T = int(input())


    if(V <=  W):
        print("NO")
    else:
        X = abs(V - W)

        if abs(A - B) / X <= T:
            print("YES")
        else:
            print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
#include <iostream>

using namespace std;
int n,a,b,c,d;
string s;
int main()
{
    //freopen("A.in","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    cin >> n >> a >> b >> c >> d >> s;
    for (int i=a-1;i<max(c,d)-1;i++)
    {
        if (s[i]=='#'&&s[i+1]=='#')
        {
            cout << "No";
            return 0;
        }
    }
    if (c<d)
    {
        cout << "Yes";
        return 0;
    }
    for (int i=b-2;i<min(d-1,n-2);i++)
    {
        if (s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 592
fun main(args:Array<String>) {
    val (r,g,b,n) = readLine()!!.split(" ").map { it.toInt() }

    var ans = 0
    for(i in (0..n)) {
        val remain = n - (r*i)
        if(remain < 0) {
            break
        }
        for(j in (0..n)) {
            val tmp = remain - (j*g)
            if(tmp < 0) {
                break
            }
            if(tmp % b == 0) {
                ans++
            }
        }
    }
    println(ans)
}


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

#define MAX 31
int N;
int curr;
int arr[MAX];

void resetArr() {
    int i;
    //find array element which greater than 1
    if (arr[curr] < 2) {
        while(arr[curr] < 2) {
            curr--;
        }
    }
    int sum = 0;
    //get sum of array until current value
    for (i = 0; i < curr; i++) {
        sum += arr[i];
    }
    int tmp = N - sum - arr[curr] + 1;
    arr[curr]--;
    i = curr;
    while(tmp > 0) {
        arr[++i] = (tmp > arr[curr]) ? arr[curr] : tmp;
        tmp -= arr[curr];
    }
    curr = i;

    if (arr[curr+1] != 0) {
        i = curr+1;
        while (1) {
            if (arr[i] == 0) break;
            arr[i++] = 0;
        }
    }
}

void square(int left) {

    for (int i = 0; i < N; i++) {
        if (arr[i] == 0) break;
        if (i) std::cout << " ";
        std::cout << arr[i];
    }
    std::cout << std::endl;

    if (arr[curr] <= 1) return;

    if (arr[left]-1 >= arr[left+1]+1) {
        arr[left]--; arr[left+1]++;
    } else {
        int idx = left+1, sum = 1;
        arr[left]--;
        while(sum != 0) {
            if (arr[idx] - arr[idx-1] == 0) { idx++; }
            else if (arr[idx] - arr[idx-1] == 1) {  sum++; arr[idx]--; idx++; }
            else if (arr[idx] < arr[idx-1]) {
                if (sum <= arr[idx-1] - arr[idx]) { arr[idx] += sum; break; }
                else {
                    sum -= arr[idx-1] - arr[idx];
                    arr[idx] += arr[idx-1] - arr[idx];
                    idx++;
                }
            }
        }
    }

    if (arr[curr+1] >= 2) ++curr;

    if (arr[left+1] >= 2) {
        while(1) {
            left++;
            if (arr[left+1] < 2) break;
        }
        square(left);
    }

    else if (arr[left] == 1) {
        while(1) {
            left--;
            if (arr[left-1] >= 2) break;
        }
        square(left);
    }
    else {
        square(left);
    }
}

int main()
{
    while(1) {
        std::scanf("%d", &N);
        if (N == 0) break;
        for (int i = 0; i < N; i++) arr[i] = 0;
        arr[0] = N;
        curr = 1;

        while(1) {
            square(curr);
            if (arr[0] == 1) break;
            resetArr();
        }
    }

    return 0;
}



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


int main() {
    int N, K;
    std::cin >> N >> K;

    std::vector<int> As(N);
    for (int i = 0; i < N; i++) {
        std::cin >> As[i];
    }

    for (int i = K; i < N; i++) {
        if (As[i - K] < As[i]) {
            std::cout << "Yes" << std::endl;;
        } else {
            std::cout << "No" << std::endl;
        }
    }
}


Measured memory_bytes: 4048
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String si = sc.nextLine();
        int sum = 0;
        for (int i = 0; i < si.length(); i++) {
            char s = si.charAt(i);
            if (s == '1') {
                sum++;
            }
        }

        System.out.println(sum);
    }
}


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

#define FASTIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;


int main() {
	FASTIO
	ll n, x, t;
	cin >> n >> x >> t;
	ll ans = (n / x) + (n % x != 0);
	ans *= t;
	cout << ans << endl;
}

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

int main() {
    vector<int> v(4, 0);
    for (int i = 0; i < 3; i++) {
        int a, b;
        cin >> a >> b;
        v[a]++;
        v[b]++;
    }
    bool ans = true;
    for (int i = 1; i <= 4; i++) {
        if (v[i] != 2 && v[i] != 1) {
            ans = false;
            break;
        }
    }
    if (ans)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  int x,y;
  cin>>x>>y;

  ll ans=0;
  if(x<=3) ans+=(4-x)*100000;
  if(y<=3) ans+=(4-y)*100000;
  if(x==1&&y==1) ans+=400000;
  cout<<ans<<endl;

}

Measured memory_bytes: 256
N, K = map(int, input().split())

snuke = [0] * N

# K 回ループ
for i in range(K):
    d = int(input()) # A の要素数

    # A をリストとして受け取る
    A = list(map(int, input().split()))

    for j in range(d):
        snuke[A[j] - 1] = 1

ans = 0

for i in range(N):
    if snuke[i] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 9168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

set<ll> v;

int main(void){
	ll n,a,i,j,p[225816],ans=0ll,x,y;
	cin >> n;
	for(i=0ll; i<n; ++i){
		cin >> a;
		p[a-1] = i;
	}
	for(i=0ll; i<n; ++i){
		auto q = v.upper_bound(p[i]);
		if(q == v.end()){
			x = (n-p[i]);
		}else{
			x = *q - p[i];
		}
		if(q == v.begin()){
			y = p[i] + 1;
		}else{
			--q;
			y = p[i] - *q;
			++q;
		}
		ans += (i+1)*x*y;
		v.insert(p[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;

  for(int i=n; i<1000; i++){
    int j=i/100;
    int k=(i%100)/10;
    int l=(i%100)%10;

    if(j==k && k==l){
      std::cout << i << '\n';
      return 0;
    }

  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> primenum;
  primenum.push_back(2);
  for(int i=3;i<=60000;i+=2){
    int k=0;
    for(int j=3;j<=sqrt(i);j+=2){
      if(i%j==0){
	k=1;
	break;
      }
    }
    if(k==0)
      primenum.push_back(i);
  }
  int num;
  while(cin>>num){
    for(int i=0;i<primenum.size();i++){
      if(primenum[i]==num){
	cout<<primenum[i-1]<<" "<<primenum[i+1]<<endl;
	break;
      }else if(primenum[i]>num){
	cout<<primenum[i-1]<<" ";
	cout<<primenum[i]<<endl;
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n; cin >> n;
	string s; cin >> s;
	map<char,int> pre,suf;
	
	for(int i=0;i<n;i++){
		suf[s[i]]++;
	}
	
	int ans=INT_MAX;
	for(int i=0;i<n;i++){
		suf[s[i]]--;
		ans=min(ans,pre['W']+suf['E']);
		pre[s[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
   ll n, m, x;
   cin >> n >> m >> x;

   ll c[n], a[n][m];
   rep(i, n){
       cin >> c[i];
       rep(j, m)cin >> a[i][j];
   }

   ll ans = INF;

   rep(i, (1<<n)){
       ll score[m] = {};

       ll money = 0;
       rep(j, n){
           if((1<<j) & i){
               money += c[j];
               rep(k, m)score[k] += a[j][k];
           }
       }

       bool ok = true;
       rep(j, m)if(score[j] < x){
           ok = false;
           break;
       }

       if(ok)ans = min(ans, money);
   }

   if(ans >= INF)cout << -1 << endl;
   else cout << ans << endl;

}

Measured memory_bytes: 3636
#include <stdio.h>
int main() {
  int N,M;
  scanf("%d %d", &N, &M);
  int K[N];
  int A[100][100];
  int i,j,k; /*index of matrix or array */

  for (i = 0; i < N; ++i) {
    scanf("%d", &K[i]);
    for (j = 0; j < K[i]; ++j) {
      scanf("%d", &A[i][j]);
    }
  }

  int count;
  int ans = 0;
  for (k = 0; k < K[0]; ++k) {
    count = 0;
    for (i = 0; i < N; ++i) {
      for (j = 0; j < K[i]; ++j) {
        if (A[i][j] == A[0][k]) {
          ++ count;
	}
      }
    }   
    if (count == N) {
      ++ ans;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128