akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

char c[128];
string l;
int p;

int no[3]={2,1,0};
int mu[3][3] = {{0,0,0},{0,1,1},{0,1,2}};
int ad[3][3] = {{0,1,2},{1,1,2},{2,2,2}};

int G();

int F(){
	int le = G();
	while(l[p] == '*' || l[p] == '+'){
		if( l[p] == '*' ){
			p++;
			int ri = G();
			le = mu[le][ri];
		}else{
			p++;
			int ri = G();
			le = ad[le][ri];
		}
	}
	return le;
}
int G(){
	if( l[p] == '-' ){
		p++;
		return no[G()];
	}else if( l[p] == '(' ){
		p++;
		int ri = F();
		p++;
		return ri;
	}else{
		if( '0' <= l[p] && l[p] <= '9' ){
			int ri = l[p]-'0';
			p++;
			return ri;
		}else{
			int ri = c[l[p]];
			p++;
			return ri;
		}
	}
	return -1;
}
int main(){
	while(cin >> l && l != "." ){
		int ans = 0;
		for(int i = 0 ; i < 3 ; i++){
			for(int j = 0 ; j < 3 ; j++){
				for(int k = 0 ; k < 3 ; k++){
					c['P'] = i;
					c['Q'] = j;
					c['R'] = k;
					p = 0;
					if( F() == 2 ){
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
		
	}
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;

int dist[1000500][3];


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < 1000500; i++) {
    for (int j = 0; j < 3; j++) {
      dist[i][j] = INT_MAX;
    }
  }
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
  }
  int s, t;
  cin >> s >> t;
  s--; t--;
  queue<p> q;
  // 位置、3の余り
  q.push({s, 0});
  dist[s][0] = 0;
  while(!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for(auto a : to[v]){
      int nl = (l+1)%3;
      if(dist[a][nl] != INT_MAX) continue;
      dist[a][nl] = dist[v][l]+1;
      q.push({a, nl});
    }
  }

  int res = dist[t][0];
  if(res == INT_MAX) res = -1;
  else res /= 3;
  cout << res << endl;


}


Measured memory_bytes: 17408
function Main(input) {
    var N = parseInt(input[0], 10);
    var K = parseInt(input[1], 10);
    var S = input[2];

    var mozi = S.charAt(K - 1);
    var result = '';

    for (var i=0; i<N; i++) {
        if (i + 1 === K) {
            if (mozi === 'A') {
                result += 'a'
            } else if (mozi === 'B') {
                result += 'b'
            } else if (mozi === 'C') {
                result += 'c'
            }
        } else {
            result += S.charAt(i);
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	struct box {
		int w, s, v;
		bool operator < (const box& o) const {
			return w + s < o.w + o.s;
		}
	};
	int n;
	cin >> n;
	vector<box> a(n);
	for (auto& b : a) {
		cin >> b.w >> b.s >> b.v;
	}
	sort(all(a));
	const int W = 2e4 + 1;
	vector<ll> dp(W, 0);
	for (box b : a) {
		for (int w = b.s; w >= 0; w--) {
			if (dp[w] > 0 || w == 0) {
				dp[w + b.w] = max(dp[w + b.w], dp[w] + b.v);
			}
		}
	}
	cout << *max_element(all(dp));
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;
const int INF = 1000000000;

vector<string> grid;
map<pair<int,int>,bool> used;
ll white = 0;
ll black = 0;
int h,w;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
void rec(int x,int y){
	used[P(x,y)] = true;

	if(grid[y][x] == '.')white++;
	else black++;

	for(int i = 0;i < 4;i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0 <= nx && nx < w && 0 <= ny && ny < h && grid[ny][nx] != grid[y][x] && !used[P(nx,ny)]){
			rec(nx,ny);
		}
	}

}
int main(){
	cin >> h >> w;
	grid.resize(h);
	for(int i = 0;i < h;i++){
		cin >> grid[i];
	}

	ll ans = 0;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(used[P(j,i)] == false){
				rec(j,i);
				ans += white * black;
				white = 0;
				black = 0;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 33024
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		
		System.out.println((a + b < c + d) ? "Right" : (a + b > c + d) ? "Left" : "Balanced");
	}

}


Measured memory_bytes: 21716
fun main(args: Array<String>) {
    val nx = readLine()!!.split(" ")
    val numN = nx[0].toInt()
    val numX = nx[1].toLong()
    val xList = readLine()!!.split(" ").map(String::toLong).toMutableList()
    xList.add(numX)
    val diffList = mutableListOf<Long>()
    xList.sort()


    for(i in 1 .. numN){
        diffList.add(xList[i] - xList[i - 1])
    }
    var result = 0L


    if(diffList.size == 1){
        result = diffList[0]
    }else{
        for(i in 0 until diffList.size - 1){
            result = if(i == 0){
                gcd(diffList[i + 1], diffList[i])
            }else{
                gcd(diffList[i + 1], result)
            }
        }
    }

    println(result);
}

fun gcd(a:Long, b:Long):Long{
    if(a < b) return gcd(b, a);
    if(b == 0L) return a;
    return gcd(b, a % b);
}

Measured memory_bytes: 77232
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define ll long long
#define MOD 1000000007

struct mint {
  // Preparation: MOD is already defined.
  ll x;

  mint(ll x=0):x((x%MOD+MOD)%MOD){}

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint pow(mint m) const {
    return pow(m.x);
  }

  mint inv() const {
    ll a = x, b = MOD, u = 1, v = 0;
    while (b) {
      ll t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    return u;
  }

  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  // Preparation: MOD is already defined.
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(void) {

    int N, K;
    cin >> N >> K;
    vector<int> A;
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());

    if(K == 1) {
        // 常に0
        cout << 0;
        return 0;
    }

    mint ans = 0;
    combination c(N+1); 
    rep(i, N-K+1) {
        mint nck = c(N-1-i, K-1);
        ans -= (nck * A[i]);
    }
    reverse(A.begin(), A.end());
    rep(i, N-K+1) {
        mint nck = c(N-1-i, K-1);
        ans += (nck * A[i]);
    }

    cout << ans.x;
    return 0;
}

Measured memory_bytes: 2296
data = input().split()

seven = 0
five = 0

for i in range(len(data)):
	if int(data[i]) == 7:
		seven += 1
	elif int(data[i]) == 5:
		five +=1

if seven == 1 and five == 2:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 9032
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

int main()
{
    int h;
    int w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    vector<vector<int>> g(h);
    for(int i = 0;i < h;i++)
    {
        g[i].assign(w, -1);
    }
    int x = 0;
    int y = 0;
    for(int i = 0;i < n;i++)
    {
        int count = a[i];
        while(count > 0)
        {
            count--;
            g[y][x] = i + 1;
            if(y % 2 == 0)
            {
                if(x == w-1)
                {
                    y++;
                }
                else
                {
                    x++;
                }
            }
            else
            {
                if(x == 0)
                {
                    y++;
                }
                else
                {
                    x--;
                }
            }
        }
    }
    for(int i = 0;i < h;i++)
    {
        for(int j = 0;j < w;j++)
        {
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
l=[list(map(int,input().split()))for _ in range(m)]
c=[]
d=[]
for a,b in l:
    if a==1:
        c.append(b)
    if b==n:
        d.append(a)
if len(set(c)&set(d))>0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 54584
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner f = new Scanner(System.in);
        // fill in the dictionary with the initial value
        String target = f.nextLine().toLowerCase();
        int count = 0;
        while(true){
            String temp = f.nextLine();
            if(temp.equals("END_OF_TEXT")){
                break;
            }
            String[] parts = temp.split(" ");
            for(String i : parts){
               
                if(i.toLowerCase().equals(target)) count++;
            }
        }
        System.out.println(count);
    }
}



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

int main(){
    int x, y;
    int t;
    
    for (;;){
        scanf("%d%d", &x, &y);
        if(x == 0 && y == 0)break;
        if(x > y) t = x, x = y, y = t;
        printf("%d %d\n", x,y);
    }
   return 0; 
}


Measured memory_bytes: 1976
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int W, H;
  while (cin >> W >> H, W) {
    vs v(H);
    rep(i, H) cin >> v[i];
    vvi dp(H, vi(W));
    int b = 0, w = 0;
    rep(i, H) rep(j, W) {
      dp[i][j] = 2 * (v[i][j] == 'B') + (v[i][j] == 'W');
      b -= v[i][j] == 'B';
      w -= v[i][j] == 'W';
    }
    rep(_, W * H) rep(i, H) rep(j, W) {
      if (v[i][j] != '.') continue;
      if (i > 0) dp[i][j] |= dp[i - 1][j];
      if (j > 0) dp[i][j] |= dp[i][j - 1];
      if (i < H - 1) dp[i][j] |= dp[i + 1][j];
      if (j < W - 1) dp[i][j] |= dp[i][j + 1];
    }
    rep(i, H) rep(j, W) {
      b += dp[i][j] == 2;
      w += dp[i][j] == 1;
    }
    cout << b << ' ' << w << endl;
  }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

int main() { 
  int H1, M1, H2, M2, K;
cin >> H1>>M1>>H2>>M2>>K ;
int S= H1*60+M1;
int E= H2*60+M2;

cout << max(0,E-S-K) << endl;



 }

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int x;
    cin>>x;

    repa(a,-150,150){
        repa(b,-150,150){
            if(x == (ll)a*a*a*a*a-(ll)b*b*b*b*b){
                cout<<a<<" "<<b<<"\n";
                return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll N;
  cin >> N;
  vll A(N), B(N), C(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  for(int i = 0; i < N; i++) cin >> B.at(i);
  for(int i = 0; i < N; i++) cin >> C.at(i);
  ll result = 0;
  ll b;
  sort(ALL(A)); sort(ALL(B)); sort(ALL(C));
  for(int i = 0; i < N; i++){
    b = B.at(i);
    auto itea = lower_bound(ALL(A), b) - 1;
    if(lower_bound(ALL(A), b) == A.begin()) continue;
    auto itec = upper_bound(ALL(C), b);
    ll anum = itea - A.begin() + 1;
    ll cnum = C.end() - itec;
    result += anum * cnum;
  }
  cout << result << endl;
}


Measured memory_bytes: 2560
import sys
from collections import deque

data = list(sys.stdin.readline()[:-1])

ponds = deque()
result = deque()
index = 0
amount = 0
lefs = deque()

for i in data:
    if i == "\\" or i == "_":
        ponds.append([i, index])
    else:
        count = 0
        while 1 <= len(ponds):
            pond, ind = ponds.pop()
            if pond == "\\":
                count += (index - ind)
                amount += count
                pre_pond = 0
                pre_left = 0
                while 0 < len(lefs) and ind < lefs[-1]:
                    pre_left = lefs.pop()
                    pre_pond += result.pop()
                lefs.append(ind)
                result.append(count + pre_pond)
                break
    index += 1

print(amount)
if 0 == len(result):
    print(0)
else:
    print(len(result), ' '.join(map(str, result)))

Measured memory_bytes: 10296
import java.io.IOException;
import java.util.Scanner;

public class Main {
	static int time = 0;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		SSSPath sp = new SSSPath(n);

		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for (int j = 0; j < k; j++)
				sp.addPath(u, scan.nextInt(), scan.nextInt());
		}
		sp.setPath(0);

		for (int i = 0; i < n; i++)
			System.out.println(i + " " + sp.getResult(i));

		scan.close();
		System.exit(0);
	}
}

class SSSPath {
	int[][] cost;
	int[] reach;

	public SSSPath(int n) {
		reach = new int[n];
		for (int i = 0; i < n; i++)
			reach[i] = -1;

		cost = new int[n][n];
		for (int x = 0; x < n; x++)
			for (int y = 0; y < n; y++)
				cost[x][y] = -1;
	}

	public int getResult(int i) {
		return reach[i];
	}

	public void setPath(int from) {
		reach[from] = 0;
		setP(from);
	}

	private void setP(int from) {
		for (int to = 0; to < cost[from].length; to++)
			if (cost[from][to] > 0) {
				int d = reach[from] + cost[from][to];
				if (reach[to] == -1 || reach[to] > d) {
					reach[to] = d;
					setP(to);
				}
			}
	}

	public void addPath(int from, int to, int c) {
		cost[from][to] = c;
	}

}

Measured memory_bytes: 40084
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

const int N = 2e5+5;
ll n, a[N], dp[N], ans=0;

void solve()
{
       ll n; cin>>n;
       rep(i,1,n+1) cin>>a[i];
       rep(i,1,n+1)
       {
              //cin>>a[i];
              if( (i==1 && a[i]) || (a[i]-a[i-1]>1)) { cout<<-1; exit(0); }
              if(a[i]==a[i-1]+1) ans++;
              else ans+=a[i];
       }
       cout<<ans;
}


int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  vector<int> p(4);
  rep(i, 0, 4) p[i] = (s[i] -'0');

  for(int bits = 0; bits < (1 << 4); bits++) {
    int sum = p[0];
    rep(i, 0, 3) {
      if(bits & (1 << i)) sum += p[i+1];
      else sum -= p[i+1];
    }
    
    if(sum == 7) {
      rep(i, 0, 3) {
        cout << s[i];
        if(bits & (1 << i)) cout << '+';
        else cout << '-';
      }
      cout << s[3] << "=7" << endl;
      return 0;
    }
  }
}

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

int H,W,h,w;

int main()
{
    scanf("%d%d",&H,&W);
    scanf("%d%d",&h,&w);
    if(!(W % w) && !(H % h))
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    int base,exp;
    base = (H / h) * (W / w) + 1;
    exp =  -1 * (base * (h * w - 1) + 1);
    for(int i = 1; i <= H; i++)
    {
        for(int j = 1; j <= W; j++)
        {
            if(i % h == 0 && j % w == 0)printf("%d",exp);
            else printf("%d",base);
            if(j != W)printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
n, m = map(int, input().split())
student = []
for i in range(n):
  student.append(tuple(map(int, input().split())))
point = []
for i in range(m):
  point.append(tuple(map(int, input().split())))
for i in range(n):
  dis = 10 ** 20
  idx = 0
  for j in range(m):
    temp = abs(student[i][0] - point[j][0]) + abs(student[i][1] - point[j][1])
    if temp < dis:
      dis = temp
      idx = j + 1
  print(idx)

Measured memory_bytes: 9156
#include <iostream>
#include <list>
#include <algorithm>
#include <set>
#include <vector>

#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;

struct range {
  int beg, ed;
  int num;
};

int main()
{
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    list<range> s;
    REP(i,n){
      string c;
      cin>>c;
      if(c=="W"){
        int l,S;
        cin >> l >> S;
        int old = 0;
        for(auto itr=begin(s);itr!=end(s);++itr){
          auto r = *itr;
          if(old < r.beg) {
            int len = min(r.beg-old, S);
            s.insert(itr, {old, old + len, l});
            S -= len;
            if (S <= 0) break;
          }
          old  = r.ed;
        }
        if(S > 0) {
          s.push_back({old, old + S, l});
        }
      } else if (c == "D") {
        int l;
        cin>>l;
        auto itr = remove_if(begin(s),end(s),[=](const range& r){return r.num == l;});
        s.erase(itr, end(s));
      } else {
        int p;
        cin>>p;
        auto itr = find_if(begin(s),end(s),[=](const range& r){return r.beg <= p && p < r.ed;});
        if (itr != end(s))
          cout<<itr->num<<endl;
        else
          cout<<-1<<endl;
      }
      //for(auto r:s)cout<<"("<<r.beg<<","<<r.ed<<"):"<<r.num<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1368
#include<stdio.h>
#include<string.h>
int main()
{
  int K; char S[110];
  scanf("%d\n",&K);
  scanf("%s",S);
  if(strlen(S)<=K){
    printf("%s",S);
  }else{
    for(int i=0;i<K;i++){
      printf("%c",S[i]);
    }
    printf("...");
  }
}


Measured memory_bytes: 1704
#include <iostream>
#include <string>
#include <queue>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int h, w;
    cin >> h >> w;
    string s[102];
    for(int i = 0; i < h; i++) cin >> s[i];
    bool used[102][102];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) used[i][j] = false;
    }
    queue<P> que;
    que.push(P(0, 0));
    while(que.size()){
        P p = que.front();
        que.pop();
        char r, l, f, b, u;
        if(p.first % 4){
            f = '2';
            b = '5';
        }
        else{
            f = '5';
            b = '2';
        }
        if(p.second % 4){
            r = '4';
            l = '3';
        }
        else{
            r = '3';
            l = '4';
        }
        if((p.first + p.second) % 4){
            u = '6';
        }
        else{
            u = '1';
        }
        if(p.first == h - 1 && p.second == w - 1){
            cout << "YES" << endl;
            return 0;
        }
        if(p.first == h - 1 && p.second == w - 2){
            if(s[p.first][p.second + 1] == r){
                cout << "YES" << endl;
                return 0;
            }
        }
        if(p.first == h - 2 && p.second == w - 1){
            if(s[p.first + 1][p.second] == b){
                cout << "YES" << endl;
                return 0;
            }
        }
        if(p.first + 2 < h && !used[p.first + 2][p.second] && 
           s[p.first + 1][p.second] == b && s[p.first + 2][p.second] == u){
            used[p.first + 2][p.second] = true;
            que.push(P(p.first + 2, p.second));
        }
        if(p.second + 2 < w && !used[p.first][p.second + 2] &&
           s[p.first][p.second + 1] == r && s[p.first][p.second + 2] == u){
            used[p.first][p.second + 2] = true;
            que.push(P(p.first, p.second + 2));
        }
        if(p.first - 2 >= 0 && !used[p.first - 2][p.second] &&
           s[p.first - 1][p.second] == f && s[p.first - 2][p.second] == u){
            used[p.first - 2][p.second] = true;
            que.push(P(p.first - 2, p.second));
        }
        if(p.second - 2 < w && !used[p.first][p.second - 2] &&
           s[p.first][p.second - 1] == l && s[p.first][p.second - 2] == u){
            used[p.first][p.second - 2] = true;
            que.push(P(p.first, p.second - 2));
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}int a[maxn];
bool pd(int x,int y,int z){
    if(x+y>z&&x+z>y&&y+z>x)return true;
    return false;
}
signed main(){
    //file(a);
    n=read();rep(i,1,n)a[i]=read();
    sort(a+1,a+1+n);int ans=0;
    // rep(i,1,n)cout<<a[i]<<" ";cout<<endl;
    rep(i,1,n){
        int posj=i+1,posk;
        while(a[posj]==a[i])++posj;
        rep(j,posj,n){
            posk=j+1;
            while(a[posk]==a[j])++posk;
            rep(k,posk,n){
                if(pd(a[i],a[j],a[k]))++ans;
            }
        }
    }printf("%d\n",ans);


    return 0;
}

Measured memory_bytes: 3756
#include "bits/stdc++.h"
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rep(i,N) for(int i=0;i<(int)N;++i)
using namespace std;
using ll = long long;
using vint = vector<int>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
const ll INF = (1LL << 30);
const ll LINF = (1LL << 60);
const ll MOD = 1e9 + 7;

struct SegmentTree {
   using F = function<ll(ll, ll)>;
   const F f;
   const ll M;

   int size;
   vector<ll> data;

   SegmentTree(int n, const F& f, const ll& M) : f(f), M(M) {
      size = 1;
      while (size < n) size <<= 1;
      data.assign(size * 2, M);
   }

   void set(int i, ll x) {
      data[i + size] = x;
   }

   void init() {
      for (int k = size - 1; k > 0; --k) {
         data[k] = f(data[2 * k], data[2 * k + 1]);
      }
   }

   void update(int i, ll x, F f2) {
      i += size;
      data[i] = f2(data[i], x);
      while (i >>= 1) {
         data[i] = f(data[2 * i], data[2 * i + 1]);
      }
   }

   ll query(int l, int r) {
      ll L = M, R = M;
      l += size, r += size;
      while (l < r) {
         if (l & 1) L = f(L, data[l]);
         if (r & 1) R = f(R, data[r - 1]);
         l = (l + 1) / 2;
         r = r / 2;
      }
      return f(L, R);
   }
};

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

   auto f = [](ll l, ll r) { return l + r; };
   int n, q;
   cin >> n >> q;
   SegmentTree seg(n, f, 0);
   rep(i, q) {
      int t, x, y;
      cin >> t >> x >> y;
      if (t) cout << seg.query(x, y + 1) << endl;
      else seg.update(x, y, f);
   }
}


Measured memory_bytes: 4912
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = b; i <= c; i++)
    {
        if(i % a == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}




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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll H; cin >> H;
    ll ans = 1;
    ll t = 1;
    while (2*t <= H) {
        ans = 2 * ans + 1;
        t *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

int main() {
    ll n;cin>>n;
    string s;cin>>s;

    ll res = 0;
    rep(i,0,10){
        rep(j,0,10){
            rep(k,0,10){
                char c[3] = {i+'0',j+'0',k+'0'};
                int index = 0, index2 = 0;
                while(1){
                    if(c[index] == s[index2]){
                        index++;
                    }
                    if(index == 3){
                        res++;
                        break;
                    }
                    if(index2 == n)break;
                    index2++;
                }
            }
        }
    }
    cout << res << ednl;
}


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

int main()
{
	long long lnN, lnM;
	cin >> lnN;
	cin >> lnM;

	char nMatrixN[50][50];
	memset(nMatrixN, NULL, sizeof(nMatrixN));
	for (int i = 0; i < lnN; i++)
	{
		cin >> nMatrixN[i];
	}

	char nMatrixM[50][50];
	memset(nMatrixM, NULL, sizeof(nMatrixM));
	for (int i = 0; i < lnM; i++)
	{
		cin >> nMatrixM[i];
	}

	bool bJubge = false;
	for (int i = 0; i <= (lnN-lnM); i++)
	{
		for (int j = 0; j <= (lnN-lnM); j++)
		{
			// MatrixMのループ用
			bool bMatch = true;
			for (int k = 0; k < lnM; k++)
			{
				if (0 != strncmp(&nMatrixN[i + k][j], nMatrixM[k], lnM))
				{
					bMatch = false;
					break;
				}
			}

			if (true == bMatch)
			{
				bJubge = true;
				goto JUDGE;
			}
		}
	}

JUDGE:
	if (true == bJubge)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int n,a,b=0,e,f,g,i,j;
    
    scanf("%d",&n);
    int x[n];
    char c[12];
    for(i=0;i<n;i++){
        scanf("%s %d",c,&a);
        if(c[0]=='i'){
	  x[i]=a;
        }
        else if(c[6]=='F'){
	  i-=2;
	  n-=2;
        }
        else if(c[6]=='L'){
	  i--;
	  n--;
	  b++;
        }
        else{
	  i--;
	  n--;
	  e=0;
	  for(j=i;j>=0;j--){
	    if(e>0){
	      break;
	    }
	    if(a==x[j]){
	      f=i-j;
	      g=0;
	      e++;
	      while(f!=g++)x[j+g-1]=x[j+1+g-1];
	      i--;
	      n--;
	    }
	  }
        }
    }
    for(i=0;i<n-b;i++){
      if(i==n-b-1){
	printf("%d\n",x[n-1-i]);
      }
        else printf("%d ",x[n-1-i]);
    }
    return 0;
}

Measured memory_bytes: 4556
# coding: utf-8
input_lines=input().split()
K = int(input_lines[0])
S = int(input_lines[1])
M=0
for i in range(K+1):
  for j in range(i,K+1):
    k =S-i-j
    if i<=j<=k<=K:
      if i==j==k:
        M+=1
      elif i==j or j==k:
        M+=3
      else:
        M+=6
print(M)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    return H <= sum(i for i in A)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    if solve(H, N, A):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
import java.io.PrintWriter
import java.util.*
import java.math.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val a = readInt()
    val b = readInt()
    val c = readInt()
    val x = readInt()

    var cnt = 0
    for(i in 0..a) {
        for(j in 0..b) {
            for(k in 0..c) {
                val yen = i * 500 + j * 100 + k * 50
                if(yen == x) cnt++
            }
        }
    }

    println(cnt)
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 33688
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INF (1LL << 60)
#define ff first
#define se second
//#define int long long
const int dx[]={0,-1,0,1};
const int dy[]={1,0,-1,0};

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    int a=0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(n==i*j){
                a++;
            }
        }
    }
    if(a==0){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int list[] = new int[26];
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		try{
			while(scan.hasNext()){
				String str = scan.nextLine();
				char ch[] = str.toCharArray();
				for(int i = 0; i < ch.length; i++){
					/*if(ch[i] == '.'){
						scan.close();
					}*/
					CountingCharacters(ch[i]);
				}
			}
		}catch(IllegalStateException e){
			/*char alp = 97;
			for(int i = 0; i < list.length; i++){
				alp = Character.valueOf((char) (97 + i));
				System.out.println(alp + " : " + list[i]);
			}*/
		}
		scan.close();
		char alp = 97;
		for(int i = 0; i < list.length; i++){
			alp = Character.valueOf((char) (97 + i));
			System.out.println(alp + " : " + list[i]);
		}
	}

	public static void CountingCharacters(char Ch){
		Ch = Character.toLowerCase(Ch);
		char alp = 97;
		for(int i = 0; i < list.length; i++){
			//a to z = 97 to 122
			if(Ch == alp + i){
				list[i]++;
			}
		}
	}
}

Measured memory_bytes: 26220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i,N) cin >> A[i];
  vector<int> B(1001000, 0);
  rep(i,N){
    B[A[i]]++;
  }
  ll ans = 0;
  rep(i,N){
    vector<ll> res;
    for(ll j=1; j*j<=A[i]; j++){
      if(A[i]%j==0){
        res.pb(j);
        if(A[i]/j != j) res.pb(A[i]/j);
      }
    }
    int cnt = 0;
    rep(j,sz(res)){
      if(res[j]!=A[i] && B[res[j]]) {
        cnt++;
        break;
      }
      else if(res[j]==A[i]&&B[res[j]]>1){
        cnt++;
        break;
      }
    }
    //cout << cnt << endl;
    if(cnt){
      ans++;
    }
  }
  cout << N-ans << endl;
  return 0;
}


Measured memory_bytes: 7968
#include <iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    
    string str;
    cin >> str;
    bool flag = true;
    for(int i=0; i<str.size(); i++) {
        if(i<A && str[i]=='-') {
            flag=false;
            break;
        }
        if(i>A && str[i]=='-') {
            flag=false;
            break;
        }
        if(i==A && str[i]!='-') {
            flag=false;
        }
    }
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());

	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println( Math.min(a,b)+Math.min(c,d) );
    }
}


Measured memory_bytes: 22608
#include <iostream>
using namespace std;
int n,i,j;
int main()
{
    cin>>n;
    for (i=1; i<=9; ++i)
    {
        for (j=1; j<=9; ++j)
            if (i*j==n)
            {
                cout<<"Yes";
                return 0;
            }
    }
    cout<<"No";
    return 0;
}


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

long long getGcd(long long a, long long b){
    if(a < b){
        long long tmp = a;
        a = b;
        b = tmp;
    }
    
    if(b == 0)return a;
    
    return getGcd(b, a%b);
}

long long getLcm(long long a, long long b){
    long long gcd = getGcd(a, b);
    
    return a/gcd*b;
}


int main(){
    long long A, B, C, D;

    cin >> A >> B >> C >> D;

    A--;
    long long cntC1 = A / C;
    long long cntC2 = B / C;
    long long cntC = cntC2 - cntC1;

    long long cntD1 = A / D;
    long long cntD2 = B / D;
    long long cntD = cntD2 - cntD1;

    long long CD = getLcm(C, D);
    long long cntCD1 = A / CD;
    long long cntCD2 = B / CD;
    long long cntCD = cntCD2 - cntCD1;

    // cout << cntC << endl;
    // cout << cntD << endl;
    // cout << cntCD << endl;

    cout << B - A - cntC - cntD + cntCD << endl;

    return 0;
}

Measured memory_bytes: 256
from fractions import gcd

#####segfunc######                                                              
def segfunc(x,y):
    return gcd(x,y)

def init(init_val):
    #set_val                                                                    
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built                                                                      
    for i in range(num-2,-1,-1):
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
    
def update(k,x):
    k+=num-1
    seg[k]=x
    while k+1:
        k=(k-1)//2
        seg[k]=segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p+=num-1
    q+=num-2
    res=ide_ele
    while q-p>1:
        if p&1==0:
            res=segfunc(res,seg[p])
        if q&1==1:
            res=segfunc(res,seg[q])
            q-=1
        p=p//2
        q=(q-1)//2
    if p==q:
        res=segfunc(res,seg[p])
    else:
        res=segfunc(segfunc(res,seg[p]),seg[q])
    return res

ide_ele=0
n=int(input())
num=2**(n-1).bit_length()
seg=[ide_ele]*2*num
a=list(map(int,input().split()))
init(a)
ans=0
for i in range(n):
    ans=max(gcd(query(0,i),query(i+1,n)),ans)
print(ans)

Measured memory_bytes: 18196
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
string s;
int main() {
	cin>>s;
	if(s[s.size()-1]=='s') cout<<s<<"es"<<endl;
	else cout<<s<<"s"<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    bool flg = true;

    for(int i=0; i<s.length(); i++){
        if((i+1)%2 == 1){
            if(s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D'){
                continue;
            }else{
                flg = false;
                break;
            }
        }
        if((i+1)%2 == 0){
            if(s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D'){
                continue;
            }else{
                flg = false;
                break;
            }
        }
    }
    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << 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; }

vector<pair<int,int>> A(100100);
vector<pair<int,int>> B(100100);

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int v[N];
    REP(i,100100){
      	A[i].first = 0;
        A[i].second = i;
      	B[i].first = 0;
        B[i].second = i;
    }
    int a = 0,b = 0,c = 0,d = 0;
    REP(i,N){
        cin >> v[i];
        if(i % 2 == 0){
            A[v[i]].first++;
        }
        else{
            B[v[i]].first++;
        }
    }
    sort ALL(A);
  	reverse ALL(A);
    sort ALL(B);
  	reverse ALL(B);
 // cout << A[0].second << ' ' << B[0].second << endl;
    if(A[0].second != B[0].second){
      	//cout << N << ' ' << A[0].first << ' ' << B[0].first << endl;
        cout << max(0,N - (A[0].first + B[0].first)) << endl;
    }
    else{
        int ans = N-(A[1].first+B[0].first);
      	int ans1 = N-(A[0].first+B[1].first);
      	ans = min(ans,ans1);
      	ans = max(0,ans);
        cout << ans << endl;
    }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    map <string,int> mapa;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        cin >> s;
        if(!mapa.count(s)){
            cnt++;
        }
        mapa[s]++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 19244
import math
import sys
import numpy

N,K = map(int, input().split())
a = 0.000000000
b = 1
for i in range(1,N+1):
    b = 1
    if i >= K:
        a += 1/N
    else :
        tmp = i
        while tmp < K:
            tmp *= 2
            b /= 2
        a += b/N
print(a)

Measured memory_bytes: 12388
import scala.math.{min,max}

object Main {
    def main(args: Array[String]) {
        var input = io.Source.stdin.getLines().mkString("\n");
        var ss = input.split('\n').toList;
        val xs = to_array_int(ss(0));
        val a = xs(0);
        val b = xs(1);
        val res = max(max(a+a-1,b+b-1),a+b);
        println(res);
    }
    def to_array_int(s: String): Array[Int] = {
        return s.split(' ').map(_.toInt).toArray;
    }
}


Measured memory_bytes: 25544
//abc177_a.cpp
//Sat Aug 29 20:53:32 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	int d,t,s;
	cin >> d >> t >> s;

	if (s*t>=d){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3620
def solv(S, T):
    tset = set(T)
    count = 0
    for s in S:
        if s in T:
            count += 1
            T.remove(s)
    return count


if __name__ == "__main__":

    _ = input()
    S = input().split()
    _ = input()
    T = input().split()

    ans = solv(S, T)

    print(ans)



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

int main() {
  int H, W, M;
  cin >> H >> W >> M;
  vector<int> h(M), w(M);
  rep(i, M) {
    cin >> h[i] >> w[i];
    --h[i];
    --w[i];
  }

  set<P> bomb;
  rep(i, M) bomb.insert(make_pair(h[i], w[i]));

  vector<int> a(H, 0), b(W, 0);
  rep(i, M) {
    ++a[h[i]];
    ++b[w[i]];
  }

  int ma = 0, mb = 0;
  rep(i, H) ma = max(ma, a[i]);
  rep(i, W) mb = max(mb, b[i]);

  vector<int> aa, bb;
  rep(i, H) if (a[i] == ma) aa.push_back(i);
  rep(i, W) if (b[i] == mb) bb.push_back(i);

  if ((ll)aa.size() * bb.size() > M) {
    cout << ma + mb << endl;
    return 0;
  }

  rep(i, aa.size()) rep(j, bb.size()) {
    int ii = aa[i];
    int jj = bb[j];
    // printf("ii = %d, jj = %d\n", ii, jj);
    if (bomb.find(make_pair(ii, jj)) == bomb.end()) {
      cout << ma + mb << endl;
      return 0;
    }
  }

  cout << ma + mb - 1 << endl;

  return 0;
}

Measured memory_bytes: 26188